Mercurial > hg > ismi-richfaces
changeset 17:dba143f9cb85
fixed bug where only one reference would be displayed on the page.
author | casties |
---|---|
date | Fri, 10 Apr 2015 16:43:02 +0000 |
parents | 0d0a3b757981 |
children | 27883e041333 |
files | src/main/webapp/imageServer/resources/js/diva4ismi.js |
diffstat | 1 files changed, 35 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/webapp/imageServer/resources/js/diva4ismi.js Fri Apr 10 15:49:50 2015 +0000 +++ b/src/main/webapp/imageServer/resources/js/diva4ismi.js Fri Apr 10 16:43:02 2015 +0000 @@ -2,9 +2,9 @@ //rest_url : "http://localhost:8080/ismi-richfaces", debugModus : false, rest_url : "https://openmind-ismi-dev.mpiwg-berlin.mpg.de/om4-ismi", - //rest_url : "http://ismi-dev.mpiwg-berlin.mpg.de:8080/ismi-richfaces", - iipServerURL: "https://images.rasi.mcgill.ca/fcgi-bin/iipsrv.fcgi", - drupal_url: "https://drupal.mpiwg-berlin.mpg.de/ismi" + //rest_url : "http://ismi-dev.mpiwg-berlin.mpg.de:8080/ismi-richfaces", + iipServerURL: "https://images.rasi.mcgill.ca/fcgi-bin/iipsrv.fcgi", + drupal_url: "https://drupal.mpiwg-berlin.mpg.de/ismi" } function showTitleDetailsBig(titleId){ @@ -100,19 +100,24 @@ -function showBibliographyEntryFormatted(bibId,loc){ - bibId=encodeURIComponent(bibId) +function showBibliographyEntryFormatted(bibId, bibLoc){ + var id=encodeURIComponent(bibId); + var loc = bibLoc; + console.debug("setting up bib id="+id+" at loc="+loc); $.ajax({ - url: divaGlobal.drupal_url+"/formatbiblio/"+bibId, + url: divaGlobal.drupal_url+"/formatbiblio/"+id, type: 'GET', success: function(data){ + console.debug("got bib id="+id+" for loc="+loc); //inserting the template in this document - //mache rel urls zu absoluten - ref = data.nodes[0].node.citation.replace(new RegExp("/ismi","g"),divaGlobal.drupal_url) - $(loc).html(ref); + //mache rel urls zu absoluten + if (data.nodes.length > 0) { + var ref = data.nodes[0].node.citation.replace(new RegExp("/ismi","g"),divaGlobal.drupal_url); + $(loc).html(ref); + } }, error: function(data) { - console.error(bibId + ' no found.'); + console.error('unable to load formatted bib entry ' + id); } }); } @@ -171,8 +176,8 @@ var creationDate = json.data.creationDate; var readersContent = "<table>"; - var readers= json.data.readers; - for(readerKey in json.data.readers){ + var readers= json.data.readers; + for(var readerKey in json.data.readers){ var reader = json.data.readers[readerKey]; readersContent += "<tr><td class='tdTitle' style='width: 300px;'>"+reader+"</td></tr>"; } @@ -180,10 +185,10 @@ - var referencesContent="<table>"; - for(readerKey in json.data.references){ - var reader = json.data.references[readerKey]; - referencesContent += "<tr><td class='tdTitle' id='bibl-entry-"+readerKey +"' style='width: 300px;'>"+reader+"</td></tr>"; + var referencesContent="<table>"; + for(var refKey in json.data.references){ + var ref = json.data.references[refKey]; + referencesContent += "<tr><td class='tdTitle' id='bibl-entry-"+titleId+"-"+refKey+"' style='width: 300px;'>"+ref+"</td></tr>"; } referencesContent += "</table>"; @@ -231,13 +236,11 @@ //setEntry('#witness-refs',"TODO"); $('#witness-refs').html(referencesContent); - - for(readerKey in json.data.references){ - var reader = json.data.references[readerKey]; - var loc="#bibl-entry-"+readerKey ; - var bibId=json.data.references[readerKey]; - showBibliographyEntryFormatted(bibId,loc); - + for(refKey in json.data.references){ + var ref = json.data.references[refKey]; + var loc="#bibl-entry-"+titleId+"-"+refKey ; + var bibId=json.data.references[refKey]; + showBibliographyEntryFormatted(bibId,loc); } referencesContent += "</table>"; @@ -306,7 +309,7 @@ var authorMisattribution = json.data.authorMisattribution; var authorMisattributionContent = "<table>"; - for(missKey in authorMisattribution){ + for(var missKey in authorMisattribution){ var miss = authorMisattribution[missKey]; authorMisattributionContent += "<tr><td class='tdTitle' style='width: 300px;'>"+miss+"</td></tr>"; } @@ -322,9 +325,9 @@ var referencesContent="<table>"; - for(readerKey in json.data.references){ - var reader = json.data.references[readerKey]; - referencesContent += "<tr><td class='tdTitle' id='bibl-entry-"+readerKey +"' style='width: 300px;'>"+reader+"</td></tr>"; + for(var refKey in json.data.references){ + var ref = json.data.references[refKey]; + referencesContent += "<tr><td class='tdTitle' id='bibl-entry-"+titleId+"-"+refKey+"' style='width: 300px;'>"+ref+"</td></tr>"; } referencesContent += "</table>"; @@ -377,13 +380,11 @@ setEntry('#title-notes',notes); $('#title-bib').html(referencesContent); - - for(readerKey in json.data.references){ - var reader = json.data.references[readerKey]; - var loc="#bibl-entry-"+readerKey ; - var bibId=json.data.references[readerKey]; - showBibliographyEntryFormatted(bibId,loc); - + for(var refKey in json.data.references){ + var ref = json.data.references[refKey]; + var loc="#bibl-entry-"+titleId+"-"+refKey ; + var bibId=json.data.references[refKey]; + showBibliographyEntryFormatted(bibId,loc); } referencesContent += "</table>";