X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=www%2Fjsdemo%2Fexample_client.js;h=0df0002577defdfe08b92017633b6ad84daf1658;hb=7182ce9776fbcadef10afe7df72e22997f68be1c;hp=a9fe0321fc027986a8a97726d1c88de0c53405e0;hpb=12af7f286ec9d68fa3f9da31f85a652f3c3889cb;p=pazpar2-moved-to-github.git
diff --git a/www/jsdemo/example_client.js b/www/jsdemo/example_client.js
index a9fe032..0df0002 100644
--- a/www/jsdemo/example_client.js
+++ b/www/jsdemo/example_client.js
@@ -1,5 +1,5 @@
/* A very simple client that shows a basic usage of the pz2.js
-** $Id: example_client.js,v 1.1 2007-06-21 09:44:17 adam Exp $
+** $Id: example_client.js,v 1.5 2007-07-24 08:15:12 jakub Exp $
*/
// create a parameters array and pass it to the pz2's constructor
@@ -13,12 +13,13 @@ my_paz = new pz2( { "onshow": my_onshow,
"onterm": my_onterm,
"termlist": "subject,author",
"onbytarget": my_onbytarget,
+ "usesessions" : true,
"onrecord": my_onrecord } );
// some state vars
var curPage = 1;
var recPerPage = 20;
var totalRec = 0;
-var curDetRecId = -1;
+var curDetRecId = '';
var curDetRecData = null;
// wait until the DOM is ready
@@ -33,7 +34,7 @@ function domReady ()
function onFormSubmitEventHandler()
{
curPage = 1;
- curDetRecId = -1;
+ curDetRecId = '';
totalRec = 0;
my_paz.search(document.search.query.value, recPerPage, 'relevance');
return false;
@@ -61,11 +62,18 @@ function my_onshow(data) {
for (var i = 0; i < data.hits.length; i++) {
var hit = data.hits[i];
- body.innerHTML += '
'
- +'' + (i + 1 + recPerPage * ( curPage - 1)) + '. '
- +'' + hit["md-title"] +
- ' by ' + hit["md-author"] + '
';
-
+ var html = ''
+ +'' + (i + 1 + recPerPage * ( curPage - 1)) + '. '
+ +'' + hit["md-title"] +
+ ' ';
+ if (hit["md-title-remainder"] !== undefined) {
+ html += '' + hit["md-title-remainder"] + '';
+ }
+ if (hit["md-title-responsibility"] !== undefined) {
+ html += '' + hit["md-title-responsibility"] + '';
+ }
+ html += '
';
+ body.innerHTML += html;
if ( hit.recid == curDetRecId ) {
drawCurDetails();
}
@@ -86,16 +94,16 @@ function my_onterm(data) {
termlist.innerHTML = "
TERMLISTS:
";
termlist.innerHTML += '.::Subjects
';
for (var i = 0; i < data.subject.length; i++ ) {
- termlist.innerHTML += ''
+ termlist.innerHTML += ''
+ data.subject[i].name
- + ' ('
+ + ' ('
+ data.subject[i].freq
+ ')
';
}
termlist.innerHTML += "
";
termlist.innerHTML += '.::Authors
';
for (var i = 0; i < data.author.length; i++ ) {
- termlist.innerHTML += ''
+ termlist.innerHTML += ''
+ data.author[i].name
+ ' ('
+ data.author[i].freq
@@ -134,7 +142,7 @@ function my_onbytarget(data) {
// detailed record drawing
function showDetails ( prefixRecId ) {
- var recId = Number(prefixRecId.replace('rec_', ''));
+ var recId = prefixRecId.replace('rec_', '');
// remove current detailed view if any
var detRecordDiv = document.getElementById('det_'+curDetRecId);
@@ -144,7 +152,7 @@ function showDetails ( prefixRecId ) {
// if the same clicked do not redraw
if ( recId == curDetRecId ) {
- curDetRecId = -1;
+ curDetRecId = '';
return;
}
@@ -162,11 +170,18 @@ function drawCurDetails ()
'">Ttle | : '+data["md-title"] +
" |
Date | : " + data["md-date"] +
" |
Author | : " + data["md-author"] +
+ ' |
URL | : ' + data["md-electronic-url"] + '' +
" |
Subject | : " + data["md-subject"] +
" |
Location | : " + data["location"][0].name +
" |
";
}
+// limit the query after clicking the facet
+function limitQuery (field, value)
+{
+ document.search.query.value += ' and ' + field + '="' + value + '"';
+ onFormSubmitEventHandler();
+}
// simple paging functions