forked from Paradox2102/roborecon-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matches.html
133 lines (117 loc) · 6.63 KB
/
matches.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
layout: page
permalink: /matches/
---
<div id="matches-container" class="container-fluid">
<div class="row">
<div id="buttons" class="col-md-12 text-right" style="margin-bottom:10px;"></div>
<div class="col-md-12">
<table id="matches" class="table table-striped table-bordered " cellspacing="0" width="100%">
</table>
</div>
</div>
</div>
<script>
$(function() {
// *** onload ***
// build dashboard
var dashboard = $('#matches').DataTable({
initComplete: function(settings, json) {
// add print, excel, column visibility buttons
$("#matches").DataTable().buttons().container().appendTo( $('#buttons'));
// required due to incompatiblity with fixedcolumns and scroller extensions
setTimeout(function() {$("#matches").DataTable().columns.adjust().draw(); }, 10);
},
ajax: function(data, callback, settings) {
// load the data -- for testing use: $.getJSON("{{ site.baseurl }}/test-data/sample-event-scores.json", function(teamData) {
$('.loaderImage').show();
ParadoxScout.getMatches(null, function(matches, error) {
$('.loaderImage').hide();
if(error) {
AppUtility.showErrorMsg("An error occurred!", error);
}
else {
callback({
data: matches,
destroy: true,
initComplete: function(settings, json) {
setTimeout(function() {$("#matches").DataTable().columns.adjust().draw(); }, 500);
}
});
}
});
},
// responsive: true,
paging: false,
buttons: [ 'print', { extend: 'excel', title: 'Excel' } ],
columns: [
// match name
{ title: 'Match', data: 'match_key',
render: function(data,type,full,meta) {
var matchName;
switch (full.match_comp_level) {
case 'qm':
matchName = 'Quals ' + full.match_number;
break;
case 'qf':
matchName = 'Quarters ' + full.match_number + ' Match ' + full.match_set_number;
break;
case 'sf':
matchName = 'Semis ' + full.match_number + ' Match ' + full.match_set_number;
break;
case 'f':
matchName= 'Finals ' + full.match_number;
break;
}
var blueTeams = 'b0=' + full.blue_alliance_0 + '&b1=' + full.blue_alliance_1 + '&b2=' + full.blue_alliance_2;
var redTeams = 'r0=' + full.red_alliance_0 + '&r1=' + full.red_alliance_1 + '&r2=' + full.red_alliance_2;
return '<a href="{{ site.baseurl }}/match-intel?m=' + matchName + '&' + blueTeams + '&' + redTeams + '">'+ matchName + '</a>'
}
},
// alliance teams
{ title: 'Blue Alliance', data: 'blue_alliance_0', render: function(data, type, full, meta) {
var tdClass= full.blue_score > full.red_score ? 'class="matches-winning-alliance"' : '';
var headerRow = '';
// if(meta.row === 0){
headerRow = '<tr><td>Scouter 1</td><td>Scouter 2</td><td>Scouter 3</td></tr>';
// }
return '<table class="table table-bordered matches-alliance-blue" >'+headerRow+'<tr>' +
'<td ' + tdClass + '><a href="{{ site.baseurl }}/team-details?team_id=' + data + '">'+ data.replace('frc', '') + '<small><br><a href="{{ site.baseurl }}/rate?team_id=' + data + '&match_key=' + full.match_key + '"><i>Rate Team</i></a></small>' + '</a></td>' +
'<td ' + tdClass + '><a href="{{ site.baseurl }}/team-details?team_id=' + full.blue_alliance_1 + '">'+ full.blue_alliance_1.replace('frc', '') + '<small><br><a href="{{ site.baseurl }}/rate?team_id=' + full.blue_alliance_1 + '&match_key=' + full.match_key + '"><i>Rate Team</i></a></small>' + '</a></td>' +
'<td ' + tdClass + '><a href="{{ site.baseurl }}/team-details?team_id=' + full.blue_alliance_2 + '">'+ full.blue_alliance_2.replace('frc', '') + '<small><br><a href="{{ site.baseurl }}/rate?team_id=' + full.blue_alliance_2 + '&match_key=' + full.match_key + '"><i>Rate Team</i></a></small>' + '</a></td>' +
'</tr></table>'; }
},
{ title: 'Red Alliance', data: 'red_alliance_0', render: function(data, type, full, meta) {
var tdClass= full.red_score > full.blue_score ? 'class="matches-winning-alliance"' : '';
var headerRow = '';
// if(meta.row === 0){
headerRow = '<tr><td>Scouter 4</td><td>Scouter 5</td><td>Scouter 6</td></tr>';
// }
return '<table class="table table-bordered matches-alliance-red">'+headerRow+'<tr>' +
'<td ' + tdClass + '><a href="{{ site.baseurl }}/team-details?team_id=' + data + '">'+ data.replace('frc', '') + '<small><br><a href="{{ site.baseurl }}/rate?team_id=' + data + '&match_key=' + full.match_key + '"><i>Rate Team</i></a></small>' + '</a></td>' +
'<td ' + tdClass + '><a href="{{ site.baseurl }}/team-details?team_id=' + full.red_alliance_1 + '">'+ full.red_alliance_1.replace('frc', '') + '<small><br><a href="{{ site.baseurl }}/rate?team_id=' + full.red_alliance_1 + '&match_key=' + full.match_key + '"><i>Rate Team</i></a></small>' + '</a></td>' +
'<td ' + tdClass + '><a href="{{ site.baseurl }}/team-details?team_id=' + full.red_alliance_2 + '">'+ full.red_alliance_2.replace('frc', '') + '<small><br><a href="{{ site.baseurl }}/rate?team_id=' + full.red_alliance_2 + '&match_key=' + full.match_key + '"><i>Rate Team</i></a></small>' + '</a></td>' +
'</tr></table>'; }
},
{ title: 'Scores', data: 'blue_score', render: function(data, type, full, meta) {
var blueClass = full.blue_score > full.red_score ? 'class="matches-winning-alliance"' : '';
var redClass = full.red_score > full.blue_score ? 'class="matches-winning-alliance"' : '';
var headerRow = '<tr><td style="background-color:#2295C7;"> </td><td style="background-color:#D44829;"> </td></tr>';;
if(meta.row === 0){
headerRow = '<tr><td style="background-color:#2295C7;">Blue</td><td style="background-color:#D44829;">Red</td></tr>';
}
return '<table class="table table-bordered" width="100%">'+headerRow+'<tr>' +
'<td width="50%" ' + blueClass + ' style="background-color:#2295C7;">'+ (data == -1 ? ' ' : data) + '<br><br>' + '</td>' +
'<td width="50%" ' + redClass + ' style="background-color:#D44829;">'+ (full.red_score == -1 ? ' ' : full.red_score) + '</td>' +
'</tr></table>'; }
}
],
'columnDefs': [{
'orderable': false,
'defaultContent': '-',
'targets': '_all'
}],
"aaSorting": []
});
});
</script>