-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
68 lines (57 loc) · 1.88 KB
/
script.js
File metadata and controls
68 lines (57 loc) · 1.88 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
66
67
68
//shhhhh
function triggerEasterEgg() {
alert("You were warned... 😼");
document.body.style.transition = "all 0.5s ease";
document.body.style.background = "#ff69b4";
document.body.style.color = "#000";
const heading = document.querySelector("h1");
if (heading) heading.textContent = "You clicked it. There's no going back. :3";
}
document.addEventListener("DOMContentLoaded", () => {
const doNotClick = document.getElementById("doNotClick");
const hamburger = document.querySelector(".hamburger");
const navLinks = document.querySelector(".nav-links");
if (doNotClick) {
doNotClick.addEventListener("click", (e) => {
e.preventDefault();
triggerEasterEgg();
});
}
if (hamburger && navLinks) {
hamburger.addEventListener("click", () => {
hamburger.classList.toggle("open");
navLinks.classList.toggle("open");
});
}
const animatedElements = document.querySelectorAll('.animate-on-load');
animatedElements.forEach((el, index) => {
setTimeout(() => {
el.classList.add('show-on-load');
}, index * 200);
});
if (modeToggle) {
const savedMode = localStorage.getItem('theme');
if (savedMode === 'light') {
document.body.classList.add('light-mode');
modeToggle.textContent = '☀️';
} else {
modeToggle.textContent = '🌙';
}
modeToggle.addEventListener('click', () => {
const body = document.body;
body.classList.add('fade-out');
void body.offsetWidth;
setTimeout(() => {
body.classList.toggle('light-mode');
const isLight = body.classList.contains('light-mode');
modeToggle.textContent = isLight ? '☀️' : '🌙';
localStorage.setItem('theme', isLight ? 'light' : 'dark');
body.classList.remove('fade-out');
body.classList.add('fade-in');
setTimeout(() => {
body.classList.remove('fade-in');
}, 400);
}, 300);
});
}
});