From 32bc5f4852253cc6cc2f6f2a5c791891174068e1 Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Sun, 7 Apr 2019 22:32:14 +0200 Subject: [PATCH] safer logging in JS utilRegistry --- static/js/services/utilRegistry.js | 11 +++++++---- static/js/utils/checkAll.js | 2 -- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/static/js/services/utilRegistry.js b/static/js/services/utilRegistry.js index 519a444bf..a73b914bf 100644 --- a/static/js/services/utilRegistry.js +++ b/static/js/services/utilRegistry.js @@ -4,7 +4,7 @@ var registeredUtils = []; var activeUtilInstances = []; - var DEBUG_MODE = 2; + var DEBUG_MODE = /localhost/.test(window.location.href) && 2; // Registry // (revealing module pattern) @@ -26,10 +26,8 @@ * @param util Object Utility that should be added to the registry */ function registerUtil(util) { - if (DEBUG_MODE > 0) { - console.log('registering util "' + util.name + '"'); - } if (DEBUG_MODE > 2) { + console.log('registering util "' + util.name + '"'); console.log({ util }); } @@ -49,6 +47,11 @@ } function setupAllUtils() { + if (DEBUG_MODE > 1) { + console.info('registered js utilities:'); + console.table(registeredUtils); + } + registeredUtils.forEach(function(util) { setupUtil(util); }); diff --git a/static/js/utils/checkAll.js b/static/js/utils/checkAll.js index 3045d2bee..7aeb65ccb 100644 --- a/static/js/utils/checkAll.js +++ b/static/js/utils/checkAll.js @@ -1,8 +1,6 @@ (function() { 'use strict'; - window.utils = window.utils || {}; - /** * * Check All Checkbox Utility