lightmode.js: Made theme preference save to localStorage

This commit is contained in:
Sugaryy_ 2023-05-31 12:51:18 +02:00
parent 85e1d6afce
commit 8831d8c346

View file

@ -1,5 +1,24 @@
function themeToggle() { (function () {
var element = document.body; var element = document.body;
var theme = localStorage.getItem("colorscheme");
if (theme === null) {
localStorage.setItem("colorscheme", "dark")
}
if (theme === "light") {
element.classList.toggle("light-mode")
}
})();
function themeToggle() {
var theme = localStorage.getItem("colorscheme");
var element = document.body;
if (theme === "dark") {
element.classList.toggle("light-mode"); element.classList.toggle("light-mode");
localStorage.setItem("colorscheme", "light")
}
else {
element.classList.toggle("light-mode")
localStorage.setItem("colorscheme", "dark")
}
} }