more love

This commit is contained in:
didier amyot committed 2021-06-15 17:25:43 -04:00
1 parent 548d4c1def
commit 7d21d5316b
7 files changed
+188 -168

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
define(['m', '_', 'util', 'resultParser', 'views/scheduleTeamTags', 'images/rain.svg'], function (m, _ , util, resultParser, scheduleTeamTags, rainSvg) {
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([]);
return util.getDefaultResults()
.then(games)
.then(resultParser.getNightGames)
.then(function(nightGames){
return nextGameDaySchedule._getNextNightGame(nightGames, nextGameDaySchedule._toDay()).games;
});
};
nextGameDaySchedule._getNextNightGame = function(games, date){
return _.first(_.filter(games, function(game){
return game.jsDate.getTime() >= date.getTime();
}));
};
nextGameDaySchedule._getTableHead = function(){
return m('thead', m('tr', [
m('td', 'Date'),
m('td', 'Heure'),
m('td', 'Receveur'),
m('td', 'Visiteur')
]));
};
nextGameDaySchedule._responsoveText = function(largeText, smallText, game){
var ret = [];
if(game.rain){
ret.push(rainSvg('1.5em'));
ret.push(' ');
} else if(game.practice){
ret.push(m('span.uk-badge.uk-badge-success', 'pratique!'));
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),
game)),
m('td', game.time),
m('td', scheduleTeamTags.getHomeTeamTag(game)),
m('td',scheduleTeamTags.getAwayTeamTag(game))
]);
};
nextGameDaySchedule._getGamesRows = function(games){
return _.map(games(), nextGameDaySchedule._getGamesRow);
};
nextGameDaySchedule.view = function(games){
return m('table.uk-table.uk-table-hover.uk-table-striped.uk-table-condensed',[
nextGameDaySchedule._getTableHead(),
m('tbody',
nextGameDaySchedule._getGamesRows(games)
)]);
};
return nextGameDaySchedule;
});