2016-12-23 00:02:45 -06:00
|
|
|
/*
|
|
|
|
* index.js
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
|
|
|
*
|
|
|
|
* See the LICENSE file for details.
|
|
|
|
*/
|
2015-02-06 00:23:26 -06:00
|
|
|
|
2017-02-04 02:02:07 -06:00
|
|
|
/** global: Tour, showTour, accountFrontpageUri, token, billCount, accountExpenseUri, accountRevenueUri */
|
2017-01-02 03:34:01 -06:00
|
|
|
|
2015-06-27 05:21:04 -05:00
|
|
|
$(function () {
|
|
|
|
"use strict";
|
2015-08-01 00:22:48 -05:00
|
|
|
// do chart JS stuff.
|
|
|
|
drawChart();
|
2017-04-09 00:56:46 -05:00
|
|
|
if (showTour === true) {
|
2016-02-04 00:30:12 -06:00
|
|
|
$.getJSON('json/tour').done(function (data) {
|
2015-07-12 05:45:41 -05:00
|
|
|
var tour = new Tour(
|
|
|
|
{
|
|
|
|
steps: data.steps,
|
|
|
|
template: data.template,
|
|
|
|
onEnd: endTheTour
|
|
|
|
});
|
|
|
|
// Initialize the tour
|
|
|
|
tour.init();
|
|
|
|
// Start the tour
|
|
|
|
tour.start();
|
|
|
|
});
|
|
|
|
}
|
2015-07-11 03:01:13 -05:00
|
|
|
|
|
|
|
|
2015-06-27 05:21:04 -05:00
|
|
|
});
|
2015-02-06 00:23:26 -06:00
|
|
|
|
2015-07-12 05:45:41 -05:00
|
|
|
function endTheTour() {
|
|
|
|
"use strict";
|
2017-02-04 02:02:07 -06:00
|
|
|
$.post('json/end-tour', {_token: token});
|
2015-07-12 05:45:41 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-06 00:23:26 -06:00
|
|
|
function drawChart() {
|
2015-05-24 13:48:31 -05:00
|
|
|
"use strict";
|
2016-12-05 23:52:17 -06:00
|
|
|
lineChart(accountFrontpageUri, 'accounts-chart');
|
2016-11-22 12:10:38 -06:00
|
|
|
if (billCount > 0) {
|
|
|
|
pieChart('chart/bill/frontpage', 'bills-chart');
|
|
|
|
}
|
2016-11-16 13:35:25 -06:00
|
|
|
stackedColumnChart('chart/budget/frontpage', 'budgets-chart');
|
|
|
|
columnChart('chart/category/frontpage', 'categories-chart');
|
2016-12-05 23:52:17 -06:00
|
|
|
columnChart(accountExpenseUri, 'expense-accounts-chart');
|
|
|
|
columnChart(accountRevenueUri, 'revenue-accounts-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";
|
2015-04-11 00:24:07 -05:00
|
|
|
var boxes = ['in', 'out', 'bills-unpaid', 'bills-paid'];
|
2015-05-24 11:22:41 -05:00
|
|
|
for (var x in boxes) {
|
2017-01-02 03:34:01 -06:00
|
|
|
if (!boxes.hasOwnProperty(x)) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-03-06 01:20:27 -06:00
|
|
|
var box = boxes[x];
|
2016-02-04 00:30:12 -06:00
|
|
|
$.getJSON('json/box/' + box).done(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";
|
|
|
|
}
|