-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
111 lines (94 loc) · 3.11 KB
/
script.js
File metadata and controls
111 lines (94 loc) · 3.11 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
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
document.addEventListener('DOMContentLoaded', () => {
const savedTheme = localStorage.getItem("theme");
const body = document.body;
const toggleBtn = document.getElementById("theme-toggle");
// Apply saved theme or default to dark
if (savedTheme === "light") {
body.classList.remove("dark");
body.classList.add("light");
toggleBtn.textContent = "🌙";
} else {
body.classList.remove("light");
body.classList.add("dark");
toggleBtn.textContent = "☀️";
}
// When the button is clicked, toggle theme + save to localStorage
toggleBtn.addEventListener("click", () => {
if (body.classList.contains("dark")) {
body.classList.remove("dark");
body.classList.add("light");
localStorage.setItem("theme", "light");
toggleBtn.textContent = "🌙";
} else {
body.classList.remove("light");
body.classList.add("dark");
localStorage.setItem("theme", "dark");
toggleBtn.textContent = "☀️";
}
});
// Typewriter taglines
const taglines = [
"brb...",
"je débogue donc je suis",
"compiling but not complete...",
"나는 밤에 회로를 짜는 걸 좋아해",
"courage is contagious",
"in expectation, life is good",
"what is that melody?",
"girls belong in engineering!"
];
const typedText = document.getElementById('typed-text');
let taglineIndex = 0;
let charIndex = 0;
let isDeleting = false;
function typeTagline() {
const currentTagline = taglines[taglineIndex];
if (isDeleting) {
charIndex--;
typedText.textContent = currentTagline.substring(0, charIndex);
} else {
charIndex++;
typedText.textContent = currentTagline.substring(0, charIndex);
}
let typingSpeed = isDeleting ? 40 : 100;
if (!isDeleting && charIndex === currentTagline.length) {
isDeleting = true;
typingSpeed = 3000; // pause before deleting
} else if (isDeleting && charIndex === 0) {
isDeleting = false;
taglineIndex = (taglineIndex + 1) % taglines.length;
typingSpeed = 500; // pause before typing new one
}
setTimeout(typeTagline, typingSpeed);
}
typeTagline();
// Scroll fade-in
const faders = document.querySelectorAll('.fade-in');
const appear = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
entry.target.classList.add('animated');
}
});
}, { threshold: 0.2 });
faders.forEach(fade => appear.observe(fade));
const filterButtons = document.querySelectorAll(".filter-btn");
const cards = document.querySelectorAll(".resource-card");
filterButtons.forEach(btn => {
btn.addEventListener("click", () => {
// Remove active class from all
filterButtons.forEach(b => b.classList.remove("active"));
btn.classList.add("active");
const filter = btn.dataset.filter;
cards.forEach(card => {
const type = card.dataset.type;
if (filter === "all" || type === filter) {
card.style.display = "block";
} else {
card.style.display = "none";
}
});
});
});
});