From 50e3bd357f2480378f0464d6b3191322bf970f57 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 26 Oct 2017 09:35:25 +0200 Subject: [PATCH] Support having stream times from other weekdays. --- carousel.js | 24 ++++++++++++++++++++---- score.css | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/carousel.js b/carousel.js index b24c575..0d5ec25 100644 --- a/carousel.js +++ b/carousel.js @@ -241,6 +241,7 @@ parse_teams_from_spreadsheet = function(response) { "name": response.values[i][0], "mediumname": response.values[i][1], "shortname": response.values[i][2], + "tags": response.values[i][3], "nplayed": 0, "gd": 0, "pts": 0, @@ -262,7 +263,7 @@ parse_games_from_spreadsheet = function(response, group_name, include_unplayed) for ( ; response.values[i] !== undefined && response.values[i].length >= 1; ++i) { if ((response.values[i][2] && response.values[i][3]) || include_unplayed) { - var real_group_name = response.values[i][8]; + var real_group_name = response.values[i][9]; if (real_group_name === undefined) { real_group_name = group_name; } @@ -271,7 +272,8 @@ parse_games_from_spreadsheet = function(response, group_name, include_unplayed) "name2": response.values[i][1], "score1": parseInt(response.values[i][2]), "score2": parseInt(response.values[i][3]), - "streamtime": response.values[i][7], + "streamday": response.values[i][7], + "streamtime": response.values[i][8], "group_name": real_group_name }); } @@ -411,6 +413,10 @@ var display_stream_schedule_parsed = function(teams, games) { var teams_to_idx = make_teams_to_idx(teams); 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) { + return a.streamday - b.streamday; + } + var m1 = a.streamtime.match(/([0-9]+):([0-9]+)/); var m2 = b.streamtime.match(/([0-9]+):([0-9]+)/); return (m1[1] * 60 + m1[2]) - (m2[1] * 60 + m2[2]); @@ -431,10 +437,15 @@ var display_stream_schedule_parsed = function(teams, games) { if (games.length >= max_list_len) { start_idx = Math.min(start_idx, games.length - max_list_len); } + + var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]; + var shortdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; + var today = days[(new Date).getDay()]; + var short_today = shortdays[(new Date).getDay()]; var carousel = document.getElementById('carousel'); clear_carousel(carousel); - addheading(carousel, 3, "Stream schedule, Trøndisk 2017
Saturday"); + addheading(carousel, 3, "Stream schedule, Trøndisk 2017
" + today); var row_num = 0; for (i = start_idx; i < games.length && row_num < max_list_len; ++i) { @@ -450,7 +461,12 @@ var display_stream_schedule_parsed = function(teams, games) { games[i].score1 !== games[i].score2) { addtd(tr, "streamtime", games[i].score1 + "–" + games[i].score2); } else { - addth(tr, "streamtime", games[i].streamtime); + var streamtime = games[i].streamtime; + var streamday = days[games[i].streamday]; + if (streamday !== today) { + streamtime = shortdays[games[i].streamday] + " " + streamtime; + } + addth(tr, "streamtime", streamtime); } row_num++; diff --git a/score.css b/score.css index 8beb27b..ecd3e9d 100644 --- a/score.css +++ b/score.css @@ -318,6 +318,7 @@ body { } #carousel .streamtime { text-align: center; + text-transform: none; } .nplayed, .gd, .pts { -- 2.39.2