From 7a3f63e3bf202dfaa7eece4f1b889b8622a17b8e Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Fri, 4 Jun 2010 15:32:02 +0200 Subject: [PATCH] Generating iPhone style lists. Introduce an error on filtering (include the freq) --- www/iphone/example_client.js | 54 ++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/www/iphone/example_client.js b/www/iphone/example_client.js index 64843f0..3579893 100644 --- a/www/iphone/example_client.js +++ b/www/iphone/example_client.js @@ -7,6 +7,8 @@ var usesessions = true; var pazpar2path = '/pazpar2/search.pz2'; var showResponseType = ''; +var queryBeforeLimit = null; + if (document.location.hash == '#useproxy') { usesessions = false; pazpar2path = '/service-proxy/'; @@ -134,31 +136,37 @@ 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('')); @@ -199,19 +207,19 @@ function serialize(array) { var termlist = {}; function my_onterm_iphone(data) { my_onterm(data); - var targets = "-|All|\n"; + var targets = "reset_to_all|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 = "-|All|\n"; + var subjects = "reset_to_all|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 = "-|All|\n"; + var authors = "reset_to_all|All\n"; for (var i = 0; i < data.author.length; i++ ) { authors = authors + "au" + "|" + data.author[i].name + "|" + data.author[i].freq + "\n"; } @@ -335,11 +343,31 @@ function loadSelect () // limit the query after clicking the facet function limitQuery (field, value) { + if (!queryBeforeLimit) + queryBeforeLimit = document.search.query.value; document.search.query.value += ' and ' + field + '="' + value + '"'; 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_to_all') { + document.search.query.value = queryBeforeLimit; + queryBeforeLimit = null; + } + else + limitQuery(field, value); + alert("query: " + document.search.query.value); +} + // limit by target functions function limitTarget (id, name) { -- 1.7.10.4