Feature/#32 option menu #112
|
@ -16,7 +16,8 @@
|
||||||
<input type="checkbox" id="quickSearch" data-default-value="false" />
|
<input type="checkbox" id="quickSearch" data-default-value="false" />
|
||||||
<label for="quickSearch">Enable Quick Search</label><br>
|
<label for="quickSearch">Enable Quick Search</label><br>
|
||||||
|
|
||||||
<button id="saveBtn">Save</button>
|
<button id="btnSave">Save</button>
|
||||||
|
<button id="btnReset">Reset</button>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { getGlobalStorageProvider } from "./settings/storageProvider";
|
import { getGlobalStorageProvider } from "./settings/storageProvider";
|
||||||
import { onReady } from "./utils/helpers";
|
import { onReady } from "./utils/helpers";
|
||||||
|
|
||||||
const OPTION_SELECTOR = '.extension-option'
|
const OPTION_SELECTOR = 'input[type="checkbox"';
|
||||||
|
|
||||||
function storeOptions() {
|
function storeOptions() {
|
||||||
document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => {
|
document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => {
|
||||||
getGlobalStorageProvider().setData(optionElement.id, optionElement.check);
|
getGlobalStorageProvider().setData(optionElement.id, optionElement.checked);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,26 @@ function restoreOptions() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetOptions() {
|
||||||
|
document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => {
|
||||||
|
let defaultValue = optionElement.dataset.defaultValue === 'true' ? true : false;
|
||||||
|
|
||||||
|
optionElement.checked = defaultValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onReady(() => {
|
onReady(() => {
|
||||||
// register Store Button
|
// register Store Button
|
||||||
document.getElementById('saveBtn').addEventListener('click', storeOptions);
|
document.getElementById('btnSave').addEventListener('click', event => {
|
||||||
|
event.preventDefault();
|
||||||
|
storeOptions();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('btnReset').addEventListener('click', event => {
|
||||||
|
event.preventDefault();
|
||||||
|
resetOptions();
|
||||||
|
storeOptions();
|
||||||
|
})
|
||||||
|
|
||||||
// try restore options
|
// try restore options
|
||||||
restoreOptions();
|
restoreOptions();
|
||||||
|
|
Loading…
Reference in a new issue