2017-03-13 12:43:44 +00:00
|
|
|
'use strict';
|
2017-03-14 15:02:54 +00:00
|
|
|
|
2017-03-13 12:43:44 +00:00
|
|
|
let iosocket = io.connect();
|
|
|
|
|
2017-03-20 17:12:20 +00:00
|
|
|
let tbdLable = 'To be determined',
|
|
|
|
noTeam = 'Kein Team';
|
|
|
|
|
2017-03-13 12:43:44 +00:00
|
|
|
// setup all my handlers
|
|
|
|
iosocket.on('clientrefresh', () => {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
|
2017-03-19 15:00:30 +00:00
|
|
|
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
|
2017-03-20 17:12:20 +00:00
|
|
|
$('#team-container').bracket({
|
|
|
|
init: state,
|
|
|
|
decorator: {
|
|
|
|
edit: ()=>{},
|
|
|
|
render: render_fn
|
|
|
|
}
|
|
|
|
});
|
2017-03-13 12:53:22 +00:00
|
|
|
});
|
2017-03-20 17:12:20 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2017-03-13 12:53:22 +00:00
|
|
|
|
2017-03-13 12:43:44 +00:00
|
|
|
|
2017-03-16 09:41:51 +00:00
|
|
|
$( document ).ready(function() {
|
2017-03-20 17:12:20 +00:00
|
|
|
tbdLable = $('#TBD').val();
|
|
|
|
noTeam = $('#NoT').val();
|
2017-03-19 15:00:30 +00:00
|
|
|
// get my state
|
|
|
|
let context = 'main';
|
|
|
|
iosocket.emit('loadState',context);
|
2017-03-16 09:41:51 +00:00
|
|
|
});
|