-/* $Id: search.js,v 1.36 2007-01-17 14:21:29 quinn Exp $
+/* $Id: search.js,v 1.41 2007-01-18 17:42:39 quinn Exp $
* ---------------------------------------------------
* Javascript container
*/
var recstoshow = 20;
var page_window = 5; // Number of pages prior to and after the current page
var facet_list;
-var cur_facet = 0;
var cur_sort = "relevance";
var searched = 0;
var cur_id = -1;
var error = xml.getElementsByTagName("error");
if (error[0])
location = "?";
- setTimeout(ping_session, 50000);
+ else
+ setTimeout(ping_session, 50000);
}
function update_action (new_action) {
return 'Publisher';
else if (name == 'md-url')
return 'URL';
+ else if (name == 'md-title')
+ return '@';
+ else if (name == 'md-id')
+ return 'Local ID';
+ else if (name == 'recid')
+ return '@';
+ else if (name == 'location')
+ return '@';
else
return name;
}
var dname = displayname(name);
var ln = create_element('b', dname);
var tln = document.createElement('td');
- tln.setAttribute('width', 70);
+ tln.setAttribute('width', 90);
tln.setAttribute('valign', 'top');
tln.appendChild(ln);
var tr = document.createElement('tr');
return tr;
}
-function paint_details(body, xml)
+function paint_data_elements(target, node)
{
- // This is some ugly display code. Replace with your own ting o'beauty
- clear_cell(body);
- //body.appendChild(document.createElement('br'));
- var nodes = xml.childNodes[0].childNodes;
- var i;
- var table = document.createElement('table');
- table.setAttribute('cellpadding', 2);
+ var nodes = node.childNodes;
var dn = 0;
var lastname = '';
+ var i;
for (i = 0; i < nodes.length; i++)
{
if (nodes[i].nodeType != 1)
var name = nodes[i].nodeName;
if (name == 'recid' || name == 'md-title')
continue;
- if (name != lastname)
+ if (name != lastname && lastname != 'location')
{
if (dn)
{
var tr = paint_details_tr(lastname, dn);
- table.appendChild(tr);
+ target.appendChild(tr);
}
dn = document.createElement('td');
lastname = name;
}
-
+ if (name == 'location')
+ {
+ target.appendChild(paint_details_tr('Location', paint_subrecord(nodes[i])));
+ continue;
+ }
if (!nodes[i].childNodes[0])
continue;
var value = nodes[i].childNodes[0].nodeValue;
nv = document.createTextNode(value);
dn.appendChild(nv);
}
- if (dn)
+ if (dn && lastname != 'location')
{
var tr = paint_details_tr(lastname, dn);
- table.appendChild(tr);
+ target.appendChild(tr);
}
+}
+
+function paint_subrecord(node)
+{
+ var table = document.createElement('table');
+ var zurl = node.getAttribute('id');
+ var tr = paint_details_tr('Source', document.createTextNode(zurl));
+ table.appendChild(tr);
+ paint_data_elements(table, node);
+ return table;
+}
+
+function paint_details(body, xml)
+{
+ clear_cell(body);
+ var table = document.createElement('table');
+ table.setAttribute('cellpadding', 2);
+ paint_data_elements(table, xml.childNodes[0]);
body.appendChild(table);
body.style.display = 'inline';
}
term = term.replace(/[\(\)]/g, '');
if (cur_termlist == 'subject')
- query_cell.value += ' and su=(' + term + ')';
+ query_cell.value += ' and su=' + term;
else if (cur_termlist == 'author')
- query_cell.value += ' and au=(' + term + ')';
+ query_cell.value += ' and au=' + term;
else if (cur_termlist == 'date')
query_cell.value += ' and date=' + term;
start_search();
}
+function clear_termlists()
+{
+ var i;
+ for (i = 0; i < facet_list.length; i++)
+ clear_cell(facet_list[i][1]);
+}
-
-function show_termlist()
+function show_termlists()
{
if (xtermlist.readyState != 4)
return;
var i;
var xml = xtermlist.responseXML;
- var body = facet_list[cur_facet][1];
- var facet_name = facet_list[cur_facet][0];
- var hits = xml.getElementsByTagName("term");
var clients =
Number(xml.getElementsByTagName("activeclients")[0].childNodes[0].nodeValue);
+ var lists = xml.getElementsByTagName("list");
- cur_facet++;
-
- if (cur_facet >= facet_list.length)
- cur_facet = 0;
-
- if (!hits[0])
- {
- termtimer = setTimeout(check_termlist, 500);
- }
- else
+ for (i = 0; i < lists.length; i++)
{
+ var listname = lists[i].getAttribute('name');
+ var body = document.getElementById('facet_' + listname + '_terms');
+ if (body.style.display == 'none')
+ continue;
clear_cell(body);
-
- for (i = 0; i < hits.length; i++)
+ var terms = lists[i].getElementsByTagName('term');
+ var t;
+ for (t = 0; t < terms.length; t++)
{
- var namen = hits[i].getElementsByTagName("name");
- var freqn = hits[i].getElementsByTagName("frequency");
+ var namen = terms[t].getElementsByTagName("name");
+ var freqn = terms[t].getElementsByTagName("frequency");
if (namen[0])
var term = namen[0].childNodes[0].nodeValue;
var freq = freqn[0].childNodes[0].nodeValue;
var refine_cell = create_element('a', term + ' (' + freq + ')');
refine_cell.setAttribute('href', '#');
refine_cell.setAttribute('term', term);
- refine_cell.setAttribute('facet', facet_name);
+ refine_cell.setAttribute('facet', listname);
refine_cell.onclick = function () {
refine_query(this);
return false;
};
body.appendChild(refine_cell);
}
-
- if (clients > 0)
- termtimer = setTimeout(check_termlist, 1000);
}
+ if (clients > 0)
+ termtimer = setTimeout(check_termlist, 1000);
}
function check_termlist()
{
- var facet_name = facet_list[cur_facet][0];
+ var facet_names = '';
+ var i;
+ for (i = 0; i < facet_list.length; i++)
+ if (facet_list[i][1].style.display != 'none')
+ {
+ if (facet_names)
+ facet_names += ',';
+ facet_names += facet_list[i][0];
+ }
var url = "search.pz2?" +
"command=termlist" +
"&session=" + session +
- "&name=" + facet_name +
+ "&name=" + facet_names +
"&num=12";
- xtermlist = GetXmlHttpObject();
- xtermlist.onreadystatechange=show_termlist;
- xtermlist.open("GET", url);
- xtermlist.send(null);
+ SendXmlHttpObject(xtermlist = GetXmlHttpObject(), url, show_termlists);
}
function show_stat()
clearTimeout(showtimer);
showtimer = 0;
cur_id = -1;
+ clear_termlists();
var query = escape(document.getElementById('query').value);
var url = "search.pz2?" +
"command=search" +
if (obj.className == 'selected') {
obj.className = 'unselected';
container.style.display = 'inline';
+ check_termlist();
} else {
obj.className = 'selected';
container.style.display = 'none';