added basic playoff integration

This commit is contained in:
didier amyot committed 2017-08-08 22:22:51 -04:00
1 parent 7be88a2167
commit 9bf4830f7a
4 files changed
+82 -18

No files matched your search

+27 -8
View File
@@ -372,29 +372,48 @@
rain: false rain: false
# WEEK 14 # WEEK 14
-
date: 2017/8/24 # year/month/day e 6vs5 et 4vs3,
time: "19:00"
home: 6ime place # t1
away: 3ime place # t3
home_points: ~
away_points: ~
rain: false
- -
date: 2017/8/24 # year/month/day date: 2017/8/24 # year/month/day
time: "20:30"
home: 5ime place # t2
away: 4ime place # t5
home_points: ~
away_points: ~
rain: false
# WEEK 15
-
date: 2017/8/31 # year/month/day e 6vs5 et 4vs3,
time: "18:30" time: "18:30"
home: gris # t1 home: ganant 6ime vs 3ime # t1
away: orange # t3 away: 1ere place # t3
home_points: ~ home_points: ~
away_points: ~ away_points: ~
rain: false rain: false
- -
date: 2017/8/24 # year/month/day date: 2017/8/31 # year/month/day
time: "20:00" time: "20:00"
home: vert # t2 home: ganant 5ime vs 4ime # t2
away: bleu # t5 away: 2ime place # t5
home_points: ~ home_points: ~
away_points: ~ away_points: ~
rain: false rain: false
- -
date: 2017/8/24 # year/month/day date: 2017/8/31 # year/month/day
time: "21:30" time: "21:30"
home: jaune # t6 home: (gagant 2ime place (ganant 5ime vs 4ime)) # t2
away: rouge # t4 away: (gagant 1ere place (ganant 6ime vs 3ime)) # t5
home_points: ~ home_points: ~
away_points: ~ away_points: ~
rain: false rain: false
+1
View File
@@ -14,6 +14,7 @@ requirejs(['m', 'views/mainPage', 'views/historicPage', 'views/newsPage', 'views
"/nouvelles": newsPage, "/nouvelles": newsPage,
"/inscription-form": inscriptionForm, "/inscription-form": inscriptionForm,
"/calendrier": calendarPage, "/calendrier": calendarPage,
"/calendrier/playoff": calendarPage,
"/reglement": rulesPage, "/reglement": rulesPage,
"/photos": photosPage, "/photos": photosPage,
"/membre": confidentialPage, "/membre": confidentialPage,
+48 -7
View File
@@ -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){ statsView.mainTable = function(stats){
var orderedStats = _.reverse(_.sortBy(stats, ['victories', 'pointsFor'])); var orderedStats = _.reverse(_.sortBy(stats, ['victories', 'pointsFor']));
return m('table.uk-table.uk-table-hover.uk-table-striped',[ 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', 'DIF'),
m('th', 'PTS') 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 = {}; var tabView = {};
tabView.view = function(){ tabView.view = function(vnode, isPlayoff){
return m('div.uk-margin', m('h2', 'Calendrier 2017'), return m('div.uk-margin', m('h2', 'Calendrier 2017'),
m('ul.uk-tab', [ m('ul.uk-tab', [
m('li.uk-active', m('a', 'Saison')), m('li', {'class': isPlayoff || 'uk-active'},
m('li', m('a', 'Éliminatoire')) 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 = {}; var schedulView = {};
schedulView.controller = function(){ schedulView.controller = function(){
@@ -133,13 +170,17 @@ define(['m', '_', 'util', 'resultParser', 'teams', 'views/topNavBar', 'views/foo
calendarPage = {}; 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), return [m.component(topNavBar),
m('div.uk-grid.uk-margin-top.uk-margin-bottom', 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('div.uk-width-large-3-5.uk-width-medium-4-5.uk-width-small-1-1.uk-container-center',[
m.component(statsView), m.component(statsView),
m.component(tabView), m.component(tabView, isPlayoff),
m.component(schedulView)])), main
])),
m.component(footer)]; m.component(footer)];
}; };
+6 -3
View File
@@ -5,7 +5,7 @@ define(['m', '_', 'util'], function (m, _, util) {
topNavBar._urlMapping = [ topNavBar._urlMapping = [
{name: 'Accueil', path: '', fa: 'fa-home'}, {name: 'Accueil', path: '', fa: 'fa-home'},
{name: 'Nouvelles', path: 'nouvelles', fa: 'fa-newspaper-o'}, {name: 'Nouvelles', path: 'nouvelles', fa: 'fa-newspaper-o'},
{name: 'Calendrier', path: 'calendrier', fa: 'fa-calendar'}, {name: 'Calendrier', path: 'calendrier', fa: 'fa-calendar', includeSubPath: true},
{name: 'Règlement', path: 'reglement', fa: 'fa-legal'}, {name: 'Règlement', path: 'reglement', fa: 'fa-legal'},
{name: 'Membre', path: 'membre', fa: 'fa-lock'}, {name: 'Membre', path: 'membre', fa: 'fa-lock'},
// {name: 'Historique', path: 'historique', fa: 'fa-history'}, // {name: 'Historique', path: 'historique', fa: 'fa-history'},
@@ -22,7 +22,10 @@ define(['m', '_', 'util'], function (m, _, util) {
return '#/' + id_; return '#/' + id_;
}; };
topNavBar._isActive = function(id_){ topNavBar._isActive = function(id_, includeSubPath){
if(includeSubPath){
return window.location.hash.startsWith(topNavBar._getUrlForId(id_));
}
return topNavBar._getUrlForId(id_) == window.location.hash; return topNavBar._getUrlForId(id_) == window.location.hash;
}; };
topNavBar._getItemIcon = function(item){ topNavBar._getItemIcon = function(item){
@@ -30,7 +33,7 @@ define(['m', '_', 'util'], function (m, _, util) {
}; };
topNavBar._getLargeItem = function(item){ topNavBar._getLargeItem = function(item){
var class_ = topNavBar._isActive(item.path) ? 'uk-active' : ''; var class_ = topNavBar._isActive(item.path, item.includeSubPath) ? 'uk-active' : '';
var url = topNavBar._getUrlForId(item.path); var url = topNavBar._getUrlForId(item.path);
return m("li", {class: class_}, return m("li", {class: class_},
m("a", {href: url}, m("a", {href: url},