From 3c73d98be870b84efa9b9e604b3d192b84ca7491 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 26 Oct 2017 20:04:09 +0200 Subject: [PATCH] strict mode fixes in carousel.js. --- carousel.js | 68 ++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/carousel.js b/carousel.js index d79b9a0..9084ffb 100644 --- a/carousel.js +++ b/carousel.js @@ -1,4 +1,4 @@ -addheading = function(carousel, colspan, content) +function addheading(carousel, colspan, content) { var thead = document.createElement("thead"); var tr = document.createElement("tr"); @@ -9,20 +9,20 @@ addheading = function(carousel, colspan, content) thead.appendChild(tr); carousel.appendChild(thead); }; -addtd = function(tr, className, content) { +function addtd(tr, className, content) { var td = document.createElement("td"); td.appendChild(document.createTextNode(content)); td.className = className; tr.appendChild(td); }; -addth = function(tr, className, content) { +function addth(tr, className, content) { var th = document.createElement("th"); th.appendChild(document.createTextNode(content)); th.className = className; tr.appendChild(th); }; -subrank_partitions = function(games, parts, start_rank, tiebreakers) { +function subrank_partitions(games, parts, start_rank, tiebreakers) { var result = []; for (var i = 0; i < parts.length; ++i) { var part = rank(games, parts[i], start_rank, tiebreakers); @@ -34,7 +34,7 @@ subrank_partitions = function(games, parts, start_rank, tiebreakers) { return result; }; -partition = function(teams, compare) +function partition(teams, compare) { teams.sort(compare); @@ -53,7 +53,7 @@ partition = function(teams, compare) return parts; }; -explain_tiebreaker = function(parts, rule_name) +function explain_tiebreaker(parts, rule_name) { var result = []; for (var i = 0; i < parts.length; ++i) { @@ -62,7 +62,7 @@ explain_tiebreaker = function(parts, rule_name) return result.join(" > ") + " (" + rule_name + ")"; } -make_teams_to_idx = function(teams) +function make_teams_to_idx(teams) { var teams_to_idx = []; for (var i = 0; i < teams.length; i++) { @@ -71,7 +71,7 @@ make_teams_to_idx = function(teams) return teams_to_idx; } -partition_by_beat = function(games, teams) +function partition_by_beat(games, teams) { // Head-to-head score by way of components. First construct the beat matrix. var n = teams.length; @@ -149,7 +149,7 @@ partition_by_beat = function(games, teams) } // Takes in an array, gives every element a rank starting with 1, and returns. -rank = function(games, teams, start_rank, tiebreakers) { +function rank(games, teams, start_rank, tiebreakers) { if (teams.length <= 1) { // Only one team, so trivial. teams[0].rank = start_rank; @@ -234,7 +234,7 @@ rank = function(games, teams, start_rank, tiebreakers) { return result; }; -parse_teams_from_spreadsheet = function(response) { +function parse_teams_from_spreadsheet(response) { var teams = []; for (var i = 2; response.values[i].length >= 1; ++i) { teams.push({ @@ -251,7 +251,7 @@ parse_teams_from_spreadsheet = function(response) { return teams; }; -parse_games_from_spreadsheet = function(response, group_name, include_unplayed) { +function parse_games_from_spreadsheet(response, group_name, include_unplayed) { var games = []; var i; for (i = 0; i < response.values.length; ++i) { @@ -281,19 +281,19 @@ parse_games_from_spreadsheet = function(response, group_name, include_unplayed) return games; }; -var display_group = function(response, group_name) +function display_group(response, group_name) { var teams = parse_teams_from_spreadsheet(response); var games = parse_games_from_spreadsheet(response, group_name, false); display_group_parsed(teams, games, group_name); }; -var display_group_parsed = function(teams, games, group_name) +function display_group_parsed(teams, games, group_name) { document.getElementById('entire-bug').style.display = 'none'; var teams_to_idx = make_teams_to_idx(teams); - for (i = 0; i < games.length; ++i) { + for (var i = 0; i < games.length; ++i) { var idx1 = teams_to_idx[games[i].name1]; var idx2 = teams_to_idx[games[i].name2]; if (games[i].score1 === undefined || games[i].score2 === undefined || @@ -317,7 +317,7 @@ var display_group_parsed = function(teams, games, group_name) } } - tiebreakers = []; + var tiebreakers = []; teams = rank(games, teams, 1, tiebreakers); var carousel = document.getElementById('carousel'); @@ -369,7 +369,7 @@ var display_group_parsed = function(teams, games, group_name) carousel.style.display = 'table'; }; -var fade_in_rows = function(table) +function fade_in_rows(table) { var trs = table.getElementsByTagName("tr"); for (var i = 1; i < trs.length; ++i) { // The header already has its own fade-in. @@ -381,7 +381,7 @@ var fade_in_rows = function(table) } }; -var fade_out_rows = function(table) +function fade_out_rows(table) { var trs = table.getElementsByTagName("tr"); for (var i = 0; i < trs.length; ++i) { @@ -393,7 +393,7 @@ var fade_out_rows = function(table) } }; -var clear_carousel = function(table) +function clear_carousel(table) { while (table.childNodes.length > 0) { table.removeChild(table.firstChild); @@ -403,13 +403,13 @@ var clear_carousel = function(table) // Stream schedule var max_list_len = 8; -var display_stream_schedule = function(response, group_name) { +function display_stream_schedule(response, group_name) { var teams = parse_teams_from_spreadsheet(response); var games = parse_games_from_spreadsheet(response, group_name, true); display_stream_schedule_parsed(teams, games, 0); }; -var sort_game_list = function(games) { +function sort_game_list(games) { games = games.filter(function(game) { return game.streamtime !== undefined && game.streamtime.match(/[0-9]+:[0-9]+/) != null; }); games.sort(function(a, b) { if (a.streamday !== b.streamday) { @@ -423,7 +423,7 @@ var sort_game_list = function(games) { return games; } -var find_game_start_idx = function(games) { +function find_game_start_idx(games) { // Pick out a reasonable place to start the list. We'll show the last // completed match and start from there. var start_idx = games.length - 1; @@ -441,13 +441,13 @@ var find_game_start_idx = function(games) { return start_idx; } -var find_num_pages = function(games) { +function find_num_pages(games) { games = sort_game_list(games); var start_idx = find_game_start_idx(games); return Math.ceil((games.length - start_idx) / max_list_len); } -var display_stream_schedule_parsed = function(teams, games, page) { +function display_stream_schedule_parsed(teams, games, page) { document.getElementById('entire-bug').style.display = 'none'; games = sort_game_list(games); @@ -507,7 +507,7 @@ var display_stream_schedule_parsed = function(teams, games, page) { carousel.style.display = 'table'; }; -var get_group = function(group_name, cb) +function get_group(group_name, cb) { var req = new XMLHttpRequest(); req.onload = function(e) { @@ -517,24 +517,24 @@ var get_group = function(group_name, cb) req.send(); }; -var showgroup = function(group_name) +function showgroup(group_name) { get_group(group_name, display_group); }; -var showgroup_from_state = function() +function showgroup_from_state() { showgroup(state['group_name']); }; var carousel_timeout = null; -var hidetable = function() +function hidetable() { fade_out_rows(document.getElementById('carousel')); }; -var showschedule = function(page) +function showschedule(page) { var teams = []; var games = []; @@ -553,12 +553,12 @@ var showschedule = function(page) get_group('Playoffs', cb); }; -var do_series = function(series) +function do_series(series) { do_series_internal(series, 0); }; -var do_series_internal = function(series, idx) +function do_series_internal(series, idx) { (series[idx][1])(); if (idx + 1 < series.length) { @@ -566,7 +566,7 @@ var do_series_internal = function(series, idx) } }; -var showcarousel = function() +function showcarousel() { var teams_per_group = []; var games_per_group = []; @@ -604,7 +604,7 @@ var showcarousel = function() get_group('Playoffs', cb); }; -var stopcarousel = function() +function stopcarousel() { if (carousel_timeout !== null) { hidetable(); @@ -613,12 +613,12 @@ var stopcarousel = function() } }; -var hidescorebug = function() +function hidescorebug() { document.getElementById('entire-bug').style.display = 'none'; } -var showscorebug = function() +function showscorebug() { document.getElementById('entire-bug').style.display = null; }; -- 2.39.2