uniScore/public/js/front_client.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
2017-03-14 15:02:54 +00:00
var iosocket = io.connect();
var tbdLable = 'To be determined',
2017-03-20 17:12:20 +00:00
noTeam = 'Kein Team';
// setup all my handlers
iosocket.on('clientrefresh', function(){
location.reload();
});
iosocket.on('stateChange', function(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: function(){},
2017-03-20 17:12:20 +00:00
render: render_fn
},
teamWidth: 130,
scoreWidth: 20,
matchMargin: 20,
roundMargin: 20
2017-03-20 17:12:20 +00:00
});
2017-03-13 12:53:22 +00:00
});
2017-03-20 17:12:20 +00:00
function render_fn(container, data, score, state) {
switch (state) {
case "empty-bye":
container.append(noTeam)
return;
case "empty-tbd":
container.append(tbdLable)
return;
2017-03-20 17:12:20 +00:00
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-16 09:41:51 +00:00
$( document ).ready(function() {
2017-03-20 17:12:20 +00:00
tbdLable = $('#TBD').val();
noTeam = $('#NoT').val();
// get my state
var context = 'main';
iosocket.emit('loadState',context);
2017-03-16 09:41:51 +00:00
});