Merge branch 'master' into onload
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index 8ddb1b1..f34d2a9 100644 (file)
@@ -10,8 +10,9 @@ var mkws = {
 };
 
 // Define empty mkws_config for simple applications that don't define it.
-if (!mkws_config)
+if (mkws_config == null || typeof mkws_config != 'object') {
     var mkws_config = {};
+}
 
 // wrapper for jQuery lib
 function _mkws($) {
@@ -156,6 +157,7 @@ Handlebars.registerHelper('commaList', function(items, options) {
 
 
 {
+
     /* default mkws config */
     var config_default = {
        use_service_proxy: true,
@@ -185,6 +187,12 @@ Handlebars.registerHelper('commaList', function(items, options) {
        mkws.debug_level = config_default.debug_level;
     }
 
+    // make sure the mkws_config is a valid hash
+    if (!$.isPlainObject(mkws_config)) {
+       debug("ERROR: mkws_config is not an JS object, ignore it....");
+       mkws_config = {};
+    }
+
     /* override standard config values by function parameters */
     for (var k in config_default) {
        if (typeof mkws_config[k] === 'undefined')
@@ -1165,8 +1173,9 @@ function M(word) {
  * implement jQuery plugin $.pazpar2({})
  */
 function _mkws_jquery_plugin ($) {
-    function debug (string) { // delayed debug, internal variables are set after dom ready
-       setTimeout(function() { mkws.debug(string); }, 500);
+    // delayed debug, internal variables are set after dom ready
+    function debug (string) {
+       setTimeout(function() { mkws.debug_function(string); }, 500);
     }
 
     function init_popup(obj) {