Added new website
This commit is contained in:
1 parent
293b7727e2
commit
df26a3fe96
34 files changed
+10488
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import * as util from "./util.js";
|
||||
import m from "https://esm.sh/mithril@2.2.2"
|
||||
import _ from "https://esm.sh/lodash-es@4.17.21"
|
||||
import {statsView, tabView, schedulView } from './schedule.js'
|
||||
|
||||
const calendarPage = {
|
||||
view: function(){
|
||||
const availableYears = util.getAvailableYears();
|
||||
const year = _.get(m.route.param(), 'year', util.getDefaultYear());
|
||||
|
||||
return 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(statsView, {year}),
|
||||
m(tabView, {year, availableYears}),
|
||||
m(schedulView, {year}),
|
||||
]),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
m.route.mode = "hash";
|
||||
m.route(document.getElementById('mithril-content'), "/", {
|
||||
"/": calendarPage,
|
||||
"/:year": calendarPage,
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import m from "https://esm.sh/mithril@2.2.2"
|
||||
|
||||
export function rainSvg (size){
|
||||
return m("svg[viewBox='0 0 107.95 87.723']",{width: size, height: size}, [
|
||||
m("defs[id='defs16']"),
|
||||
m("g[id='layer1'][transform='translate(-310.1 -167.39)']", [
|
||||
m("g[id='g13542'][transform='translate(-2.4761 19.309)']", [
|
||||
m("path[d='m378.31 207.24c15.43-1.4 26.66-5.66 26.66-10.69 0-0.41-0.27-0.8-0.42-1.2 0.91 0.23 1.83 0.46 2.83 0.46 5.57 0 10.07-3.78 10.07-8.44 0-4.65-4.5-8.41-10.07-8.41-0.68 0-1.29 0.22-1.93 0.33 0.56-1.86 0.95-3.77 0.95-5.79 0-12.33-11.17-22.34-24.95-22.34-9.77 0-18.13 5.09-22.23 12.4-1.64-0.92-3.47-1.48-5.4-1.48-5.83 0-10.68 4.69-12.18 11.06-2.56-1.01-5.52-1.64-8.7-1.64-9.54 0-17.29 5.23-17.29 11.67 0 5.81 6.35 10.59 14.6 11.47-0.37 0.63-0.66 1.25-0.66 1.91 0 4.25 8.01 7.94 19.79 9.83'][id='path8749']", {style: {"stroke-linejoin": "round", "stroke": "#6798e9", "stroke-linecap": "round", "stroke-miterlimit": ".5", "stroke-width": "12.154", "fill": "none"}}),
|
||||
m("path[d='m338.14 223.91c-8.25 7.27 1.43 13.47 5.12 3.49l2.83-9.26-7.95 5.77z'][id='path8734']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}}),
|
||||
m("path[d='m367.18 225.11c-8.25 7.27 1.44 13.47 5.13 3.49l2.83-9.26-7.96 5.77z'][id='path8736']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}}),
|
||||
m("path[d='m360.42 209.77c-8.25 7.27 1.44 13.47 5.12 3.49l2.83-9.26-7.95 5.77z'][id='path8738']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}}),
|
||||
m("path[d='m378.31 207.24c15.43-1.4 26.66-5.66 26.66-10.69 0-0.41-0.27-0.8-0.42-1.2 0.91 0.23 1.83 0.46 2.83 0.46 5.57 0 10.07-3.78 10.07-8.44 0-4.65-4.5-8.41-10.07-8.41-0.68 0-1.29 0.22-1.93 0.33 0.56-1.86 0.95-3.77 0.95-5.79 0-12.33-11.17-22.34-24.95-22.34-9.77 0-18.13 5.09-22.23 12.4-1.64-0.92-3.47-1.48-5.4-1.48-5.83 0-10.68 4.69-12.18 11.06-2.56-1.01-5.52-1.64-8.7-1.64-9.54 0-17.29 5.23-17.29 11.67 0 5.81 6.35 10.59 14.6 11.47-0.37 0.63-0.66 1.25-0.66 1.91 0 4.25 8.01 7.94 19.79 9.83'][id='path10281']", {style: {"stroke-linejoin": "round", "stroke": "#6798e9", "stroke-linecap": "round", "stroke-miterlimit": ".5", "stroke-width": "12.154", "fill": "none"}}),
|
||||
m("path[d='m338.14 223.91c-8.25 7.27 1.43 13.47 5.12 3.49l2.83-9.26-7.95 5.77z'][id='path10283']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}}),
|
||||
m("path[d='m367.18 225.11c-8.25 7.27 1.44 13.47 5.13 3.49l2.83-9.26-7.96 5.77z'][id='path10285']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}}),
|
||||
m("path[d='m360.42 209.77c-8.25 7.27 1.44 13.47 5.12 3.49l2.83-9.26-7.95 5.77z'][id='path10287']", {style: {"stroke": "#6798e9", "stroke-miterlimit": "3.2", "stroke-width": "8", "fill": "#6798e9"}})
|
||||
])
|
||||
])
|
||||
]);
|
||||
}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/*! jQuery v3.7.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */
|
||||
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(ie,e){"use strict";var oe=[],r=Object.getPrototypeOf,ae=oe.slice,g=oe.flat?function(e){return oe.flat.call(e)}:function(e){return oe.concat.apply([],e)},s=oe.push,se=oe.indexOf,n={},i=n.toString,ue=n.hasOwnProperty,o=ue.toString,a=o.call(Object),le={},v=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},y=function(e){return null!=e&&e===e.window},C=ie.document,u={type:!0,src:!0,nonce:!0,noModule:!0};function m(e,t,n){var r,i,o=(n=n||C).createElement("script");if(o.text=e,t)for(r in u)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e}var t="3.7.1",l=/HTML$/i,ce=function(e,t){return new ce.fn.init(e,t)};function c(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!v(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}function fe(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}ce.fn=ce.prototype={jquery:t,constructor:ce,length:0,toArray:function(){return ae.call(this)},get:function(e){return null==e?ae.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=ce.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return ce.each(this,e)},map:function(n){return this.pushStack(ce.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(ae.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(ce.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(ce.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:oe.sort,splice:oe.splice},ce.extend=ce.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||v(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(ce.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||ce.isPlainObject(n)?n:{},i=!1,a[t]=ce.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},ce.extend({expando:"jQuery"+(t+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==i.call(e))&&(!(t=r(e))||"function"==typeof(n=ue.call(t,"constructor")&&t.constructor)&&o.call(n)===a)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){m(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(c(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},text:function(e){var t,n="",r=0,i=e.nodeType;if(!i)while(t=e[r++])n+=ce.text(t);return 1===i||11===i?e.textContent:9===i?e.documentElement.textContent:3===i||4===i?e.nodeValue:n},makeArray:function(e,t){var n=t||[];return null!=e&&(c(Object(e))?ce.merge(n,"string"==typeof e?[e]:e):s.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:se.call(t,e,n)},isXMLDoc:function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!l.test(t||n&&n.nodeName||"HTML")},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(c(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:le}),"function"==typeof Symbol&&(ce.fn[Symbol.iterator]=oe[Symbol.iterator]),ce.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var pe=oe.pop,de=oe.sort,he=oe.splice,ge="[\\x20\\t\\r\\n\\f]",ve=new RegExp("^"+ge+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ge+"+$","g");ce.contains=function(e,t){var n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(e.contains?e.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))};var f=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function p(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e}ce.escapeSelector=function(e){return(e+"").replace(f,p)};var ye=C,me=s;!function(){var e,b,w,o,a,T,r,C,d,i,k=me,S=ce.expando,E=0,n=0,s=W(),c=W(),u=W(),h=W(),l=function(e,t){return e===t&&(a=!0),0},f="checked|selected|async|autofocus|autoplay|conLine truncated
|
||||
@@ -0,0 +1,99 @@
|
||||
// alert("ok")
|
||||
import * as util from "./util.js";
|
||||
import * as resultParser from './resultParser.js'
|
||||
import * as teams from './teams.js'
|
||||
import m from "https://esm.sh/mithril@2.2.2"
|
||||
import {rainSvg} from "./images.js";
|
||||
import _ from "https://esm.sh/lodash-es@4.17.21"
|
||||
|
||||
import {statsView, tabView, scheduleTeamTags } from './schedule.js'
|
||||
|
||||
|
||||
const nextGameDaySchedule = {};
|
||||
|
||||
nextGameDaySchedule._toDay = function(){
|
||||
var now = new Date();
|
||||
return new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
};
|
||||
|
||||
nextGameDaySchedule.oninit = async function(){
|
||||
|
||||
const result = await m.request({
|
||||
method: "GET",
|
||||
url: `/api/results/2024.json`
|
||||
});
|
||||
const nightGames = resultParser.getNightGames(result);
|
||||
nextGameDaySchedule.games = nextGameDaySchedule._getNextNightGame(nightGames, nextGameDaySchedule._toDay());
|
||||
};
|
||||
|
||||
nextGameDaySchedule._getNextNightGame = function(games, date){
|
||||
return _(games)
|
||||
.filter(g => g.jsDate.getTime() >= date.getTime())
|
||||
.last()
|
||||
.games
|
||||
.sort((g1, g2) => g1.jsDate - g2.jsDate);
|
||||
};
|
||||
|
||||
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(){
|
||||
return m('table.uk-table.uk-table-hover.uk-table-striped.uk-table-condensed',[
|
||||
nextGameDaySchedule._getTableHead(),
|
||||
m('tbody',
|
||||
nextGameDaySchedule._getGamesRows(nextGameDaySchedule.games)
|
||||
)]);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const LittleCalendar = {}
|
||||
|
||||
LittleCalendar.view = function(){
|
||||
return m(nextGameDaySchedule);
|
||||
}
|
||||
|
||||
const containerIds = ['large-mithril-container',
|
||||
'medium-mithril-container',
|
||||
'small-mithril-container']
|
||||
|
||||
for(const id of containerIds){
|
||||
m.mount(document.getElementById(id), LittleCalendar);
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
import * as _ from "https://esm.sh/lodash-es@4.17.21"
|
||||
|
||||
|
||||
let resultParser = {};
|
||||
|
||||
resultParser._addJSDateToResult = function(res){
|
||||
let date = res.date.split('-');
|
||||
let time = _.isString(res.time) ? res.time.split(':'): [0, 0];
|
||||
res.jsDate = new Date(
|
||||
Number(date[0]),
|
||||
Number(date[1]) - 1,
|
||||
Number(date[2]),
|
||||
Number(time[0]),
|
||||
Number(time[1])
|
||||
);
|
||||
return res;
|
||||
};
|
||||
|
||||
resultParser._setCanonicalPoints = function(res){
|
||||
if(!_.isNumber(res.home_points) && _.isNumber(_.get(res, res.home))){
|
||||
res.home_points = res[res.home];
|
||||
}
|
||||
if(!_.isNumber(res.away_points) && _.isNumber(_.get(res, res.away))){
|
||||
res.away_points = res[res.away];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
resultParser.parseResults = function(rawResults){
|
||||
rawResults = _.map(rawResults, resultParser._setCanonicalPoints);
|
||||
rawResults = _.map(rawResults, resultParser._addJSDateToResult);
|
||||
rawResults = _.map(rawResults, resultParser._addCustomStyle);
|
||||
return rawResults;
|
||||
};
|
||||
|
||||
resultParser.getNightGames = function(rawResults){
|
||||
let ret = {};
|
||||
_.each(resultParser.parseResults(rawResults), function(res){
|
||||
if(_.has(ret, res.date)){
|
||||
ret[res.date].push(res);
|
||||
}else{
|
||||
ret[res.date] = [res];
|
||||
}
|
||||
});
|
||||
return _.map(ret, function(games, date){
|
||||
return resultParser._addJSDateToResult({date: date, games: games});
|
||||
});
|
||||
};
|
||||
|
||||
resultParser._getAllTeams = function(rawResults){
|
||||
let homeTeams = _.map(rawResults, 'home');
|
||||
let awayTeams = _.map(rawResults, 'away');
|
||||
return _.uniq(_.concat(homeTeams, awayTeams));
|
||||
};
|
||||
|
||||
resultParser._getWinner = function(res){
|
||||
if(res.home_points > res.away_points){
|
||||
return res.home;
|
||||
}
|
||||
if(res.home_points < res.away_points){
|
||||
return res.away;
|
||||
}
|
||||
};
|
||||
|
||||
resultParser._hasWon = function(res, team){
|
||||
return resultParser._getWinner(res) == team;
|
||||
};
|
||||
|
||||
resultParser._hasLost = function(res, team){
|
||||
return !resultParser._isDraw(res) && resultParser._getWinner(res) != team;
|
||||
};
|
||||
|
||||
resultParser._isDraw = function(res){
|
||||
return res.home_points == res.away_points;
|
||||
};
|
||||
|
||||
resultParser._getPointsFor = function(res, team){
|
||||
if(res.home == team){
|
||||
return res.home_points;
|
||||
}
|
||||
return res.away_points;
|
||||
};
|
||||
|
||||
resultParser._getPointsForOpponent = function(res, team){
|
||||
if(res.home == team){
|
||||
return res.away_points;
|
||||
}
|
||||
return res.home_points;
|
||||
};
|
||||
|
||||
resultParser._getPointsForGame = function(res, team){
|
||||
if(resultParser._hasWon(res, team)){
|
||||
return 2;
|
||||
}
|
||||
return resultParser._isDraw(res) ? 1: 0;
|
||||
};
|
||||
|
||||
resultParser._getTeamStats = function(rawResults, team){
|
||||
let ret = {
|
||||
team: team, gamePlayed: 0, victories: 0, points: 0,
|
||||
defeats: 0, draws: 0, pointsFor: 0, pointsAgaint: 0};
|
||||
_.each(rawResults, function(res){
|
||||
if((team != res.home && team != res.away) || !_.isNumber(res.home_points)){
|
||||
return;
|
||||
}
|
||||
ret.gamePlayed += 1;
|
||||
ret.victories += resultParser._hasWon(res, team) ? 1: 0;
|
||||
ret.defeats += resultParser._hasLost(res, team) ? 1: 0;
|
||||
ret.draws += resultParser._isDraw(res) ? 1: 0;
|
||||
ret.pointsFor += resultParser._getPointsFor(res, team);
|
||||
ret.pointsAgaint += resultParser._getPointsForOpponent(res, team);
|
||||
ret.points += resultParser._getPointsForGame(res, team);
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
||||
resultParser._removeTemporaryResults = function(rawResults){
|
||||
return _.filter(rawResults, function(rawResult){
|
||||
return !rawResult.temporary;
|
||||
});
|
||||
};
|
||||
|
||||
resultParser._isValidGame = function(game){
|
||||
return !game.rain && ! game.practice;
|
||||
};
|
||||
|
||||
resultParser.getStats = function(rawResults){
|
||||
rawResults = _.filter(rawResults, resultParser._isValidGame);
|
||||
rawResults = _.map(rawResults, resultParser._setCanonicalPoints);
|
||||
let allTeams = resultParser._getAllTeams(resultParser._removeTemporaryResults(rawResults));
|
||||
let getTeamStats = _.partial(resultParser._getTeamStats, rawResults);
|
||||
return _.map(allTeams, getTeamStats);
|
||||
};
|
||||
|
||||
export const getStats = resultParser.getStats;
|
||||
export const getNightGames = resultParser.getNightGames;
|
||||
@@ -0,0 +1,218 @@
|
||||
import * as util from "./util.js";
|
||||
import * as resultParser from './resultParser.js'
|
||||
import * as teams from './teams.js'
|
||||
import m from "https://esm.sh/mithril@2.2.2"
|
||||
import {rainSvg} from "./images.js";
|
||||
import _ from "https://esm.sh/lodash-es@4.17.21"
|
||||
|
||||
function ppYear(year, availableYears) {
|
||||
return _.last(availableYears) === year ? "" : year;
|
||||
}
|
||||
|
||||
|
||||
export const 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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
export const statsView = {};
|
||||
statsView.stats = [];
|
||||
|
||||
statsView.oninit = async function(vnode){
|
||||
if(statsView.currentYear === vnode.attrs.year){
|
||||
return;
|
||||
}
|
||||
statsView.currentYear = vnode.attrs.year;
|
||||
const result = await m.request({
|
||||
method: "GET",
|
||||
url: `/api/results/${vnode.attrs.year}.json`
|
||||
});
|
||||
statsView.stats = resultParser.getStats(result)
|
||||
return result;
|
||||
};
|
||||
|
||||
statsView.onupdate = statsView.oninit;
|
||||
|
||||
|
||||
statsView.getStatRow = function(teamStats){
|
||||
var formatStat = function(n){
|
||||
return teamStats.gamePlayed === 0 ? '-' : n;
|
||||
};
|
||||
return m('tr', [
|
||||
m('td', teamStats.team),
|
||||
m('td', teamStats.gamePlayed),
|
||||
m('td', formatStat(teamStats.victories)),
|
||||
m('td', formatStat(teamStats.defeats)),
|
||||
m('td', formatStat(teamStats.draws)),
|
||||
m('td', formatStat(teamStats.pointsFor)),
|
||||
m('td', formatStat(teamStats.pointsAgaint)),
|
||||
m('td', formatStat(teamStats.pointsFor - teamStats.pointsAgaint)),
|
||||
m('td', formatStat(teamStats.points))
|
||||
]);
|
||||
};
|
||||
|
||||
statsView.isStatForValidTeam = function(stat){
|
||||
var teamNames = _.map(teams.teams(), 'name');
|
||||
return _.includes(teamNames, stat.team);
|
||||
}
|
||||
|
||||
|
||||
statsView.mainTable = function(stats){
|
||||
var orderedStats = _.reverse(_.sortBy(stats, ['points', 'pointsFor']));
|
||||
return m('table.uk-table.uk-table-hover.uk-table-striped',[
|
||||
m('thead', m('tr', [
|
||||
m('th', 'Équipes'),
|
||||
m('th', 'PJ'),
|
||||
m('th', 'V'),
|
||||
m('th', 'D'),
|
||||
m('th', 'N'),
|
||||
m('th', 'PP'),
|
||||
m('th', 'PC'),
|
||||
m('th', 'DIF'),
|
||||
m('th', 'PTS')
|
||||
])),
|
||||
m('tbody', _(orderedStats)
|
||||
.filter(statsView.isStatForValidTeam)
|
||||
.map(statsView.getStatRow)
|
||||
.value())
|
||||
]);
|
||||
};
|
||||
|
||||
statsView.legend = function(){
|
||||
var items = ["PJ : Parties joués", "V : Victoire", "D : Défaite",
|
||||
"N : Nul", "PP : Points pour", "PC : Points contre",
|
||||
"DIF : Diférenciel","PTS : Points"];
|
||||
return m('ul.uk-subnav.uk-subnav-line.uk-flex-center',[
|
||||
_.map(items, function(itm){
|
||||
return m('li', itm);
|
||||
})
|
||||
]);
|
||||
};
|
||||
|
||||
statsView.view = function(vnode){
|
||||
return m('div.uk-grid',
|
||||
m('div.uk-width-medium-1-1.uk-width-large-1-1.uk-container-center',[
|
||||
m('h2', 'Classement ' + vnode.attrs.year),
|
||||
statsView.mainTable(statsView.stats),
|
||||
statsView.legend()
|
||||
]));
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
export const schedulView = {};
|
||||
|
||||
schedulView.oninit = async function(vnode){
|
||||
if(vnode.attrs.year === schedulView.currentYear){
|
||||
return;
|
||||
}
|
||||
schedulView.currentYear = vnode.attrs.year;
|
||||
const result = await m.request({
|
||||
method: "GET",
|
||||
url: `/api/results/${vnode.attrs.year}.json`
|
||||
});
|
||||
schedulView.games = resultParser.getNightGames(result)
|
||||
|
||||
};
|
||||
|
||||
schedulView.onupdate = schedulView.oninit;
|
||||
|
||||
|
||||
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(){
|
||||
return m('div.uk-grid',
|
||||
m('div.uk-width-large-3-5.uk-width-medium-1-1',
|
||||
_.map(schedulView.games, schedulView._gameView)));
|
||||
};
|
||||
|
||||
|
||||
export const tabView = {};
|
||||
|
||||
tabView._createTab = function(activeYear, availableYears, year){
|
||||
const isActive = (activeYear == year) || (activeYear == ppYear(year, availableYears));
|
||||
return m('li', {'class': isActive ? 'uk-active': ''}, // 'uk-active'
|
||||
m('a', {href: '#/' + ppYear(year, availableYears)}, 'Saison ' + year));
|
||||
}
|
||||
|
||||
tabView.view = function(vnode){
|
||||
const activeYear = vnode.attrs.year;
|
||||
const availableYears = vnode.attrs.availableYears;
|
||||
const 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))));
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as _ from "https://esm.sh/lodash-es@4.17.21"
|
||||
|
||||
|
||||
export function teams(){
|
||||
return [
|
||||
{name: 'remplaçants', color: '#FFA500'},
|
||||
{name: 'jaune', color: '#FF0'},
|
||||
{name:'rouge', color: '#F00'},
|
||||
{name:'bleu', color: '#00F'},
|
||||
{name:'gris', color: '#808080'},
|
||||
{name:'vert', color: '#008000'},
|
||||
{name: 'noir', color: '#000000'},
|
||||
{name: 'orange', color: '#FFA500'},
|
||||
{name: 'mauve', color: '#E0B0FF'}
|
||||
];
|
||||
};
|
||||
|
||||
export function getTeamColor(teamName){
|
||||
return teams().filter(t => t.name == teamName)[0]?.color;
|
||||
};
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
/*! UIkit 2.27.2 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
!function(t){if("function"==typeof define&&define.amd&&define("uikit",function(){var i=window.UIkit||t(window,window.jQuery,window.document);return i.load=function(t,e,n,o){var s,a=t.split(","),r=[],l=(o.config&&o.config.uikit&&o.config.uikit.base?o.config.uikit.base:"").replace(/\/+$/g,"");if(!l)throw new Error("Please define base path to UIkit in the requirejs config.");for(s=0;s<a.length;s+=1){var c=a[s].replace(/\./g,"/");r.push(l+"/components/"+c)}e(r,function(){n(i)})},i}),!window.jQuery)throw new Error("UIkit requires jQuery");window&&window.jQuery&&t(window,window.jQuery,window.document)}(function(t,i,e){"use strict";var n={},o=t.UIkit?Object.create(t.UIkit):void 0;if(n.version="2.27.2",n.noConflict=function(){return o&&(t.UIkit=o,i.UIkit=o,i.fn.uk=o.fn),n},n.prefix=function(t){return t},n.$=i,n.$doc=n.$(document),n.$win=n.$(window),n.$html=n.$("html"),n.support={},n.support.transition=function(){var t=function(){var t,i=e.body||e.documentElement,n={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(t in n)if(void 0!==i.style[t])return n[t]}();return t&&{end:t}}(),n.support.animation=function(){var t=function(){var t,i=e.body||e.documentElement,n={WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd oanimationend",animation:"animationend"};for(t in n)if(void 0!==i.style[t])return n[t]}();return t&&{end:t}}(),function(){Date.now=Date.now||function(){return(new Date).getTime()};for(var t=["webkit","moz"],i=0;i<t.length&&!window.requestAnimationFrame;++i){var e=t[i];window.requestAnimationFrame=window[e+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e+"CancelAnimationFrame"]||window[e+"CancelRequestAnimationFrame"]}if(/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent)||!window.requestAnimationFrame||!window.cancelAnimationFrame){var n=0;window.requestAnimationFrame=function(t){var i=Date.now(),e=Math.max(n+16,i);return setTimeout(function(){t(n=e)},e-i)},window.cancelAnimationFrame=clearTimeout}}(),n.support.touch="ontouchstart"in document||t.DocumentTouch&&document instanceof t.DocumentTouch||t.navigator.msPointerEnabled&&t.navigator.msMaxTouchPoints>0||t.navigator.pointerEnabled&&t.navigator.maxTouchPoints>0||!1,n.support.mutationobserver=t.MutationObserver||t.WebKitMutationObserver||null,n.Utils={},n.Utils.isFullscreen=function(){return document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.fullscreenElement||!1},n.Utils.str2json=function(t,i){try{return i?JSON.parse(t.replace(/([\$\w]+)\s*:/g,function(t,i){return'"'+i+'":'}).replace(/'([^']+)'/g,function(t,i){return'"'+i+'"'})):new Function("","var json = "+t+"; return JSON.parse(JSON.stringify(json));")()}catch(e){return!1}},n.Utils.debounce=function(t,i,e){var n;return function(){var o=this,s=arguments,a=function(){n=null,e||t.apply(o,s)},r=e&&!n;clearTimeout(n),n=setTimeout(a,i),r&&t.apply(o,s)}},n.Utils.throttle=function(t,i){var e=!1;return function(){e||(t.call(),e=!0,setTimeout(function(){e=!1},i))}},n.Utils.removeCssRules=function(t){var i,e,n,o,s,a,r,l,c,u;t&&setTimeout(function(){try{for(u=document.styleSheets,o=0,r=u.length;r>o;o++){for(n=u[o],e=[],n.cssRules=n.cssRules,i=s=0,l=n.cssRules.length;l>s;i=++s)n.cssRules[i].type===CSSRule.STYLE_RULE&&t.test(n.cssRules[i].selectorText)&&e.unshift(i);for(a=0,c=e.length;c>a;a++)n.deleteRule(e[a])}}catch(d){}},0)},n.Utils.isInView=function(t,e){var o=i(t);if(!o.is(":visible"))return!1;var s=n.$win.scrollLeft(),a=n.$win.scrollTop(),r=o.offset(),l=r.left,c=r.top;return e=i.extend({topoffset:0,leftoffset:0},e),c+o.height()>=a&&c-e.topoffset<=a+n.$win.height()&&l+o.width()>=s&&l-e.leftoffset<=s+n.$win.width()?!0:!1},n.Utils.checkDisplay=function(t,e){var o=n.$("[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]",t||document);return t&&!o.length&&(o=i(t)),o.trigger("display.uk.check"),e&&("string"!=typeof e&&(e='[class*="uk-animation-"]'),o.find(e).each(function(){var t=n.$(this),i=t.attr("class"),e=i.match(/uk-animation-(.+)/);t.removeClass(e[0]).width(),t.addClass(e[0])})),o},n.Utils.options=function(t){if("string"!=i.type(t))return t;-1!=t.indexOf(":")&&"}"!=t.trim().substr(-1)&&(t="{"+t+"}");var e=t?t.indexOf("{"):-1,o={};if(-1!=e)try{o=n.Utils.str2json(t.substr(e))}catch(s){}return o},n.Utils.animate=function(t,e){var o=i.Deferred();return t=n.$(t),t.css("display","none").addClass(e).one(n.support.animation.end,function(){t.removeClass(e),o.resolve()}),t.css("display",""),o.promise()},n.Utils.uid=function(t){return(t||"id")+(new Date).getTime()+"RAND"+Math.ceil(1e5*Math.random())},n.Utils.template=function(t,i){for(var e,n,o,s,a=t.replace(/\n/g,"\\n").replace(/\{\{\{\s*(.+?)\s*\}\}\}/g,"{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),r=0,l=[],c=0;r<a.length;){if(e=a[r],e.match(/\{\{\s*(.+?)\s*\}\}/))switch(r+=1,e=a[r],n=e[0],o=e.substring(e.match(/^(\^|\#|\!|\~|\:)/)?1:0Line truncated
|
||||
if(e=u.split("-"),h=d[u]?d[u]:d["bottom-left"],this.justified&&this.justified.length)i(a.css({left:0}),this.justified,c);else if(this.options.preventflip!==!0){var p;switch(this.checkBoundary(n.left+h.left,n.top+h.top,r,l,c)){case"x":"x"!==this.options.preventflip&&(p=o.x[u]||"right-top");break;case"y":"y"!==this.options.preventflip&&(p=o.y[u]||"top-left");break;case"xy":this.options.preventflip||(p=o.xy[u]||"right-bottom")}p&&(e=p.split("-"),h=d[p]?d[p]:d["bottom-left"],a.addClass("uk-dropdown-autoflip"),this.checkBoundary(n.left+h.left,n.top+h.top,r,l,c)&&(e=u.split("-"),h=d[u]?d[u]:d["bottom-left"]))}r>c&&(a.addClass("uk-dropdown-stack"),this.trigger("stack.uk.dropdown",[this])),a.css(h).css("display","").addClass("uk-dropdown-"+e[0])}},checkBoundary:function(i,e,n,o,s){var a="";return(0>i||i-t.$win.scrollLeft()+n>s)&&(a+="x"),(e-t.$win.scrollTop()<0||e-t.$win.scrollTop()+o>window.innerHeight)&&(a+="y"),a}}),t.component("dropdownOverlay",{defaults:{justify:!1,cls:"",duration:200},boot:function(){t.ready(function(i){t.$("[data-uk-dropdown-overlay]",i).each(function(){var i=t.$(this);i.data("dropdownOverlay")||t.dropdownOverlay(i,t.Utils.options(i.attr("data-uk-dropdown-overlay")))})})},init:function(){var e=this;this.justified=this.options.justify?t.$(this.options.justify):!1,this.overlay=this.element.find("uk-dropdown-overlay"),this.overlay.length||(this.overlay=t.$('<div class="uk-dropdown-overlay"></div>').appendTo(this.element)),this.overlay.addClass(this.options.cls),this.on({"beforeshow.uk.dropdown":function(t,n){e.dropdown=n,e.justified&&e.justified.length&&i(e.overlay.css({display:"block",marginLeft:"",marginRight:""}),e.justified,e.justified.outerWidth())},"show.uk.dropdown":function(){var i=e.dropdown.dropdown.outerHeight(!0);e.dropdown.element.removeClass("uk-open"),e.overlay.stop().css("display","block").animate({height:i},e.options.duration,function(){e.dropdown.dropdown.css("visibility",""),e.dropdown.element.addClass("uk-open"),t.Utils.checkDisplay(e.dropdown.dropdown,!0)}),e.pointerleave=!1},"hide.uk.dropdown":function(){e.overlay.stop().animate({height:0},e.options.duration)},"pointerenter.uk.dropdown":function(){clearTimeout(e.remainIdle)},"pointerleave.uk.dropdown":function(){e.pointerleave=!0}}),this.overlay.on({mouseenter:function(){e.remainIdle&&(clearTimeout(e.dropdown.remainIdle),clearTimeout(e.remainIdle))},mouseleave:function(){e.pointerleave&&n&&(e.remainIdle=setTimeout(function(){n&&n.hide()},n.options.remaintime))}})}})}(UIkit),function(t){"use strict";var i=[];t.component("gridMatchHeight",{defaults:{target:!1,row:!0,ignorestacked:!1,observe:!1},boot:function(){t.ready(function(i){t.$("[data-uk-grid-match]",i).each(function(){var i,e=t.$(this);e.data("gridMatchHeight")||(i=t.gridMatchHeight(e,t.Utils.options(e.attr("data-uk-grid-match"))))})})},init:function(){var e=this;this.columns=this.element.children(),this.elements=this.options.target?this.find(this.options.target):this.columns,this.columns.length&&(t.$win.on("load resize orientationchange",function(){var i=function(){e.element.is(":visible")&&e.match()};return t.$(function(){i()}),t.Utils.debounce(i,50)}()),this.options.observe&&t.domObserve(this.element,function(){e.element.is(":visible")&&e.match()}),this.on("display.uk.check",function(){this.element.is(":visible")&&this.match()}.bind(this)),i.push(this))},match:function(){var i=this.columns.filter(":visible:first");if(i.length){var e=Math.ceil(100*parseFloat(i.css("width"))/parseFloat(i.parent().css("width")))>=100;return e&&!this.options.ignorestacked?this.revert():t.Utils.matchHeights(this.elements,this.options),this}},revert:function(){return this.elements.css("min-height",""),this}}),t.component("gridMargin",{defaults:{cls:"uk-grid-margin",rowfirst:"uk-row-first"},boot:function(){t.ready(function(i){t.$("[data-uk-grid-margin]",i).each(function(){var i,e=t.$(this);e.data("gridMargin")||(i=t.gridMargin(e,t.Utils.options(e.attr("data-uk-grid-margin"))))})})},init:function(){t.stackMargin(this.element,this.options)}})}(UIkit),function(t){"use strict";function i(i,e){return e?("object"==typeof i?(i=i instanceof jQuery?i:t.$(i),i.parent().length&&(e.persist=i,e.persist.data("modalPersistParent",i.parent()))):i="string"==typeof i||"number"==typeof i?t.$("<div></div>").html(i):t.$("<div></div>").html("UIkit.modal Error: Unsupported data type: "+typeof i),i.appendTo(e.element.find(".uk-modal-dialog")),e):void 0}var e,n=!1,o=0,s=t.$html;t.$win.on("resize orientationchange",t.Utils.debounce(function(){t.$(".uk-modal.uk-open").each(function(){return t.$(this).data("modal")&&t.$(this).data("modal").resize()})},150)),t.component("modal",{defaults:{keyboard:!0,bgclose:!0,minScrollHeight:150,center:!1,modal:!0},scrollable:!1,transition:!1,hasTransitioned:!0,init:function(){if(e||(e=t.$("body")),this.element.length){var i=this;this.paddingdir="padding-"+("left"==t.langdirection?"right":"left"),this.dialog=this.find(".uk-modal-dialog"),this.active=!1,this.element.attr("aria-hiddLine truncated
|
||||
@@ -0,0 +1,63 @@
|
||||
import m from "https://esm.sh/mithril@2.2.2"
|
||||
import * as _ from "https://esm.sh/lodash-es@4.17.21"
|
||||
|
||||
|
||||
let availableYears = []
|
||||
m.request({
|
||||
method: "GET",
|
||||
url: `api/available-years.json`
|
||||
}).then(d => {
|
||||
availableYears = d.sort();
|
||||
})
|
||||
|
||||
|
||||
function resultatsURL (year){
|
||||
var cacheBuster = window.Date.now();
|
||||
year = !!year ? year: util.getDefaultYear();
|
||||
return "api/resultats" + year + ".json?_=" + cacheBuster;
|
||||
};
|
||||
|
||||
export function getAvailableYears(){
|
||||
if(window.availableYears){
|
||||
return _.clone(window.availableYears)
|
||||
}
|
||||
return availableYears.map(x => x)
|
||||
|
||||
};
|
||||
|
||||
export function getDefaultYear(){
|
||||
return _.max(getAvailableYears());
|
||||
}
|
||||
|
||||
export function formatDate(date){
|
||||
const monthNames = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin',
|
||||
'juillet', 'août', 'septembre', 'octobre', 'novembre',
|
||||
'decembre'];
|
||||
return [date.getDate(),
|
||||
monthNames[date.getMonth()],
|
||||
date.getFullYear()].join(' ');
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
export function getResults(year){
|
||||
var url = resultatsURL(year);
|
||||
return m.request({method: "GET", url: url})
|
||||
};
|
||||
|
||||
export function getDefaultResults() {
|
||||
return getResults(getDefaultYear());
|
||||
};
|
||||
|
||||
|
||||
export function formatDateSmall(date){
|
||||
var smallMonthNames = ['janv', 'févr', 'mars', 'avr', 'mai', 'juin',
|
||||
'juill', 'août', 'sept', 'oct', 'nov',
|
||||
'dec'];
|
||||
return [date.getDate(),
|
||||
smallMonthNames[date.getMonth()],
|
||||
date.getFullYear() % 1000].join(' ');
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user