diff --git a/html/_layouts/default.php b/html/_layouts/default.php index c2cf3b1969abba3e4af30665383941b2679a6bd8..b53340b7480ebbd30f6076d9735fad1fc82dd9a5 100644 --- a/html/_layouts/default.php +++ b/html/_layouts/default.php @@ -269,6 +269,12 @@ if( !empty($csv) ){ <div id="partien" class="div_left"> </div> + <div id="lastresults" class="d-none" ondblclick="hideLastResults(true)"> + <table> + <tbody> + </tbody> + </table> + </div> diff --git a/html/assets/css/custom.scss b/html/assets/css/custom.scss index 2c4f5b48b6a0e17ff3a7b23f48f619ac50ad2732..8cb6f82e5f533c38123fa5c33d6aa7860b1cb4f5 100644 --- a/html/assets/css/custom.scss +++ b/html/assets/css/custom.scss @@ -304,3 +304,19 @@ td.n { color: firebrick; } .dashed { border-bottom: 1px dashed blue; } + +#lastresults { + position: fixed; + top: 40px; + left: 40px; + background: gainsboro; + padding:1em; + border: 1px solid dimgray; + cursor: pointer; + table tbody tr { + td:nth-child(6){ text-align: center; } + &.lastresults_summe { + font-weight: bold; + } + } +} diff --git a/html/assets/js/script.js b/html/assets/js/script.js index d29d51a429dc30e49b92b1879440a5d940556091..00d552e9d672278ffddfbbfb223490435d16476c 100644 --- a/html/assets/js/script.js +++ b/html/assets/js/script.js @@ -317,7 +317,7 @@ function grpPartien( date,steps,saison,runde,spieltag,Bg ){ tmp+='<td data-id="'+v[a1].nt+'"><img class="flags" src="./images/flags/'+(( v[a1].flag ) ? v[a1].flag : v[a1].nt.toLowerCase())+'.svg"> '+v[a1].name.replace(/\(NL\)/g,'')+' <sup>'+v[a1].nt.toUpperCase()+'</sup></td>'; tmp+='<td data-mid="'+(( ergebnis.MID != undefined ) ? ergebnis.MID : '0' )+'">'+th+'</td>'; - tmp+='<td>:</td>'; + tmp+='<td onmouseenter="showLastResults(\''+v[h1].nt+'\',\''+v[a1].nt+'\')" onmouseleave="hideLastResults()" onclick="ignoreHideLastResults()">:</td>'; tmp+='<td>'+ta+'</td>'; tmp+='</tr>'; @@ -601,3 +601,74 @@ function calculateHistorie(){ $('#historie').toggleClass('active',true); $('h4.tabelle').toggleClass('d-none',true); } + +var R=undefined; + +function showLastResults(H,A){ + $('#lastresults').toggleClass('d-none',false); + R=ERGEBNISSE.filter((a) => ( a.H==H && a.A==A || a.A==H && a.H==A) ).slice(-5); + $('#lastresults table tbody').html(R.map( + (c) => + ( '<tr>\ + <td>'+c.saison+'</td>\ + <td>'+c.runde+'</td>\ + <td><img class="flags" src="./images/flags/'+(( c.H == H ) ? c.H : c.A )+'.svg"></td>\ + <td><img class="flags" src="./images/flags/'+(( c.A == A ) ? c.A : c.H )+'.svg"></td>\ + <td><a href="https://ultrasoccer.de/match/?id='+c.MID+'" target="ultrasoccer">'+(( c.H == H ) ? c.TH : c.TA )+'</a></td>\ + <td>:</td>\ + <td><a href="https://ultrasoccer.de/match/?id='+c.MID+'" target="ultrasoccer">'+(( c.A == A ) ? c.TA : c.TH )+'</a></td>\ + </tr>' ) + ) + ); + + var d=R.map( + (a) => + ( + { 'TH' : (( a.H == H ) ? parseInt(a.TH) : parseInt(a.TA)), + 'TA' : (( a.A == A ) ? parseInt(a.TA) : parseInt(a.TH)), + 'S' : (( a.H == H ) ? parseInt(a.TH) > parseInt(a.TA) : parseInt(a.TA) > parseInt(a.TH)) ? 1 : 0, + 'U' : parseInt(a.TH) == parseInt(a.TA) ? 1 : 0, + 'N' : (( a.H == H ) ? parseInt(a.TH) < parseInt(a.TA) : parseInt(a.TA) < parseInt(a.TH)) ? 1 : 0 + } + ) + ).reduce( + (sum,val) => + ( + sum.TH += val.TH, + sum.TA += val.TA, + sum.S += val.S, + sum.U += val.U, + sum.N += val.N, + sum + ) + ); + + $('#lastresults table tbody').append( + '<tr class="lastresults_summe">\ + <td colspan="4">Tore</td><\ + <td>'+d.TH+'</td>\ + <td>:</td>\ + <td>'+d.TA+'</td>\ + </tr>\ + <tr class="lastresults_summe">\ + <td colspan="4">S/U/N</td><\ + <td>'+d.S+'</td>\ + <td>'+d.U+'</td>\ + <td>'+d.N+'</td>\ + </tr>' + ); + + console.log( 'III',d ) + +} + +var ignore_hidelastresults=false; + +function hideLastResults(force=false){ + if( !ignore_hidelastresults || force ) $('#lastresults').toggleClass('d-none',true); + if( force ) ignore_hidelastresults=false; +} + +function ignoreHideLastResults(){ + ignore_hidelastresults=true; +}