-/* $Id: search.js,v 1.27 2007-01-16 05:29:48 quinn Exp $
+/* $Id: search.js,v 1.28 2007-01-16 15:02:35 quinn Exp $
* ---------------------------------------------------
* Javascript container
*/
var cur_facet = 0;
var cur_sort = "relevance";
var searched = 0;
+var cur_id = -1;
+var cur_rec = 0;
function initialize ()
{
set_sort();
}
-
function GetXmlHttpObject()
{
var objXMLHttp=null
return name;
}
-function show_details()
+function paint_details(body, xml)
{
- if (xfetchDetails.readyState != 4)
- return;
- var xml = xfetchDetails.responseXML;
- var error = xml.getElementsByTagName("error");
- if (error[0])
- {
- var msg = error[0].childNodes[0].nodeValue;
- alert(msg);
- location = "?";
- return;
- }
-
- // This is some ugly display code. Replace with your own ting o'beauty
-
- var idn = xml.getElementsByTagName('recid');
- if (!idn[0])
- return;
- var id = idn[0].childNodes[0].nodeValue;
-
- var body = document.getElementById('rec_' + id);
- if (!body)
- return;
clear_cell(body);
//body.appendChild(document.createElement('br'));
var nodes = xml.childNodes[0].childNodes;
body.style.display = 'inline';
}
+function show_details()
+{
+ if (xfetchDetails.readyState != 4)
+ return;
+ var xml = xfetchDetails.responseXML;
+ var error = xml.getElementsByTagName("error");
+ if (error[0])
+ {
+ var msg = error[0].childNodes[0].nodeValue;
+ alert(msg);
+ location = "?";
+ return;
+ }
+
+ // This is some ugly display code. Replace with your own ting o'beauty
+
+ var idn = xml.getElementsByTagName('recid');
+ if (!idn[0])
+ return;
+ var id = idn[0].childNodes[0].nodeValue;
+ cur_id = id;
+ cur_rec = xml;
+
+ var body = document.getElementById('rec_' + id);
+ if (!body)
+ return;
+ paint_details(body, xml);
+}
+
function fetch_details(id)
{
- var node = document.getElementById('rec_' + id);
- if (node && node.style.display == 'inline')
+ cur_id = -1;
+ var nodes = document.getElementsByName('listrecord');
+ var i;
+ for (i = 0; i < nodes.length; i++)
{
- node.style.display = 'none';
+ var dets = nodes[i].getElementsByTagName('div');
+ if (dets[0])
+ dets[0].style.display = 'none';
+ }
+ if (id == cur_id)
+ {
+ cur_id = -1;
return;
}
if (!session)
var record_div = document.createElement('div');
record_div.className = 'record';
+ record_div.setAttribute('name', 'listrecord');
var record_cell = create_element('a', title);
record_cell.setAttribute('href', '#');
record_div.appendChild(document.createTextNode(
' (' + count + ')'));
var det_div = document.createElement('div');
- det_div.style.display = 'none';
+ if (id == cur_id)
+ paint_details(det_div, cur_rec);
+ else
+ det_div.style.display = 'none';
det_div.setAttribute('id', 'rec_' + id);
- det_div.appendChild(document.createElement('br'));
- det_div.appendChild(document.createTextNode('Hugo'));
+ det_div.setAttribute('name', 'details');
record_div.appendChild(det_div);
record_container.appendChild(record_div);
}
stattimer = 0;
clearTimeout(showtimer);
showtimer = 0;
+ cur_id = -1;
var query = escape(document.getElementById('query').value);
var url = "search.pz2?" +
"command=search" +