From 704ecb424988ab8174c8213d0560a8def6cfd102 Mon Sep 17 00:00:00 2001 From: grey Date: Mon, 7 Aug 2023 16:59:38 +0200 Subject: [PATCH] finally introduced CNTDWN-1 (allow/disallow overrun) --- index.js | 13 +++++++++++++ lang/de_de.json | 3 ++- lang/en_uk.json | 3 ++- lang/proto_black.json | 3 ++- package-lock.json | 4 ++-- static/js/interface.js | 6 ++++++ static/js/timer/timerview.js | 3 +++ templates/newAdminPanel.html | 3 +++ 8 files changed, 33 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index f5626d7..eb58145 100644 --- a/index.js +++ b/index.js @@ -73,6 +73,7 @@ currentState = { srvTime: 0, enableColoredText: true, debug: false, + enableOverrun: true, sessionToken: Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15), }; @@ -269,6 +270,18 @@ app.get("/api/v1/set/layout/showTime", function (req, res) { updatedData() }); +app.get("/api/v1/set/enableOverrun", function (req, res) { + const resy = helper.wrapBooleanConverter(req.query.enable, res) + if (resy != undefined) { + currentState.enableOverrun = resy; + if (req.query.persist === 'true') { + dataToBeWritten.enableOverrun = currentState.enableOverrun + } + res.json({ status: "ok" }); + } + updatedData() + }); + app.get("/api/v1/set/progressbar/show", function (req, res) { currentState.showProgressbar = (req.query.show === 'true'); if (req.query.persist === 'true') { diff --git a/lang/de_de.json b/lang/de_de.json index c931975..b2c318c 100644 --- a/lang/de_de.json +++ b/lang/de_de.json @@ -46,7 +46,8 @@ "enableTextClrs": "Text Farben aktivieren:", "textClrs": "Text Farben", "addRow": "Neue Zeile", - "timeVar": "Aktiviere zeitabweichungs display:" + "timeVar": "Aktiviere zeitabweichungs display:", + "allowOverrun": "Überlauf erlauben: " }, "untis": { diff --git a/lang/en_uk.json b/lang/en_uk.json index 56d604c..a9a2e74 100644 --- a/lang/en_uk.json +++ b/lang/en_uk.json @@ -49,7 +49,8 @@ "addRow": "Add Row", "timeVar": "Enable time variance display:", "language": "Select a language", - "apply": "Apply" + "apply": "Apply", + "allowOverrun": "Allow overrun:" }, "untis": { diff --git a/lang/proto_black.json b/lang/proto_black.json index bf4547a..0652a19 100644 --- a/lang/proto_black.json +++ b/lang/proto_black.json @@ -46,7 +46,8 @@ "enableTextClrs": "██████ ████ ███████:", "textClrs": "████ ██████", "addRow": "███ ███", - "timeVar": "██████ ████ ███████ ███████:" + "timeVar": "██████ ████ ███████ ███████:", + "allowOverrun": "██████ ████████:" }, "untis": { diff --git a/package-lock.json b/package-lock.json index 9181e57..f762a8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "opencountdown", - "version": "1.0.4", + "version": "1.0.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "opencountdown", - "version": "1.0.4", + "version": "1.0.7", "license": "LGPL-3.0", "dependencies": { "body-parser": "^1.20.1", diff --git a/static/js/interface.js b/static/js/interface.js index 12d2fa9..5c3cbe7 100644 --- a/static/js/interface.js +++ b/static/js/interface.js @@ -131,6 +131,7 @@ $(function () { $("#showMillis")[0].checked = jsonResult.showMilliSeconds; $("#progBarShow")[0].checked = jsonResult.showProgressbar; $("#textColors")[0].checked = jsonResult.enableColoredText; + $("#allowOverrun")[0].checked = jsonResult.enableOverrun; console.log(document.getElementById("tableCopySource")) let tableEntryDom = document.getElementById("tableCopySource").cloneNode(true) @@ -266,6 +267,7 @@ $(function () { const showMillisB = $("#showMillis")[0].checked const progBarShowB = $("#progBarShow")[0].checked const textColorsB = $("#textColors")[0].checked + const allowOverrun = $("#allowOverrun")[0].checked const colors = convertColorSegments("colors1") const colors2 = convertColorSegments("colors2") @@ -276,6 +278,8 @@ $(function () { allPathes.push("/api/v1/set/text/enableColoring?enable=" + textColorsB) allPathes.push("/api/v1/set/progressbar/colors?isBase64=true&colors=" + btoa(JSON.stringify(colors))) allPathes.push("/api/v1/set/text/colors?isBase64=true&colors=" + btoa(JSON.stringify(colors2))) + allPathes.push("/api/v1/set/enableOverrun?enable=" + allowOverrun) + for (pI in allPathes) { @@ -301,11 +305,13 @@ $(function () { const showMillisB = $("#showMillis")[0].checked const progBarShowB = $("#progBarShow")[0].checked const textColorsB = $("#textColors")[0].checked + const allowOverrun = $("#allowOverrun")[0].checked allPathes.push("/api/v1/set/layout/showTime?persist=true&show=" + showTimeB) allPathes.push("/api/v1/set/layout/showMillis?persist=true&show=" + showMillisB) allPathes.push("/api/v1/set/progressbar/show?persist=true&show=" + progBarShowB) allPathes.push("/api/v1/set/text/enableColoring?persist=true&enable=" + textColorsB) + allPathes.push("/api/v1/set/enableOverrun?persist=true&enable=" + allowOverrun) for (pI in allPathes) { const path = allPathes[pI]; diff --git a/static/js/timer/timerview.js b/static/js/timer/timerview.js index ab55218..884c732 100644 --- a/static/js/timer/timerview.js +++ b/static/js/timer/timerview.js @@ -186,6 +186,9 @@ function handleUpdate() { progressBar.style.width = percentage(diff, dataFrame.timeAmountInital) + "%"; } else { progressBar.style.width = "0%"; + if(!dataFrame.enableOverrun) { + timer.innerHTML = "00:00:00"; + } } progressBar.style.backgroundColor = findProgessColor(dataFrame.colorSegments, diff) diff --git a/templates/newAdminPanel.html b/templates/newAdminPanel.html index 5c0107d..e8541e9 100644 --- a/templates/newAdminPanel.html +++ b/templates/newAdminPanel.html @@ -262,6 +262,9 @@
+ + +
<%= it.lang.labels.progbarColors %>