From 08e4a27c0db7fc2867cce3eb6f80799148c03ba6 Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Fri, 25 Jul 2025 15:30:07 +0200 Subject: Moved to a mobile friendly CSS framework --- app/static/custom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/static/custom.js') diff --git a/app/static/custom.js b/app/static/custom.js index 1d36493..2c47448 100644 --- a/app/static/custom.js +++ b/app/static/custom.js @@ -3,7 +3,7 @@ let timerRunningFlag = Number(sessionStorage.getItem("timerRunningFlag")) || 0; let deadline = Number(sessionStorage.getItem("deadline")) || new Date().getTime(); let clock = 0; -function setTimer(m, s) { +window.onload += function setTimer(m, s) { let timer = document.getElementById("timer-display"); m = m < 10 ? ("0" + m) : m; s = s < 10 ? ("0" + s) : s; -- cgit v1.3.1 From c041e74af8c69e8fb0680558e23dd7be542afcf6 Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Fri, 25 Jul 2025 15:52:42 +0200 Subject: Working version --- app/static/custom.css | 3 +++ app/static/custom.js | 52 +++++++++++++++++++++-------------------------- app/templates/controls.j2 | 16 +++++++++------ app/templates/players.j2 | 51 ++++++++++++++++++++++++---------------------- 4 files changed, 63 insertions(+), 59 deletions(-) (limited to 'app/static/custom.js') diff --git a/app/static/custom.css b/app/static/custom.css index 9992ee5..8aa5b57 100644 --- a/app/static/custom.css +++ b/app/static/custom.css @@ -9,6 +9,9 @@ td { margin-top: 20px; margin-bottom: 20px; } +footer { + text-align: center; +} .parent { display: grid; grid-column-gap: 20px; diff --git a/app/static/custom.js b/app/static/custom.js index 2c47448..3daeb17 100644 --- a/app/static/custom.js +++ b/app/static/custom.js @@ -3,7 +3,7 @@ let timerRunningFlag = Number(sessionStorage.getItem("timerRunningFlag")) || 0; let deadline = Number(sessionStorage.getItem("deadline")) || new Date().getTime(); let clock = 0; -window.onload += function setTimer(m, s) { +function setTimer(m, s) { let timer = document.getElementById("timer-display"); m = m < 10 ? ("0" + m) : m; s = s < 10 ? ("0" + s) : s; @@ -61,37 +61,31 @@ function startTimer(fresh) { clock = setInterval(refreshTimer, 1000); } -if (timerRunningFlag) startTimer(0); else resetTimer(); +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-start").addEventListener('click', ()=> { + if (timerRunningFlag != 0) return; + startTimer(1); + }); -document.getElementById("timer-inc").addEventListener('click', ()=> { - if (timerRunningFlag == 0) { - minsPerRound += 1; + document.getElementById("timer-stop").addEventListener('click', ()=>{ resetTimer(); - } -}); + }); -document.getElementById("timer-dec").addEventListener('click', ()=> { - if (timerRunningFlag == 0 && minsPerRound != 0) { - minsPerRound -= 1; - resetTimer(); - } -}); + document.getElementById("timer-inc").addEventListener('click', ()=> { + if (timerRunningFlag == 0) { + minsPerRound += 1; + resetTimer(); + } + }); -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; + document.getElementById("timer-dec").addEventListener('click', ()=> { + if (timerRunningFlag == 0 && minsPerRound != 0) { + minsPerRound -= 1; + resetTimer(); } - } -}; \ No newline at end of file + }); +} \ No newline at end of file diff --git a/app/templates/controls.j2 b/app/templates/controls.j2 index a8cba89..14e7520 100644 --- a/app/templates/controls.j2 +++ b/app/templates/controls.j2 @@ -37,10 +37,14 @@ hx-target="#games">RESET!

Timer

-
- - - - - +
+
+ + + +
+
+
+ +
\ No newline at end of file diff --git a/app/templates/players.j2 b/app/templates/players.j2 index f10b0a9..4b9660e 100644 --- a/app/templates/players.j2 +++ b/app/templates/players.j2 @@ -18,30 +18,33 @@ {% endfor %}

Controls

-
-
- -
-
-
-
- - -
-
-
-
{{ footer() }}
-
+
+ +
+

Player Update

+
+
+
+ + +
+
+
+
{{ footer() }}
+ \ No newline at end of file -- cgit v1.3.1 From 63e1b52e1b76e136e6534949980d85ffe413f0c9 Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Fri, 25 Jul 2025 16:06:20 +0200 Subject: Working mobile and desktop version --- app/__init__.py | 3 +- app/static/custom.js | 91 ----------------------------------------------- app/static/file.js | 11 ++++++ app/static/timer.js | 91 +++++++++++++++++++++++++++++++++++++++++++++++ app/templates/controls.j2 | 12 +++---- app/templates/games.j2 | 2 +- app/templates/index.j2 | 4 +-- app/templates/macros.j2 | 4 +-- app/templates/players.j2 | 14 ++------ 9 files changed, 117 insertions(+), 115 deletions(-) delete mode 100644 app/static/custom.js create mode 100644 app/static/file.js create mode 100644 app/static/timer.js (limited to 'app/static/custom.js') diff --git a/app/__init__.py b/app/__init__.py index 639f030..0e0ea09 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -31,7 +31,7 @@ g = Session() @app.route("/", methods=["GET"]) def home(): - return render_template("index.j2", url_for=url_for) + return render_template("index.j2", url_for=url_for, login_status=is_logged_in()) @app.route("/control", methods=["GET"]) @@ -46,6 +46,7 @@ def get_list_of_players(): regulars=g.players.regulars(), guests=g.players.guests(), url_for=url_for, + login_status=is_logged_in(), ) diff --git a/app/static/custom.js b/app/static/custom.js deleted file mode 100644 index 3daeb17..0000000 --- a/app/static/custom.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 diff --git a/app/static/file.js b/app/static/file.js new file mode 100644 index 0000000..403ddf6 --- /dev/null +++ b/app/static/file.js @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..e8e7854 --- /dev/null +++ b/app/static/timer.js @@ -0,0 +1,91 @@ +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 diff --git a/app/templates/controls.j2 b/app/templates/controls.j2 index 14e7520..8e7440e 100644 --- a/app/templates/controls.j2 +++ b/app/templates/controls.j2 @@ -1,10 +1,4 @@ {% from "macros.j2" import court_button %} -

Courts

-
-{% for court in courts %} - {{ court_button(court) }} -{% endfor %} -

Generation

@@ -47,4 +41,10 @@
+
+

Courts

+
+{% for court in courts %} + {{ court_button(court) }} +{% endfor %}
\ No newline at end of file diff --git a/app/templates/games.j2 b/app/templates/games.j2 index ce2a412..5041ce1 100644 --- a/app/templates/games.j2 +++ b/app/templates/games.j2 @@ -10,7 +10,7 @@ {% for game in games %} - + {{ game.court.id }} {{ game.team_1[0].first_name }}{{ " " + game.team_1[0].last_name }} {{ game.team_1[1].first_name }}{{ " " + game.team_1[1].last_name }} diff --git a/app/templates/index.j2 b/app/templates/index.j2 index 8a13fa0..af6ca4c 100644 --- a/app/templates/index.j2 +++ b/app/templates/index.j2 @@ -3,7 +3,7 @@ {{ header(url_for) }} -
{{ navbar(url_for) }}
+
{{ navbar(url_for, login_status) }}

Games

@@ -11,6 +11,6 @@
{{ footer() }}
- + diff --git a/app/templates/macros.j2 b/app/templates/macros.j2 index 17a2940..e82b910 100644 --- a/app/templates/macros.j2 +++ b/app/templates/macros.j2 @@ -31,7 +31,7 @@ {%- endmacro %} -{% macro navbar(url_for) -%} +{% macro navbar(url_for, login_status) -%} {%- endmacro %} \ No newline at end of file diff --git a/app/templates/players.j2 b/app/templates/players.j2 index 4b9660e..bacb215 100644 --- a/app/templates/players.j2 +++ b/app/templates/players.j2 @@ -3,7 +3,7 @@ {{ header(url_for) }} -
{{ navbar(url_for) }}
+
{{ navbar(url_for, login_status) }}

Members

@@ -34,17 +34,7 @@
{{ footer() }}
- +
\ No newline at end of file -- cgit v1.3.1