-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
71 lines (63 loc) · 2.1 KB
/
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
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
const menubtn = document.querySelector('.menu')
menu = document.querySelector('header ul')
up = document.querySelector('.up')
menubtn.onclick = function() {
if (!menu.classList.contains('open')) {
menu.classList.add('open')
menubtn.style.transform = 'rotate(180deg)'
menubtn.classList.remove('uil-bars')
menubtn.classList.add('uil-times')
} else {
menu.classList.remove('open')
menubtn.style.transform = 'rotate(0deg)'
menubtn.classList.add('uil-bars')
menubtn.classList.remove('uil-times')
}
}
window.addEventListener('scroll', () => {
if (document.body.scrollTop > 10 || document.documentElement.scrollTop > 10) {
up.style.display = "block"
} else {
up.style.display = "none"
}
if (menu.classList.contains('open')) {
menu.classList.remove('open')
menubtn.style.transform = 'rotate(0deg)'
menubtn.classList.add('uil-bars')
menubtn.classList.remove('uil-times')
}
})
up.addEventListener('click', () => {
document.body.scrollTop = 0
document.documentElement.scrollTop = 0
})
const htmlbar = document.getElementById('bar1')
cssbar = document.getElementById('bar2')
jsbar = document.getElementById('bar3')
window.addEventListener('scroll', () => {
if (document.body.scrollTop > 1200 || document.documentElement.scrollTop > 1200) {
htmlbar.classList.add('activehtml')
cssbar.classList.add('activecss')
jsbar.classList.add('activejs')
}
})
document.addEventListener('DOMContentLoaded', function() {
const toggle = document.querySelector('.switchcircle');
const body = document.body;
const icon = document.querySelector('.switchcircle ion-icon');
let isDarkMode = false;
toggle.addEventListener('click', function() {
if (isDarkMode) {
// Switch to light mode
body.style.backgroundColor = 'white';
body.style.color = 'black';
icon.setAttribute('name', 'moon-outline');
} else {
// Switch to dark mode
body.style.backgroundColor = 'black';
body.style.color = 'white';
icon.setAttribute('name', 'sunny-outline');
}
isDarkMode = !isDarkMode;
});
});