Cleanup, comments, removed ejs stuff
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
let wss = "ws://" + window.location.hostname + ":3001" // Build socketio endpoint from window.location
|
||||
const socket = io(wss); // Connect to socketio server
|
||||
|
||||
// ######################################################################################################################################################
|
||||
// Websockets event handler
|
||||
// ######################################################################################################################################################
|
||||
|
||||
socket.on('connected', (message) => {
|
||||
console.log("Connected");
|
||||
})
|
||||
});
|
||||
|
||||
socket.on('timerDurationLeft', (message) => {
|
||||
console.log(message) // Log durationLeft in client console
|
||||
@@ -16,4 +20,29 @@ socket.on('timerEnded', (message) => {
|
||||
|
||||
socket.on('refresh', (message) => {
|
||||
document.location.reload() // Reload page on received 'refresh' messagen
|
||||
});
|
||||
});
|
||||
|
||||
// ######################################################################################################################################################
|
||||
// General functions
|
||||
// ######################################################################################################################################################
|
||||
|
||||
// Update DOM timer elements from passed values
|
||||
function updateTimerFrontend(values) {
|
||||
document.getElementById("durationLeft").innerHTML = values.print; // Display durationLeft as prettyfied string
|
||||
}
|
||||
|
||||
// Initial update gets called whenever page has been loaded
|
||||
async function initialUpdate() {
|
||||
timerGetValues(); // Request new values for timer
|
||||
}
|
||||
|
||||
// ######################################################################################################################################################
|
||||
// Timerfunctions
|
||||
// ######################################################################################################################################################
|
||||
|
||||
// Request important timer values
|
||||
async function timerGetValues() {
|
||||
const response = await fetch("/admin/timerGetValues"); // Call API Endpoint /admin/timerGetValues
|
||||
const data = await response.json(); // Wait for asynchronous transfer to complete
|
||||
updateTimerFrontend(data); // Update admin frontend
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
let wss = "ws://" + window.location.hostname + ":3001" // Build socketio endpoint from window.location
|
||||
const socket = io(wss); // Connect to socketio server
|
||||
|
||||
// ######################################################################################################################################################
|
||||
// Websockets event handler
|
||||
// ######################################################################################################################################################
|
||||
|
||||
socket.on('connected', (message) => {
|
||||
console.log("Connected");
|
||||
})
|
||||
});
|
||||
|
||||
socket.on('timerDurationLeft', (message) => {
|
||||
console.log(message) // Log durationLeft in client console
|
||||
@@ -23,19 +27,44 @@ socket.on('score', (message) => {
|
||||
document.getElementById("score").innerHTML = message; // Display score in corresponding html Element
|
||||
});
|
||||
|
||||
// ######################################################################################################################################################
|
||||
// General functions
|
||||
// ######################################################################################################################################################
|
||||
|
||||
// Update DOM timer elements from passed values
|
||||
function updateTimerFrontend(values) {
|
||||
document.getElementById("durationLeft").innerHTML = values.print; // Display durationLeft as prettyfied string
|
||||
}
|
||||
|
||||
// Update DOM score elements from passed values
|
||||
function updateScoreFrontend(values) {
|
||||
document.getElementById("score").innerHTML = values.print; // Set switch status to received score enabled value
|
||||
document.getElementById("score").innerHTML = values.print; // Set score on admin interface
|
||||
}
|
||||
|
||||
async function initialUpdate() {
|
||||
scoreGetValues();
|
||||
timerGetValues(); // Request new values for timer
|
||||
scoreGetValues(); // Request new values for score
|
||||
}
|
||||
|
||||
// ######################################################################################################################################################
|
||||
// Timerfunctions
|
||||
// ######################################################################################################################################################
|
||||
|
||||
// Request important timer values
|
||||
async function timerGetValues() {
|
||||
const response = await fetch("/admin/timerGetValues"); // Call API Endpoint /admin/timerGetValues
|
||||
const data = await response.json(); // Wait for asynchronous transfer to complete
|
||||
updateTimerFrontend(data); // Update admin frontend
|
||||
}
|
||||
|
||||
// ######################################################################################################################################################
|
||||
// Scoreboardfunctions
|
||||
// ######################################################################################################################################################
|
||||
|
||||
// Request important values for score
|
||||
async function scoreGetValues() {
|
||||
const response = await fetch("/admin/scoreGetValues"); // Call API Endpoint /admin/scoreGetValues
|
||||
const data = await response.json(); // Wait for asynchronous transfer to complete and parse json (which got received by backend)
|
||||
console.log(data); // Print received data
|
||||
updateScoreFrontend(data); // Update admin frontend with received values for scoreboard
|
||||
const response = await fetch("/admin/scoreGetValues"); // Call API Endpoint /admin/scoreGetValues
|
||||
const data = await response.json(); // Wait for asynchronous transfer to complete and parse json (which got received by backend)
|
||||
console.log(data); // Print received data
|
||||
updateScoreFrontend(data); // Update admin frontend with received values for scoreboard
|
||||
}
|
||||
Reference in New Issue
Block a user