From fedeacaef933cb7cd737cca3aa288a8ecee73a19 Mon Sep 17 00:00:00 2001 From: Lukas Bachschwell Date: Mon, 20 Mar 2017 18:12:20 +0100 Subject: [PATCH] Lablenames and more --- public/js/back_client.js | 36 ++++++++++++-------- public/js/front_client.js | 32 +++++++++++++++++- routes/routes.js | 4 +-- views/admin.hbs | 3 ++ views/index.hbs | 2 ++ views/login.hbs | 71 +++++++++++++++++++++------------------ 6 files changed, 98 insertions(+), 50 deletions(-) diff --git a/public/js/back_client.js b/public/js/back_client.js index 7110907..95f73d4 100644 --- a/public/js/back_client.js +++ b/public/js/back_client.js @@ -2,6 +2,9 @@ // This is the backend client js let iosocket = io.connect(); +let tbdLable = 'To be determined', +noTeam = 'Kein Team'; + // setup all my handlers iosocket.on('clientrefresh', () => { location.reload(); @@ -18,20 +21,16 @@ iosocket.on('stateChange', (state) => { } }); - $('.increment').click(function(){ + $('.increment').click(function() { alert('haha'); + // trigger a state update? }); - $('.decrement').click(function(){ + $('.decrement').click(function() { alert('haha'); }); }); -// get my state -let context = 'admin'; -iosocket.emit('loadState', context); - - // Bracket editing @@ -39,8 +38,8 @@ iosocket.emit('loadState', context); /* Custom data objects passed as teams */ var customData = { teams: [ - ["Team 1","Team 2"], - ["Team 3","Team 4"] + ["Team 1", "Team 2"], + ["Team 3", "Team 4"] ], results: [] } @@ -73,27 +72,36 @@ function edit_fn(container, data, doneCb) { function render_fn(container, data, score, state) { switch (state) { case "empty-bye": - container.append("No team") + container.append(noTeam) return; case "empty-tbd": - container.append("Upcoming") + container.append("To be determined") return; - case "entry-no-score": + console.log('no score');// no return case "entry-default-win": + console.log('default win');// no return case "entry-complete": container.append(data); return; } + console.log(container); } function saveFn(data, userData) { iosocket.emit('editState', data); } - $(function() { - $('#refresh').click(function(){ + // Dom is loaded + $('#refresh').click(function() { iosocket.emit('clientrefresh'); }); + // Reading config (not state) from dom... and after all jquery is a doomed dom lib + tbdLable = $('#TBD').val(); + noTeam = $('#NoT').val(); + + // get my state + let context = 'admin'; + iosocket.emit('loadState', context); }); diff --git a/public/js/front_client.js b/public/js/front_client.js index 6624e63..3cb6e53 100644 --- a/public/js/front_client.js +++ b/public/js/front_client.js @@ -2,6 +2,9 @@ let iosocket = io.connect(); +let tbdLable = 'To be determined', +noTeam = 'Kein Team'; + // setup all my handlers iosocket.on('clientrefresh', () => { location.reload(); @@ -11,11 +14,38 @@ iosocket.on('stateChange', (state) => { console.log(state); // basically the server tracks the state since it is the same for al clients // So we know that we HAVE to update at this point - $('#team-container').bracket({init: state}); + $('#team-container').bracket({ + init: state, + decorator: { + edit: ()=>{}, + render: render_fn + } + }); }); +function lolz() { +} +function render_fn(container, data, score, state) { + switch (state) { + case "empty-bye": + container.append(noTeam) + return; + case "empty-tbd": + container.append(tbdLable) + retrun; + case "entry-no-score": + console.log('no score');// no return + case "entry-default-win": + console.log('default win');// no return + case "entry-complete": + container.append(data); + return; + } +} $( document ).ready(function() { + tbdLable = $('#TBD').val(); + noTeam = $('#NoT').val(); // get my state let context = 'main'; iosocket.emit('loadState',context); diff --git a/routes/routes.js b/routes/routes.js index 765810e..057d38f 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -4,7 +4,7 @@ let passwd = 'insecure'; /* GET home page. */ router.get('/', function(req, res, next) { - res.render('index', { mainHeader: 'Aktueller Spielstand' }); + res.render('index', { mainHeader: '🍺🍺🍺 Aktueller Spielstand 🍺🍺🍺🍺', TBD:'I am TBD', NoTeam:'No TeamYet' }); }); router.get('/login', function(req, res, next) { @@ -31,7 +31,7 @@ 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' }); + res.render('admin', { mainHeader: 'Admin Interface', TBD:'I am TBD', NoTeam:'No TeamYet' }); }else{ res.redirect('/login'); } diff --git a/views/admin.hbs b/views/admin.hbs index 33c2607..5738592 100644 --- a/views/admin.hbs +++ b/views/admin.hbs @@ -27,5 +27,8 @@ + + + diff --git a/views/index.hbs b/views/index.hbs index 3574a74..fc4c4eb 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -23,5 +23,7 @@ + + diff --git a/views/login.hbs b/views/login.hbs index 4f631a0..9875b27 100644 --- a/views/login.hbs +++ b/views/login.hbs @@ -1,43 +1,48 @@ - - - Login - - - - - - - + + + Login + + + - + + + + + - - + + -

{{mainHeader}}

-
-
- + + +

{{mainHeader}}

+
+ +

+ +
+ + -