X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=www%2Fjsdemo%2Fexample_client.js;h=fd9c37ee8eded2de4dadbbff82324efe729656ad;hb=88f96194d5a63278eb57b32c814019dab51da9ff;hp=e67f10794ef7f3039dbcd74714cea4da279f3837;hpb=40c86d166a9ab3b675087dd6c96eb09713757224;p=pazpar2-moved-to-github.git
diff --git a/www/jsdemo/example_client.js b/www/jsdemo/example_client.js
index e67f107..fd9c37e 100644
--- a/www/jsdemo/example_client.js
+++ b/www/jsdemo/example_client.js
@@ -1,5 +1,4 @@
/* A very simple client that shows a basic usage of the pz2.js
-** $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
@@ -7,9 +6,11 @@
// autoInit is set to true on default
var usesessions = true;
var pazpar2path = '/pazpar2/search.pz2';
-if (document.location.hash == '#nosessions') {
+var showResponseType = '';
+if (document.location.hash == '#useproxy') {
usesessions = false;
- pazpar2path = '/pazpar2-proxy/';
+ pazpar2path = '/service-proxy/';
+ showResponseType = 'json';
}
my_paz = new pz2( { "onshow": my_onshow,
@@ -21,6 +22,7 @@ my_paz = new pz2( { "onshow": my_onshow,
"termlist": "xtargets,subject,author",
"onbytarget": my_onbytarget,
"usesessions" : usesessions,
+ "showResponseType": showResponseType,
"onrecord": my_onrecord } );
// some state vars
var curPage = 1;
@@ -56,26 +58,26 @@ function my_onshow(data) {
// navi
var results = document.getElementById("results");
- var html = '';
+ var html = [];
for (var i = 0; i < data.hits.length; i++) {
var hit = data.hits[i];
- html += '
'
+ html.push('
'
+'
'+ (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"] +'';
- }
+ + hit["md-title"] +' ');
+ if (hit["md-title-remainder"] !== undefined) {
+ html.push('
' + hit["md-title-remainder"] + ' ');
+ }
+ if (hit["md-title-responsibility"] !== undefined) {
+ html.push('
'+hit["md-title-responsibility"]+'');
+ }
if (hit.recid == curDetRecId) {
- html += renderDetails(curDetRecData);
+ html.push(renderDetails(curDetRecData));
}
- html += '
';
+ html.push('
');
}
- replaceHtml(results, html);
+ replaceHtml(results, html.join(''));
}
function my_onstat(data) {
@@ -91,42 +93,30 @@ function my_onstat(data) {
}
function my_onterm(data) {
- var termlist = document.getElementById("termlist");
- termlist.innerHTML = "
TERMLISTS:
";
-
- termlist.innerHTML += '.::Sources
';
+ var termlists = [];
+ termlists.push('
TERMLISTS:
.::Sources
');
for (var i = 0; i < data.xtargets.length && i < SourceMax; i++ ) {
- termlist.innerHTML += ''
- + data.xtargets[i].name
- + ' ('
- + data.xtargets[i].freq
- + ')
';
+ termlists.push('' + data.xtargets[i].name
+ + ' (' + data.xtargets[i].freq + ')
');
}
-
- termlist.innerHTML += "
";
-
- termlist.innerHTML += '.::Subjects
';
+
+ termlists.push('
.::Subjects
');
for (var i = 0; i < data.subject.length && i < SubjectMax; i++ ) {
- termlist.innerHTML += ''
- + data.subject[i].name
- + ' ('
- + data.subject[i].freq
- + ')
';
+ termlists.push('' + data.subject[i].name + ' ('
+ + data.subject[i].freq + ')
');
}
-
- termlist.innerHTML += "
";
-
- termlist.innerHTML += '.::Authors
';
+
+ termlists.push('
.::Authors
');
for (var i = 0; i < data.author.length && i < AuthorMax; i++ ) {
- termlist.innerHTML += ''
+ termlists.push(''
+ data.author[i].name
+ ' ('
+ data.author[i].freq
- + ')
';
+ + ')
');
}
-
+ var termlist = document.getElementById("termlist");
+ replaceHtml(termlist, termlists.join(''));
}
function my_onrecord(data) {