Created a simple paging/More records
[pazpar2-moved-to-github.git] / www / iphone / example_client.js
1 /* A very simple client that shows a basic usage of the pz2.js
2 */
3
4 // create a parameters array and pass it to the pz2's constructor
5 // then register the form submit event with the pz2.search function
6 // autoInit is set to true on default
7 var usesessions = false;
8 var pazpar2path = '/service-proxy/';
9 var showResponseType = '';
10 // Facet configuration
11 var querys = {'su': '', 'au': '', 'xt': ''};
12 var query_client_server = {'su': 'subject', 'au': 'author', 'xt': 'xtargets'};
13 var querys_server = {};
14 var useLimit = 1;
15 // Fail to get JSON working stabil.
16 var showResponseType = 'xml';
17 if (document.location.hash == '#pazpar2' || document.location.search.match("useproxy=false")) {
18     usesessions = true;
19     pazpar2path = '/pazpar2/search.pz2';
20     showResponseType = 'xml';
21 }
22
23
24 my_paz = new pz2( { "onshow": my_onshow,
25                     "showtime": 500,            //each timer (show, stat, term, bytarget) can be specified this way
26                     "pazpar2path": pazpar2path,
27                     "oninit": my_oninit,
28                     "onstat": my_onstat,
29                     "onterm": my_onterm_iphone,
30                     "termlist": "xtargets,subject,author",
31                     "onbytarget": my_onbytarget,
32                     "usesessions" : usesessions,
33                     "showResponseType": showResponseType,
34                     "onrecord": my_onrecord } );
35 // some state vars
36 var curPage = 1;
37 var recPerPage = 100;
38 var recToShowPageSize = 20;
39 var recToShow = recToShowPageSize;
40 var recIDs = {};
41 var totalRec = 0;
42 var curDetRecId = '';
43 var curDetRecData = null;
44 var curSort = 'relevance';
45 var curFilter = 'ALL';
46 var submitted = false;
47 var SourceMax = 16;
48 var SubjectMax = 10;
49 var AuthorMax = 10;
50 var tab = "recordview"; 
51
52 var triedPass = "";
53 var triedUser = "";
54
55 function loginFormSubmit() {
56     triedUser = document.loginForm.username.value;
57     triedPass = document.loginForm.password.value;
58     auth.login( {"username": triedUser,
59                 "password": triedPass},
60         authCb, authCb);
61 }
62
63 function handleKeyPress(e)  
64 {  
65   var key;  
66   if(window.event)  
67     key = window.event.keyCode;  
68   else  
69     key = e.which;  
70
71   if(key == 13 || key == 10)  
72   {  
73       button = document.getElementById('button');
74       button.focus();
75       button.click();
76
77       return false;  
78   }  
79   else  
80     return true;  
81 }  
82
83 function authCb(authData) {
84     if (!authData.loginFailed) {
85         triedUser = "";
86         triedPass = "";
87     }
88
89     if (authData.loggedIn == true) {        
90         showhide("recordview");
91     }
92 }
93
94 function logOutClick() {
95     auth.logOut(authCb, authCb);
96 }
97
98 function loggedOut() {
99     var login = document.getElementById("login");
100     login.innerHTML = 'Login';
101 }
102
103 function loggingOutFailed() {
104     alert("Logging out failed");
105 }
106
107 function login() {
108     showhide("login");
109 }
110
111 function logout() {
112     auth.logOut(loggedOut, loggingOutFailed, true);
113 }
114
115 function logInOrOut() {
116     var loginElement = document.getElementById("login");
117     if (loginElement.innerHTML == 'Login')
118         login();
119     else
120         logout();
121 }
122 function loggedIn() {
123     var login = document.getElementById("login");
124     login.innerHTML = 'Logout(' + auth.displayName + ')';
125     document.getElementById("log").innerHTML = login.innerHTML;
126 }
127
128 function auth_check() {
129     auth.check(loggedIn, login);
130     domReady();
131 }
132
133 //
134 // Pz2.js event handlers:
135 //
136 function my_oninit() {
137     my_paz.stat();
138     my_paz.bytarget();
139 }
140
141 function showMoreRecords() {
142     var i = recToShow;
143     recToShow += recToShowPageSize;
144     for ( ; i < recToShow && i < recPerPage; i++) {
145         var element = document.getElementById(recIDs[i]);
146         if (element)
147             element.style.display = '';
148     }
149     if (i == recPerPage) {
150         var element = document.getElementById('recdiv_END');
151         if (element)
152             element.style.display = 'none';
153     }
154 }
155
156 function my_onshow(data) {
157     totalRec = data.merged;
158     // move it out
159     var pager = document.getElementById("pager");
160     pager.innerHTML = "";
161     pager.innerHTML +='<hr/><div style="float: right">Displaying: ' 
162                     + (data.start + 1) + ' to ' + (data.start + data.num) +
163                      ' of ' + data.merged + ' (found: ' 
164                      + data.total + ')</div>';
165     drawPager(pager);
166
167     var results = document.getElementById("results");
168     
169     var html = [];
170     if (data.hits == undefined) 
171         return ;
172     var style = '';
173     for (var i = 0; i < data.hits.length; i++) {
174         var hit = data.hits[i];
175         var recID = "recdiv_" + hit.recid; 
176         //var recID = "recdiv_" + i; 
177         recIDs[i] = recID;
178         if (i == recToShow)
179             style = ' style="display:none" ';
180         html.push('<li id="' + recID + '" ' + style +  '>' 
181                   +'<a href="#" id="rec_'+hit.recid
182                   +'" onclick="showDetails(this.id);return false;">' 
183                   + hit["md-title"] +'</a> '); 
184         if (hit["md-title-responsibility"] !== undefined) {
185             html.push('<a href="#">'+hit["md-title-responsibility"]+'</a> ');
186             if (hit["md-title-remainder"] !== undefined) {
187                 html.push('<a href="#">' + hit["md-title-remainder"] + ' </a> ');
188             }
189         }
190         if (hit.recid == curDetRecId) {
191             html.push(renderDetails_iphone(curDetRecData));
192         }
193         html.push('</li>');
194     }
195     // set up "More..." if needed. 
196     style = 'display:none';
197     if (recToShow < recPerPage) {
198         style = 'display:block';
199     }
200     html.push('<li id="recdiv_END" style="' + style + '"><a onclick="showMoreRecords()">More...</a></li>');     
201
202     replaceHtml(results, html.join(''));
203 }
204
205 function my_onstat(data) {
206     var stat = document.getElementById("stat");
207     if (stat == null)
208         return;
209     
210     stat.innerHTML = '<b> .:STATUS INFO</b> -- Active clients: '
211                         + data.activeclients
212                         + '/' + data.clients + ' -- </span>'
213                         + '<span>Retrieved records: ' + data.records
214                         + '/' + data.hits + ' :.</span>';
215 }
216
217 function showhide(newtab) {
218     var showtermlist = false;
219     if (newtab != null)
220         tab = newtab;
221     
222     if (tab == "recordview") {
223         document.getElementById("recordview").style.display = '';
224     }
225     else 
226         document.getElementById("recordview").style.display = 'none';
227
228     if (tab == "xtargets") {
229         document.getElementById("term_xtargets").style.display = '';
230         showtermlist = true;
231     }
232     else
233         document.getElementById("term_xtargets").style.display = 'none';
234
235     if (tab == "subjects") {
236         document.getElementById("term_subjects").style.display = '';
237         showtermlist = true;
238     }
239     else
240         document.getElementById("term_subjects").style.display = 'none';
241
242     if (tab == "authors") {
243         document.getElementById("term_authors").style.display = '';
244         showtermlist = true;
245     }
246     else
247         document.getElementById("term_authors").style.display = 'none';
248
249     if (showtermlist == false) 
250         document.getElementById("termlist").style.display = 'none';
251     else 
252         document.getElementById("termlist").style.display = '';
253
254     var tabDiv = document.getElementById("loginDiv");
255     if (tab == "login") {
256         tabDiv.style.display = '';
257     }
258     else {
259         tabDiv.style.display = 'none';
260     }
261 }
262
263 function my_onterm(data) {
264     var termlists = [];
265     
266     termlists.push('<div id="term_xtargets" >');
267     termlists.push('<h4 class="termtitle">Sources</h4>');
268     termlists.push('<ul>');
269     termlists.push('<li><a href="#" target_id="reset_xt" onclick="limitOrResetTarget(\'reset_xt\',\'All\');return false;">All</a></li>');
270     for (var i = 0; i < data.xtargets.length && i < SourceMax; i++ ) {
271         termlists.push('<li><a href="#" target_id='+data.xtargets[i].id
272             + ' onclick="limitOrResetTarget(this.getAttribute(\'target_id\'), \'' + data.xtargets[i].name + '\');return false;">' 
273             + data.xtargets[i].name + ' (' + data.xtargets[i].freq + ')</a></li>');
274     }
275     termlists.push('</ul>');
276     termlists.push('</div>');
277      
278     termlists.push('<div id="term_subjects" >');
279     termlists.push('<h4>Subjects</h4>');
280     termlists.push('<ul>');
281     termlists.push('<li><a href="#" target_id="reset_su" onclick="limitOrResetQuery(\'reset_su\',\'All\');return false;">All</a></li>');
282     for (var i = 0; i < data.subject.length && i < SubjectMax; i++ ) {
283         termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'su\', \'' + data.subject[i].name + '\');return false;">' 
284                        + data.subject[i].name + ' (' + data.subject[i].freq + ')</a></li>');
285     }
286     termlists.push('</ul>');
287     termlists.push('</div>');
288             
289     termlists.push('<div id="term_authors" >');
290     termlists.push('<h4 class="termtitle">Authors</h4>');
291     termlists.push('<ul>');
292     termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'reset_au\',\'All\');return false;">All<a></li>');
293     for (var i = 0; i < data.author.length && i < AuthorMax; i++ ) {
294         termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'au\', \'' + data.author[i].name +'\');return false;">' 
295                             + data.author[i].name 
296                             + '  (' 
297                             + data.author[i].freq 
298                             + ')</a></li>');
299     }
300     termlists.push('</ul>');
301     termlists.push('</div>');
302     var termlist = document.getElementById("termlist");
303     replaceHtml(termlist, termlists.join(''));
304     showhide();
305 }
306
307 var termlist = {};
308 function my_onterm_iphone(data) {
309     my_onterm(data);
310     var targets = "reset_xt|All\n";
311     
312     for (var i = 0; i < data.xtargets.length; i++ ) {
313         
314         targets = targets + data.xtargets[i].id + "|" + data.xtargets[i].name + "|" + data.xtargets[i].freq + "\n";
315     }
316     termlist["xtargets"] = targets;
317     var subjects = "reset_su|All\n";
318     for (var i = 0; i < data.subject.length; i++ ) {
319         subjects = subjects + "su" + "|" + data.subject[i].name + "|" + data.subject[i].freq + "\n";
320     }
321     termlist["subjects"] = subjects;
322     var authors = "reset_au|All\n";
323     for (var i = 0; i < data.author.length; i++ ) {
324         authors = authors + "au" + "|" + data.author[i].name + "|" + data.author[i].freq + "\n";
325     }
326     termlist["authors"] = authors;
327     callback.send("termlist", "refresh");
328 }
329
330 function getTargets() {
331         return termlist['xtargets'];
332 }
333
334 function getSubjects() {
335         return termlist['subjects'];
336 }
337
338 function getAuthors() {
339         return termlist['authors'];
340 }
341
342 function my_onrecord(data) {
343     // FIXME: record is async!!
344     clearTimeout(my_paz.recordTimer);
345     // in case on_show was faster to redraw element
346     var detRecordDiv = document.getElementById('det_'+data.recid);
347     if (detRecordDiv) return;
348     curDetRecData = data;
349     var recordDiv = document.getElementById('recdiv_'+curDetRecData.recid);
350     var html = renderDetails_iphone(curDetRecData);
351     recordDiv.innerHTML += html;
352 }
353
354 function my_onrecord_iphone(data) {
355     my_onrecord(data);
356     callback.send("record", data.recid, data, data.xtargets[i].freq);
357 }
358
359
360 function my_onbytarget(data) {
361     var targetDiv = document.getElementById("bytarget");
362     var table ='<table><thead><tr><td>Target ID</td><td>Hits</td><td>Diags</td>'
363         +'<td>Records</td><td>State</td></tr></thead><tbody>';
364     
365     for (var i = 0; i < data.length; i++ ) {
366         table += "<tr><td>" + data[i].id +
367             "</td><td>" + data[i].hits +
368             "</td><td>" + data[i].diagnostic +
369             "</td><td>" + data[i].records +
370             "</td><td>" + data[i].state + "</td></tr>";
371     }
372
373     table += '</tbody></table>';
374     targetDiv.innerHTML = table;
375 }
376
377 ////////////////////////////////////////////////////////////////////////////////
378 ////////////////////////////////////////////////////////////////////////////////
379
380 // wait until the DOM is ready
381 function domReady () 
382
383     document.search.onsubmit = onFormSubmitEventHandler;
384     document.search.query.value = '';
385     document.select.sort.onchange = onSelectDdChange;
386     document.select.perpage.onchange = onSelectDdChange;
387     if (document.location.search.match("inApp=true")) 
388         applicationMode(true);
389     else
390         applicationMode(false);
391 }
392  
393 function applicationMode(newmode) 
394 {
395     var searchdiv = document.getElementById("searchForm");
396     if (newmode)
397         inApp = newmode;
398     if (inApp) {
399         document.getElementById("heading").style.display="none";
400         searchdiv.style.display = 'none';
401     }
402     else { 
403         
404         document.getElementById("nav").style.display="";
405         document.getElementById("normal").style.display="inline";
406         document.getElementById("normal").style.visibility="";
407         searchdiv.style.display = '';
408         document.search.onsubmit = onFormSubmit;
409     }
410     callback.init();
411 }
412 // when search button pressed
413 function onFormSubmitEventHandler() 
414 {
415     resetPage();
416     document.getElementById("logo").style.display = 'none';
417     loadSelect();
418     triggerSearch();
419     submitted = true;
420     return true;
421 }
422
423 function onSelectDdChange()
424 {
425     if (!submitted) return false;
426     resetPage();
427     loadSelect();
428     my_paz.show(0, recPerPage, curSort);
429     return false;
430 }
431
432 function resetPage()
433 {
434     curPage = 1;
435     totalRec = 0;
436 }
437
438 function getFacets() {
439     var result = "";
440     for (var key in querys_server) {
441         if (result.length > 0)
442             result += ","
443         result += querys_server[key];
444     }
445     return result;
446 }
447
448 function triggerSearch ()
449 {
450     // Restore to initial page size
451     recToShow = recToShowPageSize;
452     my_paz.search(document.search.query.value, recPerPage, curSort, curFilter, undefined,
453         {
454            "limit" : getFacets() 
455         }
456         );
457 }
458
459 function loadSelect ()
460 {
461     curSort = document.select.sort.value;
462     recPerPage = document.select.perpage.value;
463 }
464
465 // limit the query after clicking the facet
466 function limitQuery(field, value)
467 {
468   var newQuery = ' and ' + field + '="' + value + '"';
469   querys[field] += newQuery;
470   document.search.query.value += newQuery;
471   onFormSubmitEventHandler();
472   showhide("recordview");
473 }
474
475 // limit the query after clicking the facet
476 function limitQueryServer(field, value)
477 {
478     // Check for client field usage
479     var fieldname = query_client_server[field];
480     if (!fieldname) 
481         fieldname = field;      
482     
483     var newQuery = fieldname + '=' + value.replace(",", "\\,").replace("|", "\\,");
484     // Does it already exists?
485     if (querys_server[fieldname]) 
486         querys_server[fieldname] += "," + newQuery;
487     else
488         querys_server[fieldname] = newQuery;
489 //  document.search.query.value += newQuery;
490   onFormSubmitEventHandler();
491   showhide("recordview");
492 }
493
494
495
496 // limit the query after clicking the facet
497 function removeQuery (field, value) {
498         document.search.query.value.replace(' and ' + field + '="' + value + '"', '');
499     onFormSubmitEventHandler();
500     showhide("recordview");
501 }
502
503 // limit the query after clicking the facet
504 function limitOrResetQuery (field, value, selected) {
505     if (useLimit) {
506         limitOrResetQueryServer(field,value, selected);
507         return ;
508     }
509     if (field == 'reset_su' || field == 'reset_au') {
510         var reset_field = field.substring(6);
511         document.search.query.value = document.search.query.value.replace(querys[reset_field], '');
512         querys[reset_field] = '';
513         onFormSubmitEventHandler();
514         showhide("recordview");
515     }
516     else 
517         limitQuery(field, value);
518         //alert("limitOrResetQuerry: query after: " + document.search.query.value);
519 }
520
521 // limit the query after clicking the facet
522 function limitOrResetQueryServer (field, value, selected) {
523     if (field.substring(0,6) == 'reset_') {
524         var clientname = field.substring(6);
525         var fieldname = query_client_server[clientname];
526         if (!fieldname) 
527             fieldname = clientname;     
528         delete querys_server[fieldname];
529         onFormSubmitEventHandler();
530         showhide("recordview");
531     }
532     else 
533         limitQueryServer(field, value);
534         //alert("limitOrResetQuerry: query after: " + document.search.query.value);
535 }
536
537
538
539
540 // limit by target functions
541 function limitTarget (id, name)
542 {
543     curFilter = 'pz:id=' + id;
544     resetPage();
545     loadSelect();
546     triggerSearch();
547     showhide("recordview");
548     return false;
549 }
550
551 function delimitTarget ()
552 {
553     curFilter = 'ALL'; 
554     resetPage();
555     loadSelect();
556     triggerSearch();
557     return false;
558 }
559
560 function limitOrResetTarget(id, name) {
561         if (id == 'reset_xt') {
562                 delimitTarget();
563         }
564         else {
565                 limitTarget(id,name);
566         }
567 }
568
569 function drawPager (pagerDiv)
570 {
571     //client indexes pages from 1 but pz2 from 0
572     var onsides = 6;
573     var pages = Math.ceil(totalRec / recPerPage);
574     
575     var firstClkbl = ( curPage - onsides > 0 ) 
576         ? curPage - onsides
577         : 1;
578
579     var lastClkbl = firstClkbl + 2*onsides < pages
580         ? firstClkbl + 2*onsides
581         : pages;
582
583     var prev = '<span id="prev">&#60;&#60; Prev</span><b> | </b>';
584     if (curPage > 1)
585         var prev = '<a href="#" id="prev" onclick="pagerPrev();">'
586         +'&#60;&#60; Prev</a><b> | </b>';
587
588     var middle = '';
589     for(var i = firstClkbl; i <= lastClkbl; i++) {
590         var numLabel = i;
591         if(i == curPage)
592             numLabel = '<b>' + i + '</b>';
593
594         middle += '<a href="#" onclick="showPage(' + i + ')"> '
595             + numLabel + ' </a>';
596     }
597     
598     var next = '<b> | </b><span id="next">Next &#62;&#62;</span>';
599     if (pages - curPage > 0)
600     var next = '<b> | </b><a href="#" id="next" onclick="pagerNext()">'
601         +'Next &#62;&#62;</a>';
602
603     predots = '';
604     if (firstClkbl > 1)
605         predots = '...';
606
607     postdots = '';
608     if (lastClkbl < pages)
609         postdots = '...';
610
611     pagerDiv.innerHTML += '<div style="float: none">' 
612         + prev + predots + middle + postdots + next + '</div><hr/>';
613 }
614
615 function showPage (pageNum)
616 {
617     curPage = pageNum;
618     my_paz.showPage( curPage - 1 );
619 }
620
621 // simple paging functions
622
623 function pagerNext() {
624     if ( totalRec - recPerPage*curPage > 0) {
625         my_paz.showNext();
626         curPage++;
627     }
628 }
629
630 function pagerPrev() {
631     if ( my_paz.showPrev() != false )
632         curPage--;
633 }
634
635 // swithing view between targets and records
636
637 function switchView(view) {
638     
639     var targets = document.getElementById('targetview');
640     var records = document.getElementById('recordview');
641     
642     switch(view) {
643         case 'targetview':
644             targets.style.display = "block";            
645             records.style.display = "none";
646             break;
647         case 'recordview':
648             targets.style.display = "none";            
649             records.style.display = "block";
650             break;
651         default:
652             alert('Unknown view.');
653     }
654 }
655
656 // detailed record drawing
657 function showDetails (prefixRecId) {
658     var recId = prefixRecId.replace('rec_', '');
659     var oldRecId = curDetRecId;
660     curDetRecId = recId;
661     
662     // remove current detailed view if any
663     var detRecordDiv = document.getElementById('det_'+oldRecId);
664     //alert("oldRecId: " + oldRecId + " " + detRecordDiv != null); 
665     // lovin DOM!
666     if (detRecordDiv)
667       detRecordDiv.parentNode.removeChild(detRecordDiv);
668
669     // if the same clicked, just hide
670     if (recId == oldRecId) {
671         curDetRecId = '';
672         curDetRecData = null;
673         return;
674     }
675     // request the record
676     my_paz.record(recId);
677 }
678
679 function replaceHtml(el, html) {
680   var oldEl = typeof el === "string" ? document.getElementById(el) : el;
681   /*@cc_on // Pure innerHTML is slightly faster in IE
682     oldEl.innerHTML = html;
683     return oldEl;
684     @*/
685   var newEl = oldEl.cloneNode(false);
686   newEl.innerHTML = html;
687   oldEl.parentNode.replaceChild(newEl, oldEl);
688   /* Since we just removed the old element from the DOM, return a reference
689      to the new element, which can be used to restore variable references. */
690   return newEl;
691 };
692
693 function renderDetails(data, marker)
694 {
695     var details = '<div class="details" id="det_'+data.recid+'"><table>';
696     if (marker) details += '<tr><td>'+ marker + '</td></tr>';
697     if (data["md-title"] != undefined) {
698         details += '<tr><td><b>Title</b></td><td><b>:</b> '+data["md-title"];
699         if (data["md-title-remainder"] !== undefined) {
700               details += ' : <span>' + data["md-title-remainder"] + ' </span>';
701         }
702         if (data["md-title-responsibility"] !== undefined) {
703               details += ' <span><i>'+ data["md-title-responsibility"] +'</i></span>';
704         }
705           details += '</td></tr>';
706     }
707     if (data["md-date"] != undefined)
708         details += '<tr><td><b>Date</b></td><td><b>:</b> ' + data["md-date"] + '</td></tr>';
709     if (data["md-author"] != undefined)
710         details += '<tr><td><b>Author</b></td><td><b>:</b> ' + data["md-author"] + '</td></tr>';
711     if (data["md-electronic-url"] != undefined)
712         details += '<tr><td><b>URL</b></td><td><b>:</b> <a href="' + data["md-electronic-url"] + '" target="_blank">' + data["md-electronic-url"] + '</a>' + '</td></tr>';
713     if (data["location"][0]["md-subject"] != undefined)
714         details += '<tr><td><b>Subject</b></td><td><b>:</b> ' + data["location"][0]["md-subject"] + '</td></tr>';
715     if (data["location"][0]["@name"] != undefined)
716         details += '<tr><td><b>Location</b></td><td><b>:</b> ' + data["location"][0]["@name"] + " (" +data["location"][0]["@id"] + ")" + '</td></tr>';
717     details += '</table></div>';
718     return details;
719 }
720
721 function renderLine(title, value) {
722     if (value != undefined)
723         return '<li><h3>' + title + '</h3> <big>' + value + '</big></li>';
724     return '';
725 }
726
727 function renderLineURL(title, URL, display) {
728     if (URL != undefined)
729         return '<li><h3>' + title + '</h3> <a href="' + URL + '" target="_blank">' + display + '</a></li>';
730     return '';
731 }
732
733 function renderLineEmail(dtitle, email, display) {
734     if (email != undefined)
735         return '<li><h3>' + title + '</h3> <a href="mailto:' + email + '" target="_blank">' + display + '</a></li>';
736     return '';
737 }
738
739 function renderDetails_iphone(data, marker)
740 {
741         //return renderDetails(data,marker);
742
743     if (!data) 
744         return ""; 
745     var details = '<div class="details" id="det_'+data.recid+'" >'
746 /*
747     details = '<div id="header" id="det_'+data.recid+'">' 
748         + '<h1>Detailed Info</h1>' 
749         + '<a id="backbutton" href="hidedetail(\'det_' + data.recid + '\')">Back</a>' 
750         + '</div>';
751 */
752     if (marker) 
753         details += '<h4>'+ marker + '</h4>'; 
754     details += '<ul class="field">';
755     if (data["md-title"] != undefined) {
756         details += '<li><h3>Title</h3> <big> ' + data["md-title"];
757         if (data["md-title-remainder"] !== undefined) {
758               details += ' ' + data["md-title-remainder"] + ' ';
759         }
760         if (data["md-title-responsibility"] !== undefined) {
761               details += '<i>'+ data["md-title-responsibility"] +'</i>';
762         }
763         details += '</big>'
764         details += '</li>'
765     }
766     details 
767         +=renderLine('Date',    data["md-date"])
768         + renderLine('Author',  data["md-author"])
769         + renderLineURL('URL',  data["md-electronic-url"], data["md-electronic-url"])
770         + renderLine('Subject', data["location"][0]["md-subject"]);
771     
772     if (data["location"][0]["@name"] != undefined)
773         details += renderLine('Location', data["location"][0]["@name"] + " (" +data["location"][0]["@id"] + ")");
774     details += '</ul></div>';
775     return details;
776 }
777
778 //EOF