refactor: hide countdown after deadline

This commit is contained in:
Oliver Booth 2024-02-23 05:04:50 +00:00
parent 279d824772
commit 21be5e9622
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
2 changed files with 15 additions and 10 deletions

View File

@ -94,14 +94,17 @@
<div style="margin:50px 0;"></div>
<div id="usa-countdown" class="container">
<div class="row">
<div class="col-3 usa-countdown-element" id="usa-countdown-days">00</div>
<div class="col-3 usa-countdown-element" id="usa-countdown-hours">00</div>
<div class="col-3 usa-countdown-element" id="usa-countdown-minutes">00</div>
<div class="col-3 usa-countdown-element" id="usa-countdown-seconds">00</div>
@if (DateTimeOffset.UtcNow < new DateTime(2024, 03, 08))
{
<div id="usa-countdown" class="container">
<div class="row">
<div class="col-3 usa-countdown-element" id="usa-countdown-days">00</div>
<div class="col-3 usa-countdown-element" id="usa-countdown-hours">00</div>
<div class="col-3 usa-countdown-element" id="usa-countdown-minutes">00</div>
<div class="col-3 usa-countdown-element" id="usa-countdown-seconds">00</div>
</div>
</div>
</div>
}
<div style="margin:50px 0;"></div>

View File

@ -99,7 +99,9 @@ declare const Prism: any;
UI.updateUI();
const usaCountdown = document.getElementById("usa-countdown");
usaCountdown.addEventListener("click", () => window.location.href = "/blog/2024/02/19/the-american");
UI.updateUsaCountdown(usaCountdown);
setInterval(() => UI.updateUsaCountdown(usaCountdown), 1000);
if (usaCountdown) {
usaCountdown.addEventListener("click", () => window.location.href = "/blog/2024/02/19/the-american");
UI.updateUsaCountdown(usaCountdown);
setInterval(() => UI.updateUsaCountdown(usaCountdown), 1000);
}
})();