From eebee58a810c0936dd9aa8c2a77495cb1bc6e023 Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Fri, 18 Nov 2011 16:30:13 +0100 Subject: [PATCH] Add thumbnails to list view. Add separate detail view. Use CSS class more --- www/iphone/example_client.js | 206 ++++++++++++++++++++++++++++++++---------- 1 file changed, 158 insertions(+), 48 deletions(-) diff --git a/www/iphone/example_client.js b/www/iphone/example_client.js index 71f5add..e447c9e 100644 --- a/www/iphone/example_client.js +++ b/www/iphone/example_client.js @@ -14,13 +14,15 @@ var querys_server = {}; 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, @@ -153,6 +155,35 @@ function showMoreRecords() { } } +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 @@ -172,35 +203,72 @@ function my_onshow(data) { 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('
  • ' - +'' - + hit["md-title"] +' '); - if (hit["md-title-remainder"] !== undefined) { - html.push('' + hit["md-title-remainder"] + ' '); + html.push('
  • ' ); + html.push(''); + 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(""); + html.push(''); + html.push(hit["md-title"]); + html.push(""); + + if (hit["md-title-remainder"] != undefined) { + html.push(''); + html.push(hit["md-title-remainder"]); + html.push(""); + lines++; } if (hit["md-author"] != undefined) { - html.push(''+hit["md-author"]+' '); + html.push(''); + html.push(hit["md-author"]); + html.push(""); + lines++; + } + else if (hit["md-title-responsibility"] != undefined) { + html.push(''); + html.push(hit["md-title-responsibility"]); + html.push(""); + lines++; } - else if (hit["md-title-responsibility"] !== undefined) { - html.push(''+hit["md-title-responsibility"]+' '); + for (var idx = lines ; idx < 2 ; idx++) { + html.push(''); + html.push(" "); + html.push(""); } +/* if (hit.recid == curDetRecId) { html.push(renderDetails_iphone(curDetRecData)); } +*/ html.push('
  • '); } + document.getElementById("loading").style.display = 'none'; // set up "More..." if needed. style = 'display:none'; if (recToShow < recPerPage) { style = 'display:block'; } - html.push('
  • More...
  • '); + html.push('
  • More...
  • '); replaceHtml(results, html.join('')); } @@ -217,13 +285,15 @@ function my_onstat(data) { + '/' + data.hits + ' :.'; } -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'; @@ -249,6 +319,16 @@ function showhide(newtab) { 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 @@ -268,10 +348,10 @@ function my_onterm(data) { termlists.push('
    '); termlists.push('

    Sources

    '); - termlists.push('