2 IriSP.Widget.call(this, Popcorn, config, Serializer); |
2 IriSP.Widget.call(this, Popcorn, config, Serializer); |
3 this.__counter = 0; |
3 this.__counter = 0; |
4 this.__oldList = []; |
4 this.__oldList = []; |
5 |
5 |
6 this.ajax_mode = IriSP.widgetsDefaults["AnnotationsListWidget"].ajax_mode; |
6 this.ajax_mode = IriSP.widgetsDefaults["AnnotationsListWidget"].ajax_mode; |
|
7 this.project_url = IriSP.widgetsDefaults["AnnotationsListWidget"].project_url; |
7 }; |
8 }; |
8 |
9 |
9 |
10 |
10 IriSP.AnnotationsListWidget.prototype = new IriSP.Widget(); |
11 IriSP.AnnotationsListWidget.prototype = new IriSP.Widget(); |
11 |
12 |
119 return; |
120 return; |
120 |
121 |
121 var view_types = serializer.getIds("Contributions"); |
122 var view_types = serializer.getIds("Contributions"); |
122 var l = []; |
123 var l = []; |
123 |
124 |
|
125 var media = this._serializer.currentMedia()["id"]; |
|
126 |
124 for (i = 0; i < annotations.length; i++) { |
127 for (i = 0; i < annotations.length; i++) { |
125 var annotation = annotations[i]; |
128 var annotation = annotations[i]; |
126 |
129 |
127 /* filter the annotations whose type is not the one we want */ |
130 /* filter the annotations whose type is not the one we want */ |
128 /* We want _all_ the annotations. |
131 /* We want _all_ the annotations. |
137 obj["id"] = a.id; |
140 obj["id"] = a.id; |
138 obj["title"] = a.content.title; |
141 obj["title"] = a.content.title; |
139 obj["desc"] = a.content.description; |
142 obj["desc"] = a.content.description; |
140 obj["begin"] = IriSP.msToTime(annotation.begin); |
143 obj["begin"] = IriSP.msToTime(annotation.begin); |
141 obj["end"] = IriSP.msToTime(annotation.end); |
144 obj["end"] = IriSP.msToTime(annotation.end); |
142 obj["url"] = document.location.href.split("#")[0] + "/" + annotation.meta["project"]; |
145 |
143 l.push(obj); |
146 /* only if the annotation isn't present in the document create an |
|
147 external link */ |
|
148 if (!this.annotations_ids.hasOwnProperty(obj["id"])) { |
|
149 // braindead url; jacques didn't want to create a new one in the platform, |
|
150 // so we append the cutting id to the url. |
|
151 obj["url"] = this.project_url + "/" + media + "/" + |
|
152 annotation.meta["project"] + "/" + |
|
153 annotation.meta["id-ref"] + "/"; |
|
154 |
|
155 // obj["url"] = document.location.href.split("#")[0] + "/" + annotation.meta["project"]; |
|
156 l.push(obj); |
|
157 } |
144 } |
158 } |
145 |
159 |
146 this.do_redraw(l); |
160 this.do_redraw(l); |
147 }; |
161 }; |
148 IriSP.AnnotationsListWidget.prototype.draw = function() { |
162 IriSP.AnnotationsListWidget.prototype.draw = function() { |
149 |
163 |
|
164 /* build a table of the annotations present in the document for faster |
|
165 lookup |
|
166 */ |
|
167 this.annotations_ids = {}; |
|
168 |
|
169 var annotations = this._serializer._data.annotations; |
|
170 var i = 0; |
|
171 for(i = 0; i < annotations.length; i++) { |
|
172 this.annotations_ids[annotations[i]["id"]] = 1; |
|
173 } |
|
174 |
150 this.drawList(); |
175 this.drawList(); |
151 |
176 |
152 if (!this.ajax_mode) { |
177 if (!this.ajax_mode) { |
153 this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", IriSP.wrap(this, function() { this.drawList(true); })); |
178 this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", IriSP.wrap(this, function() { this.drawList(true); })); |
154 this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.redraw)); |
179 this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.redraw)); |