summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorTinWoodman92 <chrhodgden@gmail.com>2023-12-15 20:07:07 -0600
committerTinWoodman92 <chrhodgden@gmail.com>2023-12-15 20:07:07 -0600
commit3c13057bc5726686ce937d1b13c1a0430e0085d4 (patch)
tree6c51436b42bac5e6496abe521bc729588d03fba2 /app.js
parent793f966038552b7f913a429a2d9e46666468c22f (diff)
added dynamic theme
Diffstat (limited to 'app.js')
-rw-r--r--app.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/app.js b/app.js
index 122cad7..333c354 100644
--- a/app.js
+++ b/app.js
@@ -1,5 +1,9 @@
console.log('Hello from app.js!');
+const setStyleVariable = function(styleVariable, styleValue) {
+ document.documentElement.style.setProperty(styleVariable, styleValue);
+};
+
const toggleTheme = function() {
document.documentElement.style.setProperty(this.id, Number(this.checked));
localStorage.setItem(this.id, Number(this.checked));
@@ -16,8 +20,8 @@ const initInput = function(styleVariable=null) {
const inputObject = document.getElementById(styleVariable);
if (inputObject) {
- inputObject.addEventListener('change', toggleTheme);
if (inputObject.type == 'checkbox') {
+ inputObject.addEventListener('change', toggleTheme);
inputObject.checked = initValue
};
};