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
+186 -166

No files matched your search

+5
View File
@@ -118,7 +118,12 @@ define(['_'], function(_) {
});
};
resultParser._isValidGame = function(game){
return !game.rain && ! game.practice;
};
resultParser.getStats = function(rawResults){
rawResults = _.filter(rawResults, resultParser._isValidGame);
rawResults = _.map(rawResults, resultParser._setCanonicalPoints);
var allTeams = resultParser._getAllTeams(resultParser._removeTemporaryResults(rawResults));
var getTeamStats = _.partial(resultParser._getTeamStats, rawResults);
+1 -100
View File
@@ -1,4 +1,4 @@
define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/footer', 'images/rain.svg'], function(m, _, util, resultParser, teams, topNavBar, footer, rainSvg) {
define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/footer', 'views/schedulView'], function(m, _, util, resultParser, teams, topNavBar, footer, schedulView) {
function ppYear(year, availableYears) {
return _.last(availableYears) == year ? "" : year;
}
@@ -116,105 +116,6 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
));
};
var schedulView = {};
schedulView.controller = function(year){
var games = m.prop([]);
return util.getResults(year)
.then(games)
.then(resultParser.getNightGames);
};
schedulView._getTeamTag = function(teamName){
var teamColor = teams.getTeamColor(teamName);
return [
m('i.fa.fa-flag', {style: {color: teamColor}}),
m('span', ' ' + teamName)
];
};
schedulView._getAwayPracticeTeamTag = function(){
return [
m('i.fa.fa-hand-spock-o', {style: {color: ' #ff1493'}}),
m('span', ' Amis #1')
];
};
schedulView._getHomePracticeTeamTag = function(){
return [
m('i.fa.fa-hand-spock-o', {style: {color: '#acbf60'}}),
m('span', ' Amis #2')
];
};
schedulView._getAwayTeamTag = function(game){
if(game.practice){
return schedulView._getAwayPracticeTeamTag();
}
return schedulView._getTeamTag(game.away);
};
schedulView._getHomeTeamTag = function(game){
if(game.practice){
return schedulView._getHomePracticeTeamTag();
}
return schedulView._getTeamTag(game.home);
};
schedulView._asGamePoints = function(points){
return !_.isNumber(points) ? '-' : points + '';
};
schedulView._practiceIcon = function(game){
if(game.practice){
return m('i.fa.fa-handshake-o');
}
return m('span', ' ');
};
schedulView._rainIcon = function(game){
if(game.rain){
return m('span', {title: 'pluie, partie annulée.'}, rainSvg('1.5em'));
}
return m('span', {style: {visibility: 'hidden'}}, rainSvg('1.5em'));
};
schedulView._gameName = function(game){
return [schedulView._rainIcon(game),
" ",
game.time];
};
schedulView._gameRow = function(game){
return m('tr',[
m('td', schedulView._gameName(game)),
m('td', schedulView._getAwayTeamTag(game)),
m('td', schedulView._asGamePoints(game.away_points)),
m('td', 'vs'),
m('td', schedulView._getHomeTeamTag(game)),
m('td', schedulView._asGamePoints(game.home_points))
]);
};
schedulView._gameView = function(gameNight){
return m('div', [m('h3', util.formatDate(gameNight.jsDate)),
m('table.uk-table.uk-table-hover.uk-table-condensed.uk-table-striped',
m('tbody',[
_.map(gameNight.games, schedulView._gameRow),
])
)
]);
};
schedulView.view = function(games){
return m('div.uk-grid',
m('div.uk-width-large-3-5.uk-width-medium-1-1',
_.map(games(), schedulView._gameView)));
};
calendarPage = {};
calendarPage.view = function(vnode){
+1 -65
View File
@@ -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,71 +25,7 @@ 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 = {};
+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;
});
+1 -1
View File
@@ -19,7 +19,7 @@ define(['m', '_', 'util', 'resultParser', 'views/topNavBar', 'views/footer'], fu
rulesPage.ruleSection = function(){
var urlASBM = 'http://www.asbm.ca/';
return [
m('h2', 'Règlements 2019'),
m('h2', 'Règlements 2021'),
m('ul',[
m('li', m('h3', m('a', {href: 'files/reglements_de_terrain2019.pdf'},'Règles de jeu'))),
m('li', m('h3', m('a', {href: 'files/regles_procedures2019.pdf'},'Règles et procédures'))),
+60
View File
@@ -0,0 +1,60 @@
define(['m', '_', 'util', 'resultParser', 'teams', 'views/scheduleTeamTags', 'images/rain.svg'], function(m, _, util, resultParser, teams, scheduleTeamTags, rainSvg) {
var schedulView = {};
schedulView.controller = function(year){
var games = m.prop([]);
return util.getResults(year)
.then(games)
.then(resultParser.getNightGames);
};
schedulView._asGamePoints = function(points){
return !_.isNumber(points) ? '-' : points + '';
};
schedulView._rainIcon = function(game){
if(game.rain){
return m('span', {title: 'pluie, partie annulée.'}, rainSvg('1.5em'));
}
return m('span', {style: {visibility: 'hidden'}}, rainSvg('1.5em'));
};
schedulView._gameName = function(game){
return [schedulView._rainIcon(game),
" ",
game.time];
};
schedulView._gameRow = function(game){
return m('tr',[
m('td', schedulView._gameName(game)),
m('td', scheduleTeamTags.getAwayTeamTag(game)),
m('td', schedulView._asGamePoints(game.away_points)),
m('td', 'vs'),
m('td', scheduleTeamTags.getHomeTeamTag(game)),
m('td', schedulView._asGamePoints(game.home_points))
]);
};
schedulView._gameView = function(gameNight){
return m('div', [m('h3', util.formatDate(gameNight.jsDate)),
m('table.uk-table.uk-table-hover.uk-table-condensed.uk-table-striped',
m('tbody',[
_.map(gameNight.games, schedulView._gameRow),
])
)
]);
};
schedulView.view = function(games){
return m('div.uk-grid',
m('div.uk-width-large-3-5.uk-width-medium-1-1',
_.map(games(), schedulView._gameView)));
};
return schedulView;
})
+45
View File
@@ -0,0 +1,45 @@
define(['m', '_', 'teams'], function(m, _, teams) {
var scheduleTeamTags = {};
scheduleTeamTags._getTeamTag = function(teamName){
var teamColor = teams.getTeamColor(teamName);
return [
m('i.fa.fa-flag', {style: {color: teamColor}}),
m('span', ' ' + teamName)
];
};
scheduleTeamTags._getAwayPracticeTeamTag = function(){
return [
m('i.fa.fa-hand-spock-o', {style: {color: ' #ff1493'}, title: 'pratique'}),
m('span', ' Amis #1')
];
};
scheduleTeamTags._getHomePracticeTeamTag = function(){
return [
m('i.fa.fa-hand-spock-o', {style: {color: '#acbf60'}, title: 'pratique'}),
m('span', ' Amis #2')
];
};
scheduleTeamTags.getAwayTeamTag = function(game){
if(game.practice){
return scheduleTeamTags._getAwayPracticeTeamTag();
}
return scheduleTeamTags._getTeamTag(game.away);
};
scheduleTeamTags.getHomeTeamTag = function(game){
if(game.practice){
return scheduleTeamTags._getHomePracticeTeamTag();
}
return scheduleTeamTags._getTeamTag(game.home);
};
return scheduleTeamTags;
})