184 } |
184 } |
185 } |
185 } |
186 }; |
186 }; |
187 |
187 |
188 IriSP.createAnnotationWidget.prototype.showStartScreen = function() { |
188 IriSP.createAnnotationWidget.prototype.showStartScreen = function() { |
189 this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().show(); |
189 this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide(); |
190 this.selector.find("Ldt-createAnnotation-Description").val("Type your annotation here."); |
190 this.selector.find(".Ldt-createAnnotation-startScreen").show(); |
191 this.selector.find(".Ldt-createAnnotation-endScreen").hide(); |
191 this.selector.find("Ldt-createAnnotation-Description").val("Type your annotation here."); |
|
192 }; |
|
193 |
|
194 IriSP.createAnnotationWidget.prototype.showWaitScreen = function() { |
|
195 this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide(); |
|
196 this.selector.find(".Ldt-createAnnotation-waitScreen").show(); |
192 }; |
197 }; |
193 |
198 |
194 IriSP.createAnnotationWidget.prototype.showEndScreen = function() { |
199 IriSP.createAnnotationWidget.prototype.showEndScreen = function() { |
195 this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide(); |
200 this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide(); |
196 |
201 |
231 this.selector.find(".Ldt-createAnnotation-errorMessage").hide(); |
236 this.selector.find(".Ldt-createAnnotation-errorMessage").hide(); |
232 textfield.css("background-color", ""); |
237 textfield.css("background-color", ""); |
233 } |
238 } |
234 })); |
239 })); |
235 } else { |
240 } else { |
236 this.showEndScreen(); |
241 this.showWaitScreen(); |
237 |
242 |
238 this.sendLdtData(contents, function() { |
243 this.sendLdtData(contents, function() { |
239 if (_this.cinecast_version) { |
244 if (_this.cinecast_version) { |
240 if (_this._Popcorn.media.paused) |
245 if (_this._Popcorn.media.paused) |
241 _this._Popcorn.play(); |
246 _this._Popcorn.play(); |
242 |
|
243 window.setTimeout(IriSP.wrap(_this, function() { this.showStartScreen(); }), 5000); |
|
244 } |
247 } |
|
248 debugger; |
|
249 _this.showEndScreen(); |
|
250 window.setTimeout(IriSP.wrap(_this, function() { this.showStartScreen(); }), 5000); |
245 }); |
251 }); |
246 } |
252 } |
247 }; |
253 }; |
248 |
254 |
249 IriSP.createAnnotationWidget.prototype.handleSliderChanges = function(params) { |
255 IriSP.createAnnotationWidget.prototype.handleSliderChanges = function(params) { |
265 } |
271 } |
266 } else { |
272 } else { |
267 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
273 var duration = +this._serializer.currentMedia().meta["dc:duration"]; |
268 annotation["begin"] = +((duration * (this.sliceLeft / 100)).toFixed(0)); |
274 annotation["begin"] = +((duration * (this.sliceLeft / 100)).toFixed(0)); |
269 annotation["end"] = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0)); |
275 annotation["end"] = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0)); |
270 console.log(annotation["begin"], annotation["end"]); |
|
271 } |
276 } |
272 |
277 |
273 annotation["type"] = this._serializer.getContributions(); |
278 annotation["type"] = this._serializer.getContributions(); |
274 if (typeof(annotation["type"]) === "undefined") |
279 if (typeof(annotation["type"]) === "undefined") |
275 annotation["type"] = ""; |
280 annotation["type"] = ""; |
293 var jsonString = JSON.stringify(apiJson); |
298 var jsonString = JSON.stringify(apiJson); |
294 var project_id = this._serializer._data.meta.id; |
299 var project_id = this._serializer._data.meta.id; |
295 |
300 |
296 var url = Mustache.to_html("{{platf_url}}/ldtplatform/api/ldt/projects/{{id}}.json", |
301 var url = Mustache.to_html("{{platf_url}}/ldtplatform/api/ldt/projects/{{id}}.json", |
297 {platf_url: IriSP.platform_url, id: project_id}); |
302 {platf_url: IriSP.platform_url, id: project_id}); |
298 console.log(url, jsonString); |
303 |
299 IriSP.jQuery.ajax({ |
304 IriSP.jQuery.ajax({ |
300 url: url, |
305 url: url, |
301 type: 'PUT', |
306 type: 'PUT', |
302 contentType: 'application/json', |
307 contentType: 'application/json', |
303 data: jsonString, |
308 data: jsonString, |
304 //dataType: 'json', |
309 //dataType: 'json', |
305 success: function(json, textStatus, XMLHttpRequest) { |
310 success: function(json, textStatus, XMLHttpRequest) { |
306 debugger; |
311 |
307 /* add the annotation to the annotations and tell the world */ |
312 /* add the annotation to the annotations and tell the world */ |
308 delete annotation.tags; |
313 delete annotation.tags; |
309 annotation.content.description = annotation.content.data; |
314 annotation.content.description = annotation.content.data; |
310 delete annotation.content.data; |
315 delete annotation.content.data; |
311 annotation.id = json.annotations[0].id; |
316 annotation.id = json.annotations[0].id; |
312 annotation.title = _this._currentAnnotation.content.title; |
317 annotation.title = ""; |
313 annotation.meta = meta; |
318 annotation.meta = meta; |
314 annotation.meta["id-ref"] = annotation["type"]; |
319 annotation.meta["id-ref"] = annotation["type"]; |
315 // everything is shared so there's no need to propagate the change |
320 // everything is shared so there's no need to propagate the change |
316 _this._serializer._data.annotations.push(annotation); |
321 _this._serializer._data.annotations.push(annotation); |
317 _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation"); |
322 _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation"); |