2018-09-09 23:02:04 +00:00
|
|
|
const DOM = generateElementsVariable([
|
|
|
|
"days",
|
|
|
|
"visitCount",
|
|
|
|
"mode",
|
|
|
|
"settings"
|
|
|
|
]);
|
|
|
|
|
2017-04-09 22:31:09 +00:00
|
|
|
function updateDays(e) {
|
2018-09-09 23:02:04 +00:00
|
|
|
browser.storage.local.set({
|
|
|
|
days: parseInt(DOM.days.value),
|
|
|
|
visitCount: parseInt(DOM.visitCount.value),
|
|
|
|
mode: DOM.mode.value
|
|
|
|
});
|
2017-02-07 23:38:33 +00:00
|
|
|
e.preventDefault();
|
2017-02-07 23:31:13 +00:00
|
|
|
}
|
2018-09-09 23:02:04 +00:00
|
|
|
|
|
|
|
async function restoreOptions() {
|
|
|
|
const res = await browser.storage.local.get();
|
|
|
|
DOM.days.value = res.days || 0;
|
|
|
|
DOM.visitCount.value = res.visitCount || 0;
|
|
|
|
DOM.mode.value = res.mode || "days";
|
2017-02-07 23:31:13 +00:00
|
|
|
}
|
2018-09-09 23:02:04 +00:00
|
|
|
|
|
|
|
DOM.settings.addEventListener("input", updateDays);
|
2017-04-09 22:31:09 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", restoreOptions);
|