# HG changeset patch # User hamidouk # Date 1328006512 -3600 # Node ID 71835c06c30270144e52639fc6c9c5af3315972f # Parent 9ee8cc15e2442333cd1156966f43023b68810129 new version of the annotationListWidget which gets its data from a different url. diff -r 9ee8cc15e244 -r 71835c06c302 src/ldt/ldt/static/ldt/js/LdtPlayer-release.js --- a/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js Mon Jan 30 17:21:13 2012 +0100 +++ b/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js Tue Jan 31 11:41:52 2012 +0100 @@ -1705,11 +1705,13 @@ ajax_mode: true, /* use ajax to get information about the annotations. if set to false, only search in the annotations for the current project. */ - ajax_url: platform_url + "/ldtplatform/api/ldt/segments/", /* partial - url of - where to - get the - ajax */ + + /* the platform generates some funky urls. We replace them afterwards to point to the + correct place - this setting will probably be overwritten by the platform + implementers. + Note that the player has to replace the variables between {{ and }} by its own values. + */ + ajax_url: platform_url + "/ldtplatform/api/ldt/segments/{media}/{begin}/{end}", ajax_granularity: 10000, /* how much ms should we look before and after the current timecode */ @@ -2268,8 +2270,7 @@ var widgets = IriSP.configureWidgets(pop, layoutManager, config.gui); var modules = IriSP.configureModules(pop, config.modules); }); -}; -/* To wrap a player the develop should create a new class derived from +};/* To wrap a player the develop should create a new class derived from the IriSP.PopcornReplacement.player and defining the correct functions */ /** jwplayer player wrapper */ @@ -2365,6 +2366,7 @@ splitArr = window.location.href.split( "#" ) history.replaceState( {}, "", splitArr[0] + "#id=" + annotationId); + // reset the mutex afterwards to prevent the module from reacting to his own changes. window.setTimeout(function() { _this.mutex = false }, 50); }; @@ -2484,7 +2486,14 @@ }; IriSP.AnnotationsListWidget.prototype.ajaxRedraw = function(timecode) { - var pre_url = IriSP.widgetsDefaults["AnnotationsListWidget"].ajax_url; + + /* the platform gives us a special url - of the type : http://path/{media}/{begin}/{end} + we double the braces using regexps and we feed it to mustache to build the correct url + we have to do that because the platform only knows at run time what view it's displaying. + */ + + var platf_url = IriSP.widgetsDefaults["AnnotationsListWidget"].ajax_url + .replace(/\{/g, '{{').replace(/\}/g, '}}'); var media_id = this._serializer.currentMedia()["id"]; var duration = +this._serializer.currentMedia().meta["dc:duration"]; @@ -2496,10 +2505,9 @@ if (end_timecode > duration) end_timecode = duration; - var templ = Mustache.to_html("{{pre_url}}/{{media_id}}/{{begin_timecode}}/{{end_timecode}}", - {pre_url: pre_url, media_id: media_id, begin_timecode: begin_timecode, - end_timecode: end_timecode}); - + var templ = Mustache.to_html(platf_url, {media: media_id, begin: begin_timecode, + end: end_timecode}); + /* we create on the fly a serializer to get the ajax */ var serializer = new IriSP.JSONSerializer(IriSP.__dataloader, templ); serializer.sync(IriSP.wrap(this, function(json) { this.processJson(json, serializer) })); @@ -2543,7 +2551,7 @@ // so we append the cutting id to the url. obj["url"] = this.project_url + "/" + media + "/" + annotation.meta["project"] + "/" + - annotation.meta["id-ref"] + "/"; + annotation.meta["id-ref"]; // obj["url"] = document.location.href.split("#")[0] + "/" + annotation.meta["project"]; }