X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=www%2Fiphone%2Fexample_client.js;h=f3dbc0e1d59152449b6c0800160629a4199a525f;hb=ba078badeed6453da3df9c8ebfaa330e5efd95a1;hp=b728f959bcd900ada469e73dab8d066c94a7c0d2;hpb=a14c3ce9ee3f8b46f28fb3eaf99e4cb71d3fad18;p=pazpar2-moved-to-github.git
diff --git a/www/iphone/example_client.js b/www/iphone/example_client.js
index b728f95..f3dbc0e 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 querys = {'su': '', 'au': '', 'xt': ''};
+
if (document.location.hash == '#useproxy') {
usesessions = false;
pazpar2path = '/service-proxy/';
@@ -37,7 +39,6 @@ var SourceMax = 16;
var SubjectMax = 10;
var AuthorMax = 10;
var tab = "recordview";
-var inApp = false;
//
@@ -58,7 +59,7 @@ function my_onshow(data) {
' of ' + data.merged + ' (found: '
+ data.total + ')';
drawPager(pager);
- // navi
+
var results = document.getElementById("results");
var html = [];
@@ -76,7 +77,7 @@ function my_onshow(data) {
}
}
if (hit.recid == curDetRecId) {
- html.push(renderDetails(curDetRecData));
+ html.push(renderDetails_iphone(curDetRecData));
}
html.push('');
}
@@ -112,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;
@@ -135,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();
}
@@ -200,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;
@@ -240,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;
}
@@ -277,14 +280,30 @@ function domReady ()
document.search.query.value = '';
document.select.sort.onchange = onSelectDdChange;
document.select.perpage.onchange = onSelectDdChange;
- if (!inApp)
- document.getElementById("heading").style.display="";
+ if (document.location.search.match("inApp=true"))
+ applicationMode(true);
+}
+
+function applicationMode(newmode)
+{
+ var searchdiv = document.getElementById("searchForm");
+ if (newmode)
+ inApp = newmode;
+ if (inApp) {
+ document.getElementById("heading").style.display="none";
+ searchdiv.style.display = 'none';
+ }
+ else {
+ searchdiv.style.display = '';
+ document.search.onsubmit = onFormSubmit;
+ }
+ callback.init();
}
-
// when search button pressed
function onFormSubmitEventHandler()
{
resetPage();
+ document.getElementById("logo").style.display = 'none';
loadSelect();
triggerSearch();
submitted = true;
@@ -318,21 +337,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();
@@ -343,8 +380,6 @@ function limitTarget (id, name)
function delimitTarget ()
{
- var navi = document.getElementById('navi');
- navi.innerHTML = '';
curFilter = null;
resetPage();
loadSelect();
@@ -352,6 +387,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
@@ -394,7 +438,7 @@ function drawPager (pagerDiv)
if (lastClkbl < pages)
postdots = '...';
- pagerDiv.innerHTML += ''
+ pagerDiv.innerHTML += '
'
+ prev + predots + middle + postdots + next + '
';
}
@@ -447,6 +491,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);
@@ -502,4 +547,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 += '
';
+ if (data["md-title"] != undefined) {
+ details += 'Title
' + data["md-title"];
+ if (data["md-title-remainder"] !== undefined) {
+ details += ' ' + data["md-title-remainder"] + ' ';
+ }
+ if (data["md-title-responsibility"] !== undefined) {
+ details += ''+ data["md-title-responsibility"] +'';
+ }
+ details += ''
+ details += ' '
+ }
+ 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"]);
+
+ if (data["location"][0]["@name"] != undefined)
+ details += renderLine('Location', data["location"][0]["@name"] + " (" +data["location"][0]["@id"] + ")");
+ details += '
';
+ return details;
+}
+
+//EOF