diff --git a/data/resultats.yaml b/data/resultats.yaml index a68d891..4019978 100644 --- a/data/resultats.yaml +++ b/data/resultats.yaml @@ -92,6 +92,7 @@ home: rouge home_points: ~ away_points: ~ + rain: true - date: 2016/6/16 # year/month/day @@ -100,6 +101,7 @@ home: gris home_points: ~ away_points: ~ + rain: true - date: 2016/6/23 # year/month/day diff --git a/script/views/mainPage.js b/script/views/mainPage.js index e129d5a..dbdbb25 100644 --- a/script/views/mainPage.js +++ b/script/views/mainPage.js @@ -1,4 +1,4 @@ -define(['m', '_', 'util', 'resultParser', 'views/topNavBar', 'views/footer', 'articles/articles'], function (m, _ , util, resultParser, topNavBar, footer, articles) { +define(['m', '_', 'util', 'resultParser', 'views/topNavBar', 'views/footer', 'articles/articles', 'images/rain.svg'], function (m, _ , util, resultParser, topNavBar, footer, articles, rainSvg) { var mainPageLogo = {}; mainPageLogo.view = function(){ @@ -24,19 +24,25 @@ define(['m', '_', 'util', 'resultParser', 'views/topNavBar', 'views/footer', 'ar var nextGameDaySchedule = {}; + nextGameDaySchedule._toDay = function(){ + var now = new Date(); + return new Date(now.getFullYear(), now.getMonth(), now.getDate()); + }; + nextGameDaySchedule.controller = function(){ var games = m.prop([]); + var toDay = new Date(); return m.request({method: "GET", url: util.resultatsURL()}) .then(games) .then(resultParser.getNightGames) .then(function(nightGames){ - return nextGameDaySchedule._getNextNightGame(nightGames, _.now()).games; + return nextGameDaySchedule._getNextNightGame(nightGames, nextGameDaySchedule._toDay()).games; }); }; nextGameDaySchedule._getNextNightGame = function(games, date){ return _.first(_.filter(games, function(game){ - return game.jsDate.getTime() > date; + return game.jsDate.getTime() >= date.getTime(); })); }; @@ -49,15 +55,22 @@ define(['m', '_', 'util', 'resultParser', 'views/topNavBar', 'views/footer', 'ar ])); }; - nextGameDaySchedule._responsoveText = function(largeText, smallText){ - return [m('span.uk-visible-large', largeText), - m('span.uk-hidden-large', smallText)]; + nextGameDaySchedule._responsoveText = function(largeText, smallText, rain){ + var ret = []; + if(rain){ + ret.push(rainSvg('1.5em')); + ret.push(' '); + } + ret.push(m('span.uk-visible-large', largeText)); + ret.push(m('span.uk-hidden-large', smallText)); + return ret; }; nextGameDaySchedule._getGamesRow = function(game){ return m('tr', [ m('td', nextGameDaySchedule._responsoveText(util.formatDate(game.jsDate), - util.formatDateSmall(game.jsDate))), + util.formatDateSmall(game.jsDate), + game.rain)), m('td', game.time), m('td', game.away), m('td', game.home)