This repository has been archived by the owner on Dec 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matchInfoJs.html
112 lines (93 loc) · 4.52 KB
/
matchInfoJs.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
<script>
function processResults (value) {
var apiResponse = value.results;
console.log(apiResponse);
var currentTeamInfo;
for (var i = 0; i < apiResponse.length; i++) {
output = '<div class="team-info-table-container mdl-cell--2-col-desktop mdl-cell--4-col-tablet mdl-cell--4-col-phone"><h5><strong>' + apiResponse[i].position + ' - ' + apiResponse[i].result.team
+ ' </strong></h5><table class="team-info-table mdl-data-table mdl-js-data-table mdl-shadow--2dp full-width scouting-table-disp"><thead><tr><th class="mdl-data-table__cell--non-numeric">Property</th><th>Value</th></tr></thead><tbody>';
if (apiResponse[i].result.hasOwnProperty("data")) {
currentTeamInfo = apiResponse[i].result.data;
for (var j = 0; j < currentTeamInfo.length; j++) {
output += '<tr><td class="mdl-data-table__cell--non-numeric">' + currentTeamInfo[j].propName + '</td><td class="mdl-data-table__cell--non-numeric">' + currentTeamInfo[j].value + '</td></tr>';
}
output += '</tbody></table></div>';
} else {
output = '<div class="team-info-table-container mdl-cell--2-col-desktop mdl-cell--4-col-tablet mdl-cell--4-col-phone"><h5><strong>' + apiResponse[i].position + ' - ' + apiResponse[i].result.team
+ ' </strong></h5><i class="material-icons">info_outline</i> No data available';
}
$('#match-team-info-tables').append(output);
}
$('#match-info-data-loading').removeClass("is-active").addClass("hidden");
}
function processMatchTeams(value) {
var match = value.results,
partner,
opponent1,
opponent2;
alert(match.matchnumber);
//determine alliance and position on alliance
if (match.red1 === queryTeam) {
alliance = "red";
alliancePosition = "red1";
} else if (match.red2 === queryTeam) {
alliance = "red";
alliancePosition = "red2";
} else if (match.blue1 === queryTeam) {
alliance = "blue";
alliancePosition = "blue1";
} else if (match.blue2 === queryTeam) {
alliance = "blue";
alliancePosition = "blue2";
}
//determine partner for this match
if (alliance === "red") {
if (alliancePosition === "red1") {
partner = match.red2;
} else { //this team is red2, so partner is red1
partner = match.red1;
}
} else if (alliance === "blue") {
if (alliancePosition === "blue1") {
partner = match.blue2;
} else { //this team is blue2, so partner is blue1
partner = match.blue1;
}
}
if (alliance === "red") {
opponent1 = match.blue1;
opponent2 = match.blue2;
} else {
opponent1 = match.red1;
opponent2 = match.red2;
}
//getTeamInfo(partner);
//getTeamInfo(opponent1);
//getTeamInfo(opponent2);
console.log(alliance);
console.log(alliancePosition);
}
function getTeamInfo(team) {
var url = "https://script.google.com/a/macros/woodward.edu/s/AKfycbxsKMe0cdyYScaJXipBoA2bFSY8Aj-jxlQqyS4aDOI/dev?prefix=processResults&type=getTeamInfo&id=1vrZQpvtiJvcyKdlULZk5HOyRU5ystAiMZ4y8rF6dJEg&team=" + team;
console.log(team);
console.log(url);
$('body').append('<script src="' + url + '"><\/script>');
}
function initialize() {
componentHandler.upgradeAllRegistered(); //to make sure the loading spinner appears and not just "Loading..."
//show a warning if the user is looking at a match for a different team (one that they aren't on)
if (userTeam !== queryTeam) {
if ($('#show-diff-team').hasClass('hidden')) { //only remove the hidden class if it's present
$('#show-diff-team').removeClass('hidden');
}
} else if (!$('#show-diff-team').hasClass('hidden')) { //only add the hidden class if it's absent
$('#show-diff-team').addClass('hidden');
}
//!!!NO REFRESH IS ENABLED!!!
var url = "https://script.google.com/a/macros/woodward.edu/s/AKfycbxsKMe0cdyYScaJXipBoA2bFSY8Aj-jxlQqyS4aDOI/dev?prefix=processResults&type=getTeamInfoForMatch&id=" + instanceID + "&norefresh&match=" + matchNum;
//get match details to determine which teams are competing in this match
$('body').append('<script src="' + url + '"><\/script>');
}
initialize();
</script>
<!--<script src="https://script.google.com/a/macros/woodward.edu/s/AKfycbxsKMe0cdyYScaJXipBoA2bFSY8Aj-jxlQqyS4aDOI/dev?prefix=processResults&type=getTeamInfo&id=1vrZQpvtiJvcyKdlULZk5HOyRU5ystAiMZ4y8rF6dJEg&team=1900A"></script>-->