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

Add darkmode toggle functionality

parent 2eb5518a
Pipeline #72589 passed with stage
in 1 minute and 5 seconds
let state = localStorage.getItem("darkmode");
if(state){
element.classList.toggle("darkmode");
}
// Set default value of localstorage if not set
let dmState;
if(localStorage.getItem("darkmode") == "true") {
dmState = true;
darkModeOn();
} else {
dmState = false;
darkModeOff();
}
function darkMode() {
var element = document.body;
element.classList.toggle("darkmode");
localStorage.setItem("darkmode", true);
}
\ No newline at end of file
if(dmState) {
darkModeOff();
} else {
darkModeOn();
}
}
function darkModeOn() {
dmState = true;
document.body.classList.add("darkmode");
localStorage.setItem("darkmode", "true");
document.getElementById('customSwitch1').checked = true
}
function darkModeOff() {
dmState = false;
document.body.classList.remove("darkmode");
localStorage.setItem("darkmode", "false");
document.getElementById('customSwitch1').checked = false
}
\ No newline at end of file
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