Browse Source

Adjustable Bg color

master
Lukas Bachschwell 1 year ago
parent
commit
1b4336c4d9
4 changed files with 84 additions and 52 deletions
  1. +5
    -2
      Readme.md
  2. +5
    -1
      config.json.sample
  3. +47
    -25
      routes/routes.js
  4. +27
    -24
      views/index.hbs

+ 5
- 2
Readme.md 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


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:

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.
- We need a randomize teams feature
- Bessere Kontrolle be namechange
- nicht immer das ganze feld klearen nach nem namechange

+ 5
- 1
config.json.sample View File

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

+ 47
- 25
routes/routes.js View File

@@ -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");
}
});



+ 27
- 24
views/index.hbs View File

@@ -1,29 +1,32 @@
<!DOCTYPE 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>
<body>
<h1>{{mainHeader}}</h1>

<div class="main-content">
<div id="team-container">

</div>

<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>

<body style="background-color: {{bgcolor}};">
<h1>{{mainHeader}}</h1>

<div class="main-content">
<div id="team-container">

</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>

Loading…
Cancel
Save