-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
90 lines (74 loc) · 2.77 KB
/
Copy pathscript.js
File metadata and controls
90 lines (74 loc) · 2.77 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
const CORRECT_PIN = "0512";
let currentPin = "";
function updateDots() {
const dots = document.querySelectorAll('.dot');
dots.forEach((dot, index) => {
if (index < currentPin.length) {
dot.classList.add('filled');
} else {
dot.classList.remove('filled');
}
});
}
function pressKey(num) {
const errorMsg = document.getElementById('error-message');
errorMsg.classList.remove('show');
const lockContainer = document.querySelector('.lock-container');
lockContainer.classList.remove('shake');
const audio = document.getElementById("main-music");
if (audio && audio.paused) audio.play().catch(e => console.log(e));
if (currentPin.length < 4) {
currentPin += num;
updateDots();
}
}
function clearPin() {
currentPin = currentPin.slice(0, -1);
updateDots();
const errorMsg = document.getElementById('error-message');
errorMsg.classList.remove('show');
}
function submitPin() {
if (currentPin.length === 0) return;
if (currentPin === CORRECT_PIN) {
// Unlock success
const lockScreen = document.getElementById('lock-screen');
lockScreen.classList.add('unlock-anim');
setTimeout(() => {
lockScreen.classList.remove('active');
lockScreen.classList.remove('unlock-anim');
const welcomeScreen = document.getElementById('welcome-screen');
welcomeScreen.classList.add('active');
setTimeout(() => {
welcomeScreen.classList.add('fade-out');
setTimeout(() => {
welcomeScreen.classList.remove('active');
welcomeScreen.classList.remove('fade-out');
document.getElementById('main-screen').classList.add('active');
const mainMusic = document.getElementById('main-music');
if (mainMusic) {
mainMusic.volume = 0.5;
mainMusic.play().catch(e => console.log('Autoplay prevented', e));
}
}, 800);
}, 2000);
}, 800);
} else {
// Unlock failed
const errorMsg = document.getElementById('error-message');
errorMsg.classList.add('show');
const lockContainer = document.querySelector('.lock-container');
lockContainer.classList.add('shake');
// Vibrate if supported
if (navigator.vibrate) {
navigator.vibrate([100, 50, 100]);
}
currentPin = "";
setTimeout(() => {
updateDots();
}, 400);
}
}
function openMenu(menuName) {
window.location.href = `pages/${menuName}.html`;
}