Browse Source

added totals

pull/1/head
Mayel de Borniol 6 years ago
parent
commit
5e2ff51b05
2 changed files with 23 additions and 8 deletions
  1. +22
    -7
      extension/extension.js
  2. +1
    -1
      extension/manifest.json

+ 22
- 7
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 = '<th>Official Rate</th><th>Official Value</th><th>Market Value</th>';
$("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('<td>'+faircoins+'</td>');
var faircoins = $(this).find('td:nth-child(3)').text();
calculateEuros(dateISO, faircoins, this);
// $(this).append('<td>'+faircoins+'</td>');
});
calculateEuros(dateISO, faircoins, this);
$(this).append('<tr><td><strong>Totals</strong></td><td></td><td>' + (Math.round(total_fair * 100) / 100) + ' FAIR</td><td></td><td>€ ' + (Math.round(total_euro * 100) / 100) + '</td><td>€ ' + (Math.round(total_market * 100) / 100) + '</td></tr>');
});
}
@ -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('<td>' + parseFloat(selectedPriceData[3]).toString() + '</td>');
$(el).append('<td>€ ' + (Math.round(euros * 100) / 100) + '</td>');

+ 1
- 1
extension/manifest.json

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "FairCoin Calculator",
"version": "1.0",
"version": "1.1",
"permissions": [
"webRequest",
"<all_urls>",

Loading…
Cancel
Save