aboutsummaryrefslogtreecommitdiff
path: root/src/app/settings.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/settings.js')
-rw-r--r--src/app/settings.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/app/settings.js b/src/app/settings.js
index 853cd0b..23b38c9 100644
--- a/src/app/settings.js
+++ b/src/app/settings.js
@@ -31,16 +31,26 @@ var Settings = {
switches[i].setAttribute("onclick", `Settings.switch(${i})`);
}
},
- switch: (element) => {
+ switch: (element, state) => {
let switches = document.querySelectorAll(".switch");
- element = switches[element];
+ if (switches[element]) {
+ element = switches[element];
+ }
+
+ let on = () => {
+ element.classList.add("on");
+ element.classList.remove("off");
+ }
- if (element.classList.contains("on")) {
+ let off = () => {
element.classList.add("off");
element.classList.remove("on");
+ }
+
+ if (state != undefined) {
+ if (state) {on()} else {off()}
} else {
- element.classList.add("on");
- element.classList.remove("off");
+ if (element.classList.contains("on")) {off()} else {on()}
}
Settings.reloadSwitches();