X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=carousel.js;h=1a38e1b7d077fd17251333fa9ad14996c067da52;hb=0830813a9a0a59443b1a068e217bf9524f82052e;hp=b4ac56e16ed2cff7a5b2140a37f7e7b495be27db;hpb=79d13f17aa64d6292b34168d5ff82659fac64b4f;p=ultimatescore diff --git a/carousel.js b/carousel.js index b4ac56e..1a38e1b 100644 --- a/carousel.js +++ b/carousel.js @@ -351,6 +351,7 @@ function parse_teams_from_spreadsheet(response) { "mediumname": response.values[i][1], "shortname": response.values[i][2], //"tags": response.values[i][3], + "ngames": 0, "nplayed": 0, "gd": 0, "pts": 0, @@ -418,6 +419,24 @@ function apply_games_to_teams(games, teams) } } +// So that we can just have one team list, and let membership be defined by games. +function filter_teams(teams, response) +{ + let teams_to_idx = make_teams_to_idx(teams); + let games = parse_games_from_spreadsheet(response, 'irrelevant group name', true); + for (let i = 0; i < games.length; ++i) { + let idx1 = teams_to_idx[games[i].name1]; + let idx2 = teams_to_idx[games[i].name2]; + if (idx1 !== undefined) { + ++teams[idx1].ngames; + } + if (idx2 !== undefined) { + ++teams[idx2].ngames; + } + } + return teams.filter(function(team) { return team.ngames > 0; }); +} + function display_group_parsed(teams, games, group_name) { document.getElementById('entire-bug').style.display = 'none'; @@ -628,9 +647,10 @@ function showgroup(group_name) 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); + teams = filter_teams(teams, response); display_group_parsed(teams, games, group_name); + publish_group_rank(response, group_name); // Update the spreadsheet in the background. }); - publish_group_rank(group_name); // Update the spreadsheet in the background. } @@ -650,7 +670,7 @@ function showschedule(page) { let teams = []; let games = []; - let num_left = 4; + let num_left = 5; let cb = function(response, group_name) { teams = teams.concat(parse_teams_from_spreadsheet(response)); @@ -664,6 +684,7 @@ function showschedule(page) get_group('Group B', cb); get_group('Group C', cb); get_group('Playoffs', cb); + get_group('Playoffs 9th-13th', cb); }; function do_series(series) @@ -685,11 +706,12 @@ function showcarousel() let games_per_group = []; let combined_teams = []; let combined_games = []; - let num_left = 4; + let num_left = 5; let cb = function(response, group_name) { let teams = parse_teams_from_spreadsheet(response); let games = parse_games_from_spreadsheet(response, group_name, true); + teams = filter_teams(teams, response); teams_per_group[group_name] = teams; games_per_group[group_name] = games; @@ -702,6 +724,8 @@ function showcarousel() [ 13000, function() { display_group_parsed(teams_per_group['Group B'], games_per_group['Group B'], 'Group B'); } ], [ 2000, function() { hidetable(); } ], [ 13000, function() { display_group_parsed(teams_per_group['Group C'], games_per_group['Group C'], 'Group C'); } ], + [ 2000, function() { hidetable(); } ], + [ 13000, function() { display_group_parsed(teams_per_group['Playoffs 9th-13th'], games_per_group['Playoffs 9th-13th'], 'Playoffs 9th–13th'); } ], [ 2000, function() { hidetable(); } ] ]; let num_pages = find_num_pages(combined_games); @@ -717,6 +741,7 @@ function showcarousel() get_group('Group A', cb); get_group('Group B', cb); get_group('Group C', cb); + get_group('Playoffs 9th-13th', cb); get_group('Playoffs', cb); };