Added previous seasons to the web site
This commit is contained in:
1 parent
da7951b1cb
commit
cee0e920c3
7 files changed
+69
-302
No files matched your search
@@ -1,9 +1,14 @@
|
||||
define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/footer', 'images/rain.svg'], function(m, _, util, resultParser, teams, topNavBar, footer, rainSvg) {
|
||||
function ppYear(year, availableYears) {
|
||||
return _.last(availableYears) == year ? "" : year;
|
||||
}
|
||||
|
||||
var statsView = {};
|
||||
|
||||
statsView.controller = function(){
|
||||
statsView.controller = function(year){
|
||||
var games = m.prop([]);
|
||||
return m.request({method: "GET", url: "api/resultats.json"})
|
||||
var url = "api/resultats" + year + ".json";
|
||||
return m.request({method: "GET", url: url})
|
||||
.then(games)
|
||||
.then(resultParser.getStats);
|
||||
};
|
||||
@@ -63,10 +68,10 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
|
||||
]);
|
||||
};
|
||||
|
||||
statsView.view = function(stats){
|
||||
statsView.view = function(stats, year){
|
||||
return m('div.uk-grid',
|
||||
m('div.uk-width-medium-1-1.uk-width-large-1-1.uk-container-center',[
|
||||
m('h2', 'Classement 2018'),
|
||||
m('h2', 'Classement ' + year),
|
||||
statsView.mainTable(stats()),
|
||||
statsView.legend()
|
||||
]));
|
||||
@@ -75,12 +80,16 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
|
||||
|
||||
var tabView = {};
|
||||
|
||||
tabView.view = function(vnode, isPlayoff){
|
||||
return m('div.uk-margin', m('h2', 'Calendrier 2018'),
|
||||
m('ul.uk-tab', [
|
||||
m('li', {'class': isPlayoff || 'uk-active'},
|
||||
m('a', {href: '#/calendrier'}, 'Saison')),
|
||||
]));
|
||||
tabView._createTab = function(activeYear, availableYears, year){
|
||||
var isActive = (activeYear == year) || (activeYear == ppYear(year, availableYears));
|
||||
return m('li', {'class': isActive ? 'uk-active': ''}, // 'uk-active'
|
||||
m('a', {href: '#/calendrier/' + ppYear(year, availableYears)}, 'Saison ' + year));
|
||||
}
|
||||
|
||||
tabView.view = function(vnode, isPlayoff, activeYear, availableYears){
|
||||
var createTab = _.partial(tabView._createTab, activeYear, availableYears);
|
||||
return m('div.uk-margin', m('h2', 'Calendrier ' + ppYear(activeYear, availableYears)),
|
||||
m('ul.uk-tab', _.reverse(_.map(availableYears, createTab))));
|
||||
};
|
||||
|
||||
var playoffView = {};
|
||||
@@ -110,9 +119,10 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
|
||||
|
||||
var schedulView = {};
|
||||
|
||||
schedulView.controller = function(){
|
||||
schedulView.controller = function(year){
|
||||
var games = m.prop([]);
|
||||
return m.request({method: "GET", url: "api/resultats.json"})
|
||||
var url = "api/resultats" + year + ".json"
|
||||
return m.request({method: "GET", url: url})
|
||||
.then(games)
|
||||
.then(resultParser.getNightGames);
|
||||
};
|
||||
@@ -168,14 +178,15 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
|
||||
calendarPage = {};
|
||||
|
||||
calendarPage.view = function(vnode){
|
||||
var toto = vnode;
|
||||
var isPlayoff = window.location.hash.endsWith('playoff');
|
||||
var main = isPlayoff ? m.component(playoffView) : m.component(schedulView);
|
||||
var year = _.get(m.route.param(), 'year', '');
|
||||
var availableYears = window.availableYears || [];
|
||||
var main = isPlayoff ? m.component(playoffView) : m.component(schedulView, year, availableYears);
|
||||
return [m.component(topNavBar),
|
||||
m('div.uk-grid.uk-margin-top.uk-margin-bottom',
|
||||
m('div.uk-width-large-3-5.uk-width-medium-4-5.uk-width-small-1-1.uk-container-center',[
|
||||
m.component(statsView),
|
||||
m.component(tabView, isPlayoff),
|
||||
m.component(statsView, year, availableYears),
|
||||
m.component(tabView, isPlayoff, year, availableYears),
|
||||
main
|
||||
])),
|
||||
m.component(footer)];
|
||||
|
||||
Reference in new issue
Block a user