53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
let iosocket = io.connect();
|
|
|
|
let tbdLable = 'To be determined',
|
|
noTeam = 'Kein Team';
|
|
|
|
// setup all my handlers
|
|
iosocket.on('clientrefresh', () => {
|
|
location.reload();
|
|
});
|
|
|
|
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,
|
|
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);
|
|
});
|