Unverified Commit f269ab3c authored by Johannes Tomren Røsvik's avatar Johannes Tomren Røsvik
Browse files

Refactor darkmode.js

parent a6f3eea8
Pipeline #72591 canceled with stage
let dmState = false;
let body = document.body;
let toggleButton = document.getElementById('customSwitch1');
// Set default value of localstorage if not set
let dmState;
if(localStorage.getItem("darkmode") == "true") {
dmState = true;
darkModeOn();
......@@ -18,14 +21,14 @@ function darkMode() {
function darkModeOn() {
dmState = true;
document.body.classList.add("darkmode");
body.classList.add("darkmode");
localStorage.setItem("darkmode", "true");
document.getElementById('customSwitch1').checked = true
toggleButton.checked = true
}
function darkModeOff() {
dmState = false;
document.body.classList.remove("darkmode");
body.classList.remove("darkmode");
localStorage.setItem("darkmode", "false");
document.getElementById('customSwitch1').checked = false
}
\ No newline at end of file
toggleButton.checked = false
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment