-
Notifications
You must be signed in to change notification settings - Fork 0
/
mode.js
113 lines (89 loc) · 3.05 KB
/
mode.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//dark mode toggle
var data = localStorage.getItem("counter");
var counter = parseInt(data);
if(counter % 2 == 0){
light();
}
else{
dark();
}
function darkLight(){
counter++;
if(counter % 2 == 0){
light();
}
else{
dark();
}
localStorage.setItem("counter", counter.toString());
}
function light(){
var modeBtn = document.getElementById("mode-btn");
modeBtn.innerHTML = '<i id="mode" class="fas fa-moon">';
var modeBtn = document.getElementById("mode-btn_");
modeBtn.innerHTML = '<i id="mode" class="fas fa-moon">';
var lightNav = document.getElementById("nav");
lightNav.style.backgroundColor = "tomato";
var lightCard = document.getElementsByClassName("card");
for(var i=0; i<lightCard.length; i++){
lightCard[i].style.backgroundColor = "white";
lightCard[i].style.border = "solid white 3px";
}
var lightFeed = document.getElementsByClassName("feed");
for(var i=0; i<lightFeed.length; i++){
lightFeed[i].style.backgroundColor = "antiquewhite";
lightFeed[i].style.border = "solid antiquewhite 3px";
}
var text = document.getElementsByTagName("p");
for(var i=0; i<text.length; i++){
text[i].style.color = "black";
}
var text = document.getElementsByTagName("h4");
for(var i=0; i<text.length; i++){
text[i].style.color = "black";
}
var top = document.getElementById("top-btn");
top.src = "./images/backtotop.png";
document.body.style.background = "rgb(255, 156, 27)";
}
function dark(){
var modeBtn = document.getElementById("mode-btn");
modeBtn.innerHTML = '<i id="mode" class="fas fa-sun">';
var modeBtn = document.getElementById("mode-btn_");
modeBtn.innerHTML = '<i id="mode" class="fas fa-sun">';
var darkNav = document.getElementById("nav");
darkNav.style.backgroundColor = "rgb(100, 100, 100)";
var darkCard = document.getElementsByClassName("card");
for(var i=0; i<darkCard.length; i++){
darkCard[i].style.backgroundColor = "rgb(43, 43, 43)";
darkCard[i].style.border = "solid rgb(43, 43, 43) 3px";
}
var darkFeed = document.getElementsByClassName("feed");
for(var i=0; i<darkFeed.length; i++){
darkFeed[i].style.backgroundColor = "rgb(100, 100, 100)";
darkFeed[i].style.border = "solid rgb(100, 100, 100) 3px";
}
var text = document.getElementsByTagName("p");
for(var i=0; i<text.length; i++){
text[i].style.color = "white";
}
var text = document.getElementsByTagName("h4");
for(var i=0; i<text.length; i++){
text[i].style.color = "white";
}
var top = document.getElementById("top-btn");
top.src = "./images/dark top.png";
document.body.style.background = "rgb(48, 48, 48)";
}
var toTop = document.getElementById("to-top");
console.log(toTop);
toTop.style.display = "none";
window.addEventListener("scroll", () => {
console.log('scroll');
if (window.pageYOffset > 100) {
toTop.style.display = "block";
}
else{
toTop.style.display = "none";
}
});