From 7cea3107863c9012afb5c4428b2a5a27674127f5 Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Fri, 18 May 2007 15:16:18 +0000 Subject: [PATCH] Added simple stylesheet to the example. --- js/pz2.js | 4 +-- www/example/example_client.js | 65 +++++++++++++++++++++------------ www/example/index.html | 79 +++++++++++++++++++++++++++++------------ 3 files changed, 101 insertions(+), 47 deletions(-) diff --git a/js/pz2.js b/js/pz2.js index 723b176..1609983 100644 --- a/js/pz2.js +++ b/js/pz2.js @@ -1,5 +1,5 @@ /* -** $Id: pz2.js,v 1.17 2007-05-18 12:38:48 jakub Exp $ +** $Id: pz2.js,v 1.18 2007-05-18 15:16:18 jakub Exp $ ** pz2.js - pazpar2's javascript client library. */ @@ -219,7 +219,7 @@ pz2.prototype = { }, stat: function() { - if( !__myself.searchStatusOK ) + if( !__myself.initStatusOK ) return; // if called explicitly takes precedence clearTimeout(__myself.statTimer); diff --git a/www/example/example_client.js b/www/example/example_client.js index 5629656..4dbac1c 100644 --- a/www/example/example_client.js +++ b/www/example/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-05-18 11:36:39 jakub Exp $ +** $Id: example_client.js,v 1.2 2007-05-18 15:16:18 jakub Exp $ */ // create a parameters array and pass it to the pz2's constructor @@ -24,6 +24,7 @@ var curDetRecData = null; function domReady () { document.search.onsubmit = onFormSubmitEventHandler; + my_paz.stat(); } // when search button pressed @@ -43,15 +44,19 @@ function my_onshow(data) { var body = document.getElementById("body"); body.innerHTML = ""; - body.innerHTML +='
Displaying: ' + data.start + ' to ' + (data.start + data.num) + - ' of ' + data.merged + ' (total not merged hits: ' + data.total + ')

'; + body.innerHTML +='
Displaying: ' + + data.start + ' to ' + (data.start + data.num) + + ' of ' + data.merged + ' (total not merged hits: ' + + data.total + ')
'; - body.innerHTML += 'Prev | ' - + 'Next
'; + body.innerHTML += '
' + +'<< Prev | ' + +'' + +'Next >>

'; for (var i = 0; i < data.hits.length; i++) { var hit = data.hits[i]; - body.innerHTML += '
' + body.innerHTML += '
' +'' + (i + 1 + recPerPage * ( curPage - 1)) + '. ' +'' + hit["md-title"] + ' by ' + hit["md-author"] + '
'; @@ -74,15 +79,23 @@ function my_onstat(data) { function my_onterm(data) { var termlist = document.getElementById("termlist"); - termlist.innerHTML = ""; - termlist.innerHTML += "
--Author
"; + termlist.innerHTML = "
TERMLISTS:
"; + termlist.innerHTML += "
--Author
"; for (var i = 0; i < data.author.length; i++ ) { - termlist.innerHTML += '
' + data.author[i].name + ' (' + data.author[i].freq + ')
'; + termlist.innerHTML += '
' + + data.author[i].name + + ' (' + + data.author[i].freq + + ')
'; } termlist.innerHTML += "
"; termlist.innerHTML += "
--Subject
"; for (var i = 0; i < data.subject.length; i++ ) { - termlist.innerHTML += '
' + data.subject[i].name + ' (' + data.subject[i].freq + ')
'; + termlist.innerHTML += '
' + + data.subject[i].name + + ' (' + + data.subject[i].freq + + ')
'; } } @@ -98,31 +111,38 @@ function my_onrecord(data) { function my_onbytarget(data) { var targetDiv = document.getElementById("bytarget"); - targetDiv.innerHTML = 'IDHitsDiagRecState'; + var table = 'Target IDHitsDiags' + +'RecordsState'; for (var i = 0; i < data.length; i++ ) { - targetDiv.innerHTML += "" + data[i].id + - "" + data[i].hits + - "" + data[i].diagnostic + - "" + data[i].records + - "" + data[i].state + ""; + table += "" + data[i].id + + "" + data[i].hits + + "" + data[i].diagnostic + + "" + data[i].records + + "" + data[i].state + ""; } + + table += ''; + targetDiv.innerHTML = table; + } // detailed record drawing function showDetails ( prefixRecId ) { var recId = Number(prefixRecId.replace('rec_', '')); - // if the same clicked ignore - if ( recId == curDetRecId ) - return; - - // if different remove the old one + // remove current detailed view if any var detRecordDiv = document.getElementById('det_'+curDetRecId); // lovin DOM! if ( detRecordDiv ) detRecordDiv.parentNode.removeChild(detRecordDiv); + // if the same clicked do not redraw + if ( recId == curDetRecId ) { + curDetRecId = -1; + return; + } + curDetRecId = recId; // request the record @@ -133,7 +153,8 @@ function drawCurDetails () { var data = curDetRecData; var recordDiv = document.getElementById('rec_'+data.recid); - recordDiv.innerHTML += '
Ttle: ' + data["md-title"] + + recordDiv.innerHTML += '
Ttle: '+data["md-title"] + "
Date: " + data["md-date"] + "
Author: " + data["md-author"] + "
Subject: " + data["md-subject"] + diff --git a/www/example/index.html b/www/example/index.html index dba3c6d..789f7b3 100644 --- a/www/example/index.html +++ b/www/example/index.html @@ -1,4 +1,8 @@ - + + + + @@ -9,17 +13,51 @@ overflow-y: scroll; } - html, body { - color: #002863; - font-family: verdana, arial, sans-serif; + body { + font-family: tahoma, arial, sans-serif; font-size: small; } - input.search { - background-color: #f0f0f0; - color: #002863; - border: 1px solid #a5acb2; - width: 420px; + hr { + border: 0; + color: gray; + background-color: gray; + height: 1px; + } + + .heading { + background-color: #ff8c71; + border-color: #ff8c71; + color: #ffffff; + font-size: large; + } + + input#button { + border: 3px groove #3171f2; + background-color: #6b9bfd; + padding: 1px; + width: 5em; + color: #FFFFFF; + font-weight: bold; + font-size: 12px; + margin-left: 8px; + cursor: pointer; + } + + input#query { + border: 2px inset #ff613c; + padding: 3px; + font-size: 12px; + } + + div.record { + padding: 5px; + } + + div.details { + border: 3px dashed gray; + padding: 5px; + margin: 4px; } @@ -29,37 +67,32 @@ - +
- - + +
Exemplary pazpar2 client [using pz2.js]
PazPar2
- Search: - +
-
+
- TERMLISTS: -

- RESULTS: -

-
-
+
+

- STATUS INFO: + STATUS INFO:

@@ -67,7 +100,7 @@

- TARGET IFO: + TARGET INFO:

-- 1.7.10.4