-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (52 loc) · 2.07 KB
/
Copy pathscript.js
File metadata and controls
61 lines (52 loc) · 2.07 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
const body = document.body;
const themeToggle = document.getElementById("themeToggle");
const themeIcon = document.getElementById("themeIcon");
const menuToggle = document.getElementById("menuToggle");
const mobileNav = document.getElementById("mobileNav");
const savedTheme = localStorage.getItem("portfolio-theme");
if (savedTheme === "light") body.classList.add("light");
function updateThemeIcon() {
themeIcon.textContent = body.classList.contains("light") ? "☀" : "☾";
themeToggle.setAttribute("aria-label", body.classList.contains("light")
? "Switch to dark mode" : "Switch to light mode");
}
updateThemeIcon();
themeToggle.addEventListener("click", () => {
body.classList.toggle("light");
localStorage.setItem("portfolio-theme", body.classList.contains("light") ? "light" : "dark");
updateThemeIcon();
});
menuToggle.addEventListener("click", () => {
const open = mobileNav.classList.toggle("open");
menuToggle.setAttribute("aria-expanded", String(open));
menuToggle.textContent = open ? "×" : "☰";
});
mobileNav.querySelectorAll("a").forEach(link => {
link.addEventListener("click", () => {
mobileNav.classList.remove("open");
menuToggle.setAttribute("aria-expanded", "false");
menuToggle.textContent = "☰";
});
});
document.querySelectorAll(".js-project-link").forEach(link => {
link.addEventListener("click", (event) => {
const url = link.dataset.url;
if (!url || url.includes("example.com")) {
event.preventDefault();
alert("This project is still under development. The Link will be updated upon completion of testing and deployment,Thank you.");
}
});
});
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("visible");
observer.unobserve(entry.target);
}
});
}, { threshold: 0.12 });
document.querySelectorAll(".reveal").forEach((el, index) => {
el.style.transitionDelay = `${Math.min(index % 6, 5) * 60}ms`;
observer.observe(el);
});
document.getElementById("year").textContent = new Date().getFullYear();