/* A very simple client that shows a basic usage of the pz2.js
-** $Id: example_client.js,v 1.4 2007-07-16 17:01:46 adam Exp $
+** $Id: example_client.js,v 1.6 2008-01-15 13:59:18 jakub Exp $
*/
// create a parameters array and pass it to the pz2's constructor
// then register the form submit event with the pz2.search function
// autoInit is set to true on default
+if (document.location.hash == '#nosessions') {
+ var usesessions = false;
+ var pazpar2path = '/masterkey-core/php/p3.php';
+} else {
+ var usesessions = true;
+ var pazpar2path = '/pazpar2/search.pz2';
+}
+
my_paz = new pz2( { "onshow": my_onshow,
"showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way
- "pazpar2path": "/pazpar2/search.pz2",
+ "pazpar2path": pazpar2path,
"onstat": my_onstat,
"onterm": my_onterm,
"termlist": "subject,author",
"onbytarget": my_onbytarget,
- "usesessions" : true,
+ "usesessions" : usesessions,
"onrecord": my_onrecord } );
// some state vars
var curPage = 1;
termlist.innerHTML = "<hr/><b>TERMLISTS:</b><hr/>";
termlist.innerHTML += '<div class="termtitle">.::Subjects</div>';
for (var i = 0; i < data.subject.length; i++ ) {
- termlist.innerHTML += '<span>'
+ termlist.innerHTML += '<span class="jslink" onclick="limitQuery(\'su\', this.firstChild.nodeValue)">'
+ data.subject[i].name
- + ' </span><span> ('
+ + '</span><span> ('
+ data.subject[i].freq
+ ')</span><br/>';
}
termlist.innerHTML += "<hr/>";
termlist.innerHTML += '<div class="termtitle">.::Authors</div>';
for (var i = 0; i < data.author.length; i++ ) {
- termlist.innerHTML += '<span>'
+ termlist.innerHTML += '<span class="jslink" onclick="limitQuery(\'au\', this.firstChild.nodeValue)">'
+ data.author[i].name
+ ' </span><span> ('
+ data.author[i].freq
"</td></tr></table></div>";
}
+// limit the query after clicking the facet
+function limitQuery (field, value)
+{
+ document.search.query.value += ' and ' + field + '="' + value + '"';
+ onFormSubmitEventHandler();
+}
// simple paging functions