-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdark.js
57 lines (48 loc) · 1.51 KB
/
dark.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
let darkmode=0;
const themeicon = document.getElementById("theme-icon");
themeicon.addEventListener("click", changetheme);
const header=document.querySelector("#header");
const searchbox=document.querySelector("#search");
const footer=document.querySelector("footer");
const githublink=document.querySelector("#github-link");
const d= new Date();
// console.log(d.getHours());
if(d.getHours()>=20 || d.getHours()<5){
applydarkmode();
}
function applydarkmode(){
darkmode=1;
themeicon.innerText="light_mode";
document.body.style.backgroundColor = "#121212";
document.body.style.color = "#fff";
header.style.backgroundColor="rgba(255, 255, 255, 0.12)";
header.style.color="#fff";
search.style.backgroundColor="rgba(255, 255, 255, 0.12)";
searchBar.style.color="#fff";
footer.style.backgroundColor="rgba(255, 255, 255, 0.12)";
footer.style.color="#fff";
githublink.style.color="#fff";
}
function applylightmode(){
darkmode=0;
themeicon.innerText="dark_mode";
document.body.style.backgroundColor = "#f5f5f5";
document.body.style.color = "#333";
header.style.backgroundColor="#fff";
header.style.color="#333";
search.style.backgroundColor="#fff";
searchBar.style.color="#333";
footer.style.backgroundColor="#fff";
footer.style.color="#333";
githublink.style.color="#333";
}
function changetheme(){
// console.log("Clicked!");
removeQuestions();
if(darkmode){
applylightmode();
}
else{
applydarkmode();
}
}