Adding randomize feature

This commit is contained in:
2018-11-24 18:57:48 +01:00
parent f4e631f972
commit 488a9e08c1
7 changed files with 3269 additions and 48 deletions

View File

@ -2,7 +2,7 @@
// This is the backend client js
var iosocket = io.connect();
var tbdLable = 'To be determined',
var tbdLabel = 'To be determined',
noTeam = 'Kein Team';
// setup all my handlers
@ -102,9 +102,12 @@ $(function() {
// Dom is loaded
$('#refresh').click(function() {
iosocket.emit('clientrefresh');
});
$('#randomize').click(function() {
iosocket.emit('randomizeTeams');
});
// Reading config (not state) from dom... and after all jquery is a doomed dom lib
tbdLable = $('#TBD').val();
tbdLabel = $('#TBD').val();
noTeam = $('#NoT').val();
// get my state

View File

@ -1,23 +1,23 @@
'use strict';
"use strict";
var iosocket = io.connect();
var tbdLable = 'To be determined',
noTeam = 'Kein Team';
var tbdLabel = "To be determined",
noTeam = "Kein Team";
// setup all my handlers
iosocket.on('clientrefresh', function(){
iosocket.on("clientrefresh", function() {
location.reload();
});
iosocket.on('stateChange', function(state){
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
$('#team-container').bracket({
$("#team-container").bracket({
init: state,
decorator: {
edit: function(){},
edit: function() {},
render: render_fn
},
teamWidth: 130,
@ -30,26 +30,25 @@ iosocket.on('stateChange', function(state){
function render_fn(container, data, score, state) {
switch (state) {
case "empty-bye":
container.append(noTeam)
container.append(noTeam);
return;
case "empty-tbd":
container.append(tbdLable)
container.append(tbdLabel);
return;
case "entry-no-score":
console.log('no score');// no return
console.log("no score"); // no return
case "entry-default-win":
console.log('default win');// no return
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
var context = 'main';
iosocket.emit('loadState',context);
});
$(document).ready(function() {
tbdLabel = $("#TBD").val();
noTeam = $("#NoT").val();
// get my state
var context = "main";
iosocket.emit("loadState", context);
});