Log the actual query when a search is submitted.
[mkws-moved-to-github.git] / tools / htdocs / mkws.js
index 446fc7c..b6f059e 100644 (file)
@@ -267,6 +267,9 @@ function my_onshow(data) {
        html.push('<div class="record" id="mkwsRecdiv_' + hit.recid + '" >',
                  renderSummary(hit),
                  '</div>');
+       if (hit.recid == curDetRecId) {
+            html.push(renderDetails(curDetRecData));
+       }
     }
     replaceHtml(results, html.join(''));
 }
@@ -274,20 +277,13 @@ function my_onshow(data) {
 
 function renderSummary(hit)
 {
-    var html = [];
-    html.push('<a href="#" id="mkwsRec_'+hit.recid
-              +'" onclick="mkws.showDetails(this.id);return false;"><b>'
-              + hit["md-title"] +' </b></a>');
-    if (hit["md-title-remainder"] !== undefined) {
-       html.push('<span>' + hit["md-title-remainder"] + ' </span>');
-    }
-    if (hit["md-title-responsibility"] !== undefined) {
-       html.push('<span><i>'+hit["md-title-responsibility"]+'</i></span>');
-    }
-    if (hit.recid == curDetRecId) {
-        html.push(renderDetails(curDetRecData));
+    if (mkws.templateSummary === undefined) {
+       loadTemplate("Summary");
     }
-    return html.join('');
+
+    hit._id = "mkwsRec_" + hit.recid;
+    hit._onclick = "mkws.showDetails(this.id);return false;"
+    return mkws.templateSummary(hit);
 }
 
 
@@ -453,7 +449,7 @@ function triggerSearch ()
        }
     }
 
-    debug("triggerSearch: filters = " + JSON.stringify(mkws.filters) + ", pp2filter = " + pp2filter + ", pp2limit = " + pp2limit);
+    debug("triggerSearch(" + document.mkwsSearchForm.mkwsQuery.value + "): filters = " + JSON.stringify(mkws.filters) + ", pp2filter = " + pp2filter + ", pp2limit = " + pp2limit);
     my_paz.search(document.mkwsSearchForm.mkwsQuery.value, recPerPage, curSort, pp2filter, undefined, { limit: pp2limit });
 }
 
@@ -786,6 +782,18 @@ function defaultTemplate(name)
        </tr>\
       </table>\
 ';
+    } else if (name === "Summary") {
+       return '\
+      <a href="#" id="{{_id}}" onclick="{{_onclick}}">\
+       <b>{{md-title}}</b>\
+      </a>\
+      {{#if md-title-remainder}}\
+        <span>{{md-title-remainder}}</span>\
+      {{/if}}\
+      {{#if md-title-responsibility}}\
+       <span><i>{{md-title-responsibility}}</i></span>\
+      {{/if}}\
+';
     }
 
     var s = "There is no default '" + name +"' template!";