equal
deleted
inserted
replaced
89 } |
89 } |
90 |
90 |
91 }; |
91 }; |
92 |
92 |
93 IriSP.AnnotationsListWidget.prototype.ajaxRedraw = function(timecode) { |
93 IriSP.AnnotationsListWidget.prototype.ajaxRedraw = function(timecode) { |
94 var pre_url = IriSP.widgetsDefaults["AnnotationsListWidget"].ajax_url; |
94 |
|
95 /* 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 |
|
97 we have to do that because the platform only knows at run time what view it's displaying. |
|
98 */ |
|
99 |
|
100 var platf_url = IriSP.widgetsDefaults["AnnotationsListWidget"].ajax_url |
|
101 .replace(/\{/g, '{{').replace(/\}/g, '}}'); |
95 var media_id = this._serializer.currentMedia()["id"]; |
102 var media_id = this._serializer.currentMedia()["id"]; |
96 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
103 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
97 |
104 |
98 var begin_timecode = (Math.floor(this._Popcorn.currentTime()) - 300) * 1000; |
105 var begin_timecode = (Math.floor(this._Popcorn.currentTime()) - 300) * 1000; |
99 if (begin_timecode < 0) |
106 if (begin_timecode < 0) |
101 |
108 |
102 var end_timecode = (Math.floor(this._Popcorn.currentTime()) + 300) * 1000; |
109 var end_timecode = (Math.floor(this._Popcorn.currentTime()) + 300) * 1000; |
103 if (end_timecode > duration) |
110 if (end_timecode > duration) |
104 end_timecode = duration; |
111 end_timecode = duration; |
105 |
112 |
106 var templ = Mustache.to_html("{{pre_url}}/{{media_id}}/{{begin_timecode}}/{{end_timecode}}", |
113 var templ = Mustache.to_html(platf_url, {media: media_id, begin: begin_timecode, |
107 {pre_url: pre_url, media_id: media_id, begin_timecode: begin_timecode, |
114 end: end_timecode}); |
108 end_timecode: end_timecode}); |
115 |
109 |
|
110 /* we create on the fly a serializer to get the ajax */ |
116 /* we create on the fly a serializer to get the ajax */ |
111 var serializer = new IriSP.JSONSerializer(IriSP.__dataloader, templ); |
117 var serializer = new IriSP.JSONSerializer(IriSP.__dataloader, templ); |
112 serializer.sync(IriSP.wrap(this, function(json) { this.processJson(json, serializer) })); |
118 serializer.sync(IriSP.wrap(this, function(json) { this.processJson(json, serializer) })); |
113 }; |
119 }; |
114 |
120 |