Difference between revisions of "User:Areid/common.js"
From ipswichmakerspace
m |
m |
||
Line 3: | Line 3: | ||
var $subtotals = $('tr td b').filter(function(i) { return $(this).text()=='£subtotal'; }); | var $subtotals = $('tr td b').filter(function(i) { return $(this).text()=='£subtotal'; }); | ||
+ | var prior = ''; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
$subtotals.each(function(i, e) { | $subtotals.each(function(i, e) { | ||
Line 15: | Line 11: | ||
} | } | ||
− | |||
$costs = $('td:contains('+prior+')').nextAll('td:nth-child(7)'); | $costs = $('td:contains('+prior+')').nextAll('td:nth-child(7)'); | ||
var costotal = 0, cost = 0; | var costotal = 0, cost = 0; | ||
$costs.each(function(ci,ce) { | $costs.each(function(ci,ce) { | ||
cost = parseFloat($(ce).text().trim().replace('£','')); | cost = parseFloat($(ce).text().trim().replace('£','')); | ||
− | |||
− | |||
costotal += cost; | costotal += cost; | ||
− | |||
}); | }); | ||
− | $(e).text('£' + costotal | + | $(e).text('£' + costotal.toFixed(2)); |
− | + | ||
− | + | ||
}); | }); | ||
} | } |
Revision as of 08:45, 28 January 2018
if (mw.config.values.wgTitle == 'Wishlist') { var $subtotals = $('tr td b').filter(function(i) { return $(this).text()=='£subtotal'; }); var prior = ''; $subtotals.each(function(i, e) { if (prior=='') { prior = $(e).parent().parent().prev().children('td:nth-child(3)').text().trim(); } $costs = $('td:contains('+prior+')').nextAll('td:nth-child(7)'); var costotal = 0, cost = 0; $costs.each(function(ci,ce) { cost = parseFloat($(ce).text().trim().replace('£','')); costotal += cost; }); $(e).text('£' + costotal.toFixed(2)); }); }