diff options
author | Devaev Maxim <[email protected]> | 2020-07-19 14:25:54 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-07-19 14:25:54 +0300 |
commit | ab13399a2afa07346f635f9c70fca93ec9201e5e (patch) | |
tree | 4aac943d5409459ab4123f3b701b8b7528a27142 /web/share/js/tools.js | |
parent | faedb829b95df47147442b784e4583ddfc4db252 (diff) |
drive mode radio switch
Diffstat (limited to 'web/share/js/tools.js')
-rw-r--r-- | web/share/js/tools.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/web/share/js/tools.js b/web/share/js/tools.js index 5bd41548..92a701d2 100644 --- a/web/share/js/tools.js +++ b/web/share/js/tools.js @@ -135,6 +135,22 @@ export var tools = new function() { }; }; + this.setOnClickRadio = function(name, callback) { + for (let el of $$$(`input[type="radio"][name="${name}"]`)) { + this.setOnClick(el, callback) + } + }; + + this.getRadioValue = function(name, value) { + return document.querySelector(`input[type="radio"][name="${name}"]:checked`).value; + }; + + this.setRadioValue = function(name, value) { + for (let el of $$$(`input[type="radio"][name="${name}"]`)) { + el.checked = (el.value === value); + } + }; + this.setProgressPercent = function(el, title, percent) { el.setAttribute("data-label", title); $(`${el.id}-value`).style.width = `${percent}%`; |