From 5a2509922bc906df7233657d8af277c70c0f0d5c Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Fri, 5 Jan 2007 02:12:51 +0000 Subject: [PATCH] Implemented selectable subject/author facet in simple client --- www/test1/search.js | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/www/test1/search.js b/www/test1/search.js index 6c605a1..d5df1a6 100644 --- a/www/test1/search.js +++ b/www/test1/search.js @@ -1,4 +1,4 @@ -/* $Id: search.js,v 1.7 2007-01-04 22:03:56 quinn Exp $ +/* $Id: search.js,v 1.8 2007-01-05 02:12:51 quinn Exp $ * --------------------------------------------------- * Javascript container */ @@ -21,7 +21,7 @@ var session_cells = Array('query', 'startrec', 'action_type'); var old_session = session_read(); var url_surveillence; var recstoshow = 15; - +var cur_termlist = "subject"; function initialize () { @@ -221,13 +221,46 @@ function check_search() function refine_query (obj) { var query_cell = document.getElementById('query'); - var subject = obj.innerHTML; + var term = obj.innerHTML; - subject = subject.replace(/[\(\)]/g, ''); - query_cell.value += ' and su=(' + subject + ')'; + term = term.replace(/[\(\)]/g, ''); + if (cur_termlist == 'subject') + query_cell.value += ' and su=(' + term + ')'; + else if (cur_termlist == 'author') + query_cell.value += ' and au=(' + term + ')'; start_search(); } +function set_termlist(termlist) +{ + cur_termlist = termlist; + check_termlist(); + if (termtimer) + { + clearTimeout(termtimer); + termtimer = 0; + } +} + +function show_termlistoptions(body) +{ + var opts = Array( + Array('subject', 'Subject'), + Array('author', 'Author') + ); + + for (i in opts) + { + if (opts[i][0] == cur_termlist) + body.innerHTML += opts[i][1]; + else + body.innerHTML += '' + opts[i][1] + ''; + body.innerHTML += ' '; + } + body.innerHTML += '

'; +} + function show_termlist() { if (xtermlist.readyState != 4) @@ -242,11 +275,11 @@ function show_termlist() if (!hits[0]) { termtimer = setTimeout(check_termlist, 1000); - } else { body.innerHTML = "Limit results:
"; + show_termlistoptions(body); for (i = 0; i < hits.length; i++) { var namen = hits[i].getElementsByTagName("name"); @@ -266,7 +299,7 @@ function check_termlist() var url = "search.pz2?" + "command=termlist" + "&session=" + session + - "&name=" + "subject"; + "&name=" + cur_termlist; xtermlist = GetXmlHttpObject(); xtermlist.onreadystatechange=show_termlist; xtermlist.open("GET", url); -- 1.7.10.4