berndkohlmaier
Forum Replies Created
Viewing 3 replies - 1 through 3 (of 3 total)
-
Forum: Plugins
In reply to: [SportsPress - Sports Club & League Manager] player list totalsNow it is working.
But some calculations were not correct. It is not right to calculate the average of percentage values to get the average of the totals.
So i changed the calculation of the free-throw percentage to calculate it at the end of the sum-loop.
The “points per game” and “threes per game” is also not correct as average. But i can not calculate this, because i need the number of games for this – which i dont have. So i had to omit these two values.This is the final code i am using now:
<script> jQuery(window).load(function(){ setTimeout( function() { /* totals = multidimensional array for all items types = 0 => ignore (e.g. name), 1 => sum, 2=> avg, 3=> "Gesamt", 4=>percent of last 2 */ var totals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], types = [ 3,0,1,1,1,1,4,1,1,0,0 ], $this, $rows, nRows = 0, i = 0, tmp = 0; $table = jQuery(".sp-template-player-list table"); $rows = $table.find("tr"); nRows = $rows.length; $rows.each(function(){ /* loop over all lines to sum values */ if (i != 0) { $this = jQuery(this); i = 0; $this.find("td").each(function(){ /* 1: total sum */ if (types[i] == 1) { tmp = parseFloat( jQuery(this).text() ) || 0; totals[i] += tmp; } /* 4: percent a/b */ else if (types[i] == 6) { tmp = a * 100 / b; tmp = Math.round(tmp * 100) / 100; totals[i] += tmp; } /* 2: avg */ else if (types[i] == 2) { tmp = parseFloat( jQuery(this).text() ) || 0; tmp = tmp / nRows; tmp = Math.round(tmp * 100) / 100; totals[i] += tmp; } /* 3: "Gesamt" */ else if (types[i] == 3) { totals[i] = "Gesamt"; } /* any other */ else { totals[i] = ""; } i++; }); } else { i = 1; } }); /* display totals line */ html = "<tr>"; for (i=0; i<totals.length; i++) { if (types[i] == 4) { tmp = totals[i-2] * 100 / totals[i-1]; tmp = Math.round(tmp * 10) / 10; html += "<td>" + tmp + "</td>"; } else { html += "<td>" + totals[i] + "</td>"; } } html += "</tr>"; $table.append(html); }, 2000); }); </script>
Forum: Plugins
In reply to: [SportsPress - Sports Club & League Manager] player list totalsI have inserted the code into my page and i see the script appearing in the header.
But i see no difference, and no summary line.
Am i missing anything ?
kind regards, Bernd.
Forum: Plugins
In reply to: [SportsPress - Sports Club & League Manager] player list totals
Viewing 3 replies - 1 through 3 (of 3 total)