From 2f1b5e8cffbdcf5d0771d1afa233a3d0f0520c98 Mon Sep 17 00:00:00 2001 From: TonyFord <tonyford@strategy-investor.de> Date: Fri, 18 Mar 2022 18:04:13 +0100 Subject: [PATCH] add Historie add saison 31 --- html/31.php | 35 +++++++++++++++++++++++++ html/_data/partien/11.yml | 11 ++++++++ html/_layouts/default.php | 19 ++++++++++---- html/assets/css/custom.scss | 38 ++++++++++++++++++++++++--- html/assets/js/script.js | 52 ++++++++++++++++++++++++++++++------- 5 files changed, 137 insertions(+), 18 deletions(-) create mode 100644 html/31.php create mode 100644 html/_data/partien/11.yml diff --git a/html/31.php b/html/31.php new file mode 100644 index 0000000..d221953 --- /dev/null +++ b/html/31.php @@ -0,0 +1,35 @@ +--- +layout: default +saison: 31 +saison_now: 31 +date: '2022-03-26' +ligaspieltag: 8 +step: 1 +finals_step: 2 +startliste: + - + - se + - es + - is + - hr + - cm + - pl + - bw + - co + - hu + - fr + - fi + +startliste_partien_pause: + - 2 + - 2 + - 2 + - 2 + - 2 + - 2 + - 2 + - 2 + - 2 + - 2 + - 2 +--- diff --git a/html/_data/partien/11.yml b/html/_data/partien/11.yml new file mode 100644 index 0000000..ffac1de --- /dev/null +++ b/html/_data/partien/11.yml @@ -0,0 +1,11 @@ +- [ 1, 2,11, 3,10, 4,9, 5,8, 6,7 ] +- [ 1, 1,2, 11,3, 10,4, 9,5, 8,6 ] +- [ 1, 1,3, 4,11, 5,10, 6,9, 7,8 ] +- [ 1, 1,4, 2,3, 11,5, 10,6, 7,9 ] +- [ 1, 5,1, 2,4, 6,11, 7,10, 8,9 ] +- [ 1, 1,6, 2,5, 3,4, 11,7, 8,10 ] +- [ 1, 7,1, 6,2, 3,5, 8,11, 9,10 ] +- [ 1, 1,8, 2,7, 3,6, 4,5, 9,11 ] +- [ 1, 9,1, 8,2, 3,7, 4,6, 10,11 ] +- [ 1, 10,1, 9,2, 3,8, 4,7, 5,6 ] +- [ 1, 11,1, 10,2, 9,3, 4,8, 5,7 ] diff --git a/html/_layouts/default.php b/html/_layouts/default.php index f728b9c..1f25f53 100644 --- a/html/_layouts/default.php +++ b/html/_layouts/default.php @@ -46,7 +46,7 @@ if( !empty($csv) ){ <head> <link rel="stylesheet" href="assets/css/all.min.css"> - <link rel="stylesheet" href="assets/css/custom.css?2"> + <link rel="stylesheet" href="assets/css/custom.css?3"> <script src="assets/js/jquery.min.js"></script> <script src="assets/js/script.js"></script> </head> @@ -140,9 +140,9 @@ if( !empty($csv) ){ calculateAssists('{{ page.saison }}'); calculateZwk('{{ page.saison }}'); - $('h2.tabelle button').on('click', + $('h4.tabelle button').on('click', function(){ - $('h2.tabelle button').toggleClass('active',false); + $('h4.tabelle button').toggleClass('active',false); $(this).toggleClass('active',true); $('table.tabelle').toggleClass('d-none',true); $('#tabelle_'+$(this).text().toLowerCase()).toggleClass('d-none',false); @@ -170,7 +170,7 @@ if( !empty($csv) ){ <div class="div_right"> <div id="saisons"> - <button id="ewige" class="" onclick="calculateEwige()"><b>EWIGE</b></button> + <button id="historie" class="" onclick="calculateHistorie()"><b>HISTORIE</b></button> <button id="ewige" class="" onclick="calculateEwige()"><b>EWIGE</b></button> {% for f in site.pages %} {% assign fn = f.name | slice:0,2 %} {% assign fn_isnumeric = fn | is_numeric %} @@ -180,7 +180,7 @@ if( !empty($csv) ){ {% endif %} {% endfor %} </div> - <h2 class="tabelle">Tabelle <button>Zweikampf</button><button>Assists</button><button>Tore</button><button class="punktestand active">Punktestand</button></h2> + <h4 class="tabelle">Tabelle <button>Zweikampf</button><button>Assists</button><button>Tore</button><button class="punktestand active">Punktestand</button></h2> <table id="tabelle_punktestand" class="tabelle"> <thead> @@ -254,6 +254,15 @@ if( !empty($csv) ){ </tbody> </table> + <table id="tabelle_historie" class="tabelle d-none" ondblclick="backToActiveTable()"> + <thead> + <tr> + </tr> + </thead> + <tbody> + </tbody> + </table> + </div> <div id="partien" class="div_left"> diff --git a/html/assets/css/custom.scss b/html/assets/css/custom.scss index 3a422eb..ddcbe6c 100644 --- a/html/assets/css/custom.scss +++ b/html/assets/css/custom.scss @@ -55,12 +55,13 @@ table.tabelle { /* padding-left: 10px; */ } -h2.tabelle { +h4.tabelle { padding:5px; + margin:0px; } -h2.tabelle { +h4.tabelle { max-width: 600px; background: cornflowerblue; button { @@ -257,7 +258,7 @@ td.n { color: firebrick; } #saisons { padding-left: 5px; - margin-bottom: -22px; + margin-bottom: 5px; button { cursor: pointer; border-radius: 0px; @@ -268,3 +269,34 @@ td.n { color: firebrick; } } } } + +#tabelle_historie { + thead tr th { + width: 24px; + text-align: center; + &.rest { + width: initial; + } + &:first-child { + width:30px; + text-align: right; + } + } + tbody tr { + td { + &:first-child { + text-align: right; + } + img { + display: block; + margin: auto; + } + &.master { + background: gold; + } + } + &:nth-child(4) td { + border-bottom: 1px dashed blue; + } + } +} diff --git a/html/assets/js/script.js b/html/assets/js/script.js index c3c9d0d..9078693 100644 --- a/html/assets/js/script.js +++ b/html/assets/js/script.js @@ -168,7 +168,9 @@ function calculatePartien(saison,date){ } function grpPartien( date,steps,saison,runde,spieltag,Bg ){ - if( Grps.map( (a) => ( a.filter((b) => (b == undefined)).length > 0 ) )[0] ){ + + if( Grps.map( (a) => ( a.filter((b) => (b == undefined )).length > 0 ) )[0] ){ + console.log( JSON.parse(JSON.stringify(Grps))); alert( 'Error: Einige Teams existieren nicht in der DB' ); return; } @@ -290,7 +292,7 @@ function calculatePunktestand(saison,runde,show=true){ var startliste=STARTLISTE.reduce((a,b)=>(a)); - var Tabelle=Object.values(TEAMS).filter( (a) => ( ( a.start <= saison || saison == 0 ) && ( startliste.indexOf( a.nt ) > -1 || ( saison == 0 && a.nt != 'xx' ) ) ) ) + var Tabelle=Object.values(TEAMS).filter( (a) => ( ( a.start <= saison || saison == 0 ) && ( startliste.indexOf( a.nt ) > -2 || ( saison == 0 && a.nt != 'xx' ) ) ) ) .sort( function(a,b){ return a[saison].P < b[saison].P || @@ -298,7 +300,13 @@ function calculatePunktestand(saison,runde,show=true){ ( a[saison].P == b[saison].P && a[saison].Td == b[saison].Td && a[saison].Tp < b[saison].Tp ) || ( a[saison].P == b[saison].P && a[saison].Td == b[saison].Td && a[saison].Tp == b[saison].Tp && a.nt > b.nt ) ? 1 : -1; } - ); + ).filter( + function(b){ + if( ! b[saison].active && saison != 0 ) return false; + if( b[saison].P == 0 && b[saison].Tp == 0 && b[saison].Tn == 0 ) return false; + //if( b.nt == 'xx' ) return false; + return true; + } ); if( !show ){ return Tabelle; @@ -309,7 +317,6 @@ function calculatePunktestand(saison,runde,show=true){ Tabelle.forEach( function(v,i){ - if( ! v[saison].active && saison != 0 ) return; var tmp='<td>'+(i+1)+'</td>'; var t=v[saison].Tr.map( (a) => ( a != 'X' ) ? 1 : 0 ); if( t.length == 0 ) t.push(0); @@ -334,7 +341,6 @@ function calculateTore(saison){ var STATISTIK=saison == 0 ? STATISTIK_ALL : STATISTIK_SAISON; var n=Object.entries( STATISTIK ).sort( function(a,b){ return ( ( a[1].T < b[1].T || ( a[1].T == b[1].T && a[1].S > b[1].S ) ) ? 1 : -1 ) } ).slice(0,10).map( function(v,i){ - console.log( v ); var team=TEAMS.filter( (a) => ( a.nt == v[1].nt ) ); if( team.length == 0 ){ var team_flag='<img class="flags" src="./images/flags/xx.svg" title="n/a">'; @@ -358,7 +364,6 @@ function calculateTore(saison){ ); $('#tabelle_tore tbody').html( '<tr>'+n.join('</tr><tr>') + '</tr>' ); } - function calculateAssists(saison){ var STATISTIK=saison == 0 ? STATISTIK_ALL : STATISTIK_SAISON; var n=Object.entries( STATISTIK ).sort( (a,b) => ( a[1].A < b[1].A || ( a[1].A == b[1].A && a[1].S > b[1].S ) ) ? 1 : -1 ).slice(0,10).map( @@ -386,7 +391,6 @@ function calculateAssists(saison){ ); $('#tabelle_assists tbody').html( '<tr>'+n.join('</tr><tr>') + '</tr>' ); } - function calculateZwk(saison){ var STATISTIK=saison == 0 ? STATISTIK_ALL : STATISTIK_SAISON; var n=Object.entries( STATISTIK ).sort( (a,b) => ( a[1].Z < b[1].Z || ( a[1].Z == b[1].Z && a[1].S > b[1].S ) ) ? 1 : -1 ).slice(0,10).map( @@ -415,7 +419,6 @@ function calculateZwk(saison){ $('#tabelle_zweikampf tbody').html( '<tr>'+n.join('</tr><tr>') + '</tr>' ); } - function calculateTeam(saison,nt){ var STATISTIK=saison == 0 ? STATISTIK_ALL : STATISTIK_SAISON; @@ -445,7 +448,6 @@ function calculateTeam(saison,nt){ $('#tabelle_team').toggleClass('d-none',false); $('#tabelle_team tbody').html( '<tr>'+n.join('</tr><tr>') + '</tr>' ); } - function calculateEwige(){ calculatePunktestand(0,'7'); calculateTore(0); @@ -455,10 +457,40 @@ function calculateEwige(){ $('#ewige').toggleClass('active',true); $('table.tabelle').toggleClass('d-none',true); $('#tabelle_punktestand').toggleClass('d-none'); - $('h2.tabelle > button.punktestand').toggleClass('active',true); + $('h4.tabelle > button.punktestand').toggleClass('active',true); + $('h4.tabelle').toggleClass('d-none',false); } function backToActiveTable(){ $('table.tabelle').toggleClass('d-none',true); $('#tabelle_'+ $('button.active').text().toLowerCase() ).toggleClass('d-none'); } + +function calculateHistorie(){ + $('#tabelle_historie thead tr').html('<th>Pl.</th>'); + var T=[]; + for( var i=0; i<=SAISON_NOW-26; i++){ + $('#tabelle_historie thead tr').append('<th>'+(i+1)+'<sup>'+(i+26)+'</sup></th>'); + T.push(calculatePunktestand(i+26,7,false)); + } + $('#tabelle_historie thead tr').append('<th class="rest"></th>'); + + var masters=ERGEBNISSE.filter((a) => ( a.runde == 'F' )).map((a) => (a.TH*1 > a.TA*1 ? a.H.toLowerCase(): a.A.toLowerCase() )); + var mx=T.map((a)=>(a.length)).reduce((a,b) => (Math.max(a,b))); + + var tmp=''; + for( var p=0; p<mx; p++ ){ + tmp+='<tr><td>'+(p+1)+'</td>'; + for( var i=0; i<=SAISON_NOW-26; i++){ + var nt=T[i][p] != undefined ? T[i][p].nt : undefined; + tmp+='<td'+(( masters[i] == nt && nt != undefined ) ? ' class="master"' : '')+'>'+(( nt != undefined ) ? '<img class="flags" title="'+T[i][p].name+'" src="./images/flags/'+nt+'.svg">' : '')+'</td>'; + } + tmp+='</tr>'; + } + $('#tabelle_historie tbody').html(tmp); + $('table.tabelle').toggleClass('d-none',true); + $('#tabelle_historie').toggleClass('d-none',false); + $('button.active').toggleClass('active',false); + $('#historie').toggleClass('active',true); + $('h4.tabelle').toggleClass('d-none',true); +} -- GitLab