var useLimit = 1;
// Fail to get JSON working stabil.
var showResponseType = 'xml';
+
+var imageHelper = new ImageHelper();
+
if (document.location.hash == '#pazpar2' || document.location.search.match("useproxy=false")) {
usesessions = true;
pazpar2path = '/pazpar2/search.pz2';
showResponseType = 'xml';
}
-
my_paz = new pz2( { "onshow": my_onshow,
// "showtime": 2000, //each timer (show, stat, term, bytarget) can be specified this way
"pazpar2path": pazpar2path,
}
}
+function hideRecords() {
+ for ( var i = 0; i < recToShow; i++) {
+ var element = document.getElementById(recIDs[i]);
+ if (element && recIDs != curDetRecId)
+ element.style.display = 'none';
+ }
+ var element = document.getElementById('recdiv_END');
+ if (element)
+ element.style.display = 'none';
+}
+
+function showRecords() {
+ for (var i = 0 ; i < recToShow && i < recPerPage; i++) {
+ var element = document.getElementById(recIDs[i]);
+ if (element)
+ element.style.display = '';
+ }
+ var element = document.getElementById('recdiv_END');
+ if (element) {
+ if (i == recPerPage)
+ element.style.display = 'none';
+ else
+ element.style.display = '';
+ }
+}
+
+
+
+
function my_onshow(data) {
totalRec = data.merged;
// move it out
var style = '';
for (var i = 0; i < data.hits.length; i++) {
var hit = data.hits[i];
- var recID = "recdiv_" + hit.recid;
- //var recID = "recdiv_" + i;
- recIDs[i] = recID;
+ var recDivID = "recdiv_" + hit.recid;
+ recIDs[i] = recDivID;
+ var lines = 0;
if (i == recToShow)
style = ' style="display:none" ';
- html.push('<li id="' + recID + '" ' + style + '>'
- +'<a href="#" id="rec_'+hit.recid
- +'" onclick="showDetails(this.id);return false;">'
- + hit["md-title"] +'</a> ');
- if (hit["md-title-remainder"] !== undefined) {
- html.push('<a href="#">' + hit["md-title-remainder"] + ' </a> ');
+ html.push('<li class="img arrow" id="' + recDivID + '" ' + style + '>' );
+ html.push('<a class="img" href="#' + i + '" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;" >');
+ if (1) {
+ var useThumbnails = hit["md-use_thumbnails"];
+ var thumburls = hit["md-thumburl"];
+ if (thumburls && (useThumbnails == undefined || useThumbnails == "1")) {
+ var thumbnailtag = imageHelper.getImageTagByRecId(hit.recid,"md-thumburl", 60, "S");
+ html.push(thumbnailtag);
+ } else {
+ if (hit["md-isbn"] != undefined) {
+ var coverimagetag = imageHelper.getImageTagByRecId(hit.recid, "md-isbn", 60, "S");
+ if (coverimagetag.length>0) {
+ html.push(coverimagetag);
+ } else {
+ html.push(" ");
+ }
+ }
+ }
+ }
+ html.push("</a>");
+ html.push('<a href="#" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;">');
+ html.push(hit["md-title"]);
+ html.push("</a>");
+
+ if (hit["md-title-remainder"] != undefined) {
+ html.push('<a href="#" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;">');
+ html.push(hit["md-title-remainder"]);
+ html.push("</a>");
+ lines++;
}
if (hit["md-author"] != undefined) {
- html.push('<a href="#">'+hit["md-author"]+'</a> ');
+ html.push('<a href="#" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;">');
+ html.push(hit["md-author"]);
+ html.push("</a>");
+ lines++;
+ }
+ else if (hit["md-title-responsibility"] != undefined) {
+ html.push('<a href="#" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;">');
+ html.push(hit["md-title-responsibility"]);
+ html.push("</a>");
+ lines++;
}
- else if (hit["md-title-responsibility"] !== undefined) {
- html.push('<a href="#">'+hit["md-title-responsibility"]+'</a> ');
+ for (var idx = lines ; idx < 2 ; idx++) {
+ html.push('<a href="#" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;">');
+ html.push(" ");
+ html.push("</a>");
}
+/*
if (hit.recid == curDetRecId) {
html.push(renderDetails_iphone(curDetRecData));
}
+*/
html.push('</li>');
}
+ document.getElementById("loading").style.display = 'none';
// set up "More..." if needed.
style = 'display:none';
if (recToShow < recPerPage) {
style = 'display:block';
}
- html.push('<li id="recdiv_END" style="' + style + '"><a onclick="showMoreRecords()">More...</a></li>');
+ html.push('<li class="img" id="recdiv_END" style="' + style + '"><a onclick="showMoreRecords()">More...</a></li>');
replaceHtml(results, html.join(''));
}
+ '/' + data.hits + ' :.</span>';
}
-function showhide(newtab) {
+function showhide(newtab, hash) {
var showtermlist = false;
if (newtab != null)
tab = newtab;
if (tab == "recordview") {
document.getElementById("recordview").style.display = '';
+ if (hash != undefined)
+ document.location.hash = hash;
}
else
document.getElementById("recordview").style.display = 'none';
else
document.getElementById("term_authors").style.display = 'none';
+ if (tab == "detailview") {
+ document.getElementById("detailview").style.display = '';
+ }
+ else {
+ document.getElementById("detailview").style.display = 'none';
+ var element = document.getElementById("rec_" + curDetRecId);
+ if (element != undefined)
+ element.scrollIntoView();
+
+ }
if (showtermlist == false)
document.getElementById("termlist").style.display = 'none';
else
termlists.push('<div id="term_xtargets" >');
termlists.push('<h4 class="termtitle">Sources</h4>');
- termlists.push('<ul>');
- termlists.push('<li><a href="#" target_id="reset_xt" onclick="limitOrResetTarget(\'reset_xt\',\'All\');return false;">All</a></li>');
+ termlists.push('<ul class="termlist">');
+ termlists.push('<li> <a href="#" target_id="reset_xt" onclick="limitOrResetTarget(\'reset_xt\',\'All\');return false;">All</a></li>');
for (var i = 0; i < data.xtargets.length && i < SourceMax; i++ ) {
- termlists.push('<li><a href="#" target_id='+data.xtargets[i].id
+ termlists.push('<li class="termlist"><a href="#" target_id='+data.xtargets[i].id
+ ' onclick="limitOrResetTarget(this.getAttribute(\'target_id\'), \'' + data.xtargets[i].name + '\');return false;">'
+ data.xtargets[i].name + ' (' + data.xtargets[i].freq + ')</a></li>');
}
termlists.push('<div id="term_subjects" >');
termlists.push('<h4>Subjects</h4>');
- termlists.push('<ul>');
+ termlists.push('<ul class="termlist">');
termlists.push('<li><a href="#" target_id="reset_su" onclick="limitOrResetQuery(\'reset_su\',\'All\');return false;">All</a></li>');
for (var i = 0; i < data.subject.length && i < SubjectMax; i++ ) {
termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'su\', \'' + data.subject[i].name + '\');return false;">'
termlists.push('<div id="term_authors" >');
termlists.push('<h4 class="termtitle">Authors</h4>');
- termlists.push('<ul>');
+ termlists.push('<ul class="termlist">');
termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'reset_au\',\'All\');return false;">All<a></li>');
for (var i = 0; i < data.author.length && i < AuthorMax; i++ ) {
termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'au\', \'' + data.author[i].name +'\');return false;">'
}
function my_onrecord(data) {
+
// FIXME: record is async!!
clearTimeout(my_paz.recordTimer);
// in case on_show was faster to redraw element
- var detRecordDiv = document.getElementById('det_'+data.recid);
- if (detRecordDiv) return;
+ var detailRecordDiv = document.getElementById('detailrecord');
+ if (!detailRecordDiv)
+ return;
curDetRecData = data;
- var recordDiv = document.getElementById('recdiv_'+curDetRecData.recid);
var html = renderDetails_iphone(curDetRecData);
- recordDiv.innerHTML += html;
+ detailRecordDiv.innerHTML = html;
+ document.getElementById("loading").style.diplay = 'none';
+ showhide('detailview');
}
function my_onrecord_iphone(data) {
applicationMode(true);
else
applicationMode(false);
+
+ var params = parseQueryString(window.location.search);
+ if (params.query) {
+ document.search.query.value = params.query;
+ onFormSubmitEventHandler();
+ }
}
function applicationMode(newmode)
"limit" : getFacets()
}
);
+ document.getElementById("loading").style.diplay = 'block';
}
function loadSelect ()
var oldRecId = curDetRecId;
curDetRecId = recId;
- // remove current detailed view if any
- var detRecordDiv = document.getElementById('det_'+oldRecId);
- //alert("oldRecId: " + oldRecId + " " + detRecordDiv != null);
- // lovin DOM!
- if (detRecordDiv)
- detRecordDiv.parentNode.removeChild(detRecordDiv);
-
- // if the same clicked, just hide
+ // if the same clicked, just show it again
if (recId == oldRecId) {
- curDetRecId = '';
- curDetRecData = null;
+ showhide('detailview');
return;
}
// request the record
my_paz.record(recId);
+ document.getElementById("loading").style.diplay = 'block';
}
function replaceHtml(el, html) {
if (marker) details += '<tr><td>'+ marker + '</td></tr>';
if (data["md-title"] != undefined) {
details += '<tr><td><b>Title</b></td><td><b>:</b> '+data["md-title"];
- if (data["md-title-remainder"] !== undefined) {
+ if (data["md-title-remainder"] != undefined) {
details += ' : <span>' + data["md-title-remainder"] + ' </span>';
}
- if (data["md-author"] !== undefined) {
+ if (data["md-author"] != undefined) {
details += ' <span><i>'+ data["md-auhtor"] +'</i></span>';
}
- details += '</td></tr>';
+ details += '</td></tr>';
}
if (data["md-date"] != undefined)
details += '<tr><td><b>Date</b></td><td><b>:</b> ' + data["md-date"] + '</td></tr>';
function renderLine(title, value) {
if (value != undefined)
- return '<li><h3>' + title + '</h3> <big>' + value + '</big></li>';
+ return '<li><h3>' + title + '</h3> <big>' + value + '<br></big></li>';
return '';
}
+function renderLines(title, values, name) {
+ var result = "";
+ result = '<li><h3>' + title + '</h3><big>';
+ if (values != undefined && values.length)
+ for (var idx = 0 ; idx < values.length ; idx++)
+ result += values[idx][name] + '<br>';
+ result += '</big>';
+ return result;
+}
+
+function renderLinesURL(title, values, name, url) {
+ var result = "";
+ result = '<li><h3>' + title + '</h3><big>';
+ if (values != undefined && values.length) {
+ for (var idx = 0 ; idx < values.length ; idx++) {
+ if (values[idx][url] != undefined)
+ result += '<a href="' + values[idx][url] + '">' + values[idx][name] + '</a><br>';
+ else
+ result += values[idx][name] + '<br>';
+ }
+ }
+ result += '</big>';
+ return result;
+}
+
function renderLineURL(title, URL, display) {
if (URL != undefined)
return '<li><h3>' + title + '</h3> <a href="' + URL + '" target="_blank">' + display + '</a></li>';
*/
if (marker)
details += '<h4>'+ marker + '</h4>';
- details += '<ul class="field">';
+ details += '<ul class="field" >';
if (data["md-title"] != undefined) {
- details += '<li><h3>Title</h3> <big> ' + data["md-title"];
- if (data["md-title-remainder"] !== undefined) {
- details += ' ' + data["md-title-remainder"] + ' ';
+ details += '<li><h3>Title</h3><big> ' + data["md-title"];
+ if (data["md-title-remainder"] != undefined) {
+ details += ' - ' + data["md-title-remainder"] + ' ';
}
- if (data["md-author"] !== undefined) {
+/*
+ if (data["md-author"] != undefined) {
details += '<i>'+ data["md-author"] +'</i>';
- } else if (data["md-title-responsibility"] !== undefined) {
+ } else if (data["md-title-responsibility"] != undefined) {
details += '<i>'+ data["md-title-responsibility"] +'</i>';
}
+*/
details += '</big>'
details += '</li>'
}
details
+=renderLine('Date', data["md-date"])
+ renderLine('Author', data["md-author"])
- + renderLineURL('URL', data["md-electronic-url"], data["md-electronic-url"])
- + renderLine('Subject', data["location"][0]["md-subject"]);
+// + renderLineURL('URL', data["md-electronic-url"], data["md-electronic-url"])
+ + renderLine('Description', data["md-description"]);
+ + renderLines('Subjects', data["location"], "md-subject");
- if (data["location"][0]["@name"] != undefined)
- details += renderLine('Location', data["location"][0]["@name"] + " (" +data["location"][0]["@id"] + ")");
+ details += renderLinesURL('Location', data["location"], "@name", "md-url_recipe");
details += '</ul></div>';
return details;
}