From 34d77cd777bd44d7bfe0e3ab3379f9be256ca88b Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Sun, 9 Nov 2025 09:56:59 +0100 Subject: Moved to javascript codebase --- app/static/custom.css | 34 ------------------ app/static/favicon.ico | Bin 15406 -> 0 bytes app/static/file.js | 11 ------ app/static/timer.js | 91 ------------------------------------------------- 4 files changed, 136 deletions(-) delete mode 100644 app/static/custom.css delete mode 100644 app/static/favicon.ico delete mode 100644 app/static/file.js delete mode 100644 app/static/timer.js (limited to 'app/static') diff --git a/app/static/custom.css b/app/static/custom.css deleted file mode 100644 index a5ca36f..0000000 --- a/app/static/custom.css +++ /dev/null @@ -1,34 +0,0 @@ -button, input, select { - width: 100%; - height: 100%; -} -td { - width: 20%; -} -.grid { - margin-top: 20px; - margin-bottom: 20px; -} -footer { - text-align: center; -} -.parent, .timer { - display: grid; - grid-column-gap: 20px; - grid-row-gap: 20px; - margin-top: 20px; - margin-bottom: 20px; - grid-auto-columns: 1fr; - grid-auto-rows: 1fr; -} -@media (min-width: 900px) { - table { - font-size: xx-large; - } - .parent { - grid-template-columns: repeat(4, 1fr); - } - .timer { - grid-template-columns: 4fr repeat(2, 1fr); - } -} diff --git a/app/static/favicon.ico b/app/static/favicon.ico deleted file mode 100644 index 64eab0a..0000000 Binary files a/app/static/favicon.ico and /dev/null differ diff --git a/app/static/file.js b/app/static/file.js deleted file mode 100644 index 403ddf6..0000000 --- a/app/static/file.js +++ /dev/null @@ -1,11 +0,0 @@ -window.onload = function() { - const fileInput = document.querySelector("#file-js input[type=file]"); - if (fileInput !== null) { - fileInput.onchange = () => { - if (fileInput.files.length > 0) { - const fileName = document.querySelector("#file-js .file-name"); - fileName.textContent = fileInput.files[0].name; - } - } - }; -} \ No newline at end of file diff --git a/app/static/timer.js b/app/static/timer.js deleted file mode 100644 index e8e7854..0000000 --- a/app/static/timer.js +++ /dev/null @@ -1,91 +0,0 @@ -let minsPerRound = Number(sessionStorage.getItem("minsPerRound")) || 12; -let timerRunningFlag = Number(sessionStorage.getItem("timerRunningFlag")) || 0; -let deadline = Number(sessionStorage.getItem("deadline")) || new Date().getTime(); -let clock = 0; - -function setTimer(m, s) { - let timer = document.getElementById("timer-display"); - m = m < 10 ? ("0" + m) : m; - s = s < 10 ? ("0" + s) : s; - timer.value = `${m}:${s}`; -} - -function setSessionData() { - sessionStorage.setItem("deadline", deadline); - sessionStorage.setItem("minsPerRound", minsPerRound); - sessionStorage.setItem("timerRunningFlag", timerRunningFlag); -} - -function resetTimer() { - clearInterval(clock); - setTimer(minsPerRound, 0); - timerRunningFlag = 0; - setSessionData(); -} - -function updateTimer(milliseconds) { - const m = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60)); - const s = Math.floor((milliseconds % (1000 * 60)) / 1000); - setTimer(m, s); -} - -function refreshTimer() { - const now = new Date().getTime(); - const millisecondsToDeadline = deadline - now; - if (millisecondsToDeadline > 0) { - updateTimer(millisecondsToDeadline); - return; - } - resetTimer(); - const notification = new Notyf({ - duration: 30 * 1000, - position: {x: 'center', y: 'top'}, - types: [{ - type: 'success', - background: 'indianred', - duration: 1000 * 1000, - dismissible: true - }] - }); - notification.success("Round completed"); -} - -function startTimer(fresh) { - if (fresh) { - now = new Date().getTime(); - const millisecondsToDeadline = minsPerRound * 60 * 1000; - deadline = now + millisecondsToDeadline; - } - timerRunningFlag = 1; - setSessionData(); - clock = setInterval(refreshTimer, 1000); -} - -window.onload = function () { - if (timerRunningFlag) - startTimer(0); - else resetTimer(); - - document.getElementById("timer-start").addEventListener('click', ()=> { - if (timerRunningFlag != 0) return; - startTimer(1); - }); - - document.getElementById("timer-stop").addEventListener('click', ()=>{ - resetTimer(); - }); - - document.getElementById("timer-inc").addEventListener('click', ()=> { - if (timerRunningFlag == 0) { - minsPerRound += 1; - resetTimer(); - } - }); - - document.getElementById("timer-dec").addEventListener('click', ()=> { - if (timerRunningFlag == 0 && minsPerRound != 0) { - minsPerRound -= 1; - resetTimer(); - } - }); -} \ No newline at end of file -- cgit v1.3.1