From 1b4336c4d9edc4c683478ca29e3eae08f6c94dc3 Mon Sep 17 00:00:00 2001 From: Lukas Bachschwell Date: Sat, 24 Nov 2018 18:26:42 +0100 Subject: [PATCH] Adjustable Bg color --- Readme.md | 9 ++++-- config.json.sample | 6 +++- routes/routes.js | 72 ++++++++++++++++++++++++++++++---------------- views/index.hbs | 45 +++++++++++++++-------------- 4 files changed, 82 insertions(+), 50 deletions(-) diff --git a/Readme.md b/Readme.md index df4ddd0..5a04a5a 100644 --- a/Readme.md +++ b/Readme.md @@ -6,13 +6,16 @@ beerpong tournament at a scoutparty This thing is based on Express with handlebars, socketio, bootstrap and some other fun - Install it with `npm install` Run it with `npm start` Develop on it with `npm run mon` - - This app is intended to be simple, the initial loaing of the state is done using the handlebar templates, after that actions and state changes are performed using websocket requests, no forther reloads are required as long as you are not changing between the main 2 views. + +TODO: + +- We need a randomize teams feature +- Bessere Kontrolle be namechange +- nicht immer das ganze feld klearen nach nem namechange diff --git a/config.json.sample b/config.json.sample index c80bdb9..307e4bf 100644 --- a/config.json.sample +++ b/config.json.sample @@ -11,6 +11,10 @@ { "param": "tbdLabel", "value": "/dev/tty.usbmodemFD121" - } + }, + { + "param": "backgroundColor", + "value": "#3357c7" + }, ] } diff --git a/routes/routes.js b/routes/routes.js index 652b4e8..cb3c5e0 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -1,46 +1,68 @@ -let express = require('express'); +let express = require("express"); let router = express.Router(); -let passwd = 'insecure'; +let passwd = "insecure"; -let low = require('lowdb'), -config = low('config.json'); +let low = require("lowdb"), + config = low("config.json"); -let tbdLabel = config.get('mainConfig').chain().find({ param: 'tbdLabel' }).value()['value']; -let byeLabel = config.get('mainConfig').chain().find({ param: 'byeLabel' }).value()['value']; +let tbdLabel = config + .get("mainConfig") + .chain() + .find({ param: "tbdLabel" }) + .value()["value"]; +let byeLabel = config + .get("mainConfig") + .chain() + .find({ param: "byeLabel" }) + .value()["value"]; +let bgcolor = config + .get("mainConfig") + .chain() + .find({ param: "backgroundColor" }) + .value()["value"]; /* GET home page. */ -router.get('/', function(req, res, next) { - res.render('index', { mainHeader: '🍺🍺🍺 Aktueller Spielstand 🍺🍺🍺🍺', TBD:tbdLabel, NoTeam:byeLabel }); +router.get("/", function(req, res, next) { + res.render("index", { + mainHeader: "🎮🕹🍺 SUPER SMASH BROS TURNIER 🎮🕹🍺", + TBD: tbdLabel, + NoTeam: byeLabel, + bgcolor: bgcolor + }); }); -router.get('/login', function(req, res, next) { +router.get("/login", function(req, res, next) { console.log(req.session.passwd); console.log(req.session); - if(req.session.passwd=='insecure'){ - res.redirect('/admin'); - }else{ - res.render('login', { mainHeader: 'Please Login' }); + if (req.session.passwd == "insecure") { + res.redirect("/admin"); + } else { + res.render("login", { mainHeader: "Please Login" }); } }); -router.post('/login', function(req, res, next) { - if(req.body.passwd=='insecure'){ - req.session.passwd='insecure'; - console.log('set'); - res.end('done') - }else{ - res.end('invalid') +router.post("/login", function(req, res, next) { + if (req.body.passwd == "insecure") { + req.session.passwd = "insecure"; + console.log("set"); + res.end("done"); + } else { + res.end("invalid"); } }); -router.get('/admin', function(req, res, next) { +router.get("/admin", function(req, res, next) { console.log(req.session.passwd); console.log(req.session); - if(req.session.passwd=='insecure'){ - res.render('admin', { mainHeader: 'Admin Interface', TBD:tbdLabel, NoTeam:byeLabel }); - }else{ - res.redirect('/login'); + if (req.session.passwd == "insecure") { + res.render("admin", { + mainHeader: "Admin Interface", + TBD: tbdLabel, + NoTeam: byeLabel + }); + } else { + res.redirect("/login"); } }); diff --git a/views/index.hbs b/views/index.hbs index e394218..6ca32b2 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -1,29 +1,32 @@ - - - Spielstand - - - - - - - - - - - -

{{mainHeader}}

+ + + Spielstand + + + -
-
+ + + + + + + + + +

{{mainHeader}}

+ +
+
-
+
+ + + + - - -