Adjustable Bg color

This commit is contained in:
Lukas Bachschwell 2018-11-24 18:26:42 +01:00
parent cbf949e7b1
commit 1b4336c4d9
4 changed files with 82 additions and 50 deletions

View File

@ -6,13 +6,16 @@ beerpong tournament at a scoutparty
This thing is based on Express with handlebars, socketio, bootstrap and some other fun This thing is based on Express with handlebars, socketio, bootstrap and some other fun
Install it with `npm install` Install it with `npm install`
Run it with `npm start` Run it with `npm start`
Develop on it with `npm run mon` 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. 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

View File

@ -11,6 +11,10 @@
{ {
"param": "tbdLabel", "param": "tbdLabel",
"value": "/dev/tty.usbmodemFD121" "value": "/dev/tty.usbmodemFD121"
} },
{
"param": "backgroundColor",
"value": "#3357c7"
},
] ]
} }

View File

@ -1,46 +1,68 @@
let express = require('express'); let express = require("express");
let router = express.Router(); let router = express.Router();
let passwd = 'insecure'; let passwd = "insecure";
let low = require('lowdb'), let low = require("lowdb"),
config = low('config.json'); config = low("config.json");
let tbdLabel = config.get('mainConfig').chain().find({ param: 'tbdLabel' }).value()['value']; let tbdLabel = config
let byeLabel = config.get('mainConfig').chain().find({ param: 'byeLabel' }).value()['value']; .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. */ /* GET home page. */
router.get('/', function(req, res, next) { router.get("/", function(req, res, next) {
res.render('index', { mainHeader: '🍺🍺🍺 Aktueller Spielstand 🍺🍺🍺🍺', TBD:tbdLabel, NoTeam:byeLabel }); 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.passwd);
console.log(req.session); console.log(req.session);
if(req.session.passwd=='insecure'){ if (req.session.passwd == "insecure") {
res.redirect('/admin'); res.redirect("/admin");
}else{ } else {
res.render('login', { mainHeader: 'Please Login' }); res.render("login", { mainHeader: "Please Login" });
} }
}); });
router.post('/login', function(req, res, next) { router.post("/login", function(req, res, next) {
if(req.body.passwd=='insecure'){ if (req.body.passwd == "insecure") {
req.session.passwd='insecure'; req.session.passwd = "insecure";
console.log('set'); console.log("set");
res.end('done') res.end("done");
}else{ } else {
res.end('invalid') 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.passwd);
console.log(req.session); console.log(req.session);
if(req.session.passwd=='insecure'){ if (req.session.passwd == "insecure") {
res.render('admin', { mainHeader: 'Admin Interface', TBD:tbdLabel, NoTeam:byeLabel }); res.render("admin", {
}else{ mainHeader: "Admin Interface",
res.redirect('/login'); TBD: tbdLabel,
NoTeam: byeLabel
});
} else {
res.redirect("/login");
} }
}); });

View File

@ -1,29 +1,32 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<meta charset="utf-8">
<title>Spielstand</title>
<link rel='stylesheet' type="text/css" href='/css/bootstrap.min.css' />
<link rel="stylesheet" type="text/css" href="/css/jquery.bracket.min.css" />
<link rel='stylesheet' type="text/css" href='/css/style.css' />
<script type='text/javascript' src='/js/jquery-3.1.1.min.js'></script>
<script type='text/javascript' src='/js/jquery.bracket.min.js'></script>
<script type='text/javascript' src='/js/bootstrap.min.js'></script>
<script type='text/javascript' src='/socket.io/socket.io.js'></script>
<script type='text/javascript' src='/js/front_client.js'></script> <head>
</head> <meta charset="utf-8">
<body> <title>Spielstand</title>
<h1>{{mainHeader}}</h1> <link rel='stylesheet' type="text/css" href='/css/bootstrap.min.css' />
<link rel="stylesheet" type="text/css" href="/css/jquery.bracket.min.css" />
<link rel='stylesheet' type="text/css" href='/css/style.css' />
<div class="main-content"> <script type='text/javascript' src='/js/jquery-3.1.1.min.js'></script>
<div id="team-container"> <script type='text/javascript' src='/js/jquery.bracket.min.js'></script>
<script type='text/javascript' src='/js/bootstrap.min.js'></script>
<script type='text/javascript' src='/socket.io/socket.io.js'></script>
<script type='text/javascript' src='/js/front_client.js'></script>
</head>
<body style="background-color: {{bgcolor}};">
<h1>{{mainHeader}}</h1>
<div class="main-content">
<div id="team-container">
</div>
</div> </div>
</div>
<input id="TBD" type="hidden" value='{{TBD}}'>
<input id="NoT" type="hidden" value='{{NoTeam}}'>
</body>
<input id="TBD" type="hidden" value='{{TBD}}'>
<input id="NoT" type="hidden" value='{{NoTeam}}'>
</body>
</html> </html>