diff --git a/index.js b/index.js index 41e80ea..165e4bc 100644 --- a/index.js +++ b/index.js @@ -155,3 +155,5 @@ app.get("/api/v1/ctrl/message/hide", function (req, res) { }); app.listen(3005); + +console.log("Server running on port 3005"); diff --git a/package-lock.json b/package-lock.json index f517a32..590f14d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,8 +13,10 @@ "bootstrap": "^5.1.3", "bootstrap-icons": "^1.8.1", "countdown": "^2.6.0", + "darkreader": "^4.9.44", "express": "^4.17.3", "jquery": "^3.6.0", + "js-cookie": "^3.0.1", "mdbootstrap": "^4.20.0", "moment": "^2.29.1" } @@ -131,6 +133,15 @@ "resolved": "https://registry.npmjs.org/countdown/-/countdown-2.6.0.tgz", "integrity": "sha1-Z3+446nUzE52QVkBuiU7UYrzQXc=" }, + "node_modules/darkreader": { + "version": "4.9.44", + "resolved": "https://registry.npmjs.org/darkreader/-/darkreader-4.9.44.tgz", + "integrity": "sha512-Mrt5s5eMaFC24Tfi2nNsXpYIfzWK/RUzJxgk0Ysqokvk9lBCn/pkUTyQGYeQbU/U3aKZEYXXqsxZjNfiLoA6QQ==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/darkreader/donate" + } + }, "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -295,6 +306,14 @@ "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz", "integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==" }, + "node_modules/js-cookie": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.1.tgz", + "integrity": "sha512-+0rgsUXZu4ncpPxRL+lNEptWMOWl9etvPHc/koSRp6MPwpRYAhmk0dUG00J4bxVV3r9uUzfo24wW0knS07SKSw==", + "engines": { + "node": ">=12" + } + }, "node_modules/mdbootstrap": { "version": "4.20.0", "resolved": "https://registry.npmjs.org/mdbootstrap/-/mdbootstrap-4.20.0.tgz", @@ -647,6 +666,11 @@ "resolved": "https://registry.npmjs.org/countdown/-/countdown-2.6.0.tgz", "integrity": "sha1-Z3+446nUzE52QVkBuiU7UYrzQXc=" }, + "darkreader": { + "version": "4.9.44", + "resolved": "https://registry.npmjs.org/darkreader/-/darkreader-4.9.44.tgz", + "integrity": "sha512-Mrt5s5eMaFC24Tfi2nNsXpYIfzWK/RUzJxgk0Ysqokvk9lBCn/pkUTyQGYeQbU/U3aKZEYXXqsxZjNfiLoA6QQ==" + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -781,6 +805,11 @@ "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz", "integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==" }, + "js-cookie": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.1.tgz", + "integrity": "sha512-+0rgsUXZu4ncpPxRL+lNEptWMOWl9etvPHc/koSRp6MPwpRYAhmk0dUG00J4bxVV3r9uUzfo24wW0knS07SKSw==" + }, "mdbootstrap": { "version": "4.20.0", "resolved": "https://registry.npmjs.org/mdbootstrap/-/mdbootstrap-4.20.0.tgz", diff --git a/package.json b/package.json index f9686a5..a5e0fa7 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,10 @@ "bootstrap": "^5.1.3", "bootstrap-icons": "^1.8.1", "countdown": "^2.6.0", + "darkreader": "^4.9.44", "express": "^4.17.3", "jquery": "^3.6.0", + "js-cookie": "^3.0.1", "mdbootstrap": "^4.20.0", "moment": "^2.29.1" } diff --git a/static/css/mainStyle.css b/static/css/mainStyle.css index 7df8493..7f7291a 100644 --- a/static/css/mainStyle.css +++ b/static/css/mainStyle.css @@ -101,4 +101,10 @@ body { placeholder { border: red 2px dashed; background-color: yellow; +} + +pre { + overflow: auto; + word-wrap: normal; + white-space: pre; } \ No newline at end of file diff --git a/static/js/cookie.js b/static/js/cookie.js new file mode 120000 index 0000000..9097170 --- /dev/null +++ b/static/js/cookie.js @@ -0,0 +1 @@ +../../node_modules/js-cookie/dist/js.cookie.min.js \ No newline at end of file diff --git a/static/js/darkreader.js b/static/js/darkreader.js new file mode 120000 index 0000000..f810896 --- /dev/null +++ b/static/js/darkreader.js @@ -0,0 +1 @@ +../../node_modules/darkreader/darkreader.js \ No newline at end of file diff --git a/static/js/script.js b/static/js/script.js index 8c71574..cba512b 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -2,6 +2,7 @@ var newDateObj = new Date(); newDateObj = new Date(newDateObj.getTime() + 1000 * 20) allowFullscreen = true +let dataFame = {} function enterFullscreen(element) { if (element.requestFullscreen) { @@ -69,98 +70,99 @@ function findProgessColor(colors, value) { return (resColor) } -function handleUpdate() { +function requestBackend() { resp = httpGet("/api/v1/data"); - resp.onloadend = function (e) { - if(resp.status == 200){ + if (resp.status == 200) { resp = resp.responseText; var data = JSON.parse(resp); - document.getElementById("incomeData").innerHTML = JSON.stringify(data) - document.getElementById("timediff").innerHTML = new Date().getTime() - data.srvTime; - - if(data.debug){ - document.getElementById("timediff").style.display = "block"; - }else{ - document.getElementById("timediff").style.display = "none"; - } - - if (data.defaultFullScreen && document.getElementById("initalDate").innerHTML.includes("true") && allowFullscreen) { - enterFullscreen(document.documentElement); - document.getElementById("initalDate").innerHTML = "false" - } - - if (data.showMessage) { - document.getElementById("overlay").style.display = "block"; - document.getElementById("text").innerHTML = data.message - } else { - off() - } - - if (new Date().getTime() - data.messageAppearTime < 5000) { - if (!document.getElementById("text").classList.contains('blink')) { - document.getElementById("text").classList.add("blink") - } - } else { - if (document.getElementById("text").classList.contains('blink')) { - document.getElementById("text").classList.remove("blink") - } - } - - - if (data.mode == "clock") { - document.getElementById("timer").innerHTML = getTime(); - document.getElementById("testImg").style.display = "none"; - document.getElementById("wholeProgBar").style.display = "none"; - document.getElementById("clockSec").innerHTML = ""; - document.getElementById("timer").style.color = "white" - - } else if (data.mode == "timer") { - - document.getElementById("wholeProgBar").style.display = "block"; - - if (data.timerRunState) { - const now = new Date() - const diff = data.countdownGoal - now.getTime() - document.getElementById("timer").innerHTML = msToTime(diff, data); - if (diff > 0) { - document.getElementById("progBar").style.width = percentage(diff, data.timeAmountInital) + "%"; - } else { - document.getElementById("progBar").style.width = "0%"; - } - - document.getElementById("progBar").style.backgroundColor = findProgessColor(data.colorSegments, diff) - document.getElementById("testImg").style.display = "none"; - if (data.enableColoredText) { - document.getElementById("timer").style.color = findProgessColor(data.textColors, diff) - } else { - document.getElementById("timer").style.color = "white" - } - - } - if (data.showTimeOnCountdown) { - document.getElementById("clockSec").innerHTML = getTime(); - } else { - document.getElementById("clockSec").innerHTML = ""; - } - - } else if (data.mode == "black") { - document.getElementById("timer").innerHTML = ""; - document.getElementById("testImg").style.display = "none"; - document.getElementById("wholeProgBar").style.display = "none"; - document.getElementById("clockSec").innerHTML = ""; - - } else if (data.mode == "test") { - document.getElementById("timer").innerHTML = ""; - document.getElementById("testImg").style.display = "block"; - document.getElementById("progBar").style.display = "none"; - document.getElementById("clockSec").innerHTML = ""; - } + dataFame = data; + } + } +} + +function handleUpdate() { + var data = dataFame; + document.getElementById("incomeData").innerHTML = JSON.stringify(data) + document.getElementById("timediff").innerHTML = new Date().getTime() - data.srvTime; + + if (data.debug) { + document.getElementById("timediff").style.display = "block"; + } else { + document.getElementById("timediff").style.display = "none"; + } + + if (data.defaultFullScreen && document.getElementById("initalDate").innerHTML.includes("true") && allowFullscreen) { + enterFullscreen(document.documentElement); + document.getElementById("initalDate").innerHTML = "false" + } + + if (data.showMessage) { + document.getElementById("overlay").style.display = "block"; + document.getElementById("text").innerHTML = data.message + } else { + off() + } + + if (new Date().getTime() - data.messageAppearTime < 5000) { + if (!document.getElementById("text").classList.contains('blink')) { + document.getElementById("text").classList.add("blink") + } + } else { + if (document.getElementById("text").classList.contains('blink')) { + document.getElementById("text").classList.remove("blink") } - } + if (data.mode == "clock") { + document.getElementById("timer").innerHTML = getTime(); + document.getElementById("testImg").style.display = "none"; + document.getElementById("wholeProgBar").style.display = "none"; + document.getElementById("clockSec").innerHTML = ""; + document.getElementById("timer").style.color = "white" + + } else if (data.mode == "timer") { + + document.getElementById("wholeProgBar").style.display = "block"; + + if (data.timerRunState) { + const now = new Date() + const diff = data.countdownGoal - now.getTime() + document.getElementById("timer").innerHTML = msToTime(diff, data); + if (diff > 0) { + document.getElementById("progBar").style.width = percentage(diff, data.timeAmountInital) + "%"; + } else { + document.getElementById("progBar").style.width = "0%"; + } + + document.getElementById("progBar").style.backgroundColor = findProgessColor(data.colorSegments, diff) + document.getElementById("testImg").style.display = "none"; + if (data.enableColoredText) { + document.getElementById("timer").style.color = findProgessColor(data.textColors, diff) + } else { + document.getElementById("timer").style.color = "white" + } + + } + if (data.showTimeOnCountdown) { + document.getElementById("clockSec").innerHTML = getTime(); + } else { + document.getElementById("clockSec").innerHTML = ""; + } + + } else if (data.mode == "black") { + document.getElementById("timer").innerHTML = ""; + document.getElementById("testImg").style.display = "none"; + document.getElementById("wholeProgBar").style.display = "none"; + document.getElementById("clockSec").innerHTML = ""; + + } else if (data.mode == "test") { + document.getElementById("timer").innerHTML = ""; + document.getElementById("testImg").style.display = "block"; + document.getElementById("progBar").style.display = "none"; + document.getElementById("clockSec").innerHTML = ""; + } } function httpGet(theUrl) { @@ -195,7 +197,8 @@ function off() { document.getElementById("overlay").style.display = "none"; } -setInterval(handleUpdate, 200); +setInterval(requestBackend, 500); +setInterval(handleUpdate, 2); let temp = new URLSearchParams(window.location.search).get("smaller"); diff --git a/templates/newAdminPanel.html b/templates/newAdminPanel.html index f9ab783..822d04d 100644 --- a/templates/newAdminPanel.html +++ b/templates/newAdminPanel.html @@ -17,6 +17,8 @@ + + @@ -136,7 +138,32 @@
- openCountdown + openCountdown
+ + + + + + + + + + +
@@ -213,7 +240,7 @@ - +


Timer / Messaging

@@ -273,31 +300,32 @@
-
-
+
+
-
+
-
-
- - - +
+
+ + + +
-

@@ -339,6 +367,12 @@

+

+

Raw server reponse

+ + + +
@@ -417,13 +451,42 @@