X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=carousel.js;h=b5bf8e294ee80b01d1a8368ee766714536def05c;hb=19c3289f1aa2a338f16efca9bb608e85a430a417;hp=f3c60145d4b11a9e063cd0ada7e94ae20cafd4ca;hpb=5e3676c0b149c5bc342fedf54ac87a75fbae88dc;p=ultimatescore
diff --git a/carousel.js b/carousel.js
index f3c6014..b5bf8e2 100644
--- a/carousel.js
+++ b/carousel.js
@@ -69,6 +69,8 @@ function make_teams_to_idx(teams)
let teams_to_idx = [];
for (let i = 0; i < teams.length; i++) {
teams_to_idx[teams[i].name] = i;
+ teams_to_idx[teams[i].mediumname] = i;
+ teams_to_idx[teams[i].shortname] = i;
}
return teams_to_idx;
}
@@ -235,7 +237,7 @@ function rank(games, teams, start_rank, tiebreakers) {
// See if the two teams have both played a third team k.
for (let k in results_i) {
if (!results_i.hasOwnProperty(k)) continue;
- if (results_j[k] !== undefined) {
+ if (results_j !== undefined && results_j[k] !== undefined) {
gd_i += results_i[k][0] - results_i[k][1];
gd_j += results_j[k][0] - results_j[k][1];
}
@@ -275,7 +277,7 @@ function rank(games, teams, start_rank, tiebreakers) {
// See if the two teams have both played a third team k.
for (let k in results_i) {
if (!results_i.hasOwnProperty(k)) continue;
- if (results_j[k] !== undefined) {
+ if (results_j !== undefined && results_j[k] !== undefined) {
goals_i += results_i[k][0];
goals_j += results_j[k][0];
}
@@ -350,17 +352,8 @@ function parse_games_from_spreadsheet(response, group_name, include_unplayed) {
return games;
};
-function display_group(response, group_name)
+function apply_games_to_teams(games, teams)
{
- let teams = parse_teams_from_spreadsheet(response);
- let games = parse_games_from_spreadsheet(response, group_name, false);
- display_group_parsed(teams, games, group_name);
-};
-
-function display_group_parsed(teams, games, group_name)
-{
- document.getElementById('entire-bug').style.display = 'none';
-
let teams_to_idx = make_teams_to_idx(teams);
for (let i = 0; i < games.length; ++i) {
let idx1 = teams_to_idx[games[i].name1];
@@ -385,14 +378,20 @@ function display_group_parsed(teams, games, group_name)
teams[idx2].pts += 2;
}
}
+}
+function display_group_parsed(teams, games, group_name)
+{
+ document.getElementById('entire-bug').style.display = 'none';
+
+ apply_games_to_teams(games, teams);
let tiebreakers = [];
teams = rank(games, teams, 1, tiebreakers);
let carousel = document.getElementById('carousel');
clear_carousel(carousel);
- addheading(carousel, 5, "Current standings
" + group_name);
+ addheading(carousel, 5, "Current standings, " + ultimateconfig['tournament_title'] + "
" + group_name);
let tr = document.createElement("tr");
tr.className = "subfooter";
addth(tr, "rank", "");
@@ -428,7 +427,7 @@ function display_group_parsed(teams, games, group_name)
let footer_tr = document.createElement("tr");
footer_tr.className = "footer";
let td = document.createElement("td");
- td.appendChild(document.createTextNode("Norwegian Ultimate Championships 2018 | #ultimatenm"));
+ td.appendChild(document.createTextNode(ultimateconfig['tournament_footer']));
td.setAttribute("colspan", "5");
footer_tr.appendChild(td);
carousel.appendChild(footer_tr);
@@ -470,7 +469,7 @@ function clear_carousel(table)
};
// Stream schedule
-let max_list_len = 8;
+let max_list_len = 7;
function display_stream_schedule(response, group_name) {
let teams = parse_teams_from_spreadsheet(response);
@@ -542,7 +541,7 @@ function display_stream_schedule_parsed(teams, games, page) {
let carousel = document.getElementById('carousel');
clear_carousel(carousel);
- addheading(carousel, 3, "Match schedule
" + covered_days.join('/') + " (all times CET)");
+ addheading(carousel, 3, "Stream schedule, " + ultimateconfig['tournament_title'] + "
" + covered_days.join('/') + " (all times CET)");
let teams_to_idx = make_teams_to_idx(teams);
row_num = 0;
@@ -582,19 +581,25 @@ function get_group(group_name, cb)
req.onload = function(e) {
cb(JSON.parse(req.responseText), group_name);
};
- req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/122tIwrXTi5ug0Vv6Np5w3pVwEWE2KkjWxtzQQfGtOZA/values/\'' + group_name + '\'!A1:J50?key=AIzaSyAuP9yQn8g0bSay6r_RpGtpFeIbwprH1TU');
+ req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/' + ultimateconfig['score_sheet_id'] + '/values/\'' + group_name + '\'!A1:J50?key=' + ultimateconfig['api_key']);
req.send();
-};
+}
function showgroup(group_name)
{
- get_group(group_name, display_group);
-};
+ get_group(group_name, function(response, group_name) {
+ let teams = parse_teams_from_spreadsheet(response);
+ let games = parse_games_from_spreadsheet(response, group_name, false);
+ display_group_parsed(teams, games, group_name);
+ });
+ publish_group_rank(group_name); // Update the spreadsheet in the background.
+}
+
function showgroup_from_state()
{
showgroup(state['group_name']);
-};
+}
let carousel_timeout = null;
@@ -690,5 +695,18 @@ function hidescorebug()
function showscorebug()
{
document.getElementById('entire-bug').style.display = null;
-};
+}
+function showmatch2()
+{
+ let css = "-webkit-animation: fade-in 1.0s ease; -webkit-animation-fill-mode: both;";
+ document.getElementById('scorebug2').style = css;
+ document.getElementById('clockbug2').style = css;
+}
+
+function hidematch2()
+{
+ let css = "-webkit-animation: fade-out 1.0s ease; -webkit-animation-fill-mode: both;";
+ document.getElementById('scorebug2').style = css;
+ document.getElementById('clockbug2').style = css;
+}