lightmode.js: Made theme preference save to localStorage
This commit is contained in:
parent
85e1d6afce
commit
8831d8c346
1 changed files with 21 additions and 2 deletions
|
@ -1,5 +1,24 @@
|
|||
function themeToggle() {
|
||||
(function () {
|
||||
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");
|
||||
localStorage.setItem("colorscheme", "light")
|
||||
}
|
||||
else {
|
||||
element.classList.toggle("light-mode")
|
||||
localStorage.setItem("colorscheme", "dark")
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue