X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=carousel.js;h=e73a38701b455c46330a7edef42cad8306cf9770;hb=f463b5ca0f73d20b4a9fca08df334e8b53c1cfdc;hp=153d425d9b52141f544f91b9e4d3b99db5dd08ff;hpb=f1dc8cfb0b1c65dd065a3353a3056672af20a051;p=ultimatescore diff --git a/carousel.js b/carousel.js index 153d425..e73a387 100644 --- a/carousel.js +++ b/carousel.js @@ -352,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]; @@ -387,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, Trøndisk 2018
" + group_name); let tr = document.createElement("tr"); tr.className = "subfooter"; addth(tr, "rank", ""); @@ -430,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("www.trondheimfrisbeeklubb.no | #trøndisk")); td.setAttribute("colspan", "5"); footer_tr.appendChild(td); carousel.appendChild(footer_tr); @@ -472,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); @@ -544,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, Trøndisk 2018
" + covered_days.join('/') + " (all times CET)"); let teams_to_idx = make_teams_to_idx(teams); row_num = 0; @@ -586,17 +583,23 @@ function get_group(group_name, cb) }; req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/1uh7kr5v_hyD072b1G2tbQlhqd_8ldS_6j30CBocQ-4E/values/\'' + group_name + '\'!A1:J50?key=AIzaSyAuP9yQn8g0bSay6r_RpGtpFeIbwprH1TU'); 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;