Anonymous

MediaWiki:Common.js: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 550: Line 550:
}
}
});
});
function setItem(key, value) {
localStorage.setItem(key, value);
}


function getItem(key) {
let keydata = localStorage.getItem(key);
if (keydata == "undefined") {
return undefined;
}
return keydata;
}
function toggleDarkMode() {
function toggleDarkMode() {
const darkMode = getItem("darkMode");
const darkMode = getItem("darkMode");
if (darkMode !== true) {
if (darkMode !== true) {
setItem("darkMode", true);
    localStorage.setItem("darkMode", true);
document.body.classList.add("darkMode");
document.body.classList.add("darkMode");
} else {
} else {
setItem("darkMode", false);
    localStorage.setItem("darkMode", false);
document.body.classList.remove("darkMode");
document.body.classList.remove("darkMode");
}
}
}
}