mirror of
https://git.kittycat.homes/zoe/hugo-battheme.git
synced 2024-08-15 03:25:18 +00:00
dark by default
This commit is contained in:
parent
72e5576a15
commit
84ce2ba287
2 changed files with 9 additions and 9 deletions
|
@ -1,20 +1,20 @@
|
|||
const checkbox = document.getElementById("darkmode-toggle");
|
||||
const colorswitchers = document.getElementsByClassName("colorswitch");
|
||||
|
||||
if (localStorage.getItem("dark")) {
|
||||
switchToDark();
|
||||
} else {
|
||||
if (localStorage.getItem("light")) {
|
||||
switchToLight();
|
||||
} else {
|
||||
switchToDark();
|
||||
}
|
||||
checkbox.checked = localStorage.getItem("dark");
|
||||
|
||||
checkbox.addEventListener("change", function () {
|
||||
localStorage.setItem("dark", this.checked);
|
||||
localStorage.setItem("light", this.checked);
|
||||
if (this.checked) {
|
||||
switchToDark();
|
||||
} else {
|
||||
localStorage.removeItem("dark");
|
||||
switchToLight();
|
||||
} else {
|
||||
localStorage.removeItem("light");
|
||||
switchToDark();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue