comparison webapp/src/main/webapp/jquery/jquery.digilib.annotations.js @ 1100:c5ed20cd24ae

setting annotation user name works now.
author robcast
date Thu, 25 Oct 2012 17:22:36 +0200
parents ebdde1bbb026
children 34f893492adb
comparison
equal deleted inserted replaced
1099:732390b4d81a 1100:c5ed20cd24ae
20 annotations : { 20 annotations : {
21 onclick : "toggleAnnotations", 21 onclick : "toggleAnnotations",
22 tooltip : "show or hide annotations", 22 tooltip : "show or hide annotations",
23 icon : "annotations.png" 23 icon : "annotations.png"
24 }, 24 },
25 annotationuser : {
26 onclick : "setAnnotationUser",
27 tooltip : "set user account for annotations",
28 icon : "annotation-user.png"
29 },
25 annotationmark : { 30 annotationmark : {
26 onclick : "setAnnotationMark", 31 onclick : "setAnnotationMark",
27 tooltip : "create an annotation for a point", 32 tooltip : "create an annotation for a point",
28 icon : "annotation-mark.png" 33 icon : "annotation-mark.png"
29 } 34 }
31 36
32 var defaults = { 37 var defaults = {
33 // are annotations active? 38 // are annotations active?
34 'isAnnotationsVisible' : true, 39 'isAnnotationsVisible' : true,
35 // buttonset of this plugin 40 // buttonset of this plugin
36 'annotationSet' : ['annotations', 'annotationmark', 'lessoptions'], 41 'annotationSet' : ['annotations', 'annotationuser', 'annotationmark', 'lessoptions'],
37 // URL of annotation server 42 // URL of annotation server
38 'annotationServerUrl' : 'http://virtuoso.mpiwg-berlin.mpg.de:8080/AnnotationManager/annotator', 43 'annotationServerUrl' : 'http://virtuoso.mpiwg-berlin.mpg.de:8080/AnnotationManager/annotator',
39 // URL of authentication token server 44 // URL of authentication token server
40 'annotationTokenUrl' : 'http://localhost:8080/test/annotator/token?user=anonymous', 45 'annotationTokenUrl' : 'http://localhost:8080/test/annotator/token',
41 // annotation user name 46 // annotation user name
42 'annotationUser' : 'anonymous' 47 'annotationUser' : 'anonymous'
43 }; 48 };
44 49
45 var actions = { 50 var actions = {
46 /** 51 /**
47 * show/hide annotations 52 * show/hide annotations
48 */ 53 */
49 toggleAnnotations : function(data) { 54 toggleAnnotations : function (data) {
50 var show = !data.settings.isAnnotationsVisible; 55 var show = !data.settings.isAnnotationsVisible;
51 data.settings.isAnnotationsVisible = show; 56 data.settings.isAnnotationsVisible = show;
52 digilib.fn.highlightButtons(data, 'annotations', show); 57 digilib.fn.highlightButtons(data, 'annotations', show);
53 renderAnnotations(data); 58 renderAnnotations(data);
59 },
60
61 /**
62 * set user account for annotations
63 */
64 setAnnotationUser : function (data, user) {
65 var settings = data.settings;
66 if (user == null) {
67 // user name entered in JS-prompt
68 user = window.prompt("User name:", settings.annotationUser);
69 if (user != null) {
70 settings.annotationUser = user;
71 }
72 } else {
73 settings.annotationUser = user;
74 }
54 }, 75 },
55 76
56 /** 77 /**
57 * set a mark-annotation by clicking (or giving a position and a text) 78 * set a mark-annotation by clicking (or giving a position and a text)
58 * 79 *
59 * @param data 80 * @param data
60 * @param mpos 81 * @param mpos
61 * @param text 82 * @param text
62 */ 83 */
63 setAnnotationMark : function(data, mpos, text) { 84 setAnnotationMark : function (data, mpos, text) {
64 if (mpos == null) { 85 if (mpos == null) {
65 // interactive 86 // interactive
66 setAnnotationMark(data); 87 setAnnotationMark(data);
67 } else { 88 } else {
68 // use position and text 89 // use position and text
75 }; 96 };
76 97
77 /** 98 /**
78 * create a new annotation object 99 * create a new annotation object
79 */ 100 */
80 var newAnnotation = function(mpos, text, id, uri, user) { 101 var newAnnotation = function (mpos, text, id, uri, user) {
81 var annot = { 102 var annot = {
82 pos : mpos, 103 pos : mpos,
83 text : text, 104 text : text,
84 id : id, 105 id : id,
85 uri : uri, 106 uri : uri,
110 console.log("setAnnotationMark at=", evt); 131 console.log("setAnnotationMark at=", evt);
111 var mpos = geom.position(evt); 132 var mpos = geom.position(evt);
112 var pos = data.imgTrafo.invtransform(mpos); 133 var pos = data.imgTrafo.invtransform(mpos);
113 // Annotation text entered in JS-prompt 134 // Annotation text entered in JS-prompt
114 var text = window.prompt("Annotation text:"); 135 var text = window.prompt("Annotation text:");
115 if (text == null) 136 if (text == null) return false;
116 return false;
117 var annotation = newAnnotation(pos, text); 137 var annotation = newAnnotation(pos, text);
118 storeAnnotation(data, annotation); 138 storeAnnotation(data, annotation);
119 data.annotations.push(annotation); 139 data.annotations.push(annotation);
120 digilib.fn.redisplay(data); 140 digilib.fn.redisplay(data);
121 return false; 141 return false;