diff --git a/scoreboard/controllers/etc.js b/scoreboard/controllers/etc.js new file mode 100644 index 0000000..146142d --- /dev/null +++ b/scoreboard/controllers/etc.js @@ -0,0 +1,21 @@ +let splashscreenEnabled = true; + +// Toggles a splashscreen +function toggleSplashScreen() { + splashscreenEnabled = !splashscreenEnabled; +} + +// Returns splashscreen enabled attribute +function getSplashscreen() { + return splashscreenEnabled; +} + +function getValues() { + return { + splashscreenEnabled: splashscreenEnabled, + } +} + +module.exports = { + toggleSplashScreen, getSplashscreen, getValues +} \ No newline at end of file diff --git a/scoreboard/public/img/SG_Arheilgen.png b/scoreboard/public/img/SG_Arheilgen.png new file mode 100644 index 0000000..e4b7fc2 Binary files /dev/null and b/scoreboard/public/img/SG_Arheilgen.png differ diff --git a/scoreboard/public/img/SG_Arheilgen_upscaled.png b/scoreboard/public/img/SG_Arheilgen_upscaled.png new file mode 100644 index 0000000..3b42d40 Binary files /dev/null and b/scoreboard/public/img/SG_Arheilgen_upscaled.png differ diff --git a/scoreboard/public/javascripts/admin.js b/scoreboard/public/javascripts/admin.js index fc35162..bfd5164 100644 --- a/scoreboard/public/javascripts/admin.js +++ b/scoreboard/public/javascripts/admin.js @@ -26,6 +26,11 @@ socket.on('score', (message) => { // ###################################################################################################################################################### // General functions // ###################################################################################################################################################### +// Update DOM timer elements from passed values +function updateEtcFrontend(values) { + console.log(values); + document.getElementById("etcSwitchEnable").checked = values.splashscreenEnabled;// Set switch status to received score enabled value +} // Update DOM timer elements from passed values function updateTimerFrontend(values) { @@ -137,7 +142,26 @@ async function openBrowser() { } async function killBrowser() { - const response = await fetch("/admin/killBrowser"); // Call API Endpoint /admin/killBrowser + const response = await fetch("/admin/killBrowser"); // Call API Endpoint /admin/killBrowser +} + +// ###################################################################################################################################################### +// Etc endpoints +// ###################################################################################################################################################### + +// Request important values for etc stuff +async function etcGetValues() { + const response = await fetch("/admin/etcGetValues"); // Call API Endpoint /admin/etcGetValues + const data = await response.json(); // Wait for asynchronous transfer to complete + updateEtcFrontend(data); // Update admin frontend +} + +// Toggle index page to also show scoreboard +async function etcToggleSplashscreen() { + const response = await fetch("/admin/etcToggleSplashscreen");// Call API Endpoint /admin/etcToggleSplashscreen + const data = await response.json(); // Wait for asyncronous transfer to complete + updateEtcFrontend(data); // Update admin frontend + refreshMonitor(); // Refresh main monitor to display new frontend } // ###################################################################################################################################################### diff --git a/scoreboard/public/javascripts/splashscreen.js b/scoreboard/public/javascripts/splashscreen.js new file mode 100644 index 0000000..3053f07 --- /dev/null +++ b/scoreboard/public/javascripts/splashscreen.js @@ -0,0 +1,14 @@ +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('refresh', (message) => { + document.location.reload() // Reload page on received 'refresh' messagen +}); \ No newline at end of file diff --git a/scoreboard/public/stylesheets/splashscreen.css b/scoreboard/public/stylesheets/splashscreen.css new file mode 100644 index 0000000..e69de29 diff --git a/scoreboard/routes/admin.js b/scoreboard/routes/admin.js index 43c277a..9e3c316 100644 --- a/scoreboard/routes/admin.js +++ b/scoreboard/routes/admin.js @@ -33,6 +33,23 @@ router.get('/killBrowser', function(req, res, next) { res.send(); // send empty response }); +// ###################################################################################################################################################### +// Etc endpoints +// ###################################################################################################################################################### + +// Express router endpoint to toggle splashscreen +router.get('/etcToggleSplashscreen', function(req, res, next) { + etc.toggleSplashScreen(); // Toggles splashscreen + res.status(200); // Set http status code to 200 (success) + res.json(etc.getValues()); // Answer with important values +}); + +// Express router endpoint to get important etc values +router.get('/etcGetValues', function(req, res, next) { + res.status(200); // Set http status code to 200 (success) + res.json(etc.getValues()); // Answer with important values +}); + // ###################################################################################################################################################### // Timerendpoints // ###################################################################################################################################################### diff --git a/scoreboard/routes/index.js b/scoreboard/routes/index.js index 7a8422c..a64adca 100644 --- a/scoreboard/routes/index.js +++ b/scoreboard/routes/index.js @@ -2,14 +2,19 @@ var express = require('express'); var router = express.Router(); let io = require('../controllers/socketio'); -const score = require("../controllers/score"); +const score = require('../controllers/score'); +const etc = require('../controllers/etc'); /* GET home page. */ router.get('/', function(req, res, next) { - if (score.getEnabled()) { // If scoreboard is enabled - res.render('indexScore', {}); // Render the site with scoreboard - } else { // If scoreboard is not enabled - res.render('index', {}); // Render the site without scoreboard + if(etc.getSplashscreen()) { // If splashscreen is enabled + res.render('splashscreen', {}); // Render splashscreen + } else { + if (score.getEnabled()) { // If scoreboard is enabled + res.render('indexScore', {}); // Render the site with scoreboard + } else { // If scoreboard is not enabled + res.render('index', {}); // Render the site without scoreboard + } } }); diff --git a/scoreboard/views/splashscreen.hbs b/scoreboard/views/splashscreen.hbs new file mode 100644 index 0000000..0bbb512 --- /dev/null +++ b/scoreboard/views/splashscreen.hbs @@ -0,0 +1,20 @@ + + + + Index + + + + + + +
+ +
+ + + + + + + \ No newline at end of file