diff --git a/brackets.html b/brackets.html index 94cb2a8..87ea50f 100644 --- a/brackets.html +++ b/brackets.html @@ -9,9 +9,13 @@ +
+
+
+ diff --git a/lib/brackets/main.js b/lib/brackets/main.js index c151c5f..e7d6f99 100644 --- a/lib/brackets/main.js +++ b/lib/brackets/main.js @@ -1,40 +1,76 @@ Brackets = { - init: function () { - var minimalData = { - teams: [ - [ - {name: 'All Towards', gist: '808c86eb544d9efaf94a30efc91bdfaf'}, - {name: 'Rotate', gist: '6634a7f381bb679ee7c2d90d93588d66'} - ], /* first matchup */ - [ - {name: 'Long Random', gist: 'b9a0fe99060d9be1fc617bb7262f57be'}, - {name: 'Faraday Cage', gist: 'd9eb9a70ad0dc0fb1885be0fce032adc'} - ] /* second matchup */ - ] - }; + init: function(results) { + if(typeof results == 'undefined') { + results = []; + } + var teams = []; + $.each( + Brackets.teams, + function(idx, team_data) { + var match_index = Math.floor(idx / 2); + var team_index = idx % 2; + // set team + if(typeof teams[match_index] == 'undefined') { + teams[match_index] = []; + } + teams[match_index][team_index] = team_data.name; + } + ); $('#tournament_brackets').bracket({ - init: minimalData, - save: function (data) { - }, - decorator: { - render: Brackets.render_fn, - edit: Brackets.edit_fn + save: function() {}, + init: { + teams: teams, + results: results }, + disableToolbar: true, + disableTeamEdit: true, teamWidth: 150 }); + + Brackets.init_team_display(); }, - render_fn: function (container, data, score, state) { - if (data) { - container.append(data.name); - } + init_team_display: function() { + var select_options = []; + $.each( + Brackets.teams, + function(idx, team) { + select_options.push( + $('