annotate src/main/webapp/tags/js/tag.js @ 31:9f653697437e

annotationbrowser
author dwinter
date Tue, 25 Sep 2012 21:47:58 +0200
parents 05b631a084d0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31
9f653697437e annotationbrowser
dwinter
parents: 30
diff changeset
1 //var annotServer="http://localhost:8280/AnnotationManagerN4J/annotator/";
9f653697437e annotationbrowser
dwinter
parents: 30
diff changeset
2 var annotServer="http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager/annotator/";
30
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
3 var viewerAddress="http://libcoll.mpiwg-berlin.mpg.de/libviewa?url=";
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
4 var docNamespace="http://echo.mpiwg-berlin.mpg.de/documents/";
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
5
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
6 //var dcDataPath="http://euler.mpiwg-berlin.mpg.de:58080/echo_nav/echo_pages/metadata/getDCDataFromPath?path=";
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
7 var dcDataPath="http://libcoll.mpiwg-berlin.mpg.de/metadata/getDCDataFromPath?path=";
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
8 var textPath="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Texter?fn=";
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
9
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
10
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
11 function getDCdata(path,obj){
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
12
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
13 var splitted = path.split("?");
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
14 var docUri=splitted[0];
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
15
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
16 docUri = docUri.replace(docNamespace,textPath);
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
17 var md = dcDataPath+docUri+"/index.meta";
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
18
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
19 $('<div/>', {
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
20 'class': 'annotatonMetaData',
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
21 }).load(md, function (){
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
22 $(this).children().children().addClass('dcMetaData');
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
23 }).appendTo(obj);
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
24
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
25 }
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
26
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
27 function createLinkFromURI(uri){
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
28 var docUri = uri.replace(docNamespace,viewerAddress);
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
29 docUri = docUri.replace("?pn","&pn");
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
30 return docUri;
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
31 }
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
32
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
33 function annotations(tagId){
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
34 $.getJSON(annotServer+'tags/'+tagId+"/annotations?sortBy=uri", function(data) {
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
35 //var items = [];
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
36 var rows = data["rows"];
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
37
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
38 $('#annotations').html("");
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
39 for (var i=0;i<rows.length;i++){
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
40 var text=rows[i]['text'];
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
41 var author=rows[i]['user']['name'];
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
42 var docUri=createLinkFromURI(rows[i]['uri']);
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
43
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
44 var ret = '<div id="an_'+i+'" class="annotationRow">';
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
45 ret +='<div class="annotationCol">'+text+'</div>';
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
46 ret +='<div class="annotationCol">'+author+'</div>';
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
47 ret +='<div class="annotationCol"><a target="libcoll" href="'+docUri+'">'+docUri+'</a></div>';
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
48 ret+="</div>";
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
49
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
50 $('#annotations').append(ret);
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
51 //items.push(ret);
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
52 getDCdata(rows[i]['uri'],$('#an_'+i));
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
53 }
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
54 //$('#annotations').html(items.join(''));
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
55
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
56
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
57 });
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
58 }
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
59
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
60
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
61 $(document).ready(function(){
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
62 $.getJSON(annotServer+'tags', function(data) {
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
63 var items = [];
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
64 var rows = data["rows"];
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
65
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
66 for (var i=0;i<rows.length;i++){
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
67 val=rows[i]['name'];
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
68 items.push('<div class="tagLink" onclick="javascript: annotations(\''+rows[i]["id"]+'\');">'+val+'</div>');
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
69
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
70 }
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
71 $('#tagList').html(items.join(''));
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
72
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
73 });
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
74
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
75
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
76
05b631a084d0 tag viewer html
dwinter
parents:
diff changeset
77 });