19 lines
862 B
JavaScript

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) // Log durationLeft in client console
document.getElementById("durationLeft").innerHTML = message; // Display durationLeft in corresponding html Element
});
socket.on('timerEnded', (message) => {
document.getElementById("durationLeft").innerHTML = "ENDE"; // Display "STOP" in same html element as the duration
});
socket.on('refresh', (message) => {
document.location.reload() // Reload page on received 'refresh' messagen
});