Standby
This commit is contained in:
@@ -57,14 +57,14 @@
|
||||
<div id="name1" class="swimmer-name" style="display: none"></div>
|
||||
<h2>🏊♀️ Bahn 1</h2>
|
||||
<div id="time1" class="time-display">00.00</div>
|
||||
<div id="status1" class="status ready">Bereit</div>
|
||||
<div id="status1" class="status standby">Standby: Bitte beide 1x betätigen</div>
|
||||
</div>
|
||||
|
||||
<div class="lane">
|
||||
<div id="name2" class="swimmer-name" style="display: none"></div>
|
||||
<h2>🏊♂️ Bahn 2</h2>
|
||||
<div id="time2" class="time-display">00.00</div>
|
||||
<div id="status2" class="status ready">Bereit</div>
|
||||
<div id="status2" class="status standby">Standby: Bitte beide 1x betätigen</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -113,6 +113,23 @@
|
||||
document.getElementById(id).classList.remove("active");
|
||||
});
|
||||
|
||||
// Funktion um zu prüfen ob beide Buttons einer Bahn verbunden sind
|
||||
function areBothButtonsConnected(laneNumber) {
|
||||
const now = Date.now();
|
||||
if (laneNumber === 1) {
|
||||
return (
|
||||
now - heartbeatTimeouts.start1 <= 10000 &&
|
||||
now - heartbeatTimeouts.stop1 <= 10000
|
||||
);
|
||||
} else if (laneNumber === 2) {
|
||||
return (
|
||||
now - heartbeatTimeouts.start2 <= 10000 &&
|
||||
now - heartbeatTimeouts.stop2 <= 10000
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Handle WebSocket events
|
||||
ws.onopen = () => {
|
||||
console.log("WebSocket connected");
|
||||
@@ -315,24 +332,42 @@
|
||||
}
|
||||
|
||||
document.getElementById("time1").textContent = formatTime(display1);
|
||||
|
||||
// Status für Bahn 1
|
||||
const s1 = document.getElementById("status1");
|
||||
s1.className = `status ${status1}`;
|
||||
s1.textContent =
|
||||
status1 === "ready"
|
||||
? "Bereit"
|
||||
: status1 === "running"
|
||||
? "Läuft..."
|
||||
: "Beendet";
|
||||
const lane1Connected = areBothButtonsConnected(1);
|
||||
|
||||
if (status1 === "ready" && !lane1Connected) {
|
||||
s1.className = "status standby";
|
||||
s1.textContent = "Standby: Bitte beide 1x betätigen";
|
||||
} else {
|
||||
s1.className = `status ${status1}`;
|
||||
s1.textContent =
|
||||
status1 === "ready"
|
||||
? "Bereit"
|
||||
: status1 === "running"
|
||||
? "Läuft..."
|
||||
: "Beendet";
|
||||
}
|
||||
|
||||
document.getElementById("time2").textContent = formatTime(display2);
|
||||
|
||||
// Status für Bahn 2
|
||||
const s2 = document.getElementById("status2");
|
||||
s2.className = `status ${status2}`;
|
||||
s2.textContent =
|
||||
status2 === "ready"
|
||||
? "Bereit"
|
||||
: status2 === "running"
|
||||
? "Läuft..."
|
||||
: "Beendet";
|
||||
const lane2Connected = areBothButtonsConnected(2);
|
||||
|
||||
if (status2 === "ready" && !lane2Connected) {
|
||||
s2.className = "status standby";
|
||||
s2.textContent = "Standby: Bitte beide 1x betätigen";
|
||||
} else {
|
||||
s2.className = `status ${status2}`;
|
||||
s2.textContent =
|
||||
status2 === "ready"
|
||||
? "Bereit"
|
||||
: status2 === "running"
|
||||
? "Läuft..."
|
||||
: "Beendet";
|
||||
}
|
||||
|
||||
document.getElementById("best1").textContent =
|
||||
best1 > 0 ? formatTime(best1) + "s" : "--.-";
|
||||
@@ -413,4 +448,4 @@
|
||||
syncFromBackend();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Reference in New Issue
Block a user