76 this._Popcorn.trigger("IriSP.ArrowWidget.releaseArrow"); |
76 this._Popcorn.trigger("IriSP.ArrowWidget.releaseArrow"); |
77 } else { |
77 } else { |
78 if (this.cinecast_version) { |
78 if (this.cinecast_version) { |
79 var currentTime = this._Popcorn.currentTime(); |
79 var currentTime = this._Popcorn.currentTime(); |
80 var currentAnnotation = this._serializer.currentAnnotations(currentTime)[0]; |
80 var currentAnnotation = this._serializer.currentAnnotations(currentTime)[0]; |
|
81 |
81 var beginTime = IriSP.msToTime(currentAnnotation.begin); |
82 var beginTime = IriSP.msToTime(currentAnnotation.begin); |
82 var endTime = IriSP.msToTime(currentAnnotation.end); |
83 var endTime = IriSP.msToTime(currentAnnotation.end); |
|
84 |
|
85 /* save the variable because the user may take some time writing his |
|
86 comment so the currentAnnottion may change when it's time to post it */ |
|
87 this._currentAnnotation = currentAnnotation; |
83 |
88 |
84 if (typeof(currentAnnotation.content) !== "undefined") |
89 if (typeof(currentAnnotation.content) !== "undefined") |
85 this.selector.find(".Ldt-createAnnotation-Title").html(currentAnnotation.content.title); |
90 this.selector.find(".Ldt-createAnnotation-Title").html(currentAnnotation.content.title); |
86 |
91 |
87 var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime }); |
92 var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime }); |
157 |
162 |
158 this.selector.find(".Ldt-createAnnotation-endScreen-TweetLink").attr("href", twStatus); |
163 this.selector.find(".Ldt-createAnnotation-endScreen-TweetLink").attr("href", twStatus); |
159 this.selector.find(".Ldt-createAnnotation-endScreen-FbLink").attr("href", fbStatus); |
164 this.selector.find(".Ldt-createAnnotation-endScreen-FbLink").attr("href", fbStatus); |
160 this.selector.find(".Ldt-createAnnotation-endScreen-GplusLink").attr("href", gpStatus); |
165 this.selector.find(".Ldt-createAnnotation-endScreen-GplusLink").attr("href", gpStatus); |
161 |
166 |
162 this.selector.find(".Ldt-createAnnotation-endScreen").show(); |
167 this.selector.find(".Ldt-createAnnotation-endScreen").show(); |
163 } |
168 |
164 }; |
169 |
|
170 if (typeof(this._currentAnnotation) === "undefined") { |
|
171 console.log("this._currentAnnotation undefined"); |
|
172 return; |
|
173 } |
|
174 |
|
175 var apiJson = {annotations : [{}], meta: {}}; |
|
176 var annotation = apiJson["annotations"][0]; |
|
177 //annotation["type_title"] = "Contributions"; |
|
178 annotation["type_title"] = ""; |
|
179 //annotation["media"] = this._serializer.currentMedia()["id"]; |
|
180 annotation["media"] = "jeanpierremelville_lecerclerouge"; |
|
181 annotation["begin"] = this._currentAnnotation.begin; |
|
182 annotation["end"] = this._currentAnnotation.end; |
|
183 annotation["type"] = "c_23934F53-A24A-0106-3407-AA3BEF56DE19"; |
|
184 annotation.content = {}; |
|
185 annotation.content["data"] = contents; |
|
186 |
|
187 var meta = apiJson["meta"]; |
|
188 meta.creator = "An User"; |
|
189 meta.created = Date().toString(); |
|
190 |
|
191 annotation["tags"] = []; |
|
192 |
|
193 for (var i = 0; i < this.keywords.length; i++) { |
|
194 var keyword = this.keywords[i]; |
|
195 if (contents.indexOf(keyword) != -1) |
|
196 annotation["tags"].push(keyword); |
|
197 } |
|
198 |
|
199 var jsonString = JSON.stringify(apiJson); |
|
200 var project_id = this._serializer._data.meta.id; |
|
201 |
|
202 var url = Mustache.to_html("{{platf_url}}/ldtplatform/api/ldt/projects/f005b2ec-e27e-11df-8f82-00145ea4a2be.json", |
|
203 {platf_url: IriSP.platform_url, id: project_id}); |
|
204 IriSP.jQuery.ajax({ |
|
205 url: url, |
|
206 type: 'PUT', |
|
207 contentType: 'application/json', |
|
208 data: jsonString, |
|
209 // bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType |
|
210 //dataType: 'json', |
|
211 success: function(json, textStatus, XMLHttpRequest) { |
|
212 alert("success = " + json); |
|
213 }, |
|
214 error: function(jqXHR, textStatus, errorThrown) { |
|
215 alert("ERROR = " + jqXHR.responseText + ", " + errorThrown); |
|
216 } |
|
217 }); |
|
218 } |
|
219 }; |