From 9bf4830f7a4e135671e2d562d9c217b4579f67e7 Mon Sep 17 00:00:00 2001 From: didier amyot Date: Tue, 8 Aug 2017 22:22:51 -0400 Subject: [PATCH] added basic playoff integration --- data/resultats.yaml | 35 +++++++++++++++++------ script/main.js | 1 + script/views/calendarPage.js | 55 +++++++++++++++++++++++++++++++----- script/views/topNavBar.js | 9 ++++-- 4 files changed, 82 insertions(+), 18 deletions(-) diff --git a/data/resultats.yaml b/data/resultats.yaml index 93bb6a6..9b7e17d 100644 --- a/data/resultats.yaml +++ b/data/resultats.yaml @@ -372,29 +372,48 @@ rain: false # 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 + 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" - home: gris # t1 - away: orange # t3 + home: ganant 6ime vs 3ime # t1 + away: 1ere place # t3 home_points: ~ away_points: ~ rain: false - - date: 2017/8/24 # year/month/day + date: 2017/8/31 # year/month/day time: "20:00" - home: vert # t2 - away: bleu # t5 + home: ganant 5ime vs 4ime # t2 + away: 2ime place # t5 home_points: ~ away_points: ~ rain: false - - date: 2017/8/24 # year/month/day + date: 2017/8/31 # year/month/day time: "21:30" - home: jaune # t6 - away: rouge # t4 + home: (gagant 2ime place (ganant 5ime vs 4ime)) # t2 + away: (gagant 1ere place (ganant 6ime vs 3ime)) # t5 home_points: ~ away_points: ~ rain: false diff --git a/script/main.js b/script/main.js index 3f6f432..5222714 100644 --- a/script/main.js +++ b/script/main.js @@ -14,6 +14,7 @@ requirejs(['m', 'views/mainPage', 'views/historicPage', 'views/newsPage', 'views "/nouvelles": newsPage, "/inscription-form": inscriptionForm, "/calendrier": calendarPage, + "/calendrier/playoff": calendarPage, "/reglement": rulesPage, "/photos": photosPage, "/membre": confidentialPage, diff --git a/script/views/calendarPage.js b/script/views/calendarPage.js index f329cce..2852aca 100644 --- a/script/views/calendarPage.js +++ b/script/views/calendarPage.js @@ -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)]; }; diff --git a/script/views/topNavBar.js b/script/views/topNavBar.js index 90f22bc..295eeac 100644 --- a/script/views/topNavBar.js +++ b/script/views/topNavBar.js @@ -5,7 +5,7 @@ define(['m', '_', 'util'], function (m, _, util) { topNavBar._urlMapping = [ {name: 'Accueil', path: '', fa: 'fa-home'}, {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: 'Membre', path: 'membre', fa: 'fa-lock'}, // {name: 'Historique', path: 'historique', fa: 'fa-history'}, @@ -22,7 +22,10 @@ define(['m', '_', 'util'], function (m, _, util) { 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; }; topNavBar._getItemIcon = function(item){ @@ -30,7 +33,7 @@ define(['m', '_', 'util'], function (m, _, util) { }; 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); return m("li", {class: class_}, m("a", {href: url},