Remove debug statements.

This commit is contained in:
James Cole 2017-01-30 08:32:16 +01:00
parent 7688d7c619
commit c7fc10ac89
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -13,20 +13,16 @@
$(function () { $(function () {
"use strict"; "use strict";
if (triggerCount === 0) { if (triggerCount === 0) {
console.log('addNewTrigger() because count is zero');
addNewTrigger(); addNewTrigger();
} }
if (actionCount === 0) { if (actionCount === 0) {
console.log('addNewAction() because count is zero');
addNewAction(); addNewAction();
} }
if (triggerCount > 0) { if (triggerCount > 0) {
console.log('onAddNewTrigger() because count is > zero');
onAddNewTrigger(); onAddNewTrigger();
} }
if (actionCount > 0) { if (actionCount > 0) {
console.log('onAddNewAction() because count is > zero');
onAddNewAction(); onAddNewAction();
} }
@ -43,15 +39,12 @@ $(function () {
function addNewTrigger() { function addNewTrigger() {
"use strict"; "use strict";
triggerCount++; triggerCount++;
console.log('click on add_rule_trigger');
// disable the button // disable the button
$('.add_rule_trigger').attr('disabled', 'disabled'); $('.add_rule_trigger').attr('disabled', 'disabled');
console.log('Disabled the button');
// get the HTML for the new trigger // get the HTML for the new trigger
$.getJSON('json/trigger', {count: triggerCount}).done(function (data) { $.getJSON('json/trigger', {count: triggerCount}).done(function (data) {
console.log('new trigger html retrieved');
// append it to the other triggers // append it to the other triggers
$('tbody.rule-trigger-tbody').append(data.html); $('tbody.rule-trigger-tbody').append(data.html);
@ -62,7 +55,6 @@ function addNewTrigger() {
onAddNewTrigger(); onAddNewTrigger();
$('.add_rule_trigger').removeAttr('disabled'); $('.add_rule_trigger').removeAttr('disabled');
console.log('Enabled the button');
}).fail(function () { }).fail(function () {
@ -78,12 +70,10 @@ function addNewTrigger() {
*/ */
function addNewAction() { function addNewAction() {
"use strict"; "use strict";
console.log('click on add_rule_action');
actionCount++; actionCount++;
// disable the button // disable the button
$('.add_rule_action').attr('disabled', 'disabled'); $('.add_rule_action').attr('disabled', 'disabled');
console.log('Disabled the button');
$.getJSON('json/action', {count: actionCount}).done(function (data) { $.getJSON('json/action', {count: actionCount}).done(function (data) {
@ -97,13 +87,11 @@ function addNewAction() {
onAddNewAction(); onAddNewAction();
$('.add_rule_action').removeAttr('disabled'); $('.add_rule_action').removeAttr('disabled');
console.log('Enabled the button');
}).fail(function () { }).fail(function () {
alert('Cannot get a new action.'); alert('Cannot get a new action.');
$('.add_rule_action').removeAttr('disabled'); $('.add_rule_action').removeAttr('disabled');
console.log('Enabled the button');
}); });
return false; return false;
} }
@ -115,7 +103,6 @@ function addNewAction() {
*/ */
function removeTrigger(e) { function removeTrigger(e) {
"use strict"; "use strict";
console.log('click on remove-trigger');
var target = $(e.target); var target = $(e.target);
if (target.prop("tagName") == "I") { if (target.prop("tagName") == "I") {
target = target.parent(); target = target.parent();
@ -125,7 +112,6 @@ function removeTrigger(e) {
// if now at zero, immediatly add one again: // if now at zero, immediatly add one again:
if ($('.rule-trigger-tbody tr').length == 0) { if ($('.rule-trigger-tbody tr').length == 0) {
console.log('Add a new trigger again');
addNewTrigger(); addNewTrigger();
} }
return false; return false;
@ -138,7 +124,6 @@ function removeTrigger(e) {
*/ */
function removeAction(e) { function removeAction(e) {
"use strict"; "use strict";
console.log('click on remove-action');
var target = $(e.target); var target = $(e.target);
if (target.prop("tagName") == "I") { if (target.prop("tagName") == "I") {
target = target.parent(); target = target.parent();
@ -148,7 +133,6 @@ function removeAction(e) {
// if now at zero, immediatly add one again: // if now at zero, immediatly add one again:
if ($('.rule-action-tbody tr').length == 0) { if ($('.rule-action-tbody tr').length == 0) {
console.log('Add a new action again');
addNewAction(); addNewAction();
} }
return false; return false;
@ -160,7 +144,6 @@ function removeAction(e) {
*/ */
function onAddNewAction() { function onAddNewAction() {
"use strict"; "use strict";
console.log('now in onAddNewAction');
// update all "select action type" dropdown buttons so they will respond correctly // update all "select action type" dropdown buttons so they will respond correctly
$('select[name^="rule-action["]').unbind('change').change(function (e) { $('select[name^="rule-action["]').unbind('change').change(function (e) {
@ -169,7 +152,6 @@ function onAddNewAction() {
}); });
$.each($('.rule-action-holder'), function (i, v) { $.each($('.rule-action-holder'), function (i, v) {
console.log('Update action input for row ' + i);
var holder = $(v); var holder = $(v);
var select = holder.find('select'); var select = holder.find('select');
updateActionInput(select); updateActionInput(select);
@ -181,7 +163,6 @@ function onAddNewAction() {
*/ */
function onAddNewTrigger() { function onAddNewTrigger() {
"use strict"; "use strict";
console.log('now in onAddNewTrigger');
// update all "select trigger type" dropdown buttons so they will respond correctly // update all "select trigger type" dropdown buttons so they will respond correctly
$('select[name^="rule-trigger["]').unbind('change').change(function (e) { $('select[name^="rule-trigger["]').unbind('change').change(function (e) {
@ -190,7 +171,6 @@ function onAddNewTrigger() {
}); });
$.each($('.rule-trigger-holder'), function (i, v) { $.each($('.rule-trigger-holder'), function (i, v) {
console.log('Update trigger input for row ' + i);
var holder = $(v); var holder = $(v);
var select = holder.find('select'); var select = holder.find('select');
updateTriggerInput(select); updateTriggerInput(select);
@ -203,7 +183,6 @@ function onAddNewTrigger() {
* @param selectList * @param selectList
*/ */
function updateActionInput(selectList) { function updateActionInput(selectList) {
console.log('now in updateActionInput');
// the actual row this select list is in: // the actual row this select list is in:
var parent = selectList.parent().parent(); var parent = selectList.parent().parent();
// the text input we're looking for: // the text input we're looking for:
@ -212,10 +191,8 @@ function updateActionInput(selectList) {
switch (selectList.val()) { switch (selectList.val()) {
default: default:
input.typeahead('destroy'); input.typeahead('destroy');
console.log('Cannot or will not do stuff to "' + selectList.val() + '"');
break; break;
case 'set_category': case 'set_category':
console.log('Create autocomplete for category list');
createAutoComplete(input, 'json/categories'); createAutoComplete(input, 'json/categories');
break; break;
case 'clear_category': case 'clear_category':
@ -224,7 +201,6 @@ function updateActionInput(selectList) {
input.attr('disabled', 'disabled'); input.attr('disabled', 'disabled');
break; break;
case 'set_budget': case 'set_budget':
console.log('Create autocomplete for budget list');
createAutoComplete(input, 'json/budgets'); createAutoComplete(input, 'json/budgets');
break; break;
case 'add_tag': case 'add_tag':
@ -256,7 +232,6 @@ function updateTriggerInput(selectList) {
switch (selectList.val()) { switch (selectList.val()) {
default: default:
input.typeahead('destroy'); input.typeahead('destroy');
console.log('Cannot or will not add autocomplete to "' + selectList.val() + '"');
break; break;
case 'from_account_starts': case 'from_account_starts':
case 'from_account_ends': case 'from_account_ends':
@ -296,18 +271,15 @@ function updateTriggerInput(selectList) {
* @param URI * @param URI
*/ */
function createAutoComplete(input, URI) { function createAutoComplete(input, URI) {
console.log('Will create auto-complete for "' + URI + '".');
input.typeahead('destroy'); input.typeahead('destroy');
$.getJSON(URI).done(function (data) { $.getJSON(URI).done(function (data) {
input.typeahead({source: data}); input.typeahead({source: data});
console.log('Created new auto-complete!');
}); });
} }
function testRuleTriggers() { function testRuleTriggers() {
"use strict"; "use strict";
console.log('click on test_rule_triggers');
// Serialize all trigger data // Serialize all trigger data
var triggerData = $(".rule-trigger-tbody").find("input[type=text], input[type=checkbox], select").serializeArray(); var triggerData = $(".rule-trigger-tbody").find("input[type=text], input[type=checkbox], select").serializeArray();