From 5e2ff51b050d24dfec82358bc8ba675ec7f72f2b Mon Sep 17 00:00:00 2001 From: Mayel de Borniol Date: Mon, 30 Apr 2018 13:33:58 +0300 Subject: [PATCH] added totals --- extension/extension.js | 29 ++++++++++++++++++++++------- extension/manifest.json | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/extension/extension.js b/extension/extension.js index f982146..e9099e3 100644 --- a/extension/extension.js +++ b/extension/extension.js @@ -1,3 +1,7 @@ +var total_fair; +var total_euro; +var total_market; + $(function() { ajax({ @@ -19,18 +23,26 @@ $(function() { var heads = 'Official RateOfficial ValueMarket Value'; $("thead tr").append(heads); - $('tbody > tr').each(function() { + $('tbody').each(function() { + + total_fair = total_euro = total_market = 0; + + $(this).find('tr').each(function() { + + + var dateVar = $(this).find('td:first').text(); + var d = new Date(dateVar); + var dateISO = d.toISOString().slice(0, 10); + var faircoins = parseFloat($(this).find('td:nth-child(3)').text()); - var dateVar = $(this).find('td:first').text(); - var d = new Date(dateVar); - var dateISO = d.toISOString().slice(0, 10); + // $(this).append(''+faircoins+''); - var faircoins = $(this).find('td:nth-child(3)').text(); + calculateEuros(dateISO, faircoins, this); - // $(this).append(''+faircoins+''); + }); - calculateEuros(dateISO, faircoins, this); + $(this).append('Totals' + (Math.round(total_fair * 100) / 100) + ' FAIR€ ' + (Math.round(total_euro * 100) / 100) + '€ ' + (Math.round(total_market * 100) / 100) + ''); }); } @@ -64,6 +76,9 @@ $(function() { var euros = faircoins * selectedPriceData[3]; var market = faircoins * selectedPriceData[2]; + total_fair = total_fair+faircoins; + total_euro = total_euro+euros; + total_market = total_market+market; $(el).append('' + parseFloat(selectedPriceData[3]).toString() + ''); $(el).append('€ ' + (Math.round(euros * 100) / 100) + ''); diff --git a/extension/manifest.json b/extension/manifest.json index 5cebc19..8cc1021 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "FairCoin Calculator", - "version": "1.0", + "version": "1.1", "permissions": [ "webRequest", "",