From d55ccbd64dd2f0f0ec921c915a399c183df82d47 Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Mon, 7 Jun 2010 10:53:05 +0200 Subject: [PATCH] Filtering and layout fix. Filtering and reseting now works. Fix a wrong open in the term_xtarget div that would make the Subject look weird. --- www/iphone/example_client.js | 63 ++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/www/iphone/example_client.js b/www/iphone/example_client.js index 1292d8b..783a1d7 100644 --- a/www/iphone/example_client.js +++ b/www/iphone/example_client.js @@ -7,7 +7,7 @@ var usesessions = true; var pazpar2path = '/pazpar2/search.pz2'; var showResponseType = ''; -var queryBeforeLimit = null; +var querys = {'su': '', 'au': '', 'xt': ''}; if (document.location.hash == '#useproxy') { usesessions = false; @@ -113,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; @@ -138,19 +140,21 @@ function my_onterm(data) { termlists.push('
'); termlists.push('

Sources

'); termlists.push('
'); termlists.push('
'); termlists.push('
'); - termlists.push('

Subjects

'); + termlists.push('

Subjects

'); termlists.push(''); @@ -159,8 +163,9 @@ function my_onterm(data) { 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(); } @@ -207,19 +202,19 @@ function serialize(array) { var termlist = {}; function my_onterm_iphone(data) { my_onterm(data); - var targets = "reset_to_all|All\n"; + 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 = "reset_to_all|All\n"; + var subjects = "reset_su|All\n"; for (var i = 0; i < data.subject.length; i++ ) { subjects = subjects + "su" + "|" + data.subject[i].name + "|" + data.subject[i].freq + "\n"; } termlist["subjects"] = subjects; - var authors = "reset_to_all|All\n"; + var authors = "reset_au|All\n"; for (var i = 0; i < data.author.length; i++ ) { authors = authors + "au" + "|" + data.author[i].name + "|" + data.author[i].freq + "\n"; } @@ -292,11 +287,13 @@ function domReady () function applicationMode(newmode) { var searchdiv = document.getElementById("searchForm"); + var navi = document.getElementById("navi"); if (newmode) inApp = newmode; if (inApp) { document.getElementById("heading").style.display="none"; searchdiv.style.display = 'none'; + navi.style.display = 'none'; } else { searchdiv.style.display = ''; @@ -341,11 +338,11 @@ function loadSelect () } // limit the query after clicking the facet -function limitQuery (field, value) +function limitQuery(field, value) { - if (!queryBeforeLimit) - queryBeforeLimit = document.search.query.value; - document.search.query.value += ' and ' + field + '="' + value + '"'; + var newQuery = ' and ' + field + '="' + value + '"'; + querys[field] += newQuery; + document.search.query.value += newQuery; onFormSubmitEventHandler(); showhide("recordview"); } @@ -359,13 +356,16 @@ function removeQuery (field, value) { //limit the query after clicking the facet function limitOrResetQuery (field, value, selected) { - if (field == 'reset_to_all') { - document.search.query.value = queryBeforeLimit; - queryBeforeLimit = null; + 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("query: " + document.search.query.value); + //alert("limitOrResetQuerry: query after: " + document.search.query.value); } // limit by target functions @@ -395,6 +395,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 -- 1.7.10.4