This commit is contained in:
parent
1553604159
commit
124e2a87dd
1 changed files with 0 additions and 43 deletions
|
|
@ -124,47 +124,4 @@ import path from "../utils/path.ts"
|
||||||
|
|
||||||
|
|
||||||
<Footer/>
|
<Footer/>
|
||||||
|
|
||||||
<script>
|
|
||||||
const countdownElement: HTMLElement = document.getElementById("countdown")!
|
|
||||||
const daysElement: HTMLElement = countdownElement.querySelector("#days")!
|
|
||||||
const hoursElement: HTMLElement = countdownElement.querySelector("#hours")!
|
|
||||||
const minutesElement: HTMLElement = countdownElement.querySelector("#minutes")!
|
|
||||||
const secondsElement: HTMLElement = countdownElement.querySelector("#seconds")!
|
|
||||||
const targetDateTime = new Date(2026, 9, 2, 10, 0, 0)
|
|
||||||
|
|
||||||
const second = 1000
|
|
||||||
const minute = 60 * second
|
|
||||||
const hour = 60 * minute
|
|
||||||
const day = 24 * hour
|
|
||||||
|
|
||||||
function updateCountdown() {
|
|
||||||
countdownElement.classList.add("opacity-50")
|
|
||||||
countdownElement.classList.remove("opacity-0")
|
|
||||||
const diff = targetDateTime.getTime() - Date.now()
|
|
||||||
|
|
||||||
const days = Math.floor(diff / day)
|
|
||||||
const hours = Math.floor((diff % day) / hour)
|
|
||||||
const minutes = Math.floor((diff % hour) / minute)
|
|
||||||
const seconds = Math.floor((diff % minute) / second)
|
|
||||||
|
|
||||||
daysElement.style.setProperty("--value", String(days))
|
|
||||||
daysElement.innerText = String(days)
|
|
||||||
daysElement.setAttribute("aria-label", String(days))
|
|
||||||
hoursElement.style.setProperty("--value", String(hours))
|
|
||||||
hoursElement.innerText = String(hours)
|
|
||||||
hoursElement.setAttribute("aria-label", String(hours))
|
|
||||||
minutesElement.style.setProperty("--value", String(minutes))
|
|
||||||
minutesElement.innerText = String(minutes)
|
|
||||||
minutesElement.setAttribute("aria-label", String(minutes))
|
|
||||||
secondsElement.style.setProperty("--value", String(seconds))
|
|
||||||
secondsElement.innerText = String(seconds)
|
|
||||||
secondsElement.setAttribute("aria-label", String(seconds))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new Date() < targetDateTime) {
|
|
||||||
updateCountdown()
|
|
||||||
setInterval(updateCountdown, 1000)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue