aboutsummaryrefslogtreecommitdiffstats
path: root/public/js/report.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2014-08-08 07:11:56 -0700
committerAdam Soltys <[email protected]>2014-08-08 07:11:56 -0700
commit561ab2d01e059da44c0e5b34f5527fe946a1448c (patch)
tree6165fcae53610081d5f7f3ba8a5b4e56a57d14fb /public/js/report.js
parente1464288b2f53fd4c200d64df9a085dbb0ca80b7 (diff)
downloadcoinos-server-561ab2d01e059da44c0e5b34f5527fe946a1448c.tar.gz
coinos-server-561ab2d01e059da44c0e5b34f5527fe946a1448c.zip
Use connect-assets for js and css
Diffstat (limited to 'public/js/report.js')
-rw-r--r--public/js/report.js80
1 files changed, 0 insertions, 80 deletions
diff --git a/public/js/report.js b/public/js/report.js
deleted file mode 100644
index 69794ad5..00000000
--- a/public/js/report.js
+++ /dev/null
@@ -1,80 +0,0 @@
-(function() {
- var display, filterDates, g;
-
- g = typeof exports !== "undefined" && exports !== null ? exports : this;
-
- $(function() {
- var from, to;
- from = moment().subtract('days', 7);
- to = moment();
- $('#from').html(from.format("MMMM Do, YYYY"));
- $('#to').html(to.format("MMMM Do, YYYY"));
- $('#from_date').val(from.format("MM/DD/YYYY"));
- $('#to_date').val(to.format("MM/DD/YYYY"));
- $('#from_date').datepicker({
- onClose: filterDates
- });
- $('#to_date').datepicker({
- onClose: filterDates
- });
- $('#from').click(function() {
- return $('#from_date').datepicker('show');
- });
- $('#to').click(function() {
- return $('#to_date').datepicker('show');
- });
- return $.getJSON('transactions.json', function(data) {
- g.transactions = data.transactions;
- display(g.transactions);
- return filterDates();
- });
- });
-
- filterDates = function() {
- var transactions;
- $('#from').html(moment($('#from_date').datepicker('getDate')).format("MMMM Do, YYYY"));
- $('#to').html(moment($('#to_date').datepicker('getDate')).format("MMMM Do, YYYY"));
- transactions = $.grep(g.transactions, function(e, i) {
- var amount, d, from, to;
- if (!e) {
- return false;
- }
- from = moment($('#from_date').val(), "MM/DD/YYYY");
- to = moment($('#to_date').val(), "MM/DD/YYYY");
- d = moment(e.date);
- amount = parseFloat(e.exchange) * parseFloat(e.received);
- return !isNaN(parseFloat(amount)) && isFinite(amount) && ((from == null) || d.diff(from) >= 0) && ((to == null) || d.diff(to) <= 0);
- });
- return display(transactions);
- };
-
- display = function(transactions) {
- var btc, cad;
- $('.alert').remove();
- $('.report tbody tr').remove();
- $('.report').show();
- if (transactions.length === 0) {
- $('.report').before("<p class='alert alert-warning'>No transactions were found for the specified time period</p>");
- $('.report').hide();
- }
- $.each(transactions, function() {
- var amount, exchange, received;
- exchange = parseFloat(this.exchange);
- received = parseFloat(this.received);
- amount = received * exchange;
- received *= 1000;
- return $('.report tbody').append("<tr>\n <td>" + (moment(this.date, 'YYYY-MM-DD h:mm:ss').format('MMM D h:mma')) + "</td>\n <td>" + (exchange.toFixed(2)) + "</td>\n <td>" + (received.toFixed(5)) + "</td>\n <td>" + (amount.toFixed(2)) + "</td>\n</tr>");
- });
- btc = 0;
- $('table.report tbody td:nth-child(3)').each(function() {
- return btc += parseFloat($(this).html());
- });
- $('#btc').html(btc.toFixed(5));
- cad = 0;
- $('table.report tbody td:nth-child(4)').each(function() {
- return cad += parseFloat($(this).html());
- });
- return $('#cad').html(cad.toFixed(2));
- };
-
-}).call(this);