-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
96 lines (80 loc) · 3.02 KB
/
Copy pathscript.js
File metadata and controls
96 lines (80 loc) · 3.02 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
window.onload = function () {
const endTime = new Date("April 30, 2023 11:00:00").getTime();
const daysEl = document.querySelector(".days > p:first-child");
const hoursEl = document.querySelector(".hours > p:first-child");
const minsEl = document.querySelector(".minutes > p:first-child");
const secsEl = document.querySelector(".seconds > p:first-child");
const toggleButton = document.querySelector(".scroll_button");
const heading = document.querySelector("#card_contents > p:nth-child(3)");
const place = document.querySelector("#card_contents > p:nth-child(9)");
let toggleState = 0;
let celebrationDone = false;
function toggleContent() {
toggleState = (toggleState + 1) % 2;
if (toggleState === 0) {
heading.innerHTML = "Sabayaz";
place.innerHTML = "Aman Hall<br>Sangli, Maharastra";
} else {
heading.innerHTML = "Engagement";
place.innerHTML = "Aman Hall<br>Sangli, Maharastra";
}
}
toggleButton.addEventListener("click", toggleContent);
const countdownInterval = setInterval(() => {
const now = new Date().getTime();
let diff = endTime - now;
if (diff <= 0 && !celebrationDone) {
clearInterval(countdownInterval);
daysEl.textContent = '00';
hoursEl.textContent = '00';
minsEl.textContent = '00';
secsEl.textContent = '00';
triggerConfetti();
celebrationDone = true;
return;
}
let days = Math.floor(diff / (1000 * 60 * 60 * 24));
let hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
let minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
let seconds = Math.floor((diff % (1000 * 60)) / 1000);
if (seconds < 10) seconds = '0' + seconds;
if (minutes < 10) minutes = '0' + minutes;
if (hours < 10) hours = '0' + hours;
if (days < 10) days = '0' + days;
daysEl.textContent = days;
hoursEl.textContent = hours;
minsEl.textContent = minutes;
secsEl.textContent = seconds;
}, 1000);
// Confetti celebration function
function triggerConfetti() {
// Optional: if you have a central timer display too:
const timer = document.getElementById("timer");
if (timer) {
}
confetti({
particleCount: 200,
spread: 90,
origin: { y: 0.6 }
});
let duration = 2 * 1000;
let end = Date.now() + duration;
(function frame() {
confetti({
particleCount: 5,
angle: 60,
spread: 55,
origin: { x: 0 }
});
confetti({
particleCount: 5,
angle: 120,
spread: 55,
origin: { x: 1 }
});
if (Date.now() < end) {
requestAnimationFrame(frame);
}
})();
}
};