partial progress bar coloring
This commit is contained in:
parent
2619771e18
commit
94eccbca1f
@ -3,6 +3,8 @@
|
|||||||
# ToDo
|
# ToDo
|
||||||
- [X] Pausing functions
|
- [X] Pausing functions
|
||||||
- [X] Presets
|
- [X] Presets
|
||||||
- [ ] Progress bar
|
|
||||||
- [X] time on countdown page
|
- [X] time on countdown page
|
||||||
- [X] one-way messaging
|
- [X] one-way messaging
|
||||||
|
- [ ] Better UI
|
||||||
|
- [ ] Progress bar
|
||||||
|
- [ ] Endpoint docs
|
||||||
|
10
index.js
10
index.js
@ -26,7 +26,9 @@ currentState = {
|
|||||||
showTimeOnCountdown: true,
|
showTimeOnCountdown: true,
|
||||||
message: "",
|
message: "",
|
||||||
showMessage: false,
|
showMessage: false,
|
||||||
messageAppearTime: 0
|
messageAppearTime: 0,
|
||||||
|
showProgressbar: true,
|
||||||
|
colorSegments: {20000: "#FFAE00", 5000: "#ff0000", "START": "yellow"}
|
||||||
};
|
};
|
||||||
|
|
||||||
app.get("/", function (req, res) {
|
app.get("/", function (req, res) {
|
||||||
@ -86,6 +88,12 @@ app.get("/api/v1/set/showTime", function (req, res) {
|
|||||||
res.json({ status: "ok" });
|
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) {
|
app.get("/api/v1/ctrl/message/show", function (req, res) {
|
||||||
currentState.message = req.query.msg
|
currentState.message = req.query.msg
|
||||||
currentState.showMessage = true
|
currentState.showMessage = true
|
||||||
|
@ -40,13 +40,31 @@ html, body {
|
|||||||
order: 1;
|
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{
|
.testImg{
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#overlay {
|
#overlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
|
@ -13,6 +13,10 @@ function enterFullscreen(element) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function percentage(partialValue, totalValue) {
|
||||||
|
return (100 * partialValue) / totalValue;
|
||||||
|
}
|
||||||
|
|
||||||
function updateFullscreen(){
|
function updateFullscreen(){
|
||||||
if(JSON.parse(document.getElementById("incomeData").innerHTML).defaultFullScreen && allowFullscreen){
|
if(JSON.parse(document.getElementById("incomeData").innerHTML).defaultFullScreen && allowFullscreen){
|
||||||
enterFullscreen(document.documentElement)
|
enterFullscreen(document.documentElement)
|
||||||
@ -45,6 +49,24 @@ function msToTime(s, data) {
|
|||||||
return out;
|
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() {
|
function handleUpdate() {
|
||||||
resp = httpGet("/api/v1/data");
|
resp = httpGet("/api/v1/data");
|
||||||
|
|
||||||
@ -77,13 +99,22 @@ function handleUpdate() {
|
|||||||
if (data.mode == "clock") {
|
if (data.mode == "clock") {
|
||||||
document.getElementById("timer").innerHTML = getTime();
|
document.getElementById("timer").innerHTML = getTime();
|
||||||
document.getElementById("testImg").style.display = "none";
|
document.getElementById("testImg").style.display = "none";
|
||||||
|
document.getElementById("wholeProgBar").style.display = "none";
|
||||||
|
|
||||||
} else if (data.mode == "timer") {
|
} else if (data.mode == "timer") {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
document.getElementById("wholeProgBar").style.display = "block";
|
||||||
if(data.timerRunState){
|
if(data.timerRunState){
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const diff = data.countdownGoal - now.getTime()
|
const diff = data.countdownGoal - now.getTime()
|
||||||
document.getElementById("timer").innerHTML = msToTime(diff, data);
|
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";
|
document.getElementById("testImg").style.display = "none";
|
||||||
|
|
||||||
}
|
}
|
||||||
if(data.showTimeOnCountdown){
|
if(data.showTimeOnCountdown){
|
||||||
document.getElementById("clockSec").innerHTML = getTime();
|
document.getElementById("clockSec").innerHTML = getTime();
|
||||||
@ -94,10 +125,12 @@ function handleUpdate() {
|
|||||||
} else if (data.mode == "black") {
|
} else if (data.mode == "black") {
|
||||||
document.getElementById("timer").innerHTML = "";
|
document.getElementById("timer").innerHTML = "";
|
||||||
document.getElementById("testImg").style.display = "none";
|
document.getElementById("testImg").style.display = "none";
|
||||||
|
document.getElementById("wholeProgBar").style.display = "none";
|
||||||
|
|
||||||
} else if (data.mode == "test") {
|
} else if (data.mode == "test") {
|
||||||
document.getElementById("timer").innerHTML = "";
|
document.getElementById("timer").innerHTML = "";
|
||||||
document.getElementById("testImg").style.display = "block";
|
document.getElementById("testImg").style.display = "block";
|
||||||
|
document.getElementById("progBar").style.display = "none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
|
|
||||||
<form action="/api/v1/set/addMillisToTimer" target="hiddenFrame">
|
<form action="/api/v1/set/addMillisToTimer" target="hiddenFrame">
|
||||||
<select id="time" name="time" onchange="">
|
<select id="time" name="time" onchange="">
|
||||||
|
<option value="20000">debug 1 (20 secs)</option>
|
||||||
<option value="300000">00:05:00</option>
|
<option value="300000">00:05:00</option>
|
||||||
<option value="600000">00:10:00</option>
|
<option value="600000">00:10:00</option>
|
||||||
<option value="900000">00:15:00</option>
|
<option value="900000">00:15:00</option>
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
</valueStore>
|
</valueStore>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<div class="progWrapper" id="wholeProgBar">
|
||||||
|
<div class="progBar" id="progBar"></div>
|
||||||
|
</div>
|
||||||
<div class="timer" id="timer">
|
<div class="timer" id="timer">
|
||||||
00:00:00
|
00:00:00
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user