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
// This val will serve an HTML countdown timer to April 14, 2025.
// It uses CSS for styling and animations and JavaScript for the countdown logic.
export default async function main(req: Request): Promise<Response> {
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Countdown to 2025 Event Kickoff</title>
<link href="https://fonts.googleapis.com/css2?family=Merriweather:wght@700&display=swap" rel="stylesheet">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #282c34;
color: white;
font-family: 'Merriweather', serif;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
.countdown {
text-align: center;
}
.time {
font-size: 5rem;
animation: pulse 1s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
.label {
font-size: 1.5rem;
margin-top: -20px;
}
</style>
</head>
<body>
<div class="countdown">
<h1> </h1>
<div>
<span class="time" id="weeks">0</span>
<div class="label">Weeks</div>
</div>
<div>MMXXV</div>
</div>
<script>
function updateCountdown() {
const eventDate = new Date('2025-04-14T00:00:00');
const now = new Date();
const totalSeconds = Math.floor((eventDate - now) / 1000);
const weeks = Math.floor(totalSeconds / (60 * 60 * 24 * 7));
const days = Math.floor((totalSeconds % (60 * 60 * 24 * 7)) / (60 * 60 * 24));
const minutes = Math.floor((totalSeconds % (60 * 60 * 24)) / 60) % 60;
document.getElementById('weeks').textContent = weeks;
document.getElementById('days').textContent = days;
document.getElementById('minutes').textContent = minutes;
}
setInterval(updateCountdown, 1000);
updateCountdown(); // initial call to set the countdown immediately
</script>
</body>
</html>
`;
return new Response(html, { headers: { "Content-Type": "text/html" } });
}