aboutsummaryrefslogtreecommitdiffstats
path: root/public/js/report.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2014-07-15 13:42:18 -0700
committerAdam Soltys <[email protected]>2014-07-15 13:42:18 -0700
commitdccd31c4f9fcdcccdd223c36e94e3705a59233d4 (patch)
treec9690311c18fa9ce87aff9b15155531446ca981d /public/js/report.js
parent3f803ad9cf8cbdd5a5bca6274b4908f08bf76232 (diff)
downloadcoinos-server-dccd31c4f9fcdcccdd223c36e94e3705a59233d4.tar.gz
coinos-server-dccd31c4f9fcdcccdd223c36e94e3705a59233d4.zip
Use buttons for transaction report dates
Diffstat (limited to 'public/js/report.js')
-rw-r--r--public/js/report.js37
1 files changed, 27 insertions, 10 deletions
diff --git a/public/js/report.js b/public/js/report.js
index 1fd882a7..09d16a6f 100644
--- a/public/js/report.js
+++ b/public/js/report.js
@@ -4,11 +4,25 @@
g = typeof exports !== "undefined" && exports !== null ? exports : this;
$(function() {
- $('#from').val(moment().subtract('days', 7).format("MM/DD/YYYY"));
- $('#to').val(moment().format("MM/DD/YYYY"));
- $('.date').datepicker({
+ 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);
@@ -18,13 +32,15 @@
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').val(), "MM/DD/YYYY");
- to = moment($('#to').val(), "MM/DD/YYYY");
+ 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);
@@ -34,11 +50,12 @@
display = function(transactions) {
var btc, cad;
- $('tbody tr').remove();
- $('thead, tfoot').show();
+ $('.alert').remove();
+ $('.report tbody tr').remove();
+ $('.report').show();
if (transactions.length === 0) {
- $('tbody').append("<tr>\n <td colspan='5'>\n No transactions were found for the specified time period\n </td>\n</tr>");
- $('thead, tfoot').hide();
+ $('.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;
@@ -46,7 +63,7 @@
received = parseFloat(this.received);
amount = received * exchange;
received *= 1000;
- return $('tbody').append("<tr>\n <td>" + this.date + "</td>\n <td>" + this.address + "</td>\n <td>" + (exchange.toFixed(2)) + "</td>\n <td>" + (received.toFixed(5)) + "</td>\n <td>" + (amount.toFixed(2)) + "</td>\n</tr>");
+ return $('.report tbody').append("<tr>\n <td>" + this.date + "</td>\n <td>" + this.address + "</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 td:nth-child(4)').each(function() {