add options
This commit is contained in:
26
src/options/options.js
Normal file
26
src/options/options.js
Normal file
@@ -0,0 +1,26 @@
|
||||
function persistOptions() {
|
||||
var globals = {}; //global addon options
|
||||
|
||||
globals = {
|
||||
width: document.querySelector('#indicator-width').value,
|
||||
orientation: document.querySelector('#indicator-orientation').value
|
||||
};
|
||||
|
||||
return browser.storage.local.set({
|
||||
globals: globals
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
loadOptions().then((options) => {
|
||||
document.querySelector('#indicator-width').value = options.globals.width;
|
||||
document.querySelector('#indicator-orientation').value = options.globals.orientation;
|
||||
});
|
||||
});
|
||||
|
||||
var list = document.querySelectorAll('select,input');
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
list[i].addEventListener('change', (ev) => {
|
||||
persistOptions();
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user