-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (32 loc) · 1.11 KB
/
index.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
let settingmenu=document.querySelector(".setting-menu");
function settingmenutoggle(){
settingmenu.classList.toggle("setting-menu-height")
}
let darktoggle=document.getElementById("dark-btn");
darktoggle.onclick=function (){
darktoggle.classList.toggle("dark-btn-on");
document.body.classList.toggle("dark-theme");
if(localStorage.getItem("theme")=="light"){
localStorage.setItem("theme","dark");
}
else{
localStorage.setItem("theme","light");
}
}
document.addEventListener(click,function(){
if(settingmenu.classList.contains("setting-menu-height")===true){
settingmenu.classList.remove("setting-menu-height");
}
})
//Code for the website to remember if dark mode was last on for the user.
if(localStorage.getItem("theme")=="light"){
darktoggle.classList.remove("dark-btn-on");
document.body.classList.remove("dark-theme");
}
else if(localStorage.getItem("theme")=="dark"){
darktoggle.classList.add("dark-btn-on");
document.body.classList.add("dark-theme");
}
else{
localStorage.setItem("theme","light");
}