configure search box size
[mkws-moved-to-github.git] / experiments / spclient / mkws.js
index 7067296..0504753 100644 (file)
@@ -437,7 +437,7 @@ function mkws_html_all(data) {
        sort_default: "relevance",
        perpage_default: 20,
        query_width: 50,
-       switch: true, /* show/hide Records|Targets menu */
+       switch_menu: true, /* show/hide Records|Targets menu */
        debug: 0,     /* debug level for development: 0..2 */
 
        dummy: "dummy"
@@ -455,6 +455,10 @@ function mkws_html_all(data) {
        config[k] = data[k];
        debug("Set config: " + k + ' => ' + data[k]);
     }
+    if (mkws_config.query_width < 5 || mkws_config.query_width > 150) {
+       debug("Reset query width: " + mkws_config.query_width);
+       mkws_config.query_width = 50;
+    }
    
     mkws_set_lang(mkws_config); 
     mkws_html_lang(mkws_config); 
@@ -463,8 +467,8 @@ function mkws_html_all(data) {
     // document.search.query being undefined, hence the raw HTML.
     debug("HTML search form");
     $("#mkwsSearch").html('\
-    <form id="searchForm" name="search">\
-      <input id="query" type="text" size="50" />\
+    <form id="searchForm" name="search" action="" >\
+      <input id="query" type="text" size="' + mkws_config.query_width + '" />\
       <input id="button" type="submit" value="' + M('Search') + '" />\
     </form>');
 
@@ -477,7 +481,7 @@ function mkws_html_all(data) {
           </td>\
           <td valign="top">\
             <div id="ranking">\
-              <form name="select" id="select">\
+              <form name="select" id="select" action="" >\
         ' + M('Sort by') + mkws_html_sort(config) + '\
         ' + M('and show') + ' ' + mkws_html_perpage(config) + '\
         ' + M('per page') + '.\
@@ -488,8 +492,7 @@ function mkws_html_all(data) {
             <div id="results"></div>\
           </td>\
         </tr>\
-      </table>\
-    </div>');
+      </table>');
 
     mkws_html_switch(config);
     if (mkws_config.use_service_proxy)
@@ -532,8 +535,8 @@ function mkws_html_switch(config) {
       </div>');
     $("#mkwsTargets").css("display", "none");
 
-    if (!config.switch) {
-       debug("disable switch");
+    if (!config.switch_menu) {
+       debug("disable switch menu");
         $("#mkwsSwitch").css("display", "none");
     }
 }
@@ -657,11 +660,18 @@ jQuery.extend({
 function debug(string) {
     if (!mkws_debug)
        return;
-    
+   
+    var console; // IE8 quirks 
     if (!console) { /* ARGH!!! */
        return;
     }
-    
+
+    // you need to disable use strict at the top of the file!!!
+    if (mkws_debug >= 3) {
+       console.log(arguments.callee.caller);
+    } else if (mkws_debug >= 2) {
+       console.log(">>> called from function " + arguments.callee.caller.name + ' <<<');
+    }
     console.log(string);
 }