summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authoraltaf-creator <dev@altafcreator.com>2025-12-02 18:03:56 +0700
committeraltaf-creator <dev@altafcreator.com>2025-12-02 18:03:56 +0700
commit8fe0cebd63994e55d07a09099160aa054ca8af0e (patch)
tree4c20398ec3800b230fca261a4d41b18016e71c37 /frontend
parenta44a5cd30757bca16c75b4632444ebc80bfa480e (diff)
frontend
Diffstat (limited to 'frontend')
-rw-r--r--frontend/main.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/frontend/main.js b/frontend/main.js
index 7729b93..c9db1dd 100644
--- a/frontend/main.js
+++ b/frontend/main.js
@@ -138,8 +138,8 @@ async function updateMachines() {
machine_imgs[i].src = "/assets/img/dryer_on.png";
}
const now = Date.now();
- const start = Date.parse(status[1][i]);
- machine_txts[i].innerHTML = Math.ceil(((start + (status[2][i] * 60000)) - now) / 60000).toString() + " min(s) left";
+ const end = Date.parse(status[2][i]);
+ machine_txts[i].innerHTML = Math.ceil((end - now) / 6000).toString + " min(s) left";
} else if (status[0][i] == "FINISHED") {
if ((i + 1) % 2 == 0) {
machine_imgs[i].src = "/assets/img/washer_clothes.png";
@@ -175,6 +175,7 @@ async function startLoadTimers() {
const textList = []
const progList = []
+ const startTimestamps = []
const endTimestamps = []
for (let i = 0; i < timers.length; i++) {
@@ -211,6 +212,7 @@ async function startLoadTimers() {
textList.push(`timer-txt-${i}`);
progList.push(`timer-prog-${i}`);
+ startTimestamps.push(Date.parse(timers[i]["start_time"]));
endTimestamps.push(Date.parse(timers[i]["end_time"]));
}
@@ -237,7 +239,8 @@ async function startLoadTimers() {
text.innerText += seconds.toString().padStart(2, '0');
const prog = document.getElementById(progList[i]);
- prog.style.width = ((timeRemaining / (timers[i]["duration"] * 60)) * 100).toString() + "%";
+ const totalTime = endTimestamps - startTimestamps;
+ prog.style.width = ((timeRemaining / (totalTime / 60000)) * 100).toString() + "%";
if (timeRemaining <= 0) {
document.getElementById(`timer-btn-${i}`).disabled = false;