switch from "jquery" to "jQuery" module
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index e32f61c..5ea0ce9 100644 (file)
@@ -15,8 +15,9 @@ var mkws = {
  * Needs to be defined in the HTML header before including this JS file.
  * 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
 (function ($) {
@@ -88,7 +89,7 @@ mkws.debug_function = function (string) {
     }
 
     var now = $.now();
-    var timestamp = (now - mkws.debug_time.start)/1000 + " (+" + (now - mkws.debug_time.last)/1000 + ") "
+    var timestamp = ((now - mkws.debug_time.start)/1000).toFixed(3) + " (+" + ((now - mkws.debug_time.last)/1000).toFixed(3) + ") "
     mkws.debug_time.last = now;
 
     // you need to disable use strict at the top of the file!!!
@@ -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')
@@ -422,7 +430,7 @@ function onFormSubmitEventHandler()
 function newSearch(query, sort, targets)
 {
     debug("newSearch: " + query);
-   
+
     if (mkws_config.use_service_proxy && !mkws.authenticated) {
        alert("searching before authentication");
        return;