Some light refactoring. No changes.

This commit is contained in:
James Cole
2018-01-25 18:41:27 +01:00
parent 53fc4f2740
commit 7c70732247
28 changed files with 76 additions and 133 deletions

View File

@@ -36,7 +36,6 @@ $(function () {
Respond to changes in balance statements.
*/
$('input[type="number"]').on('change', function () {
console.log('On change number input.');
if (reconcileStarted) {
calculateBalanceDifference();
difference = balanceDifference - selectedAmount;
@@ -50,7 +49,6 @@ $(function () {
Respond to changes in the date range.
*/
$('input[type="date"]').on('change', function () {
console.log('On change date input.');
if (reconcileStarted) {
// hide original instructions.
$('.select_transactions_instruction').hide();
@@ -70,19 +68,16 @@ $(function () {
});
function storeReconcile() {
console.log('In storeReconcile.');
// get modal HTML:
var ids = [];
$.each($('.reconcile_checkbox:checked'), function (i, v) {
ids.push($(v).data('id'));
});
console.log('Ids is ' + ids);
var cleared = [];
$.each($('input[class="cleared"]'), function (i, v) {
var obj = $(v);
cleared.push(obj.data('id'));
});
console.log('Cleared is ' + ids);
var variables = {
startBalance: parseFloat($('input[name="start_balance"]').val()),
@@ -105,7 +100,6 @@ function storeReconcile() {
* @param e
*/
function checkReconciledBox(e) {
console.log('In checkReconciledBox.');
var el = $(e.target);
var amount = parseFloat(el.val());
// if checked, add to selected amount
@@ -125,13 +119,9 @@ function checkReconciledBox(e) {
* and put it in balanceDifference.
*/
function calculateBalanceDifference() {
console.log('In calculateBalanceDifference.');
var startBalance = parseFloat($('input[name="start_balance"]').val());
var endBalance = parseFloat($('input[name="end_balance"]').val());
balanceDifference = startBalance - endBalance;
//if (balanceDifference < 0) {
// balanceDifference = balanceDifference * -1;
//}
}
/**
@@ -139,7 +129,6 @@ function calculateBalanceDifference() {
* This more or less resets the reconciliation.
*/
function getTransactionsForRange() {
console.log('In getTransactionsForRange.');
// clear out the box:
$('#transactions_holder').empty().append($('<p>').addClass('text-center').html('<i class="fa fa-fw fa-spin fa-spinner"></i>'));
var uri = transactionsUri.replace('%start%', $('input[name="start_date"]').val()).replace('%end%', $('input[name="end_date"]').val());
@@ -154,7 +143,6 @@ function getTransactionsForRange() {
*
*/
function includeClearedTransactions() {
console.log('In includeClearedTransactions.');
$.each($('input[class="cleared"]'), function (i, v) {
var obj = $(v);
if (obj.data('younger') === false) {
@@ -168,7 +156,6 @@ function includeClearedTransactions() {
* @param data
*/
function placeTransactions(data) {
console.log('In placeTransactions.');
$('#transactions_holder').empty().html(data.html);
selectedAmount = 0;
// update start + end balance when user has not touched them.
@@ -200,7 +187,6 @@ function placeTransactions(data) {
* @returns {boolean}
*/
function startReconcile() {
console.log('In startReconcile.');
reconcileStarted = true;
// hide the start button.
@@ -222,7 +208,6 @@ function startReconcile() {
}
function updateDifference() {
console.log('In updateDifference.');
var addClass = 'text-info';
if (difference > 0) {
addClass = 'text-success';

View File

@@ -44,7 +44,6 @@ $(function () {
function startExport() {
"use strict";
console.log('startExport');
hideForm();
showLoading();
hideError();

View File

@@ -35,7 +35,6 @@ var knownErrors = 0;
$(function () {
"use strict";
console.log('in start');
timeOutId = setTimeout(checkJobStatus, startInterval);
$('.start-job').click(function () {
@@ -44,7 +43,6 @@ $(function () {
startJob();
});
if (job.configuration['auto-start']) {
console.log('Called startJob()!');
startJob();
}
});
@@ -53,7 +51,6 @@ $(function () {
* Downloads some JSON and responds to its content to see what the status is of the current import.
*/
function checkJobStatus() {
console.log('in checkJobStatus');
$.getJSON(jobStatusUri).done(reportOnJobStatus).fail(reportFailedJob);
}
@@ -61,7 +58,6 @@ function checkJobStatus() {
* This method is called when the JSON query returns an error. If possible, this error is relayed to the user.
*/
function reportFailedJob(jqxhr, textStatus, error) {
console.log('in reportFailedJob');
// hide all possible boxes:
$('.statusbox').hide();
@@ -81,7 +77,6 @@ function reportFailedJob(jqxhr, textStatus, error) {
* @param data
*/
function reportOnJobStatus(data) {
console.log('in reportOnJobStatus: ' + data.status);
switch (data.status) {
case "configured":
@@ -91,18 +86,13 @@ function reportOnJobStatus(data) {
$('.status_configured').show();
}
if (job.configuration['auto-start']) {
console.log('Job is auto start. Check status again in 500ms.');
timeOutId = setTimeout(checkJobStatus, interval);
}
if (pressedStart) {
console.log('pressedStart = true, will check extra.');
// do a time out just in case. Could be that job is running or is even done already.
timeOutId = setTimeout(checkJobStatus, 2000);
pressedStart = false;
}
if (!pressedStart) {
console.log('pressedStart = false, will do nothing.');
}
break;
case "running":
// job is running! Show the running box:
@@ -148,7 +138,6 @@ function reportOnJobStatus(data) {
break;
case "configuring":
// redirect back to configure screen.
console.log('Will now redirect to ' + jobConfigureUri);
window.location = jobConfigureUri;
break;
default:
@@ -192,9 +181,7 @@ function jobIsStalled(data) {
* Only when job is in "configured" state.
*/
function startJob() {
console.log("In startJob()");
if (job.status === "configured") {
console.log("Job started!");
// disable the button, add loading thing.
$('.start-job').prop('disabled', true).text('...');
$.post(jobStartUri, {_token: token}).fail(reportOnSubmitError);
@@ -203,7 +190,6 @@ function startJob() {
timeOutId = setTimeout(checkJobStatus, startInterval);
return;
}
console.log("Job not auto started because state is " + job.status);
}
/**