diff --git a/README.MD b/README.MD index f502efc..a31bb79 100644 --- a/README.MD +++ b/README.MD @@ -3,6 +3,8 @@ # ToDo - [X] Pausing functions - [X] Presets -- [ ] Progress bar - [X] time on countdown page -- [X] one-way messaging \ No newline at end of file +- [X] one-way messaging +- [ ] Better UI +- [ ] Progress bar +- [ ] Endpoint docs diff --git a/index.js b/index.js index 995cd51..4de5617 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,9 @@ currentState = { showTimeOnCountdown: true, message: "", showMessage: false, - messageAppearTime: 0 + messageAppearTime: 0, + showProgressbar: true, + colorSegments: {20000: "#FFAE00", 5000: "#ff0000", "START": "yellow"} }; app.get("/", function (req, res) { @@ -86,6 +88,12 @@ app.get("/api/v1/set/showTime", function (req, res) { res.json({ status: "ok" }); }); +app.get("/api/v1/set/showProgressBar", function (req, res) { + currentState.showProgressbar = (req.query.show === 'true'); + res.json({ status: "ok" }); +}); + + app.get("/api/v1/ctrl/message/show", function (req, res) { currentState.message = req.query.msg currentState.showMessage = true diff --git a/static/css/styles.css b/static/css/styles.css index 63f68fc..5800c6c 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -40,13 +40,31 @@ html, body { order: 1; } +.progWrapper{ + font-size: 10em; + background-color: rgba(63, 63, 63, 0.733); + text-align: center; + font-variant-numeric: tabular-nums; + font-family: sans-serif; + order: 1; + height: 24px; + width: 80%; + border: 1px solid rgb(63, 63, 63); +} + +.progBar { + appearance: none; + height: 100%; + width: 80%; + border-radius: 0px; + background-color: darkcyan; +} + .testImg{ height: 100%; width: 100%; } - - #overlay { position: fixed; font-family: sans-serif; diff --git a/static/js/script.js b/static/js/script.js index 52dee23..cbb54bd 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -13,6 +13,10 @@ function enterFullscreen(element) { } } +function percentage(partialValue, totalValue) { + return (100 * partialValue) / totalValue; +} + function updateFullscreen(){ if(JSON.parse(document.getElementById("incomeData").innerHTML).defaultFullScreen && allowFullscreen){ enterFullscreen(document.documentElement) @@ -45,6 +49,24 @@ function msToTime(s, data) { return out; } +function findProgessColor(colors, value){ + console.info("\n\n\n\n\n") + const allColors = Object.keys(colors); + let resColor = colors["START"] + + for(let color in allColors){ + const currColor = allColors[color] + console.log(color, currColor, parseInt(currColor), value, colors[String(currColor)]) + if(value <= parseInt(currColor)){ + console.log("trith") + resColor = colors[currColor] + } + } + + // console.info(resColor, value) + return(resColor) +} + function handleUpdate() { resp = httpGet("/api/v1/data"); @@ -77,13 +99,22 @@ function handleUpdate() { if (data.mode == "clock") { document.getElementById("timer").innerHTML = getTime(); document.getElementById("testImg").style.display = "none"; + document.getElementById("wholeProgBar").style.display = "none"; } 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); + document.getElementById("progBar").style.width = percentage(diff, data.timeAmountInital) + "%"; + document.getElementById("progBar").style.backgroundColor = findProgessColor(data.colorSegments,diff) document.getElementById("testImg").style.display = "none"; + } if(data.showTimeOnCountdown){ document.getElementById("clockSec").innerHTML = getTime(); @@ -94,10 +125,12 @@ function handleUpdate() { } else if (data.mode == "black") { document.getElementById("timer").innerHTML = ""; document.getElementById("testImg").style.display = "none"; + document.getElementById("wholeProgBar").style.display = "none"; } else if (data.mode == "test") { document.getElementById("timer").innerHTML = ""; document.getElementById("testImg").style.display = "block"; + document.getElementById("progBar").style.display = "none"; } } diff --git a/templates/adminPanel.html b/templates/adminPanel.html index f2f7f15..0eb484f 100644 --- a/templates/adminPanel.html +++ b/templates/adminPanel.html @@ -51,6 +51,7 @@
diff --git a/templates/timerPage.html b/templates/timerPage.html index 2c32f4b..8f9955e 100644 --- a/templates/timerPage.html +++ b/templates/timerPage.html @@ -27,6 +27,9 @@
+
+
+
00:00:00