-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
26 lines (22 loc) · 1005 Bytes
/
script.js
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
if (localStorage.getItem("colorScheme") !== "dark" && localStorage.getItem("colorScheme") !== "light") {
localStorage.setItem("colorScheme", "dark");
};
var mode = localStorage.getItem("colorScheme");
document.getElementsByTagName('style')[0].innerHTML = "@import url(/js\\ &\\ css/" + mode + ".css);";
console.log(document.getElementsByTagName('style')[0].innerHTML)
lightToggle.src = "/srcs/img/" + mode + ".svg"
document.body.style.colorScheme = mode
lightToggle.addEventListener("click", function() {
// if (mode === "dark") {
// mode = "light";
// localStorage.setItem("colorScheme", "light");
// } else {
// mode = "dark";
// localStorage.setItem("colorScheme", "dark");
// }
mode = mode == "dark" ? "light" : "dark"
localStorage.setItem("colorScheme", mode)
document.body.style.colorScheme = mode
document.getElementsByTagName('style')[0].innerHTML = "@import url(/js\\ &\\ css/" + mode + ".css);";
lightToggle.src = "/srcs/img/" + mode + ".svg"
});