-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (37 loc) · 1.33 KB
/
script.js
File metadata and controls
42 lines (37 loc) · 1.33 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
// script.js
const yearSpan = document.getElementById("year");
if (yearSpan) {
yearSpan.textContent = new Date().getFullYear();
}
// Lightbox for project screenshots (Projects page)
const lightbox = document.getElementById("lightbox");
const lightboxImage = document.getElementById("lightboxImage");
const lightboxClose = document.getElementById("lightboxClose");
// Only run if the lightbox exists on this page
if (lightbox && lightboxImage && lightboxClose) {
// Any screenshot inside .shot on the page
const screenshotImgs = document.querySelectorAll(".shot img");
screenshotImgs.forEach(img => {
img.addEventListener("click", () => {
lightboxImage.src = img.src;
lightboxImage.alt = img.alt || "Enlarged screenshot";
lightbox.classList.add("visible");
});
});
// Close when clicking the X
lightboxClose.addEventListener("click", () => {
lightbox.classList.remove("visible");
});
// Close when clicking the dark background
lightbox.addEventListener("click", (e) => {
if (e.target === lightbox) {
lightbox.classList.remove("visible");
}
});
// Close with Escape key
document.addEventListener("keydown", (e) => {
if (e.key === "Escape") {
lightbox.classList.remove("visible");
}
});
}