countdown / script.js
maringetxway's picture
Update script.js
84bbe4b verified
// Target date here (Year, Month (0-11), Day, Hour, Minute)
const targetDate = new Date("2025-06-14T07:00:00Z"); // UTC time
function updateCountdown() {
const now = new Date();
const diff = targetDate - now;
if (diff <= 0) {
document.getElementById("countdown").innerHTML = "<h2>πŸš€ Launched!</h2>";
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 = String(days).padStart(2, '0');
document.getElementById("hours").textContent = String(hours).padStart(2, '0');
document.getElementById("minutes").textContent = String(minutes).padStart(2, '0');
document.getElementById("seconds").textContent = String(seconds).padStart(2, '0');
}
setInterval(updateCountdown, 1000);
updateCountdown();
const audio = document.getElementById("backgroundSound");
if (audio) {
audio.volume = 0.05; // Set volume immediately when script loads
}
window.addEventListener('click', () => {
if (audio && audio.paused) {
audio.play().catch((e) => console.log("Audio autoplay blocked:", e));
}
}, { once: true });