src/js/widgets/createAnnotationWidget.js
branchpopcorn-port
changeset 626 c66bf61262fa
parent 623 d8f107938feb
child 627 13b9f14bf49a
equal deleted inserted replaced
625:63bddb6756d2 626:c66bf61262fa
   263       annotation["begin"] = this._currentAnnotation.begin;
   263       annotation["begin"] = this._currentAnnotation.begin;
   264       annotation["end"] = this._currentAnnotation.end;
   264       annotation["end"] = this._currentAnnotation.end;
   265     }
   265     }
   266   } else {
   266   } else {
   267     var duration = +this._serializer.currentMedia().meta["dc:duration"];
   267     var duration = +this._serializer.currentMedia().meta["dc:duration"];
   268     annotation["begin"] = duration * (this.sliceLeft / 100);
   268     annotation["begin"] = +((duration * (this.sliceLeft / 100)).toFixed(0));
   269     annotation["end"] = duration * ((this.sliceWidth + this.sliceLeft) / 100);
   269     annotation["end"] = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0));
   270     console.log(annotation["begin"], annotation["end"]);
   270     console.log(annotation["begin"], annotation["end"]);
   271   }
   271   }
   272   
   272   
   273   annotation["type"] = this._serializer.getContributions();
   273   annotation["type"] = this._serializer.getContributions();
   274   if (typeof(annotation["type"]) === "undefined")
   274   if (typeof(annotation["type"]) === "undefined")
   293   var jsonString = JSON.stringify(apiJson);
   293   var jsonString = JSON.stringify(apiJson);
   294   var project_id = this._serializer._data.meta.id;
   294   var project_id = this._serializer._data.meta.id;
   295   
   295   
   296   var url = Mustache.to_html("{{platf_url}}/ldtplatform/api/ldt/projects/{{id}}.json",
   296   var url = Mustache.to_html("{{platf_url}}/ldtplatform/api/ldt/projects/{{id}}.json",
   297                               {platf_url: IriSP.platform_url, id: project_id});
   297                               {platf_url: IriSP.platform_url, id: project_id});
   298                               
   298   console.log(url, jsonString);                            
   299   IriSP.jQuery.ajax({
   299   IriSP.jQuery.ajax({
   300       url: url,
   300       url: url,
   301       type: 'PUT',
   301       type: 'PUT',
   302       contentType: 'application/json',
   302       contentType: 'application/json',
   303       data: jsonString,               
   303       data: jsonString,               
   304       dataType: 'json',
   304       //dataType: 'json',
   305       success: function(json, textStatus, XMLHttpRequest) {
   305       success: function(json, textStatus, XMLHttpRequest) {
   306                     debugger;
   306                     debugger;
   307                     /* add the annotation to the annotations and tell the world */
   307                     /* add the annotation to the annotations and tell the world */
   308                     delete annotation.tags;
   308                     delete annotation.tags;
   309                     annotation.content.description = annotation.content.data;
   309                     annotation.content.description = annotation.content.data;
   316                     _this._serializer._data.annotations.push(annotation);
   316                     _this._serializer._data.annotations.push(annotation);
   317                     _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation");
   317                     _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation");
   318                     callback();
   318                     callback();
   319       }, 
   319       }, 
   320       error: 
   320       error: 
   321               function() { 
   321               function(jqXHR, textStatus, errorThrown) { 
   322                             console.log("an error occured while contacting " 
   322                             console.log("an error occured while contacting " 
   323                             + url + " and sending " + jsonString); } });
   323                             + url + " and sending " + jsonString + textStatus ); } });
   324 };
   324 };