firefly-iii/public/js/index.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2015-06-27 05:04:53 -05:00
/* globals $, columnChart, google, lineChart, pieChart, stackedColumnChart, areaChart */
2015-02-06 00:23:26 -06:00
$(function () {
"use strict";
if (typeof google !== 'undefined') {
// do google charts:
google.setOnLoadCallback(drawChart);
} else {
// do chart JS stuff.
drawChart();
}
});
2015-02-06 00:23:26 -06:00
function drawChart() {
2015-05-24 13:48:31 -05:00
"use strict";
2015-06-27 05:04:53 -05:00
areaChart('chart/account/frontpage', 'accounts-chart');
pieChart('chart/bill/frontpage', 'bills-chart');
2015-06-27 10:32:52 -05:00
stackedColumnChart('chart/budget/frontpage', 'budgets-chart');
2015-06-27 05:04:53 -05:00
columnChart('chart/category/frontpage', 'categories-chart');
2015-05-16 02:57:31 -05:00
2015-03-06 01:20:27 -06:00
getBoxAmounts();
}
function getBoxAmounts() {
2015-05-24 11:22:41 -05:00
"use strict";
var boxes = ['in', 'out', 'bills-unpaid', 'bills-paid'];
2015-05-24 11:22:41 -05:00
for (var x in boxes) {
2015-03-06 01:20:27 -06:00
var box = boxes[x];
2015-05-24 11:22:41 -05:00
$.getJSON('/json/box/' + box).success(putData).fail(failData);
2015-03-06 01:20:27 -06:00
}
2015-02-06 00:23:26 -06:00
}
2015-05-24 11:22:41 -05:00
function putData(data) {
"use strict";
$('#box-' + data.box).html(data.amount);
}
function failData() {
"use strict";
console.log('Failed to get box!');
}