-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (34 loc) · 1.53 KB
/
Copy pathscript.js
File metadata and controls
35 lines (34 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function init() {
let theme = localStorage.getItem("theme");
if (!theme) {
document.querySelector("html").setAttribute("data-theme", "light");
document.querySelector("#light").style.display = "none";
document.querySelector("#dark").style.display = null;
localStorage.setItem("theme", "light");
} else if(theme == "light") {
document.querySelector("html").setAttribute("data-theme", "light");
document.querySelector("#light").style.display = "none";
document.querySelector("#dark").style.display = null;
localStorage.setItem("theme", "light");
} else {
document.querySelector("html").setAttribute("data-theme", "dark");
document.querySelector("#dark").style.display = "none";
document.querySelector("#light").style.display = null;
localStorage.setItem("theme", "dark");
}
}
function setTheme() {
let theme = localStorage.getItem("theme");
// if(! theme) localStorage.setItem("theme", "light");
if(theme == "dark") {
document.querySelector("html").setAttribute("data-theme", "light");
document.querySelector("#light").style.display = "none";
document.querySelector("#dark").style.display = null;
localStorage.setItem("theme", "light");
} else {
document.querySelector("html").setAttribute("data-theme", "dark");
document.querySelector("#dark").style.display = "none";
document.querySelector("#light").style.display = null;
localStorage.setItem("theme", "dark");
}
}