This should fix most Javascript errors.

This commit is contained in:
James Cole
2017-01-02 10:34:01 +01:00
parent 36f1b6a834
commit f8268a864b
26 changed files with 102 additions and 51 deletions

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: accounting */
var defaultChartOptions = {
scales: {
xAxes: [
@@ -20,7 +22,7 @@ var defaultChartOptions = {
yAxes: [{
display: true,
ticks: {
callback: function (tickValue, index, ticks) {
callback: function (tickValue) {
"use strict";
return accounting.formatMoney(tickValue);

View File

@@ -7,7 +7,7 @@
*
* See the LICENSE file for details.
*/
/** global: Chart, defaultChartOptions, accounting, defaultPieOptions, noDataForChart */
var allCharts = {};
/*
@@ -97,7 +97,7 @@ function doubleYChart(URI, container) {
{
display: true,
ticks: {
callback: function (tickValue, index, ticks) {
callback: function (tickValue) {
"use strict";
return accounting.formatMoney(tickValue);
@@ -111,7 +111,7 @@ function doubleYChart(URI, container) {
{
display: true,
ticks: {
callback: function (tickValue, index, ticks) {
callback: function (tickValue) {
"use strict";
return accounting.formatMoney(tickValue);

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: jobKey */
var intervalId = 0;
$(function () {
@@ -79,7 +81,7 @@ function callExport() {
// call status, keep calling it until response is "finished"?
intervalId = window.setInterval(checkStatus, 500);
$.post('export/submit', data).done(function (data) {
$.post('export/submit', data).done(function () {
// stop polling:
window.clearTimeout(intervalId);

View File

@@ -7,6 +7,8 @@
*
* See the LICENSE file for details.
*/
/** global: moment, dateRangeConfig, accounting, currencySymbol, mon_decimal_point, frac_digits, showFullList, showOnlyTop */
$(function () {
"use strict";

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: jobImportUrl, langImportSingleError, langImportMultiError, jobStartUrl, langImportTimeOutError, langImportFinished, langImportFatalError */
var startedImport = false;
var startInterval = 2000;
var interval = 500;
@@ -31,7 +33,7 @@ function checkImportStatus() {
$.getJSON(jobImportUrl).done(reportOnJobImport).fail(failedJobImport);
}
function importComplete(data) {
function importComplete() {
"use strict";
var bar = $('#import-status-bar');
bar.removeClass('active');

View File

@@ -8,11 +8,13 @@
* See the LICENSE file for details.
*/
/** global: Tour, showTour, accountFrontpageUri, billCount, accountExpenseUri, accountRevenueUri */
$(function () {
"use strict";
// do chart JS stuff.
drawChart();
if (showTour) {
if (showTour == true) {
$.getJSON('json/tour').done(function (data) {
var tour = new Tour(
{
@@ -55,6 +57,9 @@ function getBoxAmounts() {
"use strict";
var boxes = ['in', 'out', 'bills-unpaid', 'bills-paid'];
for (var x in boxes) {
if (!boxes.hasOwnProperty(x)) {
continue;
}
var box = boxes[x];
$.getJSON('json/box/' + box).done(putData).fail(failData);
}

View File

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

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: hideable */
$(function () {
"use strict";
@@ -65,7 +67,7 @@ function showOnlyColumns(checkboxes) {
for (var i = 0; i < hideable.length; i++) {
var opt = hideable[i];
if(checkboxes.indexOf(opt) > -1) {
if (checkboxes.indexOf(opt) > -1) {
$('td.hide-' + opt).show();
$('th.hide-' + opt).show();
} else {
@@ -96,8 +98,12 @@ function readCookie(name) {
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0) return decodeURIComponent(c.substring(nameEQ.length, c.length));
while (c.charAt(0) === ' ') {
c = c.substring(1, c.length);
}
if (c.indexOf(nameEQ) === 0) {
return decodeURIComponent(c.substring(nameEQ.length, c.length));
}
}
return null;
}

View File

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

View File

@@ -8,6 +8,7 @@
* See the LICENSE file for details.
*/
/** global: categoryIncomeUri, categoryExpenseUri, accountIncomeUri, accountExpenseUri, mainUri */
$(function () {
"use strict";

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: accountReportUri, incomeReportUri, expenseReportUri, incExpReportUri, startDate, endDate, accountIds */
$(function () {
"use strict";
@@ -45,7 +47,7 @@ function clickInfoButton(e) {
$.getJSON('popup/general', {attributes: attributes}).done(respondInfoButton).fail(errorInfoButton);
}
function errorInfoButton(data) {
function errorInfoButton() {
"use strict";
// remove wait cursor
$('body').removeClass('waiting');

View File

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

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: budgetPeriodReportUri, categoryExpenseUri, categoryIncomeUri, netWorthUri, opChartUri, sumChartUri */
$(function () {
"use strict";
drawChart();

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: budgetPeriodReportUri, categoryExpenseUri, categoryIncomeUri, netWorthUri, opChartUri, sumChartUri */
$(function () {
"use strict";
drawChart();

View File

@@ -8,12 +8,14 @@
* See the LICENSE file for details.
*/
/** global: minDate */
$(function () {
"use strict";
if ($('#inputDateRange').length > 0) {
picker = $('#inputDateRange').daterangepicker(
var picker = $('#inputDateRange').daterangepicker(
{
locale: {
format: 'YYYY-MM-DD',
@@ -168,8 +170,12 @@ function readCookie(name) {
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0) return decodeURIComponent(c.substring(nameEQ.length, c.length));
while (c.charAt(0) === ' ') {
c = c.substring(1, c.length);
}
if (c.indexOf(nameEQ) === 0) {
return decodeURIComponent(c.substring(nameEQ.length, c.length));
}
}
return null;
}

View File

@@ -52,14 +52,14 @@ function addNewAction() {
function removeTrigger(e) {
"use strict";
var target = $(e.target);
if(target.prop("tagName") == "I") {
if (target.prop("tagName") == "I") {
target = target.parent();
}
// remove grand parent:
target.parent().parent().remove();
// if now at zero, immediatly add one again:
if($('.rule-trigger-tbody tr').length == 0) {
if ($('.rule-trigger-tbody tr').length == 0) {
addNewTrigger();
}
}
@@ -67,42 +67,41 @@ function removeTrigger(e) {
function removeAction(e) {
"use strict";
var target = $(e.target);
if(target.prop("tagName") == "I") {
if (target.prop("tagName") == "I") {
target = target.parent();
}
// remove grand parent:
target.parent().parent().remove();
// if now at zero, immediatly add one again:
if($('.rule-action-tbody tr').length == 0) {
if ($('.rule-action-tbody tr').length == 0) {
addNewAction();
}
}
function testRuleTriggers() {
"use strict";
// Serialize all trigger data
var triggerData = $( ".rule-trigger-tbody" ).find( "input[type=text], input[type=checkbox], select" ).serializeArray();
// Find a list of existing transactions that match these triggers
"use strict";
// Serialize all trigger data
var triggerData = $(".rule-trigger-tbody").find("input[type=text], input[type=checkbox], select").serializeArray();
// Find a list of existing transactions that match these triggers
$.get('rules/test', triggerData).done(function (data) {
var modal = $( "#testTriggerModal" );
var numTriggers = $( ".rule-trigger-body > tr" ).length;
// Set title and body
modal.find( ".transactions-list" ).html(data.html);
// Show warning if appropriate
if( data.warning ) {
modal.find( ".transaction-warning .warning-contents" ).text(data.warning);
modal.find( ".transaction-warning" ).show();
} else {
modal.find( ".transaction-warning" ).hide();
}
// Show the modal dialog
$( "#testTriggerModal" ).modal();
var modal = $("#testTriggerModal");
// Set title and body
modal.find(".transactions-list").html(data.html);
// Show warning if appropriate
if (data.warning) {
modal.find(".transaction-warning .warning-contents").text(data.warning);
modal.find(".transaction-warning").show();
} else {
modal.find(".transaction-warning").hide();
}
// Show the modal dialog
$("#testTriggerModal").modal();
}).fail(function () {
alert('Cannot get transactions for given triggers.');
});

View File

@@ -8,6 +8,9 @@
* See the LICENSE file for details.
*/
/** global: triggerCount, actionCount */
$(function () {
"use strict";
if (triggerCount === 0) {

View File

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

View File

@@ -52,7 +52,6 @@ function sortStop(event, ui) {
$.each(parent.children(), function (i, v) {
var trigger = $(v);
var id = trigger.data('id');
var order = i + 1;
entries.push(id);
});

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: originalSum, amount, accounting */
var destAccounts = {};
var srcAccounts = {};
var categories = {};

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: zoomLevel, latitude, longitude, google */
$(function () {
"use strict";
@@ -60,12 +62,12 @@ function initialize() {
Respond to zoom event.
*/
google.maps.event.addListener(map, 'zoom_changed', function () {
saveZoomLevel(event);
saveZoomLevel();
});
/*
Maybe place marker?
*/
if(doPlaceMarker) {
if(doPlaceMarker == true) {
var myLatlng = new google.maps.LatLng(latitude,longitude);
var fakeEvent = {};
fakeEvent.latLng = myLatlng;

View File

@@ -7,6 +7,7 @@
*
* See the LICENSE file for details.
*/
/** global: zoomLevel, latitude, longitude, google */
$(function () {
"use strict";
@@ -60,12 +61,12 @@ function initialize() {
Respond to zoom event.
*/
google.maps.event.addListener(map, 'zoom_changed', function () {
saveZoomLevel(event);
saveZoomLevel();
});
/*
Maybe place marker?
*/
if(doPlaceMarker) {
if(doPlaceMarker == true) {
var myLatlng = new google.maps.LatLng(latitude,longitude);
var fakeEvent = {};
fakeEvent.latLng = myLatlng;

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: zoomLevel, latitude, longitude, google */
$(function () {
"use strict";
@@ -60,12 +62,12 @@ function initialize() {
Respond to zoom event.
*/
google.maps.event.addListener(map, 'zoom_changed', function () {
saveZoomLevel(event);
saveZoomLevel();
});
/*
Maybe place marker?
*/
if(doPlaceMarker) {
if(doPlaceMarker == true) {
var myLatlng = new google.maps.LatLng(latitude,longitude);
var fakeEvent = {};
fakeEvent.latLng = myLatlng;

View File

@@ -58,19 +58,19 @@ $(document).ready(function () {
}
if ($('input[name="description"]').length > 0 && what !== undefined) {
if ($('input[name="description"]').length > 0 && !(typeof what === "undefined")) {
$.getJSON('json/transaction-journals/' + what).done(function (data) {
$('input[name="description"]').typeahead({source: data});
});
}
// also for multi input:
if ($('input[name="description[]"]').length > 0 && what !== undefined) {
if ($('input[name="description[]"]').length > 0 && !(typeof what === "undefined")) {
$.getJSON('json/transaction-journals/' + what).done(function (data) {
$('input[name="description[]"]').typeahead({source: data});
});
}
// and for the (rare) journal_description:
if ($('input[name="journal_description"]').length > 0 && what !== undefined) {
if ($('input[name="journal_description"]').length > 0 && !(typeof what === "undefined")) {
$.getJSON('json/transaction-journals/' + what).done(function (data) {
$('input[name="journal_description"]').typeahead({source: data});
});

View File

@@ -8,12 +8,14 @@
* See the LICENSE file for details.
*/
/** global: what, title, breadcrumbs, middleCrumbName, button, piggiesLength, txt */
$(document).ready(function () {
"use strict";
// respond to switch buttons when
// creating stuff:
if (doSwitch) {
if (doSwitch == true) {
updateButtons();
updateForm();
updateLayout();
@@ -35,6 +37,7 @@ function updateForm() {
$('input[name="what"]').val(what);
switch (what) {
default:
case 'withdrawal':
// show source_id and dest_name:
$('#source_account_id_holder').show();

View File

@@ -8,6 +8,8 @@
* See the LICENSE file for details.
*/
/** global: edit_selected_txt, delete_selected_txt */
$(document).ready(function () {
"use strict";
$('.mass_edit_all').show();