Feature/#32 option menu #112

Merged
Serraniel merged 31 commits from feature/#32-option-menu into develop 2020-11-09 17:28:43 +01:00
Showing only changes of commit 88a97af8f4 - Show all commits

View file

@ -1,11 +1,28 @@
import { getGlobalStorageProvider } from "./settings/storageProvider";
import { onReady } from "./utils/helpers"; import { onReady } from "./utils/helpers";
onReady(() => { const OPTION_SELECTOR = '.extension-option'
});
function saveOptions() {
function storeOptions() {
document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => {
getGlobalStorageProvider().setData(optionElement.id, optionElement.check);
});
} }
document.getElementById('save').addEventListener('click', saveOptions) function restoreOptions() {
document.querySelectorAll(OPTION_SELECTOR).forEach(optionElement => {
let defaultValue = optionElement.dataset.defaultValue === 'true' ? true : false;
getGlobalStorageProvider().getData(optionElement.id, defaultValue, value => {
optionElement.checked = value;
});
});
}
onReady(() => {
// register Store Button
document.getElementById('saveBtn').addEventListener('click', storeOptions);
// try restore options
restoreOptions();
});