# HG changeset patch
# User veltr
# Date 1326389095 -3600
# Node ID 58d4c61d724bcd1ba7ecf2d81fade6310ba35461
# Parent 110454f3425f99f8bd9e781458c34a8105f0d7fd# Parent 0059750178bcb5255c9499bdd742242a3a476065
Merge issues
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/ldt_utils/projectserializer.py
--- a/src/ldt/ldt/ldt_utils/projectserializer.py Thu Jan 12 17:36:58 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/projectserializer.py Thu Jan 12 18:24:55 2012 +0100
@@ -1,3 +1,4 @@
+from django.conf import settings
from datetime import datetime
from django.utils.datastructures import SortedDict
from ldt.ldt_utils.models import Content
@@ -15,7 +16,7 @@
"""
class ProjectSerializer:
- def __init__(self, project, from_contents=True, from_display=True):
+ def __init__(self, project, from_contents=True, from_display=True, first_cutting=None, viewable_contents=[]):
self.project = project
self.parsed = False
self.ldt_doc = None
@@ -32,6 +33,8 @@
self.display_contents_list = []
self.display_cuttings_list = []
self.display_ensemble_list = []
+ self.viewable_contents = viewable_contents
+ self.first_cutting = first_cutting
def __parse_views(self, display_node_list):
@@ -41,6 +44,7 @@
continue
content_list = []
cuttings_list = []
+
new_display = {
"id": display_id,
"contents": content_list,
@@ -62,9 +66,23 @@
ensemble_id = cutting_node.get("idens")
if ensemble_id not in self.display_ensemble_list:
self.display_ensemble_list.append(ensemble_id)
+
+ # sets cutting to display in first position for the metadataplayer
+ if self.first_cutting:
+ first_cutting = "c_%s" % self.first_cutting.upper()
+
+ annotation_types = new_display['annotation_types']
+ if len(annotation_types) > 1:
+ index = -1
+ for i, s in enumerate(annotation_types):
+ if s == first_cutting:
+ index = i
+ break
+ if index >= 0:
+ annotation_types[0], annotation_types[index] = annotation_types[index], annotation_types[0]
+
self.views_dict[display_id] = new_display
-
-
+
def __parse_ensemble(self, ensemble_node, content):
@@ -329,7 +347,9 @@
href = ""
meta_item_value = ""
- if content.videopath:
+ if content.iri_id not in self.viewable_contents:
+ href = settings.FORBIDDEN_STREAM_URL
+ elif content.videopath:
href = content.videopath.rstrip('/') + "/" + content.src
meta_item_value = content.videopath.rstrip('/') + "/"
@@ -396,8 +416,19 @@
res['annotation-types'] = self.annotation_types_dict.values() if len(self.annotation_types_dict) > 0 else None
res['annotations'] = self.annotations_dict.values() if len(self.annotations_dict) > 0 else None
+
+ if self.first_cutting:
+ first_cutting = "c_%s" % self.first_cutting.upper()
+
+ index = -1
+ for i, ann in enumerate(res['annotation-types']):
+ if ann['id'] == first_cutting:
+ index = i
+ break
+
+ if index > 0:
+ res['annotation-types'][0], res['annotation-types'][1] = res['annotation-types'][1], res['annotation-types'][0]
-
return res
def get_annotations(self, first_cutting=True):
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Thu Jan 12 18:24:55 2012 +0100
@@ -0,0 +1,57 @@
+{% extends "front/front_base.html" %}
+{% load i18n %}
+{% load thumbnail %}
+{% load front_tags %}
+
+{% block title %}Lignes de temps : groupe "{{group.name}}"{% endblock %}
+
+{% block js_import %}
+{{block.super}}
+
+
+{% endblock %}
+
+{% block css_import %}
+{{block.super}}
+
+{% endblock %}
+
+{% block js_declaration %}
+{{block.super}}
+
+
+{% endblock %}
+
+{% block body %}
+{{block.super}}
+
+
+{% endblock %}
+
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/ldt_utils/templates/front/front_home.html
--- a/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Jan 12 17:36:58 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Jan 12 18:24:55 2012 +0100
@@ -16,7 +16,12 @@
@@ -161,29 +159,29 @@
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html Thu Jan 12 17:36:58 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html Thu Jan 12 18:24:55 2012 +0100
@@ -25,6 +25,9 @@
"popcorn.jwplayer": IriSP.libdir + "popcorn.jwplayer.js",
"popcorn.youtube": IriSP.libdir + "popcorn.youtube.js",
};
+
+ IriSP.paths["imgs"] = "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}css/imgs";
+ IriSP.default_templates_vars["img_dir"] = IriSP.paths.imgs;
var config = {
gui:{
width:{{ player_width }},
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/ldt_utils/urls.py
--- a/src/ldt/ldt/ldt_utils/urls.py Thu Jan 12 17:36:58 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/urls.py Thu Jan 12 18:24:55 2012 +0100
@@ -26,6 +26,7 @@
url(r'^update/(?P.*)$', 'views.project.update_project'),
url(r'^cljson/id/(?P.*)$', 'views.json.project_json_id'),
url(r'^cljson/externalid/(?P.*)$', 'views.json.project_json_externalid'),
+ url(r'cljson/idcutting/(?P.*)/(?P.*)$', 'views.json.project_json_cutting_id'),
url(r'^rdf/id/(?P.*)$', 'views.rdf.project_annotations_rdf'),
url(r'^/?$', "views.workspace.home", name="root-view"),
url(r'^filterprojects/_(?P[\w\%\_\-\+]*?)/(?Ptrue|false)/(?P\d)$', "views.project.projects_filter",),
@@ -45,6 +46,7 @@
url(r'^front/player/(?P.*)$', 'views.front.annot_content'),
url(r'^front/search/$', 'views.front.search_index'),
url(r'^front/searchListing', 'views.front.search_listing'),
+ url(r'^front/medias', 'views.front.all_contents'),
)
urlpatterns += patterns('',
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/ldt_utils/views/front.py
--- a/src/ldt/ldt/ldt_utils/views/front.py Thu Jan 12 17:36:58 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/front.py Thu Jan 12 18:24:55 2012 +0100
@@ -48,6 +48,19 @@
@login_required
+def all_contents(request):
+ # Get all the public contents group
+ content_list = add_change_attr(request.user, Content.safe_objects.all())
+
+ is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1);
+
+ return render_to_response("front/front_all_contents.html",
+ {'content_list':content_list,
+ 'is_gecko': is_gecko},
+ context_instance=RequestContext(request))
+
+
+@login_required
def annot_content(request, content_iri_id):
# Get the wanted content
content = Content.objects.get(iri_id=content_iri_id)
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/ldt_utils/views/json.py
--- a/src/ldt/ldt/ldt_utils/views/json.py Thu Jan 12 17:36:58 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/json.py Thu Jan 12 18:24:55 2012 +0100
@@ -7,6 +7,7 @@
from ldt.ldt_utils.models import Project
from ldt.ldt_utils.projectserializer import ProjectSerializer
import ldt.auth as ldt_auth
+from guardian.shortcuts import get_objects_for_user
def project_json_id(request, id):
@@ -14,6 +15,11 @@
return project_json(request, project, False)
+def project_json_cutting_id(request, id, cutting_id):
+
+ project = get_object_or_404(Project.safe_objects, ldt_id=id)
+
+ return project_json(request, project, first_cutting=cutting_id)
def project_json_externalid(request, id):
@@ -23,7 +29,7 @@
-def project_json(request, project, serialize_contents=True): # Not checked
+def project_json(request, project, serialize_contents=True, first_cutting=None): # Not checked
if not ldt_auth.check_access(request.user, project):
return HttpResponseForbidden(_("You can not access this project"))
@@ -51,8 +57,9 @@
if escape_str:
escape_bool = {'true': True, 'false': False, "0": False, "1": True}.get(escape_str.lower())
-
- ps = ProjectSerializer(project, serialize_contents)
+ viewable_contents = get_objects_for_user(request.user, 'ldt_utils.view_content', klass=project.contents.all())
+ viewable_contents = [c.iri_id for c in viewable_contents]
+ ps = ProjectSerializer(project, serialize_contents, viewable_contents=viewable_contents, first_cutting=first_cutting)
project_dict = ps.serialize_to_cinelab()
json_str = simplejson.dumps(project_dict, ensure_ascii=False, indent=indent)
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/static/ldt/css/front_home.css
--- a/src/ldt/ldt/static/ldt/css/front_home.css Thu Jan 12 17:36:58 2012 +0100
+++ b/src/ldt/ldt/static/ldt/css/front_home.css Thu Jan 12 18:24:55 2012 +0100
@@ -8,10 +8,23 @@
width: 960px;
}
+#derniers_medias .li_right {
+ float: right; margin-top:10px;
+}
+
#derniers_medias .li_media {
+ height: 225px;
width: 300px;
}
+/* Communs */
+.title_ul {
+ list-style: none;
+}
+.graph_annotation {
+ background: url(./imgs/whitealpha.png); margin:148px -297px; position:absolute;
+}
+
/* Plus annotés */
#plus_annotes {
@@ -22,6 +35,10 @@
width: 630px; margin-right: 10px;
}
+#plus_annotes .li_right {
+ float: right; margin-top:10px;
+}
+
#plus_annotes .li_media {
width: 140px;
height: 140px;
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/static/ldt/css/imgs/facebook.png
Binary file src/ldt/ldt/static/ldt/css/imgs/facebook.png has changed
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/static/ldt/css/imgs/twitter.png
Binary file src/ldt/ldt/static/ldt/css/imgs/twitter.png has changed
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/static/ldt/css/imgs/whitealpha.png
Binary file src/ldt/ldt/static/ldt/css/imgs/whitealpha.png has changed
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/static/ldt/img/little_plus.png
Binary file src/ldt/ldt/static/ldt/img/little_plus.png has changed
diff -r 0059750178bc -r 58d4c61d724b src/ldt/ldt/static/ldt/js/LdtPlayer-release.js
--- a/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js Thu Jan 12 17:36:58 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js Thu Jan 12 18:24:55 2012 +0100
@@ -1169,7 +1169,7 @@
onPause: IriSP.PopcornReplacement.__pauseHandler,
onSeek: IriSP.PopcornReplacement.__seekHandler
}
-
+
jwplayer(IriSP.PopcornReplacement._container).setup(options);
IriSP.PopcornReplacement.media.duration = options.duration;
return IriSP.PopcornReplacement;
@@ -1281,7 +1281,6 @@
}
if (IriSP.PopcornReplacement.__delay_seek_signal === true) {
- console.log(IriSP.PopcornReplacement.currentTime());
IriSP.PopcornReplacement.trigger("seeked");
}
IriSP.PopcornReplacement.trigger("timeupdate");
@@ -2223,8 +2222,7 @@
var list = [];
- if (typeof(view_type) === "undefined") {
- console.log("no type suitable for display");
+ if (typeof(view_type) === "undefined") {
return;
}
@@ -2233,7 +2231,7 @@
/* filter the annotations whose type is not the one we want */
if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined"
- && annotation.meta["id-ref"] != view_type) {
+ && annotation.meta["id-ref"] !== view_type) {
continue;
}
@@ -2507,7 +2505,9 @@
this.selector.append(annotationMarkup);
- this.selector.hide();
+ if (!this.cinecast_version)
+ this.selector.hide();
+
for (var i = 0; i < this.keywords.length; i++) {
var keyword = this.keywords[i];
var id = IriSP.guid("button_");
@@ -2520,9 +2520,14 @@
this.selector.find("#" + id).click(function(keyword) { return function() {
var contents = _this.selector.find(".Ldt-createAnnotation-Description").val();
if (contents.indexOf(keyword) != -1) {
- var newVal = contents.replace(keyword, "");
+ var newVal = contents.replace(" " + keyword, "");
+ if (newVal == contents)
+ newVal = contents.replace(keyword, "");
} else {
- var newVal = contents + keyword;
+ if (contents === "")
+ var newVal = keyword;
+ else
+ var newVal = contents + " " + keyword;
}
_this.selector.find(".Ldt-createAnnotation-Description").val(newVal);
@@ -2537,51 +2542,90 @@
this.selector.find(".Ldt-createAnnotation-Description")
.bind("propertychange keyup input paste", IriSP.wrap(this, this.handleTextChanges));
+
+ /* the cinecast version of the player is supposed to pause when the user clicks on the button */
+ if (this.cinecast_version) {
+ this.selector.find(".Ldt-createAnnotation-Description")
+ .one("propertychange keyup input paste js_mod",
+ function() { if (!_this._Popcorn.media.paused) _this._Popcorn.pause() });
+ }
+ /* the cinecast version expects the user to comment on a defined segment.
+ As the widget is always shown, we need a way to update it's content as
+ time passes. We do this like we did with the annotationsWidget : we schedule
+ a .code start function which will be called at the right time.
+ */
+ if (this.cinecast_version) {
+ var legal_ids;
+ if (typeof(this._serializer.getChapitrage()) !== "undefined")
+ legal_id = this._serializer.getChapitrage();
+ else
+ legal_id = this._serializer.getNonTweetIds()[0];
+
+ var annotations = this._serializer._data.annotations;
+ var i;
+
+ for (i in annotations) {
+ var annotation = annotations[i];
+ if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined"
+ && legal_id !== annotation.meta["id-ref"]) {
+ continue;
+ }
+
+ code = {start: annotation.begin / 1000, end: annotation.end / 1000,
+ onStart: function(annotation) { return function() {
+ if (typeof(annotation.content) !== "undefined")
+ _this.selector.find(".Ldt-createAnnotation-Title").html(annotation.content.title);
+
+ _this._currentAnnotation = annotation;
+ var beginTime = IriSP.msToTime(annotation.begin);
+ var endTime = IriSP.msToTime(annotation.end);
+ var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime });
+ _this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate);
+ } }(annotation)
+ };
+
+ this._Popcorn.code(code);
+ }
+ }
this.selector.find(".Ldt-createAnnotation-submitButton").click(IriSP.wrap(this, this.handleButtonClick));
- this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked",
- IriSP.wrap(this, this.handleAnnotateSignal));
+
+ if (!this.cinecast_version)
+ this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked",
+ IriSP.wrap(this, this.handleAnnotateSignal));
};
+/** handles clicks on the annotate button. Works only for the non-cinecast version */
IriSP.createAnnotationWidget.prototype.handleAnnotateSignal = function() {
+
if (this._hidden == false) {
this.selector.hide();
this._hidden = true;
- /* reinit the fields */
-
- this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().show();
- this.selector.find("Ldt-createAnnotation-Description").val("");
- this.selector.find(".Ldt-createAnnotation-endScreen").hide();
// free the arrow.
this._Popcorn.trigger("IriSP.ArrowWidget.releaseArrow");
+ this._Popcorn.trigger("IriSP.SliceWidget.hide");
+
} else {
- if (this.cinecast_version) {
- var currentTime = this._Popcorn.currentTime();
- var currentAnnotation = this._serializer.currentAnnotations(currentTime)[0];
-
- var beginTime = IriSP.msToTime(currentAnnotation.begin);
- var endTime = IriSP.msToTime(currentAnnotation.end);
-
- /* save the variable because the user may take some time writing his
- comment so the currentAnnottion may change when it's time to post it */
- this._currentAnnotation = currentAnnotation;
-
- if (typeof(currentAnnotation.content) !== "undefined")
- this.selector.find(".Ldt-createAnnotation-Title").html(currentAnnotation.content.title);
-
- var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime });
- this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate);
- }
-
+ this.showStartScreen();
this.selector.show();
this._hidden = false;
+ var currentTime = this._Popcorn.currentTime();
// block the arrow.
this._Popcorn.trigger("IriSP.ArrowWidget.blockArrow");
+ var duration = +this._serializer.currentMedia().meta["dc:duration"];
+ var currentChapter = this._serializer.currentChapitre(currentTime);
+ console.log(currentTime);
+ var left = (currentChapter.begin / duration) * this.selector.width();
+ var width = (currentChapter.end / duration) * this.selector.width() - left;
+ console.log([left, width]);
+ this._Popcorn.trigger("IriSP.SliceWidget.position", [left, width]);
+ this._Popcorn.trigger("IriSP.SliceWidget.show");
}
};
+
/** watch for changes in the textfield and change the buttons accordingly */
IriSP.createAnnotationWidget.prototype.handleTextChanges = function(event) {
var contents = this.selector.find(".Ldt-createAnnotation-Description").val();
@@ -2605,14 +2649,37 @@
}
};
+IriSP.createAnnotationWidget.prototype.showStartScreen = function() {
+ this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().show();
+ this.selector.find("Ldt-createAnnotation-Description").val("Type your annotation here.");
+ this.selector.find(".Ldt-createAnnotation-endScreen").hide();
+};
+
+IriSP.createAnnotationWidget.prototype.showEndScreen = function() {
+ this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide();
+
+ if (this.cinecast_version) {
+ this.selector.find(".Ldt-createAnnotation-Title").parent().show();
+ }
+
+ var twStatus = IriSP.mkTweetUrl(document.location.href);
+ var gpStatus = IriSP.mkGplusUrl(document.location.href);
+ var fbStatus = IriSP.mkFbUrl(document.location.href);
+
+ this.selector.find(".Ldt-createAnnotation-endScreen-TweetLink").attr("href", twStatus);
+ this.selector.find(".Ldt-createAnnotation-endScreen-FbLink").attr("href", fbStatus);
+ this.selector.find(".Ldt-createAnnotation-endScreen-GplusLink").attr("href", gpStatus);
+
+ this.selector.find(".Ldt-createAnnotation-endScreen").show();
+};
+
/** handle clicks on "send annotation" button */
IriSP.createAnnotationWidget.prototype.handleButtonClick = function(event) {
var _this = this;
var textfield = this.selector.find(".Ldt-createAnnotation-Description");
var contents = textfield.val();
- if (contents === "") {
-
+ if (contents === "") {
if (this.selector.find(".Ldt-createAnnotation-errorMessage").length === 0) {
this.selector.find(".Ldt-createAnnotation-Container")
.after(IriSP.templToHTML(IriSP.createAnnotation_errorMessage_template));
@@ -2620,77 +2687,75 @@
} else {
this.selector.find(".Ldt-createAnnotation-errorMessage").show();
}
- // use namespaced events to be able to unbind them quickly and without unbinding
- // the other event handlers.
- textfield.bind("js_mod.tmp propertychange.tmp keyup.tmp input.tmp paste.tmp", IriSP.wrap(this, function() {
+
+ textfield.one("js_mod propertychange keyup input paste", IriSP.wrap(this, function() {
var contents = textfield.val();
- console.log(contents);
+
if (contents !== "") {
this.selector.find(".Ldt-createAnnotation-errorMessage").hide();
textfield.css("background-color", "");
- textfield.unbind(".tmp");
}
}));
} else {
- this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide();
-
- if (this.cinecast_version) {
- this.selector.find(".Ldt-createAnnotation-Title").parent().show();
- }
-
- var twStatus = IriSP.mkTweetUrl(document.location.href);
- var gpStatus = IriSP.mkGplusUrl(document.location.href);
- var fbStatus = IriSP.mkFbUrl(document.location.href);
-
- this.selector.find(".Ldt-createAnnotation-endScreen-TweetLink").attr("href", twStatus);
- this.selector.find(".Ldt-createAnnotation-endScreen-FbLink").attr("href", fbStatus);
- this.selector.find(".Ldt-createAnnotation-endScreen-GplusLink").attr("href", gpStatus);
-
- this.selector.find(".Ldt-createAnnotation-endScreen").show();
-
+ this.showEndScreen();
if (typeof(this._currentAnnotation) === "undefined") {
console.log("this._currentAnnotation undefined");
return;
}
- var apiJson = {annotations : [{}], meta: {}};
- var annotation = apiJson["annotations"][0];
- //annotation["type_title"] = "Contributions";
- annotation["type_title"] = "";
- annotation["media"] = this._serializer.currentMedia()["id"];
- annotation["begin"] = this._currentAnnotation.begin;
- annotation["end"] = this._currentAnnotation.end;
- annotation["type"] = this._serializer.getContributions();
- annotation.content = {};
- annotation.content["data"] = contents;
-
- var meta = apiJson["meta"];
- meta.creator = "An User";
- meta.created = Date().toString();
-
- annotation["tags"] = [];
-
- for (var i = 0; i < this.keywords.length; i++) {
- var keyword = this.keywords[i];
- if (contents.indexOf(keyword) != -1)
- annotation["tags"].push(keyword);
- }
-
- var jsonString = JSON.stringify(apiJson);
- var project_id = this._serializer._data.meta.id;
-
- var url = Mustache.to_html("{{platf_url}}/ldtplatform/api/ldt/projects/{{id}}.json",
- {platf_url: IriSP.platform_url, id: project_id});
- console.log(url);
- IriSP.jQuery.ajax({
- url: url,
- type: 'PUT',
- contentType: 'application/json',
- data: jsonString,
- // bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType
- dataType: 'json',
- success: function(json, textStatus, XMLHttpRequest) {
+ this.sendLdtData(contents, function() {
+ if (_this.cinecast_version) {
+ if (_this._Popcorn.media.paused)
+ _this._Popcorn.play();
+
+ window.setTimeout(IriSP.wrap(_this, function() { this.showStartScreen(); }), 5000);
+ }
+ });
+ }
+};
+
+IriSP.createAnnotationWidget.prototype.sendLdtData = function(contents, callback) {
+ var _this = this;
+ var apiJson = {annotations : [{}], meta: {}};
+ var annotation = apiJson["annotations"][0];
+
+ annotation["media"] = this._serializer.currentMedia()["id"];
+ annotation["begin"] = this._currentAnnotation.begin;
+ annotation["end"] = this._currentAnnotation.end;
+ annotation["type"] = this._serializer.getContributions();
+ if (typeof(annotation["type"]) === "undefined")
+ annotation["type"] = "";
+
+ annotation["type_title"] = "Contributions";
+ annotation.content = {};
+ annotation.content["data"] = contents;
+
+ var meta = apiJson["meta"];
+ meta.creator = "An User";
+ meta.created = Date().toString();
+
+ annotation["tags"] = [];
+
+ for (var i = 0; i < this.keywords.length; i++) {
+ var keyword = this.keywords[i];
+ if (contents.indexOf(keyword) != -1)
+ annotation["tags"].push(keyword);
+ }
+
+ var jsonString = JSON.stringify(apiJson);
+ var project_id = this._serializer._data.meta.id;
+
+ var url = Mustache.to_html("{{platf_url}}/ldtplatform/api/ldt/projects/{{id}}.json",
+ {platf_url: IriSP.platform_url, id: project_id});
+
+ IriSP.jQuery.ajax({
+ url: url,
+ type: 'PUT',
+ contentType: 'application/json',
+ data: jsonString,
+ dataType: 'json',
+ success: function(json, textStatus, XMLHttpRequest) {
/* add the annotation to the annotations and tell the world */
delete annotation.tags;
annotation.content.description = annotation.content.data;
@@ -2702,12 +2767,12 @@
// everything is shared so there's no need to propagate the change
_this._serializer._data.annotations.push(annotation);
_this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation");
- },
- error: function(jqXHR, textStatus, errorThrown) {
- alert("ERROR = " + jqXHR.responseText + ", " + errorThrown);
- }
- });
- }
+ callback();
+ },
+ error:
+ function() {
+ console.log("an error occured while contacting "
+ + url + " and sending " + jsonString); } });
};IriSP.PlayerWidget = function(Popcorn, config, Serializer) {
IriSP.Widget.call(this, Popcorn, config, Serializer);
@@ -3599,9 +3664,16 @@
this._Popcorn.listen("IriSP.SliceWidget.position",
IriSP.wrap(this, this.positionSliceHandler));
- this._Popcorn.trigger("IriSP.SliceWidget.position", [57, 24]);
+
+ this._Popcorn.listen("IriSP.SliceWidget.show", IriSP.wrap(this, this.show));
+ this._Popcorn.listen("IriSP.SliceWidget.hide", IriSP.wrap(this, this.hide));
+ this.selector.hide();
};
+/** responds to an "IriSP.SliceWidget.position" message
+ @param params an array with the first element being the left distance in
+ percents and the second element the width of the slice in pixels
+*/
IriSP.SliceWidget.prototype.positionSliceHandler = function(params) {
left = params[0];
width = params[1];
@@ -3670,6 +3742,14 @@
var zonePercent = (this.zoneWidth / this.selector.width()) * 100;
this._Popcorn.trigger("IriSP.SliceWidget.zoneChange", [leftPercent, zonePercent]);
+};
+
+IriSP.SliceWidget.prototype.show = function() {
+ this.selector.show();
+};
+
+IriSP.SliceWidget.prototype.hide = function() {
+ this.selector.hide();
};IriSP.SliderWidget = function(Popcorn, config, Serializer) {
IriSP.Widget.call(this, Popcorn, config, Serializer);
};
@@ -4374,6 +4454,12 @@
return ret_array;
};
+/** return the current chapitre
+ @param currentTime the current time, in seconds.
+*/
+IriSP.JSONSerializer.prototype.currentChapitre = function(currentTime) {
+ return this.currentAnnotations(currentTime, this.getChapitrage())[0];
+};
/** returns a list of ids of tweet lines (aka: groups in cinelab) */
IriSP.JSONSerializer.prototype.getTweetIds = function() {