Cleanup, formatting, comments, added onclick functions
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
|
||||
function timerStart()
|
||||
{
|
||||
fetch("/admin/timerStart", {
|
||||
method: "POST",
|
||||
headers: {'Content-Type': 'text/html'},
|
||||
body: ""
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
})
|
||||
}
|
||||
@@ -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
|
||||
});
|
||||
Reference in New Issue
Block a user