summaryrefslogtreecommitdiff
path: root/web/share/js/tools.js
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2021-08-13 16:39:56 +0300
committerMaxim Devaev <[email protected]>2021-08-13 16:39:56 +0300
commit976662df8310b145f23ac22360a3bd9e38ed65a1 (patch)
tree369dbca05e61bf9d950e15960749725f8824f2c4 /web/share/js/tools.js
parentc233e3bee7b30f7f285869d81f2e18b16b8708c2 (diff)
bindSimpleSwitch()
Diffstat (limited to 'web/share/js/tools.js')
-rw-r--r--web/share/js/tools.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/web/share/js/tools.js b/web/share/js/tools.js
index dc443517..4bc5c90b 100644
--- a/web/share/js/tools.js
+++ b/web/share/js/tools.js
@@ -280,6 +280,11 @@ export var tools = new function() {
"getBool": (key, default_value) => !!parseInt(self.storage.get(key, (default_value ? "1" : "0"))),
"setBool": (key, value) => self.storage.set(key, (value ? "1" : "0")),
+
+ "bindSimpleSwitch": function(el, key, default_value) {
+ el.checked = self.storage.getBool(key, default_value);
+ self.el.setOnClick(el, () => self.storage.setBool(key, el.checked), false);
+ },
};
};