Experimentally added display of database names after each hit
authorSebastian Hammer <quinn@indexdata.com>
Sun, 15 Apr 2007 03:24:18 +0000 (03:24 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Sun, 15 Apr 2007 03:24:18 +0000 (03:24 +0000)
js/pz2.js
www/masterkey/js/client.js

index 2cacae9..5870bae 100644 (file)
--- a/js/pz2.js
+++ b/js/pz2.js
@@ -1,5 +1,5 @@
 /*
-** $Id: pz2.js,v 1.6 2007-04-13 17:19:53 quinn Exp $
+** $Id: pz2.js,v 1.7 2007-04-15 03:24:18 quinn Exp $
 ** pz2.js - pazpar2's javascript client library.
 */
 
@@ -256,11 +256,23 @@ pz2.prototype = {
                     var hit = new Array();
                     for (i = 0; i < hits.length; i++) {
                         show.hits[i] = new Array();
+                       show.hits[i]['location'] = new Array();
                         for ( j = 0; j < hits[i].childNodes.length; j++) {
+                           var locCount = 0;
                             if ( hits[i].childNodes[j].nodeType == Node.ELEMENT_NODE ) {
-                                var nodeName = hits[i].childNodes[j].nodeName;
-                                var nodeText = hits[i].childNodes[j].firstChild.nodeValue;
-                                show.hits[i][nodeName] = nodeText;
+                               if (hits[i].childNodes[j].nodeName == 'location') {
+                                   var locNode = hits[i].childNodes[j];
+                                   var id = locNode.getAttribute('id');
+                                   show.hits[i]['location'][id] = {
+                                       "id": locNode.getAttribute("id"),
+                                       "name": locNode.getAttribute("name")
+                                   };
+                               }
+                               else {
+                                   var nodeName = hits[i].childNodes[j].nodeName;
+                                   var nodeText = hits[i].childNodes[j].firstChild.nodeValue;
+                                   show.hits[i][nodeName] = nodeText;
+                               }
                             }
                         }
                     }
index 648c738..d93de8d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-** $Id: client.js,v 1.16 2007-04-14 23:59:20 quinn Exp $
+** $Id: client.js,v 1.17 2007-04-15 03:24:18 quinn Exp $
 ** MasterKey - pazpar2's javascript client .
 */
 
@@ -24,6 +24,8 @@ var currentDetailedData = null;
 var termStartup = true;
 var advancedOn = false;
 
+var showBriefLocations = true;
+
 /* wait until the DOM is ready and register basic handlers */
 $(document).ready( function() { 
                     document.search.onsubmit = onFormSubmitEventHandler;
@@ -107,9 +109,22 @@ function my_onshow(data)
             drawDetailedRec(detailBox);
         }
 
-        if( count > 1 ) {
-            recBody.append('<span> ('+count+')</span>');
-        }
+       if (showBriefLocations) {
+           var location = data.hits[i]['location'];
+           var l;
+           var list = '';
+           for (l in location) {
+               if (list)
+                   list += ', ';
+               list += location[l].name;
+           }
+           recBody.append('<span> ('+list+')</span>');
+       }
+       else {
+           if( count > 1 ) {
+               recBody.append('<span> ('+count+')</span>');
+           }
+       }
 
         recsBody.append('<div class="resultNum">'+(currentPage*currentResultsPerPage+i+1)+'.</a>');
         recsBody.append(recBody);