From b94145ff904315c48781f958f54fae1428ef60e6 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 23 Oct 2012 10:28:49 -0700 Subject: Clean up report, save transactions as JSON --- js/report.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 js/report.js (limited to 'js/report.js') diff --git a/js/report.js b/js/report.js new file mode 100644 index 00000000..6cacf077 --- /dev/null +++ b/js/report.js @@ -0,0 +1,29 @@ +$(function() { + $('#date').datepicker(); + + $.getJSON('transactions.json', function(data) { + $.each(data.transactions, function() { + var keys = Object.keys(this); + var transaction = this; + + $.each(keys, function(i,v) { + $('tbody tr:last td:eq(' + i + ')').html(transaction[v]); + }); + + $('tbody:last').append($('tbody tr:last').clone()); + }); + $('tbody tr:last').remove(); + + var btc = 0; + $('td:nth-child(4)').each(function() { + btc += parseFloat($(this).html()); + }); + $('#btc').html(btc); + + var cad = 0; + $('td:nth-child(5)').each(function() { + cad += parseFloat($(this).html()); + }); + $('#cad').html(cad); + }); +}); -- cgit v1.2.3