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

Add comments

parent f269ab3c
Pipeline #72592 passed with stage
in 1 minute and 8 seconds
let dmState = false;
// Initialize variables
let darkModeState = false;
let body = document.body;
let toggleButton = document.getElementById('customSwitch1');
// Set default value of localstorage if not set
if(localStorage.getItem("darkmode") == "true") {
dmState = true;
darkModeState = true;
darkModeOn();
} else {
dmState = false;
darkModeState = false;
darkModeOff();
}
// Toggle dark mode
function darkMode() {
if(dmState) {
if(darkModeState) {
darkModeOff();
} else {
darkModeOn();
}
}
// Turn on dark mode
function darkModeOn() {
dmState = true;
darkModeState = true;
body.classList.add("darkmode");
localStorage.setItem("darkmode", "true");
toggleButton.checked = true
}
// Turn off dark mode
function darkModeOff() {
dmState = false;
darkModeState = false;
body.classList.remove("darkmode");
localStorage.setItem("darkmode", "false");
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