Mercurial > hg > ismi-richfaces
annotate src/main/webapp/imageServer/resources/js/diva4ismi.js @ 19:7f4e574966bd
info zu ref anzeigen
author | dwinter |
---|---|
date | Mon, 13 Apr 2015 11:14:52 +0000 |
parents | dba143f9cb85 |
children | 7edb4ff2590b |
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){ |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
111 var id=encodeURIComponent(bibId); |
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); |
123 $("#"+createIdFromRef(loc)).html(ref); | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
124 } |
10 | 125 }, |
126 error: function(data) { | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
127 console.error('unable to load formatted bib entry ' + id); |
10 | 128 } |
129 }); | |
130 } | |
131 | |
7 | 132 function loadWitnessInformation(json, titleId){ |
133 | |
134 if(divaGlobal.debugModus){ | |
135 $('#witness-id').html(titleId); | |
136 } | |
137 | |
138 var fullTitle = json.data.fullTitle; | |
139 var fullTitleTranslit = json.data.fullTitleTranslit; | |
140 var titleContent = new String(); | |
141 if(fullTitle){ | |
142 titleContent = "<table><tr><td class='tdTitle' style='width: 300px;''>"+fullTitle+"</td></tr><tr><td class='tdTitle'>"+fullTitleTranslit+"</td></tr></table>"; | |
143 }else{ | |
144 titleContent = "<table><tr><td class='tdTitle'>"+fullTitleTranslit+"</td></tr></table>" | |
145 } | |
146 | |
147 var authorName = json.data.authorName; | |
148 var authorNameTranslit = json.data.authorNameTranslit; | |
149 var authorContent = new String(); | |
150 if(authorName){ | |
151 authorContent = "<table><tr><td class='tdTitle' style='width: 300px;''>"+authorName+"</td></tr><tr><td class='tdTitle'>"+authorNameTranslit+"</td></tr></table>"; | |
152 }else{ | |
153 authorContent = "<table><tr><td class='tdTitle'>"+authorNameTranslit+"</td></tr></table>" | |
154 } | |
155 | |
156 var tableOfContents = json.data.tableOfContents; | |
157 var notesOnTitleAuthor = json.data.notesOnTitleAuthor; | |
158 var notesOnCollationAndCorrections = json.data.notesOnCollationAndCorrections; | |
159 var notesOnOwnership = json.data.notesOnOwnership; | |
160 var notes = json.data.notes; | |
161 var codex = json.data.codex; | |
162 var collection = json.data.collection; | |
163 var repository = json.data.repository; | |
164 var city = json.data.city; | |
165 var country = json.data.country; | |
166 var folios = json.data.folios; | |
167 var incipit = json.data.incipit; | |
168 var explicit = json.data.explicit; | |
169 var subject = json.data.subject; | |
170 var ahlwardtNo = json.data.ahlwardtNo; | |
171 var titleAsWrittenInWitness = json.data.titleAsWrittenInWitness; | |
172 var authorAsWrittenInWitness = json.data.authorAsWrittenInWitness; | |
173 var copyist = json.data.copyist; | |
174 var placeOfCopying = json.data.placeOfCopying; | |
175 var colophon = json.data.colophon; | |
176 | |
177 var pageDimensions = json.data.pageDimensions; | |
178 var writtenAreaDimensions = json.data.writtenAreaDimensions; | |
179 var linesPerPage = json.data.linesPerPage; | |
180 var pageLayout = json.data.pageLayout; | |
181 var script = json.data.script; | |
182 var writingSurface = json.data.writingSurface; | |
183 var creationDate = json.data.creationDate; | |
184 | |
185 var readersContent = "<table>"; | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
186 var readers= json.data.readers; |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
187 for(var readerKey in json.data.readers){ |
7 | 188 var reader = json.data.readers[readerKey]; |
189 readersContent += "<tr><td class='tdTitle' style='width: 300px;'>"+reader+"</td></tr>"; | |
190 } | |
191 readersContent += "</table>"; | |
10 | 192 |
7 | 193 |
10 | 194 |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
195 var referencesContent="<table>"; |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
196 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
|
197 var ref = json.data.references[refKey]; |
19 | 198 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 | 199 } |
200 referencesContent += "</table>"; | |
7 | 201 |
10 | 202 setEntry('#witness-title',"") //no need to display this already in titleInfomation |
203 //$('#witness-title').html(titleContent); | |
204 | |
205 setEntry('#witness-title-written-in-witness',titleAsWrittenInWitness); | |
206 | |
207 setEntry('#witness-author',"") //no need to display this already in titleInfomation | |
208 //$('#witness-author').html(authorContent); | |
209 | |
210 | |
211 setEntry('#witness-author-written-in-witness',authorAsWrittenInWitness); | |
212 //$('#witness-codex').html(codex); | |
213 setEntry('#witness-codex',''); | |
214 | |
215 setEntry('#witness-ahlwardt-no',ahlwardtNo); | |
216 setEntry('#witness-copyist',copyist); | |
217 setEntry('#witness-place-copyist',placeOfCopying); | |
218 setEntry('#witness-date-copyist',creationDate); | |
219 setEntry('#witness-colophon',colophon); | |
220 | |
7 | 221 $('#witness-readers').html(readersContent); |
10 | 222 |
223 if (( readers == null)||( readers == "")) { | |
224 $('#witness-readers').parent().hide(); | |
225 }; | |
226 setEntry('#witness-folios',folios); | |
227 setEntry('#witness-dimensions',pageDimensions); | |
228 setEntry('#witness-written-dimensions',writtenAreaDimensions); | |
229 setEntry('#witness-lines',linesPerPage); | |
230 setEntry('#witness-surface',writingSurface); | |
231 setEntry('#witness-layout',pageLayout); | |
232 | |
233 //$('#title-incipit').text(incipit); | |
234 setEntry('#witness-incipit',incipit); | |
235 | |
236 //$('#title-explicit').text(explicit); | |
237 setEntry('#witness-explicit',explicit); | |
238 | |
239 //$('#title-table-contents').text(tableOfContents); | |
240 setEntry('#witness-table-contents',tableOfContents); | |
241 setEntry('#witness-script',script); | |
242 setEntry('#witness-notes',notes); | |
243 //setEntry('#witness-refs',"TODO"); | |
244 | |
245 $('#witness-refs').html(referencesContent); | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
246 for(refKey in json.data.references){ |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
247 var ref = json.data.references[refKey]; |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
248 var loc="#bibl-entry-"+titleId+"-"+refKey ; |
19 | 249 var bibInf=json.data.references[refKey]; |
250 showBibliographyEntryFormatted(refKey,bibInf,loc); | |
10 | 251 } |
252 referencesContent += "</table>"; | |
253 | |
7 | 254 |
255 } | |
256 | |
257 function loadTitleInformation(json, titleId){ | |
258 | |
259 if(divaGlobal.debugModus){ | |
260 $('#title-id').html(titleId); | |
261 } | |
262 | |
263 var fullTitle = json.data.fullTitle; | |
264 var fullTitleTranslit = json.data.fullTitleTranslit; | |
265 var titleContent = new String(); | |
10 | 266 /* |
7 | 267 if(fullTitle){ |
10 | 268 titleContent = "<table><tr><td class='tdTitle' style='width: 300px;''>"+ |
269 '<a href="../public/dynamicPage.xhtml?eid='+titleId+'">'+fullTitle+"</a>"+'<a href="'+divaGlobal.drupal_url+"/entity/"+titleId+'">(full)</a>' | |
270 +"</td></tr><tr><td class='tdTitle'>"+fullTitleTranslit+"</td></tr></table>"; | |
7 | 271 }else{ |
10 | 272 titleContent = "<table><tr><td class='tdTitle'>"+ |
273 '<a href="../public/dynamicPage.xhtml?eid='+titleId+'">'+fullTitleTranslit+"</a>"+'<a href="'+divaGlobal.drupal_url+"/entity/"+titleId+'">(full)</a>' | |
274 +"</td></tr></table>" | |
7 | 275 } |
276 | |
10 | 277 */ |
278 if(fullTitle){ | |
279 titleContent = "<table><tr><td class='tdTitle' style='width: 300px;''>"+ | |
280 '<a href="'+divaGlobal.drupal_url+"/entity/"+titleId+'">'+fullTitle+'</a>' | |
281 +"</td></tr><tr><td class='tdTitle'>"+fullTitleTranslit+"</td></tr></table>"; | |
282 }else{ | |
283 titleContent = "<table><tr><td class='tdTitle'>"+ | |
284 '<a href="'+divaGlobal.drupal_url+"/entity/"+titleId+'">'+fullTitleTranslit+'</a>' | |
285 +"</td></tr></table>" | |
286 } | |
7 | 287 var language = json.data.language; |
288 var category = json.data.category; | |
289 var author = json.data.author; | |
10 | 290 var authorId = json.data.authorId; |
7 | 291 var aliases = json.data.aliases; |
292 var personDedicatedTo = json.data.personDedicatedTo; | |
293 var commentaryOnText = json.data.commentaryOnText; | |
294 var translationOfText = json.data.translationOfText; | |
295 var versionOfText = json.data.versionOfText; | |
296 | |
297 var aliasesContent = "<table>"; | |
298 for(aliasKey in aliases){ | |
299 var alias = aliases[aliasKey]; | |
300 //alert(alias); | |
301 aliasesContent += "<tr><td class='tdTitle' style='width: 300px;'>"+alias+"</td></tr>"; | |
302 } | |
303 aliasesContent += "</table>"; | |
304 | |
10 | 305 if (( aliases == null)||( aliases == "")) { |
306 $('#title-aliases').parent().hide(); | |
307 }; | |
308 | |
7 | 309 var dedication = json.data.dedication; |
310 var notes = json.data.notes; | |
311 var tableOfContents = json.data.tableOfContents; | |
312 var explicit = json.data.explicit; | |
313 var incipit = json.data.incipit; | |
314 var creationDate = json.data.creationDate; | |
315 var createIn = json.data.createIn; | |
316 var authorMisattribution = json.data.authorMisattribution; | |
317 | |
318 var authorMisattributionContent = "<table>"; | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
319 for(var missKey in authorMisattribution){ |
7 | 320 var miss = authorMisattribution[missKey]; |
321 authorMisattributionContent += "<tr><td class='tdTitle' style='width: 300px;'>"+miss+"</td></tr>"; | |
322 } | |
323 authorMisattributionContent += "</table>"; | |
324 | |
10 | 325 if (( authorMisattribution == null)||( authorMisattribution == "")) { |
326 $('#title-misattributions').parent().hide(); | |
327 }; | |
328 | |
329 /* var authorContent = '<a href="../public/dynamicPage.xhtml?eid='+authorId+'">'+author+"</a>"+'<a href="'+divaGlobal.drupal_url+"/entity/"+authorId+'">(full)</a>'; | |
330 */ | |
331 var authorContent = '<a href="'+divaGlobal.drupal_url+"/entity/"+authorId+'">'+author+"</a>"; | |
19 | 332 |
10 | 333 |
334 | |
335 var referencesContent="<table>"; | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
336 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
|
337 var ref = json.data.references[refKey]; |
19 | 338 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 | 339 } |
340 referencesContent += "</table>"; | |
341 | |
19 | 342 |
7 | 343 //inserting the values into the table |
344 $('#title-tile').html(titleContent); | |
345 $('#title-aliases').html(aliasesContent); | |
346 $('#title-misattributions').html(authorMisattributionContent); | |
10 | 347 $('#title-author').html(authorContent); |
348 | |
349 | |
350 //$('#title-subject').text(category); | |
351 setEntry('#title-subject',category); | |
352 | |
353 | |
354 //$('#title-lang').text(language); | |
355 setEntry('#title-lang',language); | |
356 | |
357 //$('#title-date-composition').text(creationDate); | |
358 setEntry('#title-date-composition',creationDate); | |
359 | |
360 //$('#title-place-composition').text(createIn); | |
361 setEntry('#title-place-composition',createIn); | |
362 | |
363 //$('#title-dedicated-to').text(personDedicatedTo); | |
364 setEntry('#title-dedicated-to',personDedicatedTo); | |
365 | |
366 //$('#title-dedication').text(dedication); | |
367 setEntry('#title-dedication',dedication); | |
368 | |
369 //$('#title-commentary-on').text(commentaryOnText); | |
370 setEntry('#title-commentary-on',commentaryOnText); | |
371 | |
372 //$('#title-translation-of').text(translationOfText); | |
373 setEntry('#title-translation-of',translationOfText); | |
374 | |
375 //$('#title-version-of').text(versionOfText); | |
376 setEntry('#title-version-of',versionOfText); | |
377 | |
378 //$('#title-incipit').text(incipit); | |
379 setEntry('#title-incipit',incipit); | |
380 | |
381 //$('#title-explicit').text(explicit); | |
382 setEntry('#title-explicit',explicit); | |
383 | |
384 //$('#title-table-contents').text(tableOfContents); | |
385 setEntry('#title-table-contents',tableOfContents); | |
386 | |
387 | |
388 //$('#title-notes').text(notes); | |
389 setEntry('#title-notes',notes); | |
390 | |
391 $('#title-bib').html(referencesContent); | |
17
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
392 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
|
393 var ref = json.data.references[refKey]; |
dba143f9cb85
fixed bug where only one reference would be displayed on the page.
casties
parents:
14
diff
changeset
|
394 var loc="#bibl-entry-"+titleId+"-"+refKey ; |
19 | 395 var bibInf=json.data.references[refKey]; |
396 showBibliographyEntryFormatted(refKey,bibInf,loc); | |
10 | 397 } |
398 referencesContent += "</table>"; | |
399 | |
400 | |
401 | |
402 | |
7 | 403 } |
404 | |
405 | |
406 $(document).ready(function () { | |
407 | |
408 $("#witness-edit").on('click', '.set-start-set', function(ev) | |
409 { | |
410 var dv = $('#diva-wrapper').data('diva'); | |
411 var pageNumber = dv.getCurrentPageNumber(); | |
412 var witnessId = $(this).data('witness'); | |
413 var inputElement = $('#input-start-page-' + witnessId) | |
414 inputElement.val(pageNumber); | |
415 }); | |
416 | |
417 $("#witness-edit").on('click', '.set-start-reset', function(ev) | |
418 { | |
419 var dv = $('#diva-wrapper').data('diva'); | |
420 var witnessId = $(this).data('witness'); | |
421 var inputElement = $('#input-start-page-' + witnessId) | |
422 inputElement.val(""); | |
423 }); | |
424 | |
425 $("#witness-edit").on('click', '.set-end-set', function(ev) { | |
426 var dv = $('#diva-wrapper').data('diva'); | |
427 var pageNumber = dv.getCurrentPageNumber(); | |
428 var witnessId = $(this).data('witness'); | |
429 var inputElement = $('#input-end-page-' + witnessId) | |
430 | |
431 inputElement.val(pageNumber); | |
432 }); | |
433 | |
434 $("#witness-edit").on('click', '.set-end-reset', function(ev) { | |
435 var dv = $('#diva-wrapper').data('diva'); | |
436 var witnessId = $(this).data('witness'); | |
437 var inputElement = $('#input-end-page-' + witnessId) | |
438 inputElement.val(""); | |
439 }); | |
440 | |
441 }); | |
442 |