Made termlist length tunable (partially) from browser client
[pazpar2-moved-to-github.git] / www / demo / search.js
index feed8f8..517f597 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: search.js,v 1.32 2007-01-16 19:42:20 quinn Exp $
+/* $Id: search.js,v 1.36 2007-01-17 14:21:29 quinn Exp $
  * ---------------------------------------------------
  * Javascript container
  */
@@ -222,6 +222,8 @@ function displayname(name)
        return 'ISBN';
     else if (name == 'md-publisher')
        return 'Publisher';
+    else if (name == 'md-url')
+       return 'URL';
     else
        return name;
 }
@@ -232,6 +234,8 @@ function hyperlink_field(name)
        return 'au';
     else if (name == 'md-subject')
        return 'su';
+    else if (name == 'md-url')
+       return 'URL';
     else
        return 0;
 }
@@ -290,10 +294,18 @@ function paint_details(body, xml)
        if (hyl)
        {
            nv = create_element('a', value);
-           nv.setAttribute('href', '#');
-           nv.setAttribute('term', value);
-           nv.setAttribute('searchfield', hyl);
-           nv.onclick = function() { hyperlink_search(this); return false; };
+           if (hyl == 'URL')
+           {
+               nv.setAttribute('href', value);
+               nv.setAttribute('target', '_blank');
+           }
+           else
+           {
+               nv.setAttribute('href', '#');
+               nv.setAttribute('term', value);
+               nv.setAttribute('searchfield', hyl);
+               nv.onclick = function() { hyperlink_search(this); return false; };
+           }
        }
        else
            nv = document.createTextNode(value);
@@ -329,6 +341,15 @@ function show_details()
     cur_id = id;
     cur_rec = xml;
 
+    var nodes = document.getElementsByName('listrecord');
+    var i;
+    for (i = 0; i < nodes.length; i++)
+    {
+       var dets = nodes[i].getElementsByTagName('div');
+       if (dets[0])
+           dets[0].style.display = 'none';
+    }
+
     var body = document.getElementById('rec_' + id);
     if (!body)
        return;
@@ -347,14 +368,6 @@ function hyperlink_search(obj)
 function fetch_details(id)
 {
     cur_id = -1;
-    var nodes = document.getElementsByName('listrecord');
-    var i;
-    for (i = 0; i < nodes.length; i++)
-    {
-       var dets = nodes[i].getElementsByTagName('div');
-       if (dets[0])
-           dets[0].style.display = 'none';
-    }
     if (id == cur_id)
     {
        cur_id = -1;
@@ -435,7 +448,7 @@ function show_records()
            record_div.setAttribute('name', 'listrecord');
 
             var record_cell = create_element('a', title);
-            record_cell.setAttribute('href', '#');
+            record_cell.setAttribute('href', '#' + id);
            record_cell.setAttribute('onclick', 'fetch_details(' + id + '); return false');
             record_div.appendChild(record_cell);
            if (author)
@@ -503,6 +516,8 @@ function refine_query (obj) {
        query_cell.value += ' and su=(' + term + ')';
     else if (cur_termlist == 'author')
        query_cell.value += ' and au=(' + term + ')';
+    else if (cur_termlist == 'date')
+       query_cell.value += ' and date=' + term;
 
     start_search();
 }
@@ -564,7 +579,8 @@ function check_termlist()
     var url = "search.pz2?" +
         "command=termlist" +
        "&session=" + session +
-       "&name=" + facet_name;
+       "&name=" + facet_name +
+       "&num=12";
     xtermlist = GetXmlHttpObject();
     xtermlist.onreadystatechange=show_termlist;
     xtermlist.open("GET", url);