Cleanup, formatting, comments, added onclick functions

This commit is contained in:
2024-04-21 14:24:53 +02:00
parent 093c8c6e24
commit a4d905d728
4 changed files with 38 additions and 42 deletions
+11
View File
@@ -0,0 +1,11 @@
function timerStart()
{
fetch("/admin/timerStart", {
method: "POST",
headers: {'Content-Type': 'text/html'},
body: ""
}).then(res => {
console.log(res);
})
}
+6 -14
View File
@@ -1,23 +1,15 @@
let wss = "ws://" + window.location.hostname + ":3001"
const socket = io(wss);
let wss = "ws://" + window.location.hostname + ":3001" // Build socketio endpoint from window.location
const socket = io(wss); // Connect to socketio server
socket.on('connected', (message) => {
console.log("Connected");
})
socket.on('timerDurationLeft', (message) => {
console.log(message)
document.getElementById("durationLeft").innerHTML = message;
console.log(message) // Log durationLeft in client console
document.getElementById("durationLeft").innerHTML = message; // Display durationLeft in corresponding html Element
});
socket.on('timerEnded', (message) => {
console.log(message)
document.getElementById("durationLeft").innerHTML = "STOP";
});
// let minutes = currentTime.setMinutes(6);
// let seconds = currentTime.setSeconds(25);
// document.getElementById("timer").innerHTML = minutes + ":" + seconds;
document.getElementById("durationLeft").innerHTML = "STOP"; // Display "STOP" in same html element as the duration
});