X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=www%2Fiphone%2Fexample_client.js;h=f3dbc0e1d59152449b6c0800160629a4199a525f;hb=ba078badeed6453da3df9c8ebfaa330e5efd95a1;hp=1d00c2ba96cd5d1c3adbc3cb75e8c80628c3877d;hpb=a55accca78d8ae95244e4e00ea01c54e37ac3639;p=pazpar2-moved-to-github.git
diff --git a/www/iphone/example_client.js b/www/iphone/example_client.js
index 1d00c2b..f3dbc0e 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;
@@ -59,7 +59,7 @@ function my_onshow(data) {
' of ' + data.merged + ' (found: '
+ data.total + ')';
drawPager(pager);
- // navi
+
var results = document.getElementById("results");
var html = [];
@@ -77,7 +77,7 @@ function my_onshow(data) {
}
}
if (hit.recid == curDetRecId) {
- html.push(renderDetails(curDetRecData));
+ html.push(renderDetails_iphone(curDetRecData));
}
html.push('');
}
@@ -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,20 +140,22 @@ function my_onterm(data) {
termlists.push('
');
termlists.push('
Sources
');
termlists.push('
');
+ termlists.push('- All
');
for (var i = 0; i < data.xtargets.length && i < SourceMax; i++ ) {
termlists.push('- ' + data.xtargets[i].name
- + ' (' + data.xtargets[i].freq + ')
');
+ + ' onclick="limitOrResetTarget(this.getAttribute(\'target_id\'), \'' + data.xtargets[i].name + '\');return false;">'
+ + data.xtargets[i].name + ' (' + data.xtargets[i].freq + ')');
}
termlists.push('
');
termlists.push('
');
termlists.push('');
- termlists.push('
Subjects
');
+ termlists.push('
Subjects
');
termlists.push('
');
termlists.push('
');
@@ -159,8 +163,9 @@ function my_onterm(data) {
termlists.push('');
termlists.push('
Authors
');
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";
}
@@ -248,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;
}
@@ -308,6 +303,7 @@ function applicationMode(newmode)
function onFormSubmitEventHandler()
{
resetPage();
+ document.getElementById("logo").style.display = 'none';
loadSelect();
triggerSearch();
submitted = true;
@@ -341,11 +337,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,23 +355,21 @@ 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
function limitTarget (id, name)
{
- var navi = document.getElementById('navi');
- navi.innerHTML =
- 'Source: '
- + name + '';
- navi.innerHTML += '
';
curFilter = 'pz:id=' + id;
resetPage();
loadSelect();
@@ -386,8 +380,6 @@ function limitTarget (id, name)
function delimitTarget ()
{
- var navi = document.getElementById('navi');
- navi.innerHTML = '';
curFilter = null;
resetPage();
loadSelect();
@@ -395,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
@@ -437,7 +438,7 @@ function drawPager (pagerDiv)
if (lastClkbl < pages)
postdots = '...';
- pagerDiv.innerHTML += ''
+ pagerDiv.innerHTML += '
'
+ prev + predots + middle + postdots + next + '
';
}
@@ -490,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);
@@ -545,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