44
|
1 function annotations(ressourceId){
|
|
2
|
|
3
|
|
4 if (token==""){
|
|
5 setTimeout(function(){annotations();},500);
|
|
6 return;
|
|
7 }
|
|
8
|
|
9 var headers = {'x-annotator-auth-token':token};
|
|
10
|
|
11 $.ajax({
|
|
12 url: annotServer+'ressources/'+ressourceId+'/annotations?sortBy=uri',
|
|
13 dataType: 'json',
|
|
14 headers:headers,
|
|
15 success: function(data) {
|
|
16 //var items = [];
|
|
17 var rows = data["rows"];
|
|
18
|
|
19 $('#annotations').html("");
|
|
20 for (var i=0;i<rows.length;i++){
|
|
21 var text=rows[i]['text'];
|
|
22 var author=rows[i]['user']['name'];
|
|
23 var docUri=createLinkFromURI(rows[i]['uri']);
|
|
24
|
|
25 var ret = '<div id="an_'+i+'" class="annotationRow">';
|
|
26 ret +='<div class="annotationCol">'+text+'</div>';
|
|
27 ret +='<div class="annotationCol">'+author+'</div>';
|
|
28 ret +='<div class="annotationCol"><a target="libcoll" href="'+docUri+'">'+docUri+'</a></div>';
|
|
29 ret+="</div>";
|
|
30
|
|
31 $('#annotations').append(ret);
|
|
32 //items.push(ret);
|
|
33 getDCdata(rows[i]['uri'],$('#an_'+i));
|
|
34 }
|
|
35 //$('#annotations').html(items.join(''));
|
|
36
|
|
37 }
|
|
38 });
|
|
39 }
|
|
40
|
|
41
|
|
42 $(document).ready(function(){
|
|
43
|
|
44 getToken(tokenGenerator,username);
|
|
45 $.getJSON(annotServer+'ressources', function(data) {
|
|
46 var items = [];
|
|
47 var rows = data["rows"];
|
|
48
|
|
49 for (var i=0;i<rows.length;i++){
|
|
50 val=rows[i]['name'];
|
|
51 items.push('<div class="tagLink" onclick="javascript: annotations(\''+rows[i]["id"]+'\');">'+val+'</div>');
|
|
52
|
|
53 }
|
|
54
|
|
55
|
|
56 $('#tagList').html(items.join(''));
|
|
57 annotations();
|
|
58 });
|
|
59
|
|
60
|
|
61
|
|
62 });
|
|
63
|
|
64
|
|
65
|