-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
65 lines (60 loc) · 1.8 KB
/
script.js
File metadata and controls
65 lines (60 loc) · 1.8 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
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
let tagBox = document.querySelector(".tag-box");
let contentItems = document.querySelector(".content-items")
let toggleTheme = document.querySelectorAll(".dark-mode-switch");
let tagItemArr = Array.from(tagBox.children);
let contentItemArr = Array.from(contentItems.children);
function openUlmenu() {
let ul = document.querySelector("#menu");
ul.classList.toggle("open-ul");
}
if (document.body.className!=="black-theme") {
bgWhiteOfTagItems();
}
[toggleTheme[0],toggleTheme[1]].forEach((toggleItem)=>{
toggleItem.addEventListener("click",()=>{
document.body.classList.toggle('black-theme');
if (document.body.className=="black-theme") {
bgBlackOfTagItems();
}
else{
bgWhiteOfTagItems();
}
})
});
function bgBlackOfTagItems(){
tagItemArr.forEach((tagItem)=>{
tagItem.style.background="rgba(299,299,299,0.07)";
})
}
function bgWhiteOfTagItems(){
tagItemArr.forEach((tagItem)=>{
tagItem.style.background="var(--tag-bg)";
}
)
}
tagItemArr.forEach((elem,index,arr)=>{
elem.addEventListener("click",function (){
arr.forEach((item)=>{
item.classList.remove("hover-effect")
})
this.classList.add("hover-effect");
})
})
contentItemArr.forEach((elem,index,arr)=>{
elem.addEventListener("click",function (){
arr.forEach((item)=>{
item.classList.remove("hover-effect")
})
this.classList.add("hover-effect");
})
})
let goTop = document.querySelector(".go-top a");
function scrollYBody() {
if (window.scrollY >= 400) {
goTop.style.visibility="visible";
goTop.style.opacity="1";
} else if(window.scrollY <= 50) {
goTop.style.visibility="hidden";
goTop.style.opacity="0";
}
}