refactoring

This commit is contained in:
Maxim Devaev 2021-08-12 10:21:35 +03:00
parent 68897c94ac
commit d7f65ad788
3 changed files with 7 additions and 4 deletions

View File

@ -36,9 +36,9 @@ export function Atx() {
$("atx-power-led").title = "Power Led"; $("atx-power-led").title = "Power Led";
$("atx-hdd-led").title = "Disk Activity Led"; $("atx-hdd-led").title = "Disk Activity Led";
$("atx-ask-switch").checked = parseInt(tools.storage.get("atx.ask", "1")); $("atx-ask-switch").checked = tools.storage.getBool("atx.ask", true);
tools.el.setOnClick($("atx-ask-switch"), function() { tools.el.setOnClick($("atx-ask-switch"), function() {
tools.storage.set("atx.ask", ($("atx-ask-switch").checked ? 1 : 0)); tools.storage.setBool("atx.ask", $("atx-ask-switch").checked);
}, false); }, false);

View File

@ -74,9 +74,9 @@ export function Hid(__getResolution) {
window.addEventListener("pagehide", __releaseAll); window.addEventListener("pagehide", __releaseAll);
window.addEventListener("blur", __releaseAll); window.addEventListener("blur", __releaseAll);
$("hid-pak-ask-switch").checked = parseInt(tools.storage.get("hid.pak.ask", "1")); $("hid-pak-ask-switch").checked = tools.storage.getBool("hid.pak.ask", true);
tools.el.setOnClick($("hid-pak-ask-switch"), function() { tools.el.setOnClick($("hid-pak-ask-switch"), function() {
tools.storage.set("hid.pak.ask", ($("hid-pak-ask-switch").checked ? 1 : 0)); tools.storage.setBool("hid.pak.ask", $("hid-pak-ask-switch").checked);
}, false); }, false);
$("hid-pak-keymap-selector").addEventListener("change", function() { $("hid-pak-keymap-selector").addEventListener("change", function() {

View File

@ -277,6 +277,9 @@ export var tools = new function() {
return (value !== null ? value : default_value); return (value !== null ? value : default_value);
}, },
"set": (key, value) => window.localStorage.setItem(key, value), "set": (key, value) => window.localStorage.setItem(key, value),
"getBool": (key, default_value) => !!parseInt(self.storage.get(key, (default_value ? "1" : "0"))),
"setBool": (key, value) => self.storage.set(key, (value ? "1" : "0")),
}; };
}; };