-
Notifications
You must be signed in to change notification settings - Fork 1
/
rankings.html
285 lines (264 loc) · 10.1 KB
/
rankings.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<!DOCTYPE html>
<html lang="en"><!-- InstanceBegin template="/Templates/MainTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!-- InstanceBeginEditable name="doctitle" -->
<meta name="description" content="View live qualification match results from BE 11." />
<title>Rankings - Brunswick Eruption 11</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="screen" />
<link href="buttons/buttons.css" rel="stylesheet" type="text/css"/>
<script src="jquery1.6.2.js" type="text/javascript"></script>
<link rel="icon" type="image/png" href="images/favicon.png" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6958956-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<!-- Facebook and Twitter scripts -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "http://connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<!-- End Facebook and Twitter scripts -->
<div id="headerBackground">
<div id="header">
<img id="headerImage" src="./images/header.png" alt="" onDragStart="return false;"/>
</div>
</div>
<div id="sticky_navigation_wrapper">
<div id="sticky_navigation">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="register.html">Register</a></li>
<li><a href="volunteer.html">Volunteer</a></li>
<li><a href="teams.html">Team List</a></li>
<li><a href="awards.html">Awards</a></li>
<li><a href="agenda.html">Agenda</a></li>
<li><a href="local.html">Directions</a></li>
<li><a href="history.html">History</a></li>
<li><a href="subscribe.html">Subscribe</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
</div>
<h3 class="centered"><a class="no-decoration" href="matchresults.html">Match Results</a> | <a class="no-decoration"href="webcast.html">Webcast</a></h3>
<div class="mainContent">
<h3 class="centered">Brunswick Eruption 11 Rankings</h3>
<table id="rankingsTable" class="centered table table-striped table-bordered table-condensed">
<tr>
<td><strong>Rank</strong></td>
<td><strong>Team</strong></td>
<td><strong>QS</strong></td>
<td><strong>HP</strong></td>
<td><strong>BP</strong></td>
<td><strong>TP</strong></td>
<td><strong>CP</strong></td>
<td><strong>Record (W-L-T)</strong></td>
<td><strong>Played</strong></td>
</tr>
</table>
<script type="text/javascript">
var Team = function(number) {
this.number = number;
this.QS = 0;
this.HP = 0;
this.BP = 0;
this.TP = 0;
this.CP = 0;
this.wins = 0;
this.losses = 0;
this.ties = 0;
this.played = 0;
this.matchRecords = [];
};
var teams = [];
var matchesPerTeam = 6;
/**
* Return the Team with the specified number from the list.
* If the team isn't found, it is added to the list.
*/
function getTeam(number) {
for (var i = 0; i < teams.length; i++) {
if (teams[i].number === number) {
return teams[i];
}
}
var newTeam = new Team(number);
teams.push(newTeam);
return newTeam;
}
$("document").ready( function() {
$.ajax( {
url: "getMatchResults.php",
type: "GET",
dataType: 'json',
success: function( matchResults ) {
// First get all the team data
for (var i = 0; i < matchResults.length; i++) {
// Do stuff for sorting rankings
if (matchResults[i].type === 'Q') {
var j;
var team;
var redQS, blueQS;
if (matchResults[i].redFinal > matchResults[i].blueFinal) {
redQS = 2;
blueQS = 0;
} else if (matchResults[i].redFinal < matchResults[i].blueFinal) {
redQS = 0;
blueQS = 2;
} else {
redQS = 1;
blueQS = 1;
}
var redTeams = matchResults[i].red;
for (j = 0; j < redTeams.length; j++) {
team = getTeam(redTeams[j]);
team.matchRecords.push(matchResults[i]);
team.QS += redQS + matchResults[i].CP;
team.HP += matchResults[i].redHybrid;
team.BP += matchResults[i].redBridge;
team.TP += matchResults[i].redTeleop;
team.CP += matchResults[i].CP;
if (matchResults[i].redFinal > matchResults[i].blueFinal) {
team.wins += 1;
} else if (matchResults[i].redFinal < matchResults[i].blueFinal) {
team.losses += 1;
} else {
team.ties += 1;
}
team.played++;
}
var blueTeams = matchResults[i].blue;
for (j = 0; j < blueTeams.length; j++) {
team = getTeam(blueTeams[j]);
team.matchRecords.push(matchResults[i]);
team.QS += blueQS + matchResults[i].CP;
team.HP += matchResults[i].blueHybrid;
team.BP += matchResults[i].blueBridge;
team.TP += matchResults[i].blueTeleop;
team.CP += matchResults[i].CP;
if (matchResults[i].redFinal < matchResults[i].blueFinal) {
team.wins += 1;
} else if (matchResults[i].redFinal > matchResults[i].blueFinal) {
team.losses += 1;
} else {
team.ties += 1;
}
team.played++;
}
} else if(matchResults[i].type === 'E') {
var redTeams = matchResults[i].red;
for (j = 0; j < redTeams.length; j++) {
team = getTeam(redTeams[j]);
team.matchRecords.push(matchResults[i]);
}
var blueTeams = matchResults[i].blue;
for (j = 0; j < blueTeams.length; j++) {
team = getTeam(blueTeams[j]);
team.matchRecords.push(matchResults[i]);
}
}
}
// Remove surrogate matches
for (var i = 0; i < teams.length; i++) {
if (teams[i].played > matchesPerTeam) {
var surrogateMatch = teams[i].matchRecords[2];
teams[i].CP -= surrogateMatch.CP;
if (surrogateMatch.redFinal > surrogateMatch.blueFinal) {
redQS = 2;
blueQS = 0;
} else if (surrogateMatch.redFinal < surrogateMatch.blueFinal) {
redQS = 0;
blueQS = 2;
} else {
redQS = 1;
blueQS = 1;
}
if (surrogateMatch.red.indexOf(teams[i].number) !== -1) {
// the team was red
teams[i].QS -= (redQS + surrogateMatch.CP);
teams[i].HP -= surrogateMatch.redHybrid;
teams[i].TP -= surrogateMatch.redTeleop;
teams[i].BP -= surrogateMatch.redBridge;
} else {
teams[i].QS -= (blueQS + surrogateMatch.CP);
teams[i].HP -= surrogateMatch.blueHybrid;
teams[i].TP -= surrogateMatch.blueTeleop;
teams[i].BP -= surrogateMatch.blueBridge;
}
}
}
// Then sort
teams.sort(function(a, b) {
if (a.QS === b.QS && a.HP === b.HP && a.BP === b.BP) {
return a.TP - b.TP;
} else if (a.QS === b.QS && a.HP === b.HP) {
return a.BP - b.BP;
} else if (a.QS === b.QS) {
return a.HP - b.HP;
} else {
return a.QS - b.QS;
}
return 0;
});
teams.reverse();
//Then display the rankings
var resultsTable;
for (var i = 0; i < teams.length; i++) {
resultsTable = document.getElementById('rankingsTable');
var rowCount = resultsTable.rows.length;
var row = resultsTable.insertRow(rowCount);
var cell;
row.insertCell(0).innerHTML = i + 1;
cell = row.insertCell(1);
cell.innerHTML = teams[i].number;
cell = row.insertCell(2);
cell.innerHTML = teams[i].QS
cell = row.insertCell(3);
cell.innerHTML = teams[i].HP;
cell = row.insertCell(4);
cell.innerHTML = teams[i].BP;
cell = row.insertCell(5);
cell.innerHTML = teams[i].TP;
cell = row.insertCell(6);
cell.innerHTML = teams[i].CP;
cell = row.insertCell(7);
cell.innerHTML = teams[i].wins + '-' + teams[i].losses + '-' + teams[i].ties;
cell = row.insertCell(8);
cell.innerHTML = teams[i].played;
}
}
});
});
</script>
</div>
<img id="floral" src="./images/flower.png" alt=""/>
<div id="social">
<div class="fb-like" data-href="http://www.facebook.com/BrunswickEruption" data-send="false" data-layout="box_count" data-width="50" data-show-faces="false" data-font="lucida grande"></div>
<a href="https://twitter.com/BrunsEruption" class="twitter-follow-button" data-show-count="false" data-size="large" data-show-screen-name="false">Follow @BrunsEruption</a>
</div>
<div id="footer">
<div id="footerContent">
<a href="http://www.usfirst.org" target="_blank"> <img id="FIRSTlogo" src="images/FIRST_vert.gif" alt=""/></a>
<a href="http://www.raiderrobotix.org" target="_blank"> <img id="RaiderRobotixLogo" src="images/Team25Logo.png" alt=""/></a>
</div>
<div id="copyright">
Copyright Raider Robotix / Brunswick Eruption 2012
</div>
</div>
</body>
</html>