X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=www%2Fpz2_js%2Fclient_pz2.js;h=c759e6f5c7184a40629aa8492f2ce522b8d8f569;hb=1d39a34e871d67a1c734dea8bd3ebc2e33838393;hp=1ae5dcb137722468716b6d33c77f78daa513331c;hpb=4d6b51c55019d441c826a0afa82930331321e772;p=pazpar2-moved-to-github.git diff --git a/www/pz2_js/client_pz2.js b/www/pz2_js/client_pz2.js index 1ae5dcb..c759e6f 100644 --- a/www/pz2_js/client_pz2.js +++ b/www/pz2_js/client_pz2.js @@ -1,11 +1,30 @@ -function init() { - my_paz = new pz2( { "onshow": my_onshow, - "onstat": my_onstat, - "onterm": my_onterm, - "termlist": "subject,author", - "onrecord": my_onrecord } ); -} +// very simple client that shows a basic usage of the pz2.js + +// create a parameters array and pass it to the pz2's constructor +// then register the form submit event with the pz2.search function + +my_paz = new pz2( { "onshow": my_onshow, + "showtime": 500, //each timer (show, stat, term, bytarget) can be specified this way + "onstat": my_onstat, + "onterm": my_onterm, + "termlist": "subject,author", + "onbytarget": my_onbytarget, + "onrecord": my_onrecord } ); +// wait until the DOM is ready (could have been defined in the HTML) +$(document).ready( function() { + document.search.onsubmit = onFormSubmitEventHandler; + document.getElementById("next").onclick = pagerNext; + document.getElementById("prev").onclick = pagerPrev; + } ); + +function onFormSubmitEventHandler() { + my_paz.search(document.search.query.value, 15, 'relevance'); + return false; +} +// +// pz2.js event handlers: +// function my_onshow(data) { var body = document.getElementById("body"); body.innerHTML = ""; @@ -47,10 +66,33 @@ function my_onterm(data) { } function my_onrecord(data) { + details = data; recordDiv = document.getElementById(data.recid); recordDiv.innerHTML = "
Ttle : | " + data["md-title"] + " |
Date : | " + data["md-date"] + " |
Author : | " + data["md-author"] + - " |
Subject : | " + data["md-subject"] + " |
Subject : | " + data["md-subject"] + + " |
Location : | " + data["location"][0].name + " |