added rain day for today

This commit is contained in:
didier amyot committed 2016-06-16 17:58:04 -04:00
1 parent 7a447278be
commit 813a4968b0
2 files changed
+22 -7

No files matched your search

+2
View File
@@ -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
+20 -7
View File
@@ -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)