diff options
Diffstat (limited to 'web/share/js/tools.js')
-rw-r--r-- | web/share/js/tools.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/web/share/js/tools.js b/web/share/js/tools.js index 02c6e637..6fcacf45 100644 --- a/web/share/js/tools.js +++ b/web/share/js/tools.js @@ -160,6 +160,15 @@ export var tools = new function() { el.checked = (el.value === value); } }; + this.radioClickValue = function(name, value) { + for (let el of $$$(`input[type="radio"][name="${name}"]`)) { + if (el.value === value) { + el.click(); + return; + } + } + }; + this.progressSetValue = function(el, title, percent) { el.setAttribute("data-label", title); @@ -242,6 +251,16 @@ export var tools = new function() { this.info("Browser:", this.browser); this.https = (location.protocol === "https:"); + + this.storage = new function() { + return { + "get": function(key, default_value) { + let value = window.localStorage.getItem(key); + return (value !== null ? value : default_value); + }, + "set": (key, value) => window.localStorage.setItem(key, value), + }; + }; }; export var $ = (id) => document.getElementById(id); |