-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaulaJS.html
More file actions
66 lines (59 loc) · 2.44 KB
/
Copy pathaulaJS.html
File metadata and controls
66 lines (59 loc) · 2.44 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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Cronômetro Regressivo</title>
<link rel="stylesheet" href="./css.css">
</head>
<body>
<div class="countdown-container" aria-label="Cronômetro regressivo">
<h1 class="countdown-title">Tempo Restante</h1>
<div class="time-sections">
<div class="time-section" aria-live="polite" aria-atomic="true">
<div id="days" class="time-number">00</div>
<div class="time-label">Dias</div>
</div>
<div class="time-section" aria-live="polite" aria-atomic="true">
<div id="hours" class="time-number">00</div>
<div class="time-label">Horas</div>
</div>
<div class="time-section" aria-live="polite" aria-atomic="true">
<div id="minutes" class="time-number">00</div>
<div class="time-label">Minutos</div>
</div>
<div class="time-section" aria-live="polite" aria-atomic="true">
<div id="seconds" class="time-number">00</div>
<div class="time-label">Segundos</div>
</div>
</div>
</div>
<script>
// Set the target date for the countdown (example: 7 days from now)
const countdownTarget = new Date();
countdownTarget.setDate(countdownTarget.getDate() + 7);
function updateCountdown() {
const now = new Date();
const diff = countdownTarget - now;
if (diff <= 0) {
document.getElementById("days").textContent = '00';
document.getElementById("hours").textContent = '00';
document.getElementById("minutes").textContent = '00';
document.getElementById("seconds").textContent = '00';
clearInterval(timerInterval);
return;
}
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
const hours = Math.floor((diff / (1000 * 60 * 60)) % 24);
const minutes = Math.floor((diff / (1000 * 60)) % 60);
const seconds = Math.floor((diff / 1000) % 60);
document.getElementById("days").textContent = days.toString().padStart(2, '0');
document.getElementById("hours").textContent = hours.toString().padStart(2, '0');
document.getElementById("minutes").textContent = minutes.toString().padStart(2, '0');
document.getElementById("seconds").textContent = seconds.toString().padStart(2, '0');
}
updateCountdown();
const timerInterval = setInterval(updateCountdown, 1000);
</script>
</body>
</html>