From e12161b733f19372896ebdd31be6975878af6a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Kub=C3=AD=C4=8Dek?= Date: Mon, 28 Sep 2026 11:27:43 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99id=C3=A1n=C3=AD=20timeru?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/StuzkovakWeb/Views/Home/Index.cshtml | 3 +++ web/StuzkovakWeb/wwwroot/js/site.js | 25 +++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/web/StuzkovakWeb/Views/Home/Index.cshtml b/web/StuzkovakWeb/Views/Home/Index.cshtml index d3891fe..8aa5cab 100644 --- a/web/StuzkovakWeb/Views/Home/Index.cshtml +++ b/web/StuzkovakWeb/Views/Home/Index.cshtml @@ -167,6 +167,9 @@ } +
+ Do večírku zbývá: +
diff --git a/web/StuzkovakWeb/wwwroot/js/site.js b/web/StuzkovakWeb/wwwroot/js/site.js index 0937657..587f2bb 100644 --- a/web/StuzkovakWeb/wwwroot/js/site.js +++ b/web/StuzkovakWeb/wwwroot/js/site.js @@ -1,4 +1,23 @@ -// Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification -// for details on configuring this project to bundle and minify static web assets. +const PARTY_DATE = new Date(2026, 9, 23, 16, 0); -// Write your JavaScript code. +function updateTimer() { + const timerEl = document.getElementById("timer"); + const diff = PARTY_DATE - new Date(); + + if (diff <= 0) { + timerEl.textContent = "Večírek již začal!"; + clearInterval(intervalId); + 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; + + timerEl.textContent = + `${days} dní a ${String(hours)}:${String(minutes)}:${String(seconds).padStart(2, "0")}`; +} + +updateTimer(); // run immediately so the span isn't empty for the first second +const intervalId = setInterval(updateTimer, 1000); \ No newline at end of file