more love
This commit is contained in:
1 parent
548d4c1def
commit
7d21d5316b
7 files changed
+188
-168
No files matched your search
@@ -1,4 +1,4 @@
|
||||
define(['m', '_', 'util', 'resultParser', 'views/topNavBar', 'views/footer', 'articles/articles', 'images/rain.svg'], function (m, _ , util, resultParser, topNavBar, footer, articles, rainSvg) {
|
||||
define(['m', '_', 'views/nextGameDaySchedule', 'views/topNavBar', 'views/footer', 'articles/articles'], function (m, _ , nextGameDaySchedule, topNavBar, footer, articles) {
|
||||
var mainPageLogo = {};
|
||||
|
||||
mainPageLogo.view = function(){
|
||||
@@ -25,75 +25,11 @@ 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([]);
|
||||
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, 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),
|
||||
game.rain)),
|
||||
m('td', game.time),
|
||||
m('td', game.home),
|
||||
m('td', game.away)
|
||||
]);
|
||||
};
|
||||
|
||||
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)
|
||||
)]);
|
||||
};
|
||||
|
||||
|
||||
var scheduleNotYetSet = {};
|
||||
|
||||
scheduleNotYetSet. view = function(){
|
||||
scheduleNotYetSet.view = function(){
|
||||
return m('div',
|
||||
m('h4', 'À venir...'),
|
||||
m('p', "Suite a la situation au parc Walter-Stewart, " +
|
||||
|
||||
Reference in new issue
Block a user