Mercurial > hg > ismi-richfaces
annotate src/main/webapp/imageServer/resources/js/diva4ismi.js @ 22:32d1933e0673
trim white space in bibid
author | dwinter |
---|---|
date | Tue, 14 Apr 2015 16:22:39 +0000 |
parents | 7edb4ff2590b |
children | 3e8493684729 |
rev | line source |
---|---|
7 | 1 var divaGlobal = { |
19 | 2 rest_url : "http://localhost:8080/ismi-richfaces", |
7 | 3 debugModus : false, |
19 | 4 //rest_url : "https://openmind-ismi-dev.mpiwg-berlin.mpg.de/om4-ismi", |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
5 //rest_url : "http://ismi-dev.mpiwg-berlin.mpg.de:8080/ismi-richfaces", |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
6 iipServerURL: "https://images.rasi.mcgill.ca/fcgi-bin/iipsrv.fcgi", |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
7 drupal_url: "https://drupal.mpiwg-berlin.mpg.de/ismi" |
7 | 8 } |
9 | |
10 function showTitleDetailsBig(titleId){ | |
11 showTitleDetails(titleId, 'templates/templateTitleInformationBig.html'); | |
12 } | |
13 | |
14 function showTitleDetailsSmall(titleId){ | |
15 showTitleDetails(titleId, 'templates/templateTitleInformationSmall.html'); | |
16 } | |
17 | |
18 function showWitnessDetailsBig(witnessId){ | |
19 showWitnessDetails(witnessId, 'templates/templateWitnessInformationBig.html'); | |
20 } | |
21 | |
22 function showWitnessDetailsSmall(witnessId){ | |
23 showWitnessDetails(witnessId, 'templates/templateWitnessInformationSmall.html'); | |
24 } | |
25 | |
10 | 26 function setEntry(loc,field) { |
27 if ((field == null)||(field == "")) { | |
28 $(loc).parent().hide(); | |
29 } | |
30 $(loc).html(field); | |
31 } | |
32 | |
19 | 33 function createIdFromRef(txt) { |
34 | |
35 txt=txt.replace(/\W+/g, ""); | |
36 return txt; | |
37 | |
38 } | |
39 | |
7 | 40 function showTitleDetails(titleId, template){ |
41 $.ajax({ | |
42 url: template, | |
43 type: 'GET', | |
44 success: function(data){ | |
45 //inserting the template in this document | |
46 $('#additional-information').html(data); | |
47 $('#title-details-show-more').attr('data-title-id', titleId); | |
48 $('#title-details-show-less').attr('data-title-id', titleId); | |
49 | |
8 | 50 var jsonRequest = divaGlobal.rest_url + '/jsonInterface?method=get_title_details&include_romanization=true&id=' + titleId; |
7 | 51 |
52 console.log(jsonRequest); | |
53 | |
54 $.ajax({ | |
55 url: jsonRequest, | |
56 type: 'GET', | |
57 success: function(data){ | |
58 loadTitleInformation(data, titleId); | |
59 | |
60 }, | |
61 error: function(data) { | |
62 console.error('jsonInterface error. = ' + jsonRequest); | |
63 } | |
64 }); | |
65 | |
66 }, | |
67 error: function(data) { | |
68 console.error(template + ' no found.'); | |
69 } | |
70 }); | |
71 } | |
72 | |
10 | 73 function showWitnessDetails(titleId, template){ |
7 | 74 $.ajax({ |
75 url: template, | |
76 type: 'GET', | |
77 success: function(data){ | |
78 //inserting the template in this document | |
10 | 79 $('#additional-information2').html(data); |
80 $('#witness-details-show-more').attr('data-witness-id', titleId); | |
81 $('#witness-details-show-less').attr('data-witness-id', titleId); | |
7 | 82 |
10 | 83 var jsonRequest = divaGlobal.rest_url + '/jsonInterface?method=get_witness_details&include_romanization=true&id=' + titleId; |
7 | 84 |
85 console.log(jsonRequest); | |
86 | |
87 $.ajax({ | |
88 url: jsonRequest, | |
89 type: 'GET', | |
90 success: function(data){ | |
10 | 91 loadWitnessInformation(data, titleId); |
7 | 92 |
93 }, | |
94 error: function(data) { | |
95 console.error('jsonInterface error. = ' + jsonRequest); | |
96 } | |
97 }); | |
98 | |
99 }, | |
100 error: function(data) { | |
101 console.error(template + ' no found.'); | |
102 } | |
103 }); | |
104 } | |
105 | |
10 | 106 |
107 | |
108 | |
109 | |
19 | 110 function showBibliographyEntryFormatted(bibId,bibInf, bibLoc){ |
22 | 111 var id=encodeURIComponent(bibId.trim()); |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
112 var loc = bibLoc; |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
113 console.debug("setting up bib id="+id+" at loc="+loc); |
10 | 114 $.ajax({ |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
115 url: divaGlobal.drupal_url+"/formatbiblio/"+id, |
10 | 116 type: 'GET', |
117 success: function(data){ | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
118 console.debug("got bib id="+id+" for loc="+loc); |
10 | 119 //inserting the template in this document |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
120 //mache rel urls zu absoluten |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
121 if (data.nodes.length > 0) { |
19 | 122 var ref = data.nodes[0].node.citation.replace(new RegExp("/ismi","g"),divaGlobal.drupal_url); |
20 | 123 var bib = $(loc); |
124 bib.html(ref); | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
125 } |
10 | 126 }, |
127 error: function(data) { | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
128 console.error('unable to load formatted bib entry ' + id); |
10 | 129 } |
130 }); | |
131 } | |
132 | |
7 | 133 function loadWitnessInformation(json, titleId){ |
134 | |
135 if(divaGlobal.debugModus){ | |
136 $('#witness-id').html(titleId); | |
137 } | |
138 | |
139 var fullTitle = json.data.fullTitle; | |
140 var fullTitleTranslit = json.data.fullTitleTranslit; | |
141 var titleContent = new String(); | |
142 if(fullTitle){ | |
143 titleContent = "<table><tr><td class='tdTitle' style='width: 300px;''>"+fullTitle+"</td></tr><tr><td class='tdTitle'>"+fullTitleTranslit+"</td></tr></table>"; | |
144 }else{ | |
145 titleContent = "<table><tr><td class='tdTitle'>"+fullTitleTranslit+"</td></tr></table>" | |
146 } | |
147 | |
148 var authorName = json.data.authorName; | |
149 var authorNameTranslit = json.data.authorNameTranslit; | |
150 var authorContent = new String(); | |
151 if(authorName){ | |
152 authorContent = "<table><tr><td class='tdTitle' style='width: 300px;''>"+authorName+"</td></tr><tr><td class='tdTitle'>"+authorNameTranslit+"</td></tr></table>"; | |
153 }else{ | |
154 authorContent = "<table><tr><td class='tdTitle'>"+authorNameTranslit+"</td></tr></table>" | |
155 } | |
156 | |
157 var tableOfContents = json.data.tableOfContents; | |
158 var notesOnTitleAuthor = json.data.notesOnTitleAuthor; | |
159 var notesOnCollationAndCorrections = json.data.notesOnCollationAndCorrections; | |
160 var notesOnOwnership = json.data.notesOnOwnership; | |
161 var notes = json.data.notes; | |
162 var codex = json.data.codex; | |
163 var collection = json.data.collection; | |
164 var repository = json.data.repository; | |
165 var city = json.data.city; | |
166 var country = json.data.country; | |
167 var folios = json.data.folios; | |
168 var incipit = json.data.incipit; | |
169 var explicit = json.data.explicit; | |
170 var subject = json.data.subject; | |
171 var ahlwardtNo = json.data.ahlwardtNo; | |
172 var titleAsWrittenInWitness = json.data.titleAsWrittenInWitness; | |
173 var authorAsWrittenInWitness = json.data.authorAsWrittenInWitness; | |
174 var copyist = json.data.copyist; | |
175 var placeOfCopying = json.data.placeOfCopying; | |
176 var colophon = json.data.colophon; | |
177 | |
178 var pageDimensions = json.data.pageDimensions; | |
179 var writtenAreaDimensions = json.data.writtenAreaDimensions; | |
180 var linesPerPage = json.data.linesPerPage; | |
181 var pageLayout = json.data.pageLayout; | |
182 var script = json.data.script; | |
183 var writingSurface = json.data.writingSurface; | |
184 var creationDate = json.data.creationDate; | |
185 | |
186 var readersContent = "<table>"; | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
187 var readers= json.data.readers; |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
188 for(var readerKey in json.data.readers){ |
7 | 189 var reader = json.data.readers[readerKey]; |
190 readersContent += "<tr><td class='tdTitle' style='width: 300px;'>"+reader+"</td></tr>"; | |
191 } | |
192 readersContent += "</table>"; | |
10 | 193 |
7 | 194 |
10 | 195 |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
196 var referencesContent="<table>"; |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
197 for(var refKey in json.data.references){ |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
198 var ref = json.data.references[refKey]; |
19 | 199 referencesContent += "<tr><td class='tdTitle' id='bibl-entry-"+titleId+"-"+createIdFromRef(refKey)+"' style='width: 300px;'>"+refKey+"</td></tr><tr><td class='tdTitle'>"+ref+"</td></tr>"; |
10 | 200 } |
201 referencesContent += "</table>"; | |
7 | 202 |
10 | 203 setEntry('#witness-title',"") //no need to display this already in titleInfomation |
204 //$('#witness-title').html(titleContent); | |
205 | |
206 setEntry('#witness-title-written-in-witness',titleAsWrittenInWitness); | |
207 | |
208 setEntry('#witness-author',"") //no need to display this already in titleInfomation | |
209 //$('#witness-author').html(authorContent); | |
210 | |
211 | |
212 setEntry('#witness-author-written-in-witness',authorAsWrittenInWitness); | |
213 //$('#witness-codex').html(codex); | |
214 setEntry('#witness-codex',''); | |
215 | |
216 setEntry('#witness-ahlwardt-no',ahlwardtNo); | |
217 setEntry('#witness-copyist',copyist); | |
218 setEntry('#witness-place-copyist',placeOfCopying); | |
219 setEntry('#witness-date-copyist',creationDate); | |
220 setEntry('#witness-colophon',colophon); | |
221 | |
7 | 222 $('#witness-readers').html(readersContent); |
10 | 223 |
224 if (( readers == null)||( readers == "")) { | |
225 $('#witness-readers').parent().hide(); | |
226 }; | |
227 setEntry('#witness-folios',folios); | |
228 setEntry('#witness-dimensions',pageDimensions); | |
229 setEntry('#witness-written-dimensions',writtenAreaDimensions); | |
230 setEntry('#witness-lines',linesPerPage); | |
231 setEntry('#witness-surface',writingSurface); | |
232 setEntry('#witness-layout',pageLayout); | |
233 | |
234 //$('#title-incipit').text(incipit); | |
235 setEntry('#witness-incipit',incipit); | |
236 | |
237 //$('#title-explicit').text(explicit); | |
238 setEntry('#witness-explicit',explicit); | |
239 | |
240 //$('#title-table-contents').text(tableOfContents); | |
241 setEntry('#witness-table-contents',tableOfContents); | |
242 setEntry('#witness-script',script); | |
243 setEntry('#witness-notes',notes); | |
244 //setEntry('#witness-refs',"TODO"); | |
245 | |
246 $('#witness-refs').html(referencesContent); | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
247 for(refKey in json.data.references){ |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
248 var ref = json.data.references[refKey]; |
20 | 249 var loc="#bibl-entry-"+titleId+"-"+ createIdFromRef(refKey) ; |
19 | 250 var bibInf=json.data.references[refKey]; |
251 showBibliographyEntryFormatted(refKey,bibInf,loc); | |
10 | 252 } |
253 referencesContent += "</table>"; | |
254 | |
7 | 255 |
256 } | |
257 | |
258 function loadTitleInformation(json, titleId){ | |
259 | |
260 if(divaGlobal.debugModus){ | |
261 $('#title-id').html(titleId); | |
262 } | |
263 | |
264 var fullTitle = json.data.fullTitle; | |
265 var fullTitleTranslit = json.data.fullTitleTranslit; | |
266 var titleContent = new String(); | |
10 | 267 /* |
7 | 268 if(fullTitle){ |
10 | 269 titleContent = "<table><tr><td class='tdTitle' style='width: 300px;''>"+ |
270 '<a href="../public/dynamicPage.xhtml?eid='+titleId+'">'+fullTitle+"</a>"+'<a href="'+divaGlobal.drupal_url+"/entity/"+titleId+'">(full)</a>' | |
271 +"</td></tr><tr><td class='tdTitle'>"+fullTitleTranslit+"</td></tr></table>"; | |
7 | 272 }else{ |
10 | 273 titleContent = "<table><tr><td class='tdTitle'>"+ |
274 '<a href="../public/dynamicPage.xhtml?eid='+titleId+'">'+fullTitleTranslit+"</a>"+'<a href="'+divaGlobal.drupal_url+"/entity/"+titleId+'">(full)</a>' | |
275 +"</td></tr></table>" | |
7 | 276 } |
277 | |
10 | 278 */ |
279 if(fullTitle){ | |
280 titleContent = "<table><tr><td class='tdTitle' style='width: 300px;''>"+ | |
281 '<a href="'+divaGlobal.drupal_url+"/entity/"+titleId+'">'+fullTitle+'</a>' | |
282 +"</td></tr><tr><td class='tdTitle'>"+fullTitleTranslit+"</td></tr></table>"; | |
283 }else{ | |
284 titleContent = "<table><tr><td class='tdTitle'>"+ | |
285 '<a href="'+divaGlobal.drupal_url+"/entity/"+titleId+'">'+fullTitleTranslit+'</a>' | |
286 +"</td></tr></table>" | |
287 } | |
7 | 288 var language = json.data.language; |
289 var category = json.data.category; | |
290 var author = json.data.author; | |
10 | 291 var authorId = json.data.authorId; |
7 | 292 var aliases = json.data.aliases; |
293 var personDedicatedTo = json.data.personDedicatedTo; | |
294 var commentaryOnText = json.data.commentaryOnText; | |
295 var translationOfText = json.data.translationOfText; | |
296 var versionOfText = json.data.versionOfText; | |
297 | |
298 var aliasesContent = "<table>"; | |
299 for(aliasKey in aliases){ | |
300 var alias = aliases[aliasKey]; | |
301 //alert(alias); | |
302 aliasesContent += "<tr><td class='tdTitle' style='width: 300px;'>"+alias+"</td></tr>"; | |
303 } | |
304 aliasesContent += "</table>"; | |
305 | |
10 | 306 if (( aliases == null)||( aliases == "")) { |
307 $('#title-aliases').parent().hide(); | |
308 }; | |
309 | |
7 | 310 var dedication = json.data.dedication; |
311 var notes = json.data.notes; | |
312 var tableOfContents = json.data.tableOfContents; | |
313 var explicit = json.data.explicit; | |
314 var incipit = json.data.incipit; | |
315 var creationDate = json.data.creationDate; | |
316 var createIn = json.data.createIn; | |
317 var authorMisattribution = json.data.authorMisattribution; | |
318 | |
319 var authorMisattributionContent = "<table>"; | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
320 for(var missKey in authorMisattribution){ |
7 | 321 var miss = authorMisattribution[missKey]; |
322 authorMisattributionContent += "<tr><td class='tdTitle' style='width: 300px;'>"+miss+"</td></tr>"; | |
323 } | |
324 authorMisattributionContent += "</table>"; | |
325 | |
10 | 326 if (( authorMisattribution == null)||( authorMisattribution == "")) { |
327 $('#title-misattributions').parent().hide(); | |
328 }; | |
329 | |
330 /* var authorContent = '<a href="../public/dynamicPage.xhtml?eid='+authorId+'">'+author+"</a>"+'<a href="'+divaGlobal.drupal_url+"/entity/"+authorId+'">(full)</a>'; | |
331 */ | |
332 var authorContent = '<a href="'+divaGlobal.drupal_url+"/entity/"+authorId+'">'+author+"</a>"; | |
19 | 333 |
10 | 334 |
335 | |
336 var referencesContent="<table>"; | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
337 for(var refKey in json.data.references){ |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
338 var ref = json.data.references[refKey]; |
19 | 339 referencesContent += "<tr><td class='tdTitle' id='bibl-entry-"+titleId+"-"+createIdFromRef(refKey)+"' style='width: 300px;'>"+refKey+"</td></tr><tr><td class='tdTitle'>"+ref+"</td></tr>"; |
10 | 340 } |
341 referencesContent += "</table>"; | |
342 | |
19 | 343 |
7 | 344 //inserting the values into the table |
345 $('#title-tile').html(titleContent); | |
346 $('#title-aliases').html(aliasesContent); | |
347 $('#title-misattributions').html(authorMisattributionContent); | |
10 | 348 $('#title-author').html(authorContent); |
349 | |
350 | |
351 //$('#title-subject').text(category); | |
352 setEntry('#title-subject',category); | |
353 | |
354 | |
355 //$('#title-lang').text(language); | |
356 setEntry('#title-lang',language); | |
357 | |
358 //$('#title-date-composition').text(creationDate); | |
359 setEntry('#title-date-composition',creationDate); | |
360 | |
361 //$('#title-place-composition').text(createIn); | |
362 setEntry('#title-place-composition',createIn); | |
363 | |
364 //$('#title-dedicated-to').text(personDedicatedTo); | |
365 setEntry('#title-dedicated-to',personDedicatedTo); | |
366 | |
367 //$('#title-dedication').text(dedication); | |
368 setEntry('#title-dedication',dedication); | |
369 | |
370 //$('#title-commentary-on').text(commentaryOnText); | |
371 setEntry('#title-commentary-on',commentaryOnText); | |
372 | |
373 //$('#title-translation-of').text(translationOfText); | |
374 setEntry('#title-translation-of',translationOfText); | |
375 | |
376 //$('#title-version-of').text(versionOfText); | |
377 setEntry('#title-version-of',versionOfText); | |
378 | |
379 //$('#title-incipit').text(incipit); | |
380 setEntry('#title-incipit',incipit); | |
381 | |
382 //$('#title-explicit').text(explicit); | |
383 setEntry('#title-explicit',explicit); | |
384 | |
385 //$('#title-table-contents').text(tableOfContents); | |
386 setEntry('#title-table-contents',tableOfContents); | |
387 | |
388 | |
389 //$('#title-notes').text(notes); | |
390 setEntry('#title-notes',notes); | |
391 | |
392 $('#title-bib').html(referencesContent); | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
393 for(var refKey in json.data.references){ |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
394 var ref = json.data.references[refKey]; |
20 | 395 var loc="#bibl-entry-"+titleId+"-"+ createIdFromRef(refKey) ; |
19 | 396 var bibInf=json.data.references[refKey]; |
397 showBibliographyEntryFormatted(refKey,bibInf,loc); | |
10 | 398 } |
399 referencesContent += "</table>"; | |
400 | |
401 | |
402 | |
403 | |
7 | 404 } |
405 | |
406 | |
407 $(document).ready(function () { | |
408 | |
409 $("#witness-edit").on('click', '.set-start-set', function(ev) | |
410 { | |
411 var dv = $('#diva-wrapper').data('diva'); | |
412 var pageNumber = dv.getCurrentPageNumber(); | |
413 var witnessId = $(this).data('witness'); | |
414 var inputElement = $('#input-start-page-' + witnessId) | |
415 inputElement.val(pageNumber); | |
416 }); | |
417 | |
418 $("#witness-edit").on('click', '.set-start-reset', function(ev) | |
419 { | |
420 var dv = $('#diva-wrapper').data('diva'); | |
421 var witnessId = $(this).data('witness'); | |
422 var inputElement = $('#input-start-page-' + witnessId) | |
423 inputElement.val(""); | |
424 }); | |
425 | |
426 $("#witness-edit").on('click', '.set-end-set', function(ev) { | |
427 var dv = $('#diva-wrapper').data('diva'); | |
428 var pageNumber = dv.getCurrentPageNumber(); | |
429 var witnessId = $(this).data('witness'); | |
430 var inputElement = $('#input-end-page-' + witnessId) | |
431 | |
432 inputElement.val(pageNumber); | |
433 }); | |
434 | |
435 $("#witness-edit").on('click', '.set-end-reset', function(ev) { | |
436 var dv = $('#diva-wrapper').data('diva'); | |
437 var witnessId = $(this).data('witness'); | |
438 var inputElement = $('#input-end-page-' + witnessId) | |
439 inputElement.val(""); | |
440 }); | |
441 | |
442 }); | |
443 |