Update javascript code.

This commit is contained in:
James Cole 2017-01-02 08:30:20 +01:00
parent 3cd0540474
commit 533797fc9e
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
23 changed files with 24 additions and 110 deletions

View File

@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: chartUri, incomeCategoryUri, expenseCategoryUri, expenseBudgetUri */
var fixHelper = function (e, tr) {
"use strict";
var $originals = tr.children();
@ -53,8 +55,6 @@ $(function () {
}
}
).disableSelection();
} else {
console.log('its null');
}
});
@ -62,7 +62,6 @@ $(function () {
function sortStop(event, ui) {
"use strict";
var current = $(ui.item);
console.log('sort stop');
var thisDate = current.data('date');
var originalBG = current.css('backgroundColor');
@ -86,7 +85,7 @@ function sortStop(event, ui) {
});
// do extra animation when done?
$.post('transactions/reorder', {items: submit, date: thisDate, _token: token});
$.post('transactions/reorder', {items: submit, date: thisDate});
current.animate({backgroundColor: "#5cb85c"}, 200, function () {
$(this).animate({backgroundColor: originalBG}, 200);

View File

@ -8,7 +8,7 @@
* See the LICENSE file for details.
*/
/* global comboChart, billID */
/** global: billUri */
$(function () {
"use strict";

View File

@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: spent, budgeted, available, currencySymbol */
function drawSpentBar() {
"use strict";
if ($('.spentBar').length > 0) {
@ -79,11 +81,6 @@ function updateBudgetedAmounts(e) {
}
});
}
console.log('Budget id is ' + id);
console.log('Difference = ' + (value - original ));
}
$(function () {
@ -102,17 +99,6 @@ $(function () {
*/
$('input[type="number"]').on('input', updateBudgetedAmounts);
/*
Draw the charts, if necessary:
*/
if (typeof budgetID !== 'undefined' && typeof repetitionID === 'undefined') {
columnChart('chart/budget/' + budgetID, 'budgetOverview');
}
if (typeof budgetID !== 'undefined' && typeof repetitionID !== 'undefined') {
lineChart('chart/budget/' + budgetID + '/' + repetitionID, 'budgetOverview');
}
});
function updateIncome() {

View File

@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: budgetChartUri */
$(function () {
"use strict";

View File

@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: specific */
$(function () {
"use strict";
columnChart(specific, 'period-specific-period');

View File

@ -125,7 +125,6 @@ function doubleYChart(URI, container) {
];
options.stacked = true;
options.scales.xAxes[0].stacked = true;
// console.log(options);
var chartType = 'bar';
@ -240,7 +239,6 @@ function pieChart(URI, container) {
*/
function drawAChart(URI, container, chartType, options, colorData) {
if ($('#' + container).length === 0) {
console.log('No container called ' + container + ' was found.');
return;
}
@ -249,7 +247,6 @@ function drawAChart(URI, container, chartType, options, colorData) {
if (data.labels.length === 0) {
console.log(chartType + " chart in " + container + " has no data.");
// remove the chart container + parent
var holder = $('#' + container).parent().parent();
if (holder.hasClass('box') || holder.hasClass('box-body')) {
@ -261,8 +258,6 @@ function drawAChart(URI, container, chartType, options, colorData) {
boxBody = holder;
}
boxBody.empty().append($('<p>').append($('<em>').text(noDataForChart)));
} else {
console.log("Want to add text but holder has classes: " + holder.attr("class"));
}
return;
}
@ -273,13 +268,11 @@ function drawAChart(URI, container, chartType, options, colorData) {
}
if (allCharts.hasOwnProperty(container)) {
console.log('Will draw updated ' + chartType + ' chart');
allCharts[container].data.datasets = data.datasets;
allCharts[container].data.labels = data.labels;
allCharts[container].update();
} else {
// new chart!
console.log('Will draw new ' + chartType + 'chart');
var ctx = document.getElementById(container).getContext("2d");
allCharts[container] = new Chart(ctx, {
type: chartType,
@ -289,8 +282,6 @@ function drawAChart(URI, container, chartType, options, colorData) {
}
}).fail(function () {
console.log('Failed to draw ' + chartType + ' in container ' + container);
$('#' + container).addClass('general-chart-error');
});
console.log('URL for ' + chartType + ' chart : ' + URI);
}

View File

@ -24,7 +24,6 @@ $(function () {
function startExport() {
"use strict";
console.log('Start export...');
hideForm();
showLoading();
hideError();
@ -75,15 +74,12 @@ function showError(text) {
function callExport() {
"use strict";
console.log('Start callExport()...')
var data = $('#export').serialize();
// call status, keep calling it until response is "finished"?
intervalId = window.setInterval(checkStatus, 500);
$.post('export/submit', data).done(function (data) {
console.log('Export hath succeeded!');
// stop polling:
window.clearTimeout(intervalId);
@ -114,7 +110,6 @@ function callExport() {
function checkStatus() {
"use strict";
console.log('get status...');
$.getJSON('export/status/' + jobKey).done(function (data) {
putStatusText(data.status);
});

View File

@ -11,6 +11,12 @@
$(function () {
"use strict";
$.ajaxSetup({
headers: {
'X-CSRF-Token': $('meta[name="_token"]').attr('content')
}
});
// when you click on a currency, this happens:
$('.currency-option').click(currencySelect);
@ -49,18 +55,12 @@ $(function () {
$.post(dateRangeConfig.URL, {
start: start.format('YYYY-MM-DD'),
end: end.format('YYYY-MM-DD'),
label: label,
_token: token
label: label
}).done(function () {
console.log('Succesfully sent new date range [' + start.format('YYYY-MM-DD') + '-' + end.format('YYYY-MM-DD') + '].');
window.location.reload(true);
}).fail(function () {
console.log('Could not send new date range.');
alert('Could not change date range');
});
//alert('A date range was chosen: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
}
);
@ -133,7 +133,6 @@ function triggerList(e) {
"use strict";
var link = $(e.target);
var table = link.parent().parent().parent().parent();
console.log('data-hidden = ' + table.attr('data-hidden'));
if (table.attr('data-hidden') === 'no') {
// hide all elements, return false.
table.find('.overListLength').hide();

View File

@ -28,20 +28,17 @@ $(function () {
function checkImportStatus() {
"use strict";
console.log('checkImportStatus()');
$.getJSON(jobImportUrl).done(reportOnJobImport).fail(failedJobImport);
}
function importComplete(data) {
"use strict";
console.log('importComplete()');
var bar = $('#import-status-bar');
bar.removeClass('active');
}
function updateBar(data) {
"use strict";
console.log('updateBar()');
var bar = $('#import-status-bar');
if (data.showPercentage) {
bar.addClass('progress-bar-success').removeClass('progress-bar-info');
@ -63,7 +60,6 @@ function updateBar(data) {
function reportErrors(data) {
"use strict";
console.log('reportErrors()');
if (data.errors.length == 1) {
$('#import-status-error-intro').text(langImportSingleError);
//'An error has occured during the import. The import can continue, however.'
@ -83,21 +79,18 @@ function reportErrors(data) {
function reportStatus(data) {
"use strict";
console.log('reportStatus()');
$('#import-status-txt').removeClass('text-danger').text(data.statusText);
}
function kickStartJob() {
"use strict";
console.log('kickStartJob()');
$.post(jobStartUrl, {_token: token});
$.post(jobStartUrl);
startedTheImport();
startedImport = true;
}
function updateTimeout(data) {
"use strict";
console.log('updateTimeout()');
if (data.stepsDone != stepCount) {
stepCount = data.stepsDone;
currentLimit = 0;
@ -105,12 +98,10 @@ function updateTimeout(data) {
}
currentLimit = currentLimit + interval;
// console.log("stepCount: " + stepCount + ", stepsDone: " + data.stepsDone + ", currentLimit: " + currentLimit);
}
function timeoutError() {
"use strict";
console.log('timeoutError()');
// set status
$('#import-status-txt').addClass('text-danger').text(langImportTimeOutError);
@ -121,13 +112,11 @@ function timeoutError() {
function importJobFinished(data) {
"use strict";
console.log('importJobFinished() = ' + data.finished);
return data.finished;
}
function finishedJob(data) {
"use strict";
console.log('finishedJob()');
// "There was an error during the import routine. Please check the log files. The error seems to be: '"
$('#import-status-txt').removeClass('text-danger').addClass('text-success').text(langImportFinished);
@ -142,7 +131,6 @@ function finishedJob(data) {
function reportOnJobImport(data) {
"use strict";
console.log('reportOnJobImport()');
updateBar(data);
reportErrors(data);
reportStatus(data);
@ -173,13 +161,11 @@ function reportOnJobImport(data) {
function startedTheImport() {
"use strict";
console.log('startedTheImport()');
setTimeout(checkImportStatus, interval);
}
function failedJobImport(jqxhr, textStatus, error) {
"use strict";
console.log('failedJobImport()');
// set status
// "There was an error during the import routine. Please check the log files. The error seems to be: '"
$('#import-status-txt').addClass('text-danger').text(langImportFatalError + ' ' + textStatus + ' ' + error);

View File

@ -24,8 +24,6 @@ $(function () {
tour.init();
// Start the tour
tour.start();
}).fail(function () {
console.log('Already had tour.');
});
}
@ -34,7 +32,7 @@ $(function () {
function endTheTour() {
"use strict";
$.post('json/end-tour', {_token: token});
$.post('json/end-tour');
}
@ -69,5 +67,4 @@ function putData(data) {
function failData() {
"use strict";
console.log('Failed to get box!');
}

View File

@ -78,7 +78,7 @@ function stopSorting() {
var id = holder.data('id');
order.push(id);
});
$.post('piggy-banks/sort', {_token: token, order: order}).done(function () {
$.post('piggy-banks/sort', {order: order}).done(function () {
$('.loadSpin').removeClass('fa fa-refresh fa-spin');
});
}

View File

@ -18,7 +18,6 @@ $(function () {
arr.forEach(function (val) {
$('input[type="checkbox"][value="' + val + '"]').prop('checked', true);
});
console.log('arr from cookie is ' + arr)
} else {
// no cookie? read list, store in array 'arr'
// all account ids:
@ -45,7 +44,6 @@ function clickColumnOption() {
function storeCheckboxes(checkboxes) {
"use strict";
// store new cookie with those options:
console.log('Store new cookie with those options: ' + checkboxes);
createCookie('audit-option-checkbox', checkboxes, 365);
}
@ -59,7 +57,6 @@ function readCheckboxes() {
checkboxes.push(c.val());
}
});
console.log('arr is now (default): ' + checkboxes);
return checkboxes;
}
@ -69,11 +66,9 @@ function showOnlyColumns(checkboxes) {
for (var i = 0; i < hideable.length; i++) {
var opt = hideable[i];
if(checkboxes.indexOf(opt) > -1) {
console.log(opt + ' is in checkboxes');
$('td.hide-' + opt).show();
$('th.hide-' + opt).show();
} else {
console.log(opt + ' is NOT in checkboxes');
$('th.hide-' + opt).hide();
$('td.hide-' + opt).hide();
}

View File

@ -47,7 +47,6 @@ function redrawPieChart(container, uri) {
others = '1';
}
uri = uri.replace('OTHERS', others);
console.log('URI for ' + container + ' is ' + uri);
pieChart(uri, container);

View File

@ -57,7 +57,6 @@ function redrawPieChart(container, uri) {
others = '1';
}
uri = uri.replace('OTHERS', others);
console.log('URI for ' + container + ' is ' + uri);
pieChart(uri, container);

View File

@ -62,7 +62,6 @@ function respondInfoButton(data) {
function loadAjaxPartial(holder, uri) {
"use strict";
console.log('Going to grab URI ' + uri);
$.get(uri).done(function (data) {
displayAjaxPartial(data, holder);
}).fail(function () {
@ -72,7 +71,6 @@ function loadAjaxPartial(holder, uri) {
function displayAjaxPartial(data, holder) {
"use strict";
console.log('Display stuff in ' + holder);
var obj = $('#' + holder);
obj.removeClass('loading').html(data);
@ -98,7 +96,6 @@ function displayAjaxPartial(data, holder) {
function failAjaxPartial(uri, holder) {
"use strict";
console.log('Failed to load: ' + uri);
$('#' + holder).removeClass('loading').addClass('general-chart-error');
}

View File

@ -26,7 +26,6 @@ $(function () {
// set values from cookies, if any:
if (!(readCookie('report-type') === null)) {
console.log(readCookie('report-type'));
$('select[name="report_type"]').val(readCookie('report-type'));
}
@ -61,7 +60,6 @@ function getReportOptions() {
var reportType = $('select[name="report_type"]').val();
$('#extra-options').empty();
$('#extra-options').addClass('loading');
console.log('Changed report type to ' + reportType);
$.getJSON('reports/options/' + reportType, function (data) {
$('#extra-options').removeClass('loading').html(data.html);

View File

@ -11,12 +11,6 @@
var triggerCount = 0;
var actionCount = 0;
$(function () {
"use strict";
console.log('edit-create');
});
function addNewTrigger() {
"use strict";
triggerCount++;
@ -41,7 +35,6 @@ function addNewAction() {
actionCount++;
$.getJSON('json/action', {count: actionCount}).done(function (data) {
//console.log(data.html);
$('tbody.rule-action-tbody').append(data.html);
// add action things.

View File

@ -10,7 +10,6 @@
$(function () {
"use strict";
console.log("create");
if (triggerCount === 0) {
addNewTrigger();
}

View File

@ -10,8 +10,6 @@
$(function () {
"use strict";
console.log("edit");
if (triggerCount === 0) {
addNewTrigger();
}

View File

@ -48,7 +48,6 @@ function sortStop(event, ui) {
var ruleId = current.parent().data('id');
var entries = [];
// who am i?
console.log('Rule: #' + current.parent().data('id'));
$.each(parent.children(), function (i, v) {
var trigger = $(v);
@ -58,11 +57,11 @@ function sortStop(event, ui) {
});
if (parent.hasClass('rule-triggers')) {
$.post('rules/trigger/order/' + ruleId, {_token: token, triggers: entries}).fail(function () {
$.post('rules/trigger/order/' + ruleId, {triggers: entries}).fail(function () {
alert('Could not re-order rule triggers. Please refresh the page.');
});
} else {
$.post('rules/action/order/' + ruleId, {_token: token, actions: entries}).fail(function () {
$.post('rules/action/order/' + ruleId, {actions: entries}).fail(function () {
alert('Could not re-order rule actions. Please refresh the page.');
});

View File

@ -18,19 +18,16 @@ $(function () {
$.getJSON('json/expense-accounts').done(function (data) {
destAccounts = data;
console.log('destAccounts length is now ' + destAccounts.length);
$('input[name$="destination_account_name]"]').typeahead({source: destAccounts});
});
$.getJSON('json/revenue-accounts').done(function (data) {
srcAccounts = data;
console.log('srcAccounts length is now ' + srcAccounts.length);
$('input[name$="source_account_name]"]').typeahead({source: srcAccounts});
});
$.getJSON('json/categories').done(function (data) {
categories = data;
console.log('categories length is now ' + categories.length);
$('input[name$="category]"]').typeahead({source: categories});
});
@ -45,12 +42,10 @@ function removeRow(e) {
"use strict";
var rows = $('table.split-table tbody tr');
if (rows.length === 1) {
console.log('Will not remove last split');
return false;
}
var row = $(e.target);
var index = row.data('split');
console.log('Trying to remove row with split ' + index);
$('table.split-table tbody tr[data-split="' + index + '"]').remove();
@ -70,16 +65,13 @@ function cloneRow() {
source.find('input[name$="][amount]"]').val("").on('input', calculateSum);
if (destAccounts.length > 0) {
console.log('Will be able to extend dest-accounts.');
source.find('input[name$="destination_account_name]"]').typeahead({source: destAccounts});
}
if (destAccounts.length > 0) {
console.log('Will be able to extend src-accounts.');
source.find('input[name$="source_account_name]"]').typeahead({source: srcAccounts});
}
if (categories.length > 0) {
console.log('Will be able to extend categories.');
source.find('input[name$="category]"]').typeahead({source: categories});
}
@ -103,7 +95,6 @@ function resetSplits() {
$.each($('table.split-table tbody tr'), function (i, v) {
var row = $(v);
row.attr('data-split', i);
console.log('Row is now ' + row.data('split'));
});
// loop each remove button, update the index
@ -111,7 +102,6 @@ function resetSplits() {
var button = $(v);
button.attr('data-split', i);
button.find('i').attr('data-split', i);
console.log('Remove button index is now ' + button.data('split'));
});
@ -120,7 +110,6 @@ function resetSplits() {
var cell = $(v);
var index = i + 1;
cell.text('#' + index);
console.log('Cell is now ' + cell.text());
});
// loop each possible field.
@ -129,37 +118,31 @@ function resetSplits() {
$.each($('input[name$="][description]"]'), function (i, v) {
var input = $(v);
input.attr('name', 'transactions[' + i + '][description]');
console.log('description is now ' + input.attr('name'));
});
// ends with ][destination_account_name]
$.each($('input[name$="][destination_account_name]"]'), function (i, v) {
var input = $(v);
input.attr('name', 'transactions[' + i + '][destination_account_name]');
console.log('destination_account_name is now ' + input.attr('name'));
});
// ends with ][source_account_name]
$.each($('input[name$="][source_account_name]"]'), function (i, v) {
var input = $(v);
input.attr('name', 'transactions[' + i + '][source_account_name]');
console.log('source_account_name is now ' + input.attr('name'));
});
// ends with ][amount]
$.each($('input[name$="][amount]"]'), function (i, v) {
var input = $(v);
input.attr('name', 'transactions[' + i + '][amount]');
console.log('amount is now ' + input.attr('name'));
});
// ends with ][budget_id]
$.each($('select[name$="][budget_id]"]'), function (i, v) {
var input = $(v);
input.attr('name', 'transactions[' + i + '][budget_id]');
console.log('budget_id is now ' + input.attr('name'));
});
// ends with ][category]
$.each($('input[name$="][category]"]'), function (i, v) {
var input = $(v);
input.attr('name', 'transactions[' + i + '][category]');
console.log('category is now ' + input.attr('name'));
});
}
@ -173,10 +156,8 @@ function calculateSum() {
}
sum = Math.round(sum * 100) / 100;
console.log("Sum is now " + sum);
$('.amount-warning').remove();
if (sum != originalSum) {
console.log(sum + ' does not match ' + originalSum);
var holder = $('#journal_amount_holder');
var par = holder.find('p.form-control-static');
var amount = $('<span>').text(' (' + accounting.formatMoney(sum) + ')').addClass('text-danger amount-warning').appendTo(par);

View File

@ -111,7 +111,6 @@ function updateButtons() {
if (button.data('what') == what) {
button.removeClass('btn-default').addClass('btn-info').html('<i class="fa fa-fw fa-check"></i> ' + txt[button.data('what')]);
console.log('Now displaying form for ' + what);
} else {
button.removeClass('btn-info').addClass('btn-default').text(txt[button.data('what')]);
}

View File

@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="_token" content="{{ csrf_token() }}">
<meta name="robots" content="noindex, nofolllow, noarchive, noodp, NoImageIndex, noydir">
<title>
{% if subTitle %}
@ -197,8 +198,7 @@
toLabel: '{{ 'to'|_|escape }}',
ranges: {{ dpRanges|json_encode|raw }}
};
var token = "{{ csrf_token() }}";
var language = "{{ language|escape }}";
var currencyCode = '{{ getCurrencyCode()|escape('js') }}';
var currencySymbol = '{{ getCurrencySymbol()|escape('js') }}';