-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew Faraday
committed
Oct 1, 2019
1 parent
c131d2a
commit 1923c98
Showing
4 changed files
with
112 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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( | ||
$('<option>') | ||
.html(team.name) | ||
.attr('value', team.gist) | ||
); | ||
} | ||
); | ||
$.each( | ||
['green', 'red'], | ||
function(idx, area) { | ||
area = $('.team_display#' + area); | ||
var select = $('<select>'); | ||
$.each( | ||
select_options, | ||
function(idx, option) { | ||
select.append(option.clone()); | ||
} | ||
); | ||
select.on( | ||
'change', | ||
Brackets.show_team | ||
); | ||
area.append(select); | ||
} | ||
) | ||
}, | ||
edit_fn: function (container, data, doneCb) { | ||
|
||
show_team: function(e, x) { | ||
var team_data = Brackets.get_team_data($(this).val()); | ||
console.log(team_data); | ||
}, | ||
|
||
get_match: function (idx) { | ||
var teams_data = $('#tournament_brackets').data().bracket.obj.data(); | ||
|
||
get_team_data: function(gist) { | ||
return $.grep( | ||
Brackets.teams, | ||
function(team) { | ||
return team.gist == gist; | ||
} | ||
)[0]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Brackets.teams = [ | ||
{ | ||
name: 'All Towards', | ||
gist: '808c86eb544d9efaf94a30efc91bdfaf', | ||
description: 'This just goes towards the opposite corner.', | ||
notes: ['Misses opponent', 'Original bot'] | ||
}, | ||
{ | ||
name: 'Rotate', | ||
gist: '6634a7f381bb679ee7c2d90d93588d66', | ||
description: 'Round and round and round...', | ||
notes: [] | ||
}, | ||
{ | ||
name: 'Long Random', | ||
gist: 'b9a0fe99060d9be1fc617bb7262f57be', | ||
description: "Every 10 moves it goes a random direction.", | ||
notes: ['Unpredictable'] | ||
}, | ||
{ | ||
name: 'Faraday Cage', | ||
gist: 'd9eb9a70ad0dc0fb1885be0fce032adc', | ||
description: 'A "sausage factory" which sends out high-value walkers', | ||
notes: ['Named after Alan Faraday', 'Very hard to beat', 'Interrupt it early'] | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.team_display { | ||
width: 45%; | ||
float: left; | ||
min-height: 50px; | ||
margin: 1%; | ||
border-radius: 10px; | ||
padding:10px; | ||
} | ||
|
||
#green{ | ||
background-color: lightgreen; | ||
} | ||
|
||
#red { | ||
background-color: lightpink; | ||
} | ||
|