| 1 |
/* eslint-disable no-undef */ |
| 2 |
|
| 3 |
// if wpchar is not defined, define it. |
| 4 |
if ( typeof wpchar === 'undefined' ) { |
| 5 |
|
| 6 |
var wpchar = { |
| 7 |
|
| 8 |
// This file contains a collection of utility functions. |
| 9 |
|
| 10 |
/** |
| 11 |
* Start the engine. |
| 12 |
* |
| 13 |
* @since 1.0.1 |
| 14 |
*/ |
| 15 |
init: function() { |
| 16 |
jQuery( wpchar.ready ); |
| 17 |
}, |
| 18 |
|
| 19 |
/** |
| 20 |
* Document ready. |
| 21 |
* |
| 22 |
* @since 1.0.1 |
| 23 |
*/ |
| 24 |
ready: function() { |
| 25 |
}, |
| 26 |
|
| 27 |
/** |
| 28 |
* Debug output helper. |
| 29 |
* |
| 30 |
* @since 1.3.8 |
| 31 |
* |
| 32 |
* @param {string|integer|boolean|Array|object} msg Debug message (any data). |
| 33 |
*/ |
| 34 |
debug: function( msg, type = '' ) { |
| 35 |
|
| 36 |
if ( ! wpchar.isDebug() ) { |
| 37 |
return; |
| 38 |
} |
| 39 |
|
| 40 |
if ( type ) { |
| 41 |
type = '(' + type + ')'; |
| 42 |
} |
| 43 |
|
| 44 |
console.log( '%cCharitable Debug: ' + type, 'color: #cd6622;', msg ); |
| 45 |
}, |
| 46 |
|
| 47 |
/** |
| 48 |
* Is debug mode. |
| 49 |
* |
| 50 |
* @since 1.3.8 |
| 51 |
*/ |
| 52 |
isDebug: function() { |
| 53 |
return ( ( window.location.hash && '#charitabledebug' === window.location.hash ) ); |
| 54 |
}, |
| 55 |
|
| 56 |
} |
| 57 |
|
| 58 |
wpchar.init(); |
| 59 |
|
| 60 |
} |
| 61 |
|