safer logging in JS utilRegistry
This commit is contained in:
parent
d43fbca0c3
commit
32bc5f4852
@ -4,7 +4,7 @@
|
|||||||
var registeredUtils = [];
|
var registeredUtils = [];
|
||||||
var activeUtilInstances = [];
|
var activeUtilInstances = [];
|
||||||
|
|
||||||
var DEBUG_MODE = 2;
|
var DEBUG_MODE = /localhost/.test(window.location.href) && 2;
|
||||||
|
|
||||||
// Registry
|
// Registry
|
||||||
// (revealing module pattern)
|
// (revealing module pattern)
|
||||||
@ -26,10 +26,8 @@
|
|||||||
* @param util Object Utility that should be added to the registry
|
* @param util Object Utility that should be added to the registry
|
||||||
*/
|
*/
|
||||||
function registerUtil(util) {
|
function registerUtil(util) {
|
||||||
if (DEBUG_MODE > 0) {
|
|
||||||
console.log('registering util "' + util.name + '"');
|
|
||||||
}
|
|
||||||
if (DEBUG_MODE > 2) {
|
if (DEBUG_MODE > 2) {
|
||||||
|
console.log('registering util "' + util.name + '"');
|
||||||
console.log({ util });
|
console.log({ util });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +47,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupAllUtils() {
|
function setupAllUtils() {
|
||||||
|
if (DEBUG_MODE > 1) {
|
||||||
|
console.info('registered js utilities:');
|
||||||
|
console.table(registeredUtils);
|
||||||
|
}
|
||||||
|
|
||||||
registeredUtils.forEach(function(util) {
|
registeredUtils.forEach(function(util) {
|
||||||
setupUtil(util);
|
setupUtil(util);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
window.utils = window.utils || {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Check All Checkbox Utility
|
* Check All Checkbox Utility
|
||||||
|
|||||||
Reference in New Issue
Block a user