-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
76 lines (66 loc) · 2.72 KB
/
script.js
File metadata and controls
76 lines (66 loc) · 2.72 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
(function () {
const root = document.documentElement;
const themeToggle = document.getElementById("theme-toggle");
const unlockForm = document.getElementById("unlock-form");
const passInput = document.getElementById("passcode");
const letterSlots = document.querySelectorAll(".letter-slot");
const casePanel = document.getElementById("case-files");
const lockStatus = document.getElementById("lock-status");
const monitorFrame = document.querySelector(".terminal-monitor .monitor-frame");
const yearSpan = document.getElementById("year");
// Initialise year in footer
if (yearSpan) {
yearSpan.textContent = String(new Date().getFullYear());
}
// Theme -----------------------------------------------------------------
const storedTheme = localStorage.getItem("dipti-theme");
if (storedTheme === "light" || storedTheme === "dark") {
root.setAttribute("data-theme", storedTheme);
}
if (themeToggle) {
themeToggle.addEventListener("click", function () {
const current = root.getAttribute("data-theme") || "dark";
const next = current === "dark" ? "light" : "dark";
root.setAttribute("data-theme", next);
localStorage.setItem("dipti-theme", next);
});
}
// Sherlock lock ---------------------------------------------------------
if (!unlockForm || !passInput || !casePanel || !lockStatus || !monitorFrame) {
return;
}
function updateLetterSlots(value) {
const upper = value.toUpperCase().slice(0, 4);
letterSlots.forEach(function (slot, index) {
slot.textContent = upper[index] || "_";
});
}
passInput.addEventListener("input", function (event) {
updateLetterSlots(event.target.value || "");
});
unlockForm.addEventListener("submit", function (event) {
event.preventDefault();
const value = (passInput.value || "").trim().toUpperCase();
if (value === "SHER") {
casePanel.classList.remove("is-locked");
casePanel.classList.add("is-unlocked");
lockStatus.textContent = "Terminal status: UNLOCKED";
monitorFrame.classList.add("monitor-frame--unlocked");
passInput.disabled = true;
const button = unlockForm.querySelector("button[type='submit']");
if (button) {
button.disabled = true;
button.textContent = "Unlocked";
}
// Smooth scroll to case panel
casePanel.scrollIntoView({ behavior: "smooth", block: "start" });
} else {
lockStatus.textContent = "Access denied. Try again.";
monitorFrame.classList.remove("monitor-frame--unlocked");
monitorFrame.classList.remove("monitor-frame--error");
// Trigger CSS shake animation
void monitorFrame.offsetWidth; // force reflow
monitorFrame.classList.add("monitor-frame--error");
}
});
})();