X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=www%2Fiphone%2Fexample_client.js;h=a131b8ab55b3b5c32dad4fb86e7836eb8fe92631;hb=500aedbcde075374870630681c06578d7bdc06d3;hp=cfae8ed1bb1c4a8a5acf5707d0c7103534831d77;hpb=9dcc2862e93637695e496fd11fe0c69762baa06a;p=pazpar2-moved-to-github.git diff --git a/www/iphone/example_client.js b/www/iphone/example_client.js index cfae8ed..a131b8a 100644 --- a/www/iphone/example_client.js +++ b/www/iphone/example_client.js @@ -7,10 +7,12 @@ var usesessions = true; var pazpar2path = '/pazpar2/search.pz2'; var showResponseType = ''; -if (document.location.hash == '#useproxy') { +var querys = {'su': '', 'au': '', 'xt': ''}; + +if (document.location.hash == '#useproxy' || document.location.search.match("useproxy=true")) { usesessions = false; pazpar2path = '/service-proxy/'; - showResponseType = 'json'; + showResponseType = 'xml'; } my_paz = new pz2( { "onshow": my_onshow, @@ -57,7 +59,7 @@ function my_onshow(data) { ' of ' + data.merged + ' (found: ' + data.total + ')'; drawPager(pager); - // navi + var results = document.getElementById("results"); var html = []; @@ -75,7 +77,7 @@ function my_onshow(data) { } } if (hit.recid == curDetRecId) { - html.push(renderDetails(curDetRecData)); + html.push(renderDetails_iphone(curDetRecData)); } html.push(''); } @@ -111,12 +113,14 @@ function showhide(newtab) { } else document.getElementById("term_xtargets").style.display = 'none'; + if (tab == "subjects") { document.getElementById("term_subjects").style.display = ''; showtermlist = true; } else document.getElementById("term_subjects").style.display = 'none'; + if (tab == "authors") { document.getElementById("term_authors").style.display = ''; showtermlist = true; @@ -134,44 +138,43 @@ function my_onterm(data) { var termlists = []; termlists.push('
'); - termlists.push('
.::Sources
'); + termlists.push('

Sources

'); + termlists.push(''); termlists.push('
'); termlists.push('
'); - termlists.push('
.::Subjects
'); + termlists.push('

Subjects

'); + termlists.push(''); termlists.push('
'); termlists.push('
'); - termlists.push('
.::Authors
'); + termlists.push('

Authors

'); + termlists.push(''); termlists.push('
'); var termlist = document.getElementById("termlist"); replaceHtml(termlist, termlists.join('')); - var d; -/* - for (d in ("xtargets", "subjects", "authors")) { - alert(d); - if (tab == d) - document.getElementById("term_" + d).style.display = ''; - else - document.getElementById("term_" +d ).style.display = 'none'; - } -*/ showhide(); } @@ -199,20 +202,21 @@ function serialize(array) { var termlist = {}; function my_onterm_iphone(data) { my_onterm(data); - var targets = ""; + var targets = "reset_xt|All\n"; + for (var i = 0; i < data.xtargets.length; i++ ) { targets = targets + data.xtargets[i].id + "|" + data.xtargets[i].name + "|" + data.xtargets[i].freq + "\n"; } termlist["xtargets"] = targets; - var subjects = ""; + var subjects = "reset_su|All\n"; for (var i = 0; i < data.subject.length; i++ ) { - subjects = subjects + "-" + "|" + data.subject[i].name + "|" + data.subject[i].freq + "\n"; + subjects = subjects + "su" + "|" + data.subject[i].name + "|" + data.subject[i].freq + "\n"; } termlist["subjects"] = subjects; - var authors = ""; + var authors = "reset_au|All\n"; for (var i = 0; i < data.author.length; i++ ) { - authors = authors + "-" + "|" + data.author[i].name + "|" + data.author[i].freq + "\n"; + authors = authors + "au" + "|" + data.author[i].name + "|" + data.author[i].freq + "\n"; } termlist["authors"] = authors; //document.getElementById("log").innerHTML = targets + "\n" + subjects + "\n" + authors; @@ -239,7 +243,7 @@ function my_onrecord(data) { if (detRecordDiv) return; curDetRecData = data; var recordDiv = document.getElementById('recdiv_'+curDetRecData.recid); - var html = renderDetails(curDetRecData); + var html = renderDetails_iphone(curDetRecData); recordDiv.innerHTML += html; } @@ -276,7 +280,10 @@ function domReady () document.search.query.value = ''; document.select.sort.onchange = onSelectDdChange; document.select.perpage.onchange = onSelectDdChange; - applicationMode(true); + if (document.location.search.match("inApp=true")) + applicationMode(true); + else + applicationMode(false); } function applicationMode(newmode) @@ -286,7 +293,7 @@ function applicationMode(newmode) inApp = newmode; if (inApp) { document.getElementById("heading").style.display="none"; - searchdiv.style.display = 'none'; + searchdiv.style.display = 'none'; } else { searchdiv.style.display = ''; @@ -298,6 +305,7 @@ function applicationMode(newmode) function onFormSubmitEventHandler() { resetPage(); + document.getElementById("logo").style.display = 'none'; loadSelect(); triggerSearch(); submitted = true; @@ -331,21 +339,39 @@ function loadSelect () } // limit the query after clicking the facet -function limitQuery (field, value) +function limitQuery(field, value) { - document.search.query.value += ' and ' + field + '="' + value + '"'; + var newQuery = ' and ' + field + '="' + value + '"'; + querys[field] += newQuery; + document.search.query.value += newQuery; onFormSubmitEventHandler(); showhide("recordview"); } +//limit the query after clicking the facet +function removeQuery (field, value) { + document.search.query.value.replace(' and ' + field + '="' + value + '"', ''); + onFormSubmitEventHandler(); + showhide("recordview"); +} + +//limit the query after clicking the facet +function limitOrResetQuery (field, value, selected) { + if (field == 'reset_su' || field == 'reset_au') { + var reset_field = field.substring(6); + document.search.query.value = document.search.query.value.replace(querys[reset_field], ''); + querys[reset_field] = ''; + onFormSubmitEventHandler(); + showhide("recordview"); + } + else + limitQuery(field, value); + //alert("limitOrResetQuerry: query after: " + document.search.query.value); +} + // limit by target functions function limitTarget (id, name) { - var navi = document.getElementById('navi'); - navi.innerHTML = - 'Source: ' - + name + ''; - navi.innerHTML += '
'; curFilter = 'pz:id=' + id; resetPage(); loadSelect(); @@ -356,8 +382,6 @@ function limitTarget (id, name) function delimitTarget () { - var navi = document.getElementById('navi'); - navi.innerHTML = ''; curFilter = null; resetPage(); loadSelect(); @@ -365,6 +389,15 @@ function delimitTarget () return false; } +function limitOrResetTarget(id, name) { + if (id == 'reset_xt') { + delimitTarget(); + } + else { + limitTarget(id,name); + } +} + function drawPager (pagerDiv) { //client indexes pages from 1 but pz2 from 0 @@ -407,7 +440,7 @@ function drawPager (pagerDiv) if (lastClkbl < pages) postdots = '...'; - pagerDiv.innerHTML += '
' + pagerDiv.innerHTML += '
' + prev + predots + middle + postdots + next + '

'; } @@ -460,6 +493,7 @@ function showDetails (prefixRecId) { // 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); @@ -515,4 +549,61 @@ function renderDetails(data, marker) details += '
'; return details; } - //EOF + +function renderLine(title, value) { + if (value != undefined) + return '
  • ' + title + '

    ' + value + '
  • '; + return ''; +} + +function renderLineURL(title, URL, display) { + if (URL != undefined) + return '
  • ' + title + '

    ' + display + '
  • '; + return ''; +} + +function renderLineEmail(dtitle, email, display) { + if (email != undefined) + return '
  • ' + title + '

    ' + display + '
  • '; + return ''; +} + +function renderDetails_iphone(data, marker) +{ + //return renderDetails(data,marker); + + + var details = '
    ' +/* + details = ''; +*/ + if (marker) + details += '

    '+ marker + '

    '; + details += '
    '; + return details; +} + +//EOF