-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (40 loc) · 1.53 KB
/
Copy pathscript.js
File metadata and controls
53 lines (40 loc) · 1.53 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
// Digital clock
function updateClock() {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var timeString = formatTime(hours) + ":" + formatTime(minutes) + ":" + formatTime(seconds);
document.getElementById("digital-clock").textContent = timeString;
}
function formatTime(time) {
return time.toString().padStart(2, '0');
}
setInterval(updateClock, 1000);
// Calendar
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var calendarElement = document.getElementById("calendar");
function updateCalendar() {
var now = new Date();
var dateString = now.toLocaleDateString(undefined, options);
calendarElement.textContent = dateString;
}
updateCalendar();
document.getElementById("party-button").addEventListener("click", partyPopper);
function partyPopper() {
var confettiContainer = document.getElementById("confetti-container");
for (var i = 0; i < 1000; i++) {
var confetti = document.createElement("div");
confetti.classList.add("confetti");
confetti.style.left = Math.random() * 100 + "vw";
confetti.style.animationDuration = Math.random() * 2 + 3 + "s";
confetti.style.animationDelay = Math.random() * 2 + "s";
confetti.style.transform = "rotate(" + Math.random() * 360 + "deg)";
confettiContainer.appendChild(confetti);
}
setTimeout(clearConfetti, 10000);
}
function clearConfetti() {
var confettiContainer = document.getElementById("confetti-container");
confettiContainer.innerHTML = "";
}