| author | veltr |
| Tue, 10 Apr 2012 14:17:42 +0200 | |
| changeset 855 | 1be5beb4b196 |
| parent 852 | eefb64f74a3f |
| permissions | -rw-r--r-- |
| 585 | 1 |
IriSP.AnnotationsListWidget = function(Popcorn, config, Serializer) { |
2 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
|
605
e1a6f73038b4
made the listWidget redraw at every timeupdate event (added a small optimization though,
hamidouk
parents:
603
diff
changeset
|
3 |
this.__counter = 0; |
|
e1a6f73038b4
made the listWidget redraw at every timeupdate event (added a small optimization though,
hamidouk
parents:
603
diff
changeset
|
4 |
this.__oldList = []; |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
5 |
this.searchRe = null; |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
6 |
this._ajax_cache = []; |
| 833 | 7 |
var _this = this; |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
8 |
|
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
9 |
this._Popcorn.listen("IriSP.search", function(searchString) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
10 |
_this.searchHandler(searchString); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
11 |
}); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
12 |
this._Popcorn.listen("IriSP.search.closed", function() { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
13 |
_this.searchHandler(false); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
14 |
}); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
15 |
this._Popcorn.listen("IriSP.search.cleared", function() { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
16 |
_this.searchHandler(false); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
17 |
}); |
| 585 | 18 |
}; |
19 |
||
20 |
||
21 |
IriSP.AnnotationsListWidget.prototype = new IriSP.Widget(); |
|
22 |
||
23 |
IriSP.AnnotationsListWidget.prototype.clear = function() { |
|
24 |
}; |
|
25 |
||
| 588 | 26 |
IriSP.AnnotationsListWidget.prototype.clearWidget = function() { |
| 585 | 27 |
}; |
28 |
||
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
29 |
IriSP.AnnotationsListWidget.prototype.searchHandler = function(searchString) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
30 |
this.searchRe = (searchString && searchString.length) ? IriSP.regexpFromText(searchString) : null; |
| 842 | 31 |
if (this.ajax_mode && !this.cinecast_version) { |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
32 |
var _this = this, |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
33 |
_annotations = ( |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
34 |
this.searchRe === null |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
35 |
? this._ajax_cache |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
36 |
: IriSP.underscore.filter(this._ajax_cache, function(_a) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
37 |
return (_this.searchRe.test(_a.desc) || _this.searchRe.test(_a.title)); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
38 |
}) |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
39 |
); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
40 |
this.do_redraw(_annotations); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
41 |
if (_annotations.length) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
42 |
this._Popcorn.trigger("IriSP.search.matchFound"); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
43 |
} else { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
44 |
this._Popcorn.trigger("IriSP.search.noMatchFound"); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
45 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
46 |
} else { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
47 |
this.drawList(); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
48 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
49 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
50 |
|
| 629 | 51 |
/** effectively redraw the widget - called by drawList */ |
52 |
IriSP.AnnotationsListWidget.prototype.do_redraw = function(list) { |
|
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
53 |
var _html = IriSP.templToHTML( |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
54 |
IriSP.annotationsListWidget_template, { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
55 |
annotations: list |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
56 |
}), |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
57 |
_this = this; |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
58 |
|
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
59 |
this.selector.html(_html); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
60 |
|
| 842 | 61 |
this.selector.find('.Ldt-AnnotationsList-Tag-Li').click(function() { |
62 |
_this._Popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().trim()); |
|
63 |
}) |
|
64 |
|
|
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
65 |
if (this.searchRe !== null) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
66 |
this.selector.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description") |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
67 |
.each(function() { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
68 |
var _$ = IriSP.jQuery(this); |
| 842 | 69 |
_$.html(_$.text().trim().replace(_this.searchRe, '<span class="Ldt-AnnotationsList-highlight">$1</span>')) |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
70 |
}) |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
71 |
} |
| 629 | 72 |
}; |
73 |
||
| 833 | 74 |
IriSP.AnnotationsListWidget.prototype.transformAnnotation = function(a) { |
| 841 | 75 |
var _this = this; |
| 833 | 76 |
return { |
77 |
"id" : a.id, |
|
78 |
"title": this.cinecast_version ? IriSP.get_aliased(a.meta, ['creator_name', 'creator']) : a.content.title, |
|
79 |
"desc" : this.cinecast_version ? a.content.data : a.content.description, |
|
80 |
"begin": IriSP.msToTime(a.begin), |
|
81 |
"end" : IriSP.msToTime(a.end), |
|
82 |
"thumbnail" : (typeof a.meta == "object" && typeof a.meta.thumbnail == "string") ? a.meta.thumbnail : this.default_thumbnail, |
|
83 |
"url" : (typeof a.meta == "object" && typeof a.meta.url == "string") ? a.meta.url : null, |
|
| 841 | 84 |
"created_at" :(typeof a.meta == "object" && typeof a.meta.created == "string") ? Date.parse(a.meta.created.replace(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}\:\d{2}\:\d{2}).*$/,"$2/$3/$1 $4 UTC+0000")) : null, |
| 833 | 85 |
"tags": typeof a.tags == "object" |
86 |
? IriSP.underscore(a.tags) |
|
87 |
.chain() |
|
88 |
.map(function(_t) { |
|
89 |
if (typeof _t == "string") { |
|
90 |
return _t.replace(/^.*:/,'#'); |
|
91 |
} else { |
|
92 |
if (typeof _t['id-ref'] != "undefined") { |
|
93 |
var _f = IriSP.underscore.find(_this._serializer._data.tags, function(_tag) { |
|
| 840 | 94 |
return _tag.id == _t['id-ref']; |
| 833 | 95 |
}); |
96 |
if (typeof _f != "undefined") { |
|
97 |
return IriSP.get_aliased(_f.meta, ['dc:title', 'title']); |
|
98 |
} |
|
99 |
} |
|
100 |
} |
|
101 |
return null; |
|
102 |
}) |
|
103 |
.filter(function(_t) { |
|
104 |
return _t !== null && _t !== "" |
|
105 |
}) |
|
106 |
.value() |
|
107 |
: [] |
|
108 |
} |
|
109 |
} |
|
110 |
||
| 599 | 111 |
/** draw the annotation list */ |
|
607
0b94ae49efbd
added an option to force the redraw of a list, even if the cached lists are the
hamidouk
parents:
605
diff
changeset
|
112 |
IriSP.AnnotationsListWidget.prototype.drawList = function(force_redraw) { |
| 585 | 113 |
var _this = this; |
| 674 | 114 |
|
| 833 | 115 |
// var view_type = this._serializer.getContributions(); |
| 585 | 116 |
var annotations = this._serializer._data.annotations; |
| 602 | 117 |
var currentTime = this._Popcorn.currentTime(); |
| 585 | 118 |
var list = []; |
| 588 | 119 |
|
| 833 | 120 |
/* if (typeof(view_type) === "undefined") { |
| 585 | 121 |
return; |
| 833 | 122 |
} */ |
| 585 | 123 |
for (i = 0; i < annotations.length; i++) { |
| 833 | 124 |
var obj = this.transformAnnotation(annotations[i]); |
125 |
obj.iterator = i; |
|
126 |
obj.distance = Math.abs((annotations[i].end + annotations[i].begin) / 2000 - currentTime); |
|
| 835 | 127 |
if (!this.cinecast_version || annotations[i].type == "cinecast:UserAnnotation") { |
128 |
list.push(obj); |
|
129 |
} |
|
130 |
|
|
| 585 | 131 |
} |
|
607
0b94ae49efbd
added an option to force the redraw of a list, even if the cached lists are the
hamidouk
parents:
605
diff
changeset
|
132 |
|
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
133 |
if (this.searchRe !== null) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
134 |
list = list.filter(function(_a) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
135 |
return (_this.searchRe.test(_a.desc) || _this.searchRe.test(_a.title)); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
136 |
}); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
137 |
if (list.length) { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
138 |
this._Popcorn.trigger("IriSP.search.matchFound"); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
139 |
} else { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
140 |
this._Popcorn.trigger("IriSP.search.noMatchFound"); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
141 |
} |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
142 |
} |
| 833 | 143 |
list = IriSP.underscore(list) |
144 |
.chain() |
|
145 |
.sortBy(function(_o) { |
|
146 |
return _o.distance; |
|
147 |
}) |
|
148 |
.first(10) |
|
149 |
.sortBy(function(_o) { |
|
| 841 | 150 |
return (_this.cinecast_version ? - _o.created_at : _o.iterator); |
| 833 | 151 |
}) |
152 |
.value(); |
|
|
605
e1a6f73038b4
made the listWidget redraw at every timeupdate event (added a small optimization though,
hamidouk
parents:
603
diff
changeset
|
153 |
var idList = IriSP.underscore.pluck(list, "id").sort(); |
| 642 | 154 |
|
| 842 | 155 |
if (!IriSP.underscore.isEqual(this.__oldList, idList) || this.lastSearch !== this.searchRe || typeof(force_redraw) !== "undefined") { |
| 629 | 156 |
this.do_redraw(list); |
| 833 | 157 |
this.__oldList = idList; |
| 842 | 158 |
this.lastSearch = this.searchRe; |
|
607
0b94ae49efbd
added an option to force the redraw of a list, even if the cached lists are the
hamidouk
parents:
605
diff
changeset
|
159 |
} |
| 833 | 160 |
/* save for next call */ |
|
605
e1a6f73038b4
made the listWidget redraw at every timeupdate event (added a small optimization though,
hamidouk
parents:
603
diff
changeset
|
161 |
|
|
e1a6f73038b4
made the listWidget redraw at every timeupdate event (added a small optimization though,
hamidouk
parents:
603
diff
changeset
|
162 |
|
| 599 | 163 |
}; |
164 |
||
| 674 | 165 |
IriSP.AnnotationsListWidget.prototype.ajaxRedraw = function(timecode) { |
| 748 | 166 |
|
| 752 | 167 |
/* the seeked signal sometimes passes an argument - depending on if we're using |
168 |
our popcorn lookalike or the real thing - if it's the case, use it as it's |
|
169 |
more precise than currentTime which sometimes contains the place we where at */ |
|
170 |
if (IriSP.null_or_undefined(timecode) || typeof(timecode) != "number") { |
|
171 |
var tcode = this._Popcorn.currentTime(); |
|
172 |
} else { |
|
173 |
var tcode = timecode; |
|
174 |
} |
|
175 |
|
|
176 |
|
|
| 841 | 177 |
/* the platform gives us a special url - of the type : http://path/{{media}}/{{begin}}/{{end}} |
| 748 | 178 |
we double the braces using regexps and we feed it to mustache to build the correct url |
179 |
we have to do that because the platform only knows at run time what view it's displaying. |
|
180 |
*/ |
|
181 |
|
|
| 842 | 182 |
var media_id = this.currentMedia()["id"]; |
183 |
var duration = this.getDuration(); |
|
| 698 | 184 |
|
| 752 | 185 |
var begin_timecode = (Math.floor(tcode) - 300) * 1000; |
| 698 | 186 |
if (begin_timecode < 0) |
187 |
begin_timecode = 0; |
|
188 |
|
|
| 752 | 189 |
var end_timecode = (Math.floor(tcode) + 300) * 1000; |
| 698 | 190 |
if (end_timecode > duration) |
191 |
end_timecode = duration; |
|
192 |
|
|
| 841 | 193 |
var templ = Mustache.to_html(this.ajax_url, {media: media_id, begin: begin_timecode, |
| 748 | 194 |
end: end_timecode}); |
195 |
||
| 698 | 196 |
/* we create on the fly a serializer to get the ajax */ |
197 |
var serializer = new IriSP.JSONSerializer(IriSP.__dataloader, templ); |
|
| 833 | 198 |
serializer.sync(IriSP.wrap(this, function(json) { this.processJson(json, serializer) })); |
| 674 | 199 |
}; |
200 |
||
| 698 | 201 |
/** process the received json - it's a bit hackish */ |
202 |
IriSP.AnnotationsListWidget.prototype.processJson = function(json, serializer) { |
|
203 |
/* FIXME: DRY the whole thing */ |
|
204 |
var annotations = serializer._data.annotations; |
|
205 |
if (IriSP.null_or_undefined(annotations)) |
|
206 |
return; |
|
207 |
|
|
| 784 | 208 |
/* |
209 |
commented in case we wanted to discriminate against some annotation types. |
|
| 698 | 210 |
var view_types = serializer.getIds("Contributions"); |
| 784 | 211 |
*/ |
| 698 | 212 |
var l = []; |
213 |
|
|
| 842 | 214 |
var media = this.currentMedia()["id"]; |
|
714
9056928c46de
WIP - making links to only annotations which are not present in the opened
hamidouk
parents:
703
diff
changeset
|
215 |
|
| 698 | 216 |
for (i = 0; i < annotations.length; i++) { |
| 833 | 217 |
var obj = this.transformAnnotation(annotations[i]) |
| 836 | 218 |
if (typeof obj.url == "undefined" || !obj.url) { |
219 |
/* only if the annotation isn't present in the document create an |
|
220 |
external link */ |
|
| 840 | 221 |
if (this.annotations_ids.indexOf(obj.id.toLowerCase()) == -1) { |
| 836 | 222 |
// braindead url; jacques didn't want to create a new one in the platform, |
223 |
// so we append the cutting id to the url. |
|
224 |
obj.url = this.project_url + "/" + media + "/" + |
|
225 |
annotations[i].meta.project + "/" + |
|
226 |
annotations[i].meta["id-ref"] + '#id=' + annotations[i].id; |
|
| 840 | 227 |
|
| 836 | 228 |
// obj.url = document.location.href.split("#")[0] + "/" + annotation.meta.project; |
229 |
} |
|
230 |
} |
|
| 716 | 231 |
l.push(obj); |
| 698 | 232 |
} |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
233 |
this._ajax_cache = l; |
| 698 | 234 |
this.do_redraw(l); |
235 |
}; |
|
| 599 | 236 |
IriSP.AnnotationsListWidget.prototype.draw = function() { |
|
714
9056928c46de
WIP - making links to only annotations which are not present in the opened
hamidouk
parents:
703
diff
changeset
|
237 |
|
|
9056928c46de
WIP - making links to only annotations which are not present in the opened
hamidouk
parents:
703
diff
changeset
|
238 |
/* build a table of the annotations present in the document for faster |
|
9056928c46de
WIP - making links to only annotations which are not present in the opened
hamidouk
parents:
703
diff
changeset
|
239 |
lookup |
|
9056928c46de
WIP - making links to only annotations which are not present in the opened
hamidouk
parents:
703
diff
changeset
|
240 |
*/ |
| 840 | 241 |
this.annotations_ids = IriSP.underscore(this._serializer._data.annotations).map(function(_a) { |
242 |
return _a.id.toLowerCase(); |
|
243 |
}); |
|
|
714
9056928c46de
WIP - making links to only annotations which are not present in the opened
hamidouk
parents:
703
diff
changeset
|
244 |
|
| 833 | 245 |
var _this = this; |
| 674 | 246 |
|
| 842 | 247 |
if (!this.ajax_mode || this.cinecast_version) { |
|
838
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
248 |
var _throttled = IriSP.underscore.throttle(function() { |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
249 |
_this.drawList(); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
250 |
}, 1500); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
251 |
_throttled(); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
252 |
this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", _throttled); |
|
03b03865eb9b
Transferred i18n data to widgets, corrected slider bug, added search in annotationslist
veltr
parents:
836
diff
changeset
|
253 |
this._Popcorn.listen("timeupdate", _throttled); |
| 842 | 254 |
if (this.cinecast_version) { |
255 |
window.setInterval(function() { |
|
256 |
var _tmpSerializer = new IriSP.JSONSerializer(IriSP.__dataloader, _this._config.metadata.src, true); |
|
257 |
_tmpSerializer.sync(function(json) { |
|
| 855 | 258 |
_this.annotations_ids = IriSP.underscore(_this._serializer._data.annotations).map(function(_a) { |
259 |
return _a.id.toLowerCase(); |
|
260 |
}); |
|
| 842 | 261 |
IriSP.underscore(json.annotations).each(function(_a) { |
262 |
var _j = _this.annotations_ids.indexOf(_a.id); |
|
263 |
if (_j == -1) { |
|
264 |
_this._serializer._data.annotations.push(_a); |
|
265 |
_this.annotations_ids.push(_a.id); |
|
266 |
} else { |
|
267 |
_this._serializer._data.annotations[_j] = _a; |
|
268 |
} |
|
269 |
_throttled(); |
|
270 |
}); |
|
271 |
}, true); // true is for force_refresh |
|
272 |
},this.refresh_interval); |
|
273 |
} |
|
| 674 | 274 |
} else { |
|
729
7ba63d0315ad
load the widget when the video has finished loading.
hamidouk
parents:
716
diff
changeset
|
275 |
/* update the widget when the video has finished loading and when it's seeked and paused */ |
| 698 | 276 |
this._Popcorn.listen("seeked", IriSP.wrap(this, this.ajaxRedraw)); |
|
729
7ba63d0315ad
load the widget when the video has finished loading.
hamidouk
parents:
716
diff
changeset
|
277 |
this._Popcorn.listen("loadedmetadata", IriSP.wrap(this, this.ajaxRedraw)); |
| 698 | 278 |
this._Popcorn.listen("paused", IriSP.wrap(this, this.ajaxRedraw)); |
|
730
357fc047503b
redraw the widget after that an annotation has been added.
hamidouk
parents:
729
diff
changeset
|
279 |
|
|
357fc047503b
redraw the widget after that an annotation has been added.
hamidouk
parents:
729
diff
changeset
|
280 |
this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", IriSP.wrap(this, this.ajaxRedraw)); |
| 674 | 281 |
} |
| 698 | 282 |
|
| 585 | 283 |
}; |