diff options
author | 0neGal <mail@0negal.com> | 2023-01-30 22:54:06 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-01-30 22:54:06 +0100 |
commit | 67778e1ecab4747cf886e8ffcb6a11f96ccc279c (patch) | |
tree | b1b0b26c8caeda9423cd95fa9a8f4e0c26f077cd /src/app/js/settings.js | |
parent | 4b94ba7ae03317e1dee75d637f7355f49c1f2086 (diff) | |
download | Viper-67778e1ecab4747cf886e8ffcb6a11f96ccc279c.tar.gz Viper-67778e1ecab4747cf886e8ffcb6a11f96ccc279c.zip |
remove: Settings.reloadSwitches() and .switch()
We now just use a click event listener, and check through what's at the
click location, and toggle classes as needed.
Diffstat (limited to 'src/app/js/settings.js')
-rw-r--r-- | src/app/js/settings.js | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/src/app/js/settings.js b/src/app/js/settings.js index 63b4b99..645a9ed 100644 --- a/src/app/js/settings.js +++ b/src/app/js/settings.js @@ -24,37 +24,6 @@ var Settings = { settings = {...settings, ...Settings.get()}; ipcRenderer.send("save-settings", Settings.get()); }, - reloadSwitches: () => { - let switches = document.querySelectorAll(".switch"); - - for (let i = 0; i < switches.length; i++) { - switches[i].setAttribute("onclick", `Settings.switch(${i})`); - } - }, - switch: (element, state) => { - let switches = document.querySelectorAll(".switch"); - if (switches[element]) { - element = switches[element]; - } - - let on = () => { - element.classList.add("on"); - element.classList.remove("off"); - } - - let off = () => { - element.classList.add("off"); - element.classList.remove("on"); - } - - if (state != undefined) { - if (state) {on()} else {off()} - } else { - if (element.classList.contains("on")) {off()} else {on()} - } - - Settings.reloadSwitches(); - }, get: () => { let opts = {}; let options = document.querySelectorAll(".option"); @@ -133,5 +102,11 @@ var Settings = { } } -Settings.reloadSwitches(); +document.body.addEventListener("click", (e) => { + let el = document.elementFromPoint(e.clientX, e.clientY); + if (el.classList.contains("switch") && el.tagName == "BUTTON") { + el.classList.toggle("on"); + } +}) + Settings.load(); |