90 |
90 |
91 }; |
91 }; |
92 |
92 |
93 IriSP.AnnotationsListWidget.prototype.ajaxRedraw = function(timecode) { |
93 IriSP.AnnotationsListWidget.prototype.ajaxRedraw = function(timecode) { |
94 |
94 |
|
95 /* the seeked signal sometimes passes an argument - depending on if we're using |
|
96 our popcorn lookalike or the real thing - if it's the case, use it as it's |
|
97 more precise than currentTime which sometimes contains the place we where at */ |
|
98 if (IriSP.null_or_undefined(timecode) || typeof(timecode) != "number") { |
|
99 var tcode = this._Popcorn.currentTime(); |
|
100 } else { |
|
101 var tcode = timecode; |
|
102 } |
|
103 |
|
104 |
95 /* the platform gives us a special url - of the type : http://path/{media}/{begin}/{end} |
105 /* the platform gives us a special url - of the type : http://path/{media}/{begin}/{end} |
96 we double the braces using regexps and we feed it to mustache to build the correct url |
106 we double the braces using regexps and we feed it to mustache to build the correct url |
97 we have to do that because the platform only knows at run time what view it's displaying. |
107 we have to do that because the platform only knows at run time what view it's displaying. |
98 */ |
108 */ |
99 |
109 |
100 var platf_url = IriSP.widgetsDefaults["AnnotationsListWidget"].ajax_url |
110 var platf_url = IriSP.widgetsDefaults["AnnotationsListWidget"].ajax_url |
101 .replace(/\{/g, '{{').replace(/\}/g, '}}'); |
111 .replace(/\{/g, '{{').replace(/\}/g, '}}'); |
102 var media_id = this._serializer.currentMedia()["id"]; |
112 var media_id = this._serializer.currentMedia()["id"]; |
103 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
113 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
104 |
114 |
105 var begin_timecode = (Math.floor(this._Popcorn.currentTime()) - 300) * 1000; |
115 var begin_timecode = (Math.floor(tcode) - 300) * 1000; |
106 if (begin_timecode < 0) |
116 if (begin_timecode < 0) |
107 begin_timecode = 0; |
117 begin_timecode = 0; |
108 |
118 |
109 var end_timecode = (Math.floor(this._Popcorn.currentTime()) + 300) * 1000; |
119 var end_timecode = (Math.floor(tcode) + 300) * 1000; |
110 if (end_timecode > duration) |
120 if (end_timecode > duration) |
111 end_timecode = duration; |
121 end_timecode = duration; |
112 |
122 |
|
123 console.log("b, e:", begin_timecode, end_timecode); |
113 var templ = Mustache.to_html(platf_url, {media: media_id, begin: begin_timecode, |
124 var templ = Mustache.to_html(platf_url, {media: media_id, begin: begin_timecode, |
114 end: end_timecode}); |
125 end: end_timecode}); |
115 |
126 |
116 /* we create on the fly a serializer to get the ajax */ |
127 /* we create on the fly a serializer to get the ajax */ |
117 var serializer = new IriSP.JSONSerializer(IriSP.__dataloader, templ); |
128 var serializer = new IriSP.JSONSerializer(IriSP.__dataloader, templ); |