Add total type selector for average-based player statistics

This commit is contained in:
Brian Miyaji
2017-06-08 18:06:18 +10:00
parent 1144aa2094
commit cac416fdbc
4 changed files with 54 additions and 18 deletions

View File

@@ -239,7 +239,7 @@ jQuery(document).ready(function($){
});
// Total stats calculator
$(".sp-data-table .sp-total input[data-sp-format=number]").on("updateTotal", function() {
$(".sp-data-table .sp-total input[data-sp-format=number][data-sp-total-type=total]").on("updateTotal", function() {
index = $(this).parent().index();
var sum = 0;
$(this).closest(".sp-data-table").find(".sp-post").each(function() {
@@ -248,7 +248,7 @@ jQuery(document).ready(function($){
val = $(this).find("td").eq(index).find("input").attr("placeholder");
}
if($.isNumeric(val)) {
sum += parseInt(val, 10);
sum += parseFloat(val, 10);
}
});
$(this).attr("placeholder", sum);
@@ -257,12 +257,12 @@ jQuery(document).ready(function($){
// Activate total stats calculator
if($(".sp-data-table .sp-total").size()) {
$(".sp-data-table .sp-post td input").on("keyup", function() {
$(this).closest(".sp-data-table").find(".sp-total td").eq($(this).parent().index()).find("input").trigger("updateTotal");
$(this).closest(".sp-data-table").find(".sp-total td").eq($(this).parent().index()).find("input[data-sp-format=number][data-sp-total-type=total]").trigger("updateTotal");
});
}
// Trigger total stats calculator
$(".sp-data-table .sp-total input").trigger("updateTotal");
$(".sp-data-table .sp-total input[data-sp-format=number][data-sp-total-type=total]").trigger("updateTotal");
// Sync inputs
$(".sp-sync-input").on("keyup", function() {