-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (53 loc) · 2.27 KB
/
script.js
File metadata and controls
61 lines (53 loc) · 2.27 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
// document.addEventListener('DOMContentLoaded', function () {
// var audio = document.getElementById('jingle-bells');
// audio.play();
// });
document.addEventListener('DOMContentLoaded', function () {
// Set the date for New Year's Day
const newYearDate = new Date('January 1, 2024 00:00:00').getTime();
// Update the countdown every second
const countdownElement = document.getElementById('countdown');
const countdownInterval = setInterval(updateCountdown, 1000);
function updateCountdown() {
const now = new Date().getTime();
const timeRemaining = newYearDate - now;
if (timeRemaining < 0) {
// If the countdown is over, display a message
clearInterval(countdownInterval);
countdownElement.innerHTML = '<p>Happy New Year!</p>';
} else {
// Calculate remaining days, hours, minutes, and seconds
const days = Math.floor(timeRemaining / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeRemaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000);
// Update the countdown element
countdownElement.innerHTML = `<p>${days}d ${hours}h ${minutes}m ${seconds}s</p>`;
}
}
});
var buttons = document.querySelectorAll(".toggleButton");
function close() {
buttons.forEach((button) => {
button.innerHTML = "Wanna Open Your Greetings Card??";
button.nextElementSibling.style.display = "none";
});
}
close();
buttons.forEach(function (button)
{
button.addEventListener("click", function ()
{
var extraContent = this.nextElementSibling;
if (extraContent.style.display === "none")
{
button.innerHTML = "Merry Christmas to You too!!";
extraContent.style.display = "block";
}
else
{
button.innerHTML = "Wanna Open Your Greetings Card??";
extraContent.style.display = "none";
}
});
});