added basic playoff integration
This commit is contained in:
1 parent
7be88a2167
commit
9bf4830f7a
4 files changed
+82
-18
No files matched your search
@@ -25,6 +25,12 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
|
||||
]);
|
||||
};
|
||||
|
||||
statsView.isStatForValidTeam = function(stat){
|
||||
var teamNames = _.map(teams.teams(), 'name');
|
||||
return _.includes(teamNames, stat.team);
|
||||
}
|
||||
|
||||
|
||||
statsView.mainTable = function(stats){
|
||||
var orderedStats = _.reverse(_.sortBy(stats, ['victories', 'pointsFor']));
|
||||
return m('table.uk-table.uk-table-hover.uk-table-striped',[
|
||||
@@ -39,7 +45,10 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
|
||||
m('th', 'DIF'),
|
||||
m('th', 'PTS')
|
||||
])),
|
||||
m('tbody', _.map(orderedStats, statsView.getStatRow))
|
||||
m('tbody', _(orderedStats)
|
||||
.filter(statsView.isStatForValidTeam)
|
||||
.map(statsView.getStatRow)
|
||||
.value())
|
||||
]);
|
||||
};
|
||||
|
||||
@@ -66,14 +75,42 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
|
||||
|
||||
var tabView = {};
|
||||
|
||||
tabView.view = function(){
|
||||
tabView.view = function(vnode, isPlayoff){
|
||||
return m('div.uk-margin', m('h2', 'Calendrier 2017'),
|
||||
m('ul.uk-tab', [
|
||||
m('li.uk-active', m('a', 'Saison')),
|
||||
m('li', m('a', 'Éliminatoire'))
|
||||
m('li', {'class': isPlayoff || 'uk-active'},
|
||||
m('a', {href: '#/calendrier'}, 'Saison')),
|
||||
m('li', {'class': isPlayoff && 'uk-active'},
|
||||
m('a', {href: '#/calendrier/playoff'}, 'Éliminatoire'))
|
||||
]));
|
||||
};
|
||||
|
||||
var playoffView = {};
|
||||
|
||||
playoffView.line = function(x1, y1, x2, y2){
|
||||
return m('line', {'x1': x1,
|
||||
'y1': y1,
|
||||
'x2': x2,
|
||||
'y2': y2,
|
||||
style: 'stroke:rgb(255,0,0);stroke-width:2'})
|
||||
}
|
||||
|
||||
playoffView.horizontalLine = function(x1, x2, y){
|
||||
return playoffView.line(x1, y, x2, y);
|
||||
};
|
||||
|
||||
playoffView.view = function(){
|
||||
var width = 600;
|
||||
var height = 600;
|
||||
var padding = 40;
|
||||
return m('div',
|
||||
m('svg', {width: width, height: height},
|
||||
playoffView.horizontalLine(padding, width/2 - padding, height/3),
|
||||
playoffView.horizontalLine(padding, width/2 - padding, 2 * height/3),
|
||||
|
||||
));
|
||||
}
|
||||
|
||||
var schedulView = {};
|
||||
|
||||
schedulView.controller = function(){
|
||||
@@ -133,13 +170,17 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
|
||||
|
||||
calendarPage = {};
|
||||
|
||||
calendarPage.view = function(){
|
||||
calendarPage.view = function(vnode){
|
||||
var toto = vnode;
|
||||
var isPlayoff = window.location.hash.endsWith('playoff');
|
||||
var main = isPlayoff ? m.component(playoffView) : m.component(schedulView);
|
||||
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),
|
||||
m.component(schedulView)])),
|
||||
m.component(tabView, isPlayoff),
|
||||
main
|
||||
])),
|
||||
m.component(footer)];
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user