test/integration/allocine_dossier_independant/js/LdtPlayer-release.js
branchpopcorn-port
changeset 842 4ae2247a59f4
parent 841 8da49ff273e0
child 852 eefb64f74a3f
equal deleted inserted replaced
841:8da49ff273e0 842:4ae2247a59f4
   994 "[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.noConflict=function(){s._=F;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.mixin=function(a){j(b.functions(a),function(c){J(c,
   994 "[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.noConflict=function(){s._=F;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.mixin=function(a){j(b.functions(a),function(c){J(c,
   995 b[c]=a[c])})};var K=0;b.uniqueId=function(a){var b=K++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape,function(a,b){return"',_.escape("+b.replace(/\\'/g,"'")+"),'"}).replace(d.interpolate,function(a,b){return"',"+b.replace(/\\'/g,
   995 b[c]=a[c])})};var K=0;b.uniqueId=function(a){var b=K++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape,function(a,b){return"',_.escape("+b.replace(/\\'/g,"'")+"),'"}).replace(d.interpolate,function(a,b){return"',"+b.replace(/\\'/g,
   996 "'")+",'"}).replace(d.evaluate||null,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};var n=function(a){this._wrapped=a};b.prototype=n.prototype;var u=function(a,c){return c?b(a).chain():a},J=function(a,c){n.prototype[a]=function(){var a=i.call(arguments);H.call(a,this._wrapped);return u(c.apply(b,
   996 "'")+",'"}).replace(d.evaluate||null,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};var n=function(a){this._wrapped=a};b.prototype=n.prototype;var u=function(a,c){return c?b(a).chain():a},J=function(a,c){n.prototype[a]=function(){var a=i.call(arguments);H.call(a,this._wrapped);return u(c.apply(b,
   997 a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];n.prototype[a]=function(){b.apply(this._wrapped,arguments);return u(this._wrapped,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];n.prototype[a]=function(){return u(b.apply(this._wrapped,arguments),this._chain)}});n.prototype.chain=function(){this._chain=true;return this};n.prototype.value=function(){return this._wrapped}}).call(this);
   997 a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];n.prototype[a]=function(){b.apply(this._wrapped,arguments);return u(this._wrapped,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];n.prototype[a]=function(){return u(b.apply(this._wrapped,arguments),this._chain)}});n.prototype.chain=function(){this._chain=true;return this};n.prototype.value=function(){return this._wrapped}}).call(this);
   998 /* main file */
   998 /* main file */
   999 
   999 // Why is it called main ? It only loads the libs !
  1000 
  1000 
  1001 if ( window.IriSP === undefined && window.__IriSP === undefined ) { 
  1001 if ( window.IriSP === undefined && window.__IriSP === undefined ) { 
  1002   /**
  1002   /**
  1003     @class
  1003     @class
  1004     the object under which everything goes.        
  1004     the object under which everything goes.        
  1014 */
  1014 */
  1015 
  1015 
  1016 IriSP._ = window._.noConflict();
  1016 IriSP._ = window._.noConflict();
  1017 IriSP.underscore = IriSP._;
  1017 IriSP.underscore = IriSP._;
  1018 
  1018 
  1019 IriSP.loadLibs = function( libs, config, metadata_url, callback ) {
  1019 IriSP.getLib = function(lib) {
       
  1020     return (
       
  1021         IriSP.libFiles.useCdn && typeof IriSP.libFiles.cdn[lib] == "string"
       
  1022         ? IriSP.libFiles.cdn[lib]
       
  1023         : (
       
  1024             typeof IriSP.libFiles.locations[lib] == "string"
       
  1025             ? IriSP.libFiles.locations[lib]
       
  1026             : (
       
  1027                 typeof IriSP.libFiles.inDefaultDir[lib] == "string"
       
  1028                 ? IriSP.libFiles.defaultDir + IriSP.libFiles.inDefaultDir[lib]
       
  1029                 : null
       
  1030             )
       
  1031         )
       
  1032     )
       
  1033 }
       
  1034 
       
  1035 IriSP.loadLibs = function( config, metadata_url, callback ) {
  1020     // Localize jQuery variable
  1036     // Localize jQuery variable
  1021 		IriSP.jQuery = null;
  1037 		IriSP.jQuery = null;
  1022     var $L = $LAB.script(libs.jQuery).script(libs.swfObject).wait()
  1038     var $L = $LAB.script(IriSP.getLib("jQuery")).script(IriSP.getLib("swfObject")).wait()
  1023                 .script(libs.jQueryUI);
  1039                 .script(IriSP.getLib("jQueryUI"));
  1024                                    
  1040                                    
  1025     if (config.player.type === "jwplayer" || config.player.type === "allocine") {
  1041     if (config.player.type === "jwplayer" || config.player.type === "allocine") {
  1026       // load our popcorn.js lookalike
  1042       // load our popcorn.js lookalike
  1027       $L.script(libs.jwplayer);
  1043       $L.script(IriSP.getLib("jwplayer"));
  1028     } else {
  1044     } else {
  1029       // load the real popcorn
  1045       // load the real popcorn
  1030       $L.script(libs.popcorn).script(libs["popcorn.code"]);
  1046       $L.script(IriSP.getLib("popcorn")).script(IriSP.getLib("popcorn.code"));
  1031       if (config.player.type === "youtube") {
  1047       if (config.player.type === "youtube") {
  1032         $L.script(libs["popcorn.youtube"]);
  1048         $L.script(IriSP.getLib("popcorn.youtube"));
  1033       } 
  1049       } 
  1034       if (config.player.type === "vimeo")
  1050       if (config.player.type === "vimeo")
  1035         $L.script(libs["popcorn.vimeo"]);
  1051         $L.script(IriSP.getLib("popcorn.vimeo"));
  1036       
  1052       
  1037       /* do nothing for html5 */
  1053       /* do nothing for html5 */
  1038     }       
  1054     }       
  1039     
  1055     
  1040     /* widget specific requirements */
  1056     /* widget specific requirements */
  1041     for (var idx in config.gui.widgets) {
  1057     for (var idx in config.gui.widgets) {
  1042       if (config.gui.widgets[idx].type === "PolemicWidget" ||
  1058       if (config.gui.widgets[idx].type === "PolemicWidget" ||
  1043           config.gui.widgets[idx].type === "StackGraphWidget" ||
  1059           config.gui.widgets[idx].type === "StackGraphWidget" ||
  1044           config.gui.widgets[idx].type === "SparklineWidget") {        
  1060           config.gui.widgets[idx].type === "SparklineWidget") {        
  1045         $L.script(libs.raphael);
  1061         $L.script(IriSP.getLib("raphael"));
  1046       }
  1062       }
  1047       if (config.gui.widgets[idx].type === "TraceWidget") {
  1063       if (config.gui.widgets[idx].type === "TraceWidget") {
  1048           $L.script(libs.tracemanager)
  1064           $L.script(IriSP.getLib("tracemanager"))
  1049       }
  1065       }
  1050     }
  1066     }
  1051     
  1067     
  1052     // same for modules
  1068     // same for modules
  1053     /*
  1069     /*
  1054     for (var idx in config.modules) {
  1070     for (var idx in config.modules) {
  1055       if (config.modules[idx].type === "PolemicWidget")
  1071       if (config.modules[idx].type === "PolemicWidget")
  1056         $L.script(libs.raphaelJs);
  1072         $L.script(IriSP.getLib("raphaelJs"));
  1057     }
  1073     }
  1058     */
  1074     */
  1059 
  1075 
  1060     $L.wait(function() {
  1076     $L.wait(function() {
  1061       IriSP.jQuery = window.jQuery.noConflict( true );
  1077       IriSP.jQuery = window.jQuery.noConflict( true );
  1062       
  1078       
  1063       var css_link_jquery = IriSP.jQuery( "<link>", { 
  1079       var css_link_jquery = IriSP.jQuery( "<link>", { 
  1064         rel: "stylesheet", 
  1080         rel: "stylesheet", 
  1065         type: "text/css", 
  1081         type: "text/css", 
  1066         href: libs.cssjQueryUI,
  1082         href: IriSP.getLib("cssjQueryUI"),
  1067         'class': "dynamic_css"
  1083         'class': "dynamic_css"
  1068       } );
  1084       } );
  1069       var css_link_custom = IriSP.jQuery( "<link>", { 
  1085       var css_link_custom = IriSP.jQuery( "<link>", { 
  1070         rel: "stylesheet", 
  1086         rel: "stylesheet", 
  1071         type: "text/css", 
  1087         type: "text/css", 
  1087     });
  1103     });
  1088 };
  1104 };
  1089 IriSP.annotation_template = "{{! template for an annotation displayed in a segmentWidget }}<div title='{{divTitle}}' id='{{id}}'	class='Ldt-iri-chapter Ldt-TraceMe' 	style='left: {{startPixel}}px;          width: {{pxWidth}}px;          background-color:{{hexa_color}};'    data-seek='{{seekPlace}}'    thumbnail-url='{{thumbnailUrl}}'	></div>";
  1105 IriSP.annotation_template = "{{! template for an annotation displayed in a segmentWidget }}<div title='{{divTitle}}' id='{{id}}'	class='Ldt-iri-chapter Ldt-TraceMe' 	style='left: {{startPixel}}px;          width: {{pxWidth}}px;          background-color:{{hexa_color}};'    data-seek='{{seekPlace}}'    thumbnail-url='{{thumbnailUrl}}'	></div>";
  1090 IriSP.annotationWidget_template = "{{! template for the annotation widget }}<div class='Ldt-AnnotationsWidget'>  <!-- ugly div because we want to have a double border -->  <div class='Ldt-Annotation-DoubleBorder'>      <div class='Ldt-AnnotationContent'>          <div class='Ldt-AnnotationShareIcons'>         <a target='_blank' class='Ldt-fbShare Ldt-TraceMe' title='{{i10n.share_on}} Facebook'></a>         <a target='_blank' class='Ldt-TwShare Ldt-TraceMe' title='{{i10n.share_on}} Twitter'></a>         <a target='_blank'  class='Ldt-GplusShare Ldt-TraceMe' title='{{i10n.share_on}} Google+'></a>        </div>        <div class='Ldt-SaTitle'></div>        <div class='Ldt-SaDescription'></div>        <div class='Ldt-SaKeywords'></div>    </div>  </div></div>";
  1106 IriSP.annotationWidget_template = "{{! template for the annotation widget }}<div class='Ldt-AnnotationsWidget'>  <!-- ugly div because we want to have a double border -->  <div class='Ldt-Annotation-DoubleBorder'>      <div class='Ldt-AnnotationContent'>          <div class='Ldt-AnnotationShareIcons'>         <a target='_blank' class='Ldt-fbShare Ldt-TraceMe' title='{{i10n.share_on}} Facebook'></a>         <a target='_blank' class='Ldt-TwShare Ldt-TraceMe' title='{{i10n.share_on}} Twitter'></a>         <a target='_blank'  class='Ldt-GplusShare Ldt-TraceMe' title='{{i10n.share_on}} Google+'></a>        </div>        <div class='Ldt-SaTitle'></div>        <div class='Ldt-SaDescription'></div>        <div class='Ldt-SaKeywords'></div>    </div>  </div></div>";
  1091 IriSP.annotation_loading_template = "{{! template shown while the annotation widget is loading }}<div id='Ldt-load-container'><div id='Ldt-loader'>&nbsp;</div> Chargement... </div>";
  1107 IriSP.annotation_loading_template = "{{! template shown while the annotation widget is loading }}<div id='Ldt-load-container'><div id='Ldt-loader'>&nbsp;</div> Chargement... </div>";
  1092 IriSP.annotationsListWidget_template = "{{! template for the annotation list widget }}<div class='Ldt-AnnotationsListWidget'>    <ul class='Ldt-AnnotationsList-ul'>        {{#annotations}}        <li id='Ldt-Annotation-li-{{id}}' class='Ldt-AnnotationsList-li Ldt-TraceMe'>            <img class='Ldt-AnnotationsList-Thumbnail' src='{{thumbnail}}' />            <div class='Ldt-AnnotationsList-Duration'>                <span class='Ldt-AnnotationsList-Begin'>{{begin}}</span>                <span class='Ldt-AnnotationsList-TcSeparator'>-</span>                <span class='Ldt-AnnotationsList-End'>{{end}}</span>            </div>            <div class='Ldt-AnnotationsList-Title'>            {{! if the url is not present, it means that the annotation exists            in the current project }}            {{^url}} <a href='#id={{id}}'> {{/url}}            {{! otherwise link to url }}            {{#url}} <a href='{{url}}'> {{/url}}                {{title}}            </a>            </div>            <div class='Ldt-AnnotationsList-Description'>                {{desc}}            </div>            {{#tags.length}}            <ul class='Ldt-AnnotationsList-Tags'>                {{#tags}}                <li class='Ldt-AnnotationsList-Tag-Li'>                    <div class='Ldt-AnnotationsList-Tag-Div'>{{.}}</div>                </li>                {{/tags}}            </ul>            {{/tags.length}}        </li>        {{/annotations}}    </ul></div>";
  1108 IriSP.annotationsListWidget_template = "{{! template for the annotation list widget }}<div class='Ldt-AnnotationsListWidget'>    <ul class='Ldt-AnnotationsList-ul'>        {{#annotations}}        <li id='Ldt-Annotation-li-{{id}}' class='Ldt-AnnotationsList-li Ldt-TraceMe'>            {{^url}} <a href='#id={{id}}'> {{/url}}            {{! otherwise link to url }}            {{#url}} <a href='{{url}}'> {{/url}}                <img class='Ldt-AnnotationsList-Thumbnail' src='{{thumbnail}}' />            </a>            <div class='Ldt-AnnotationsList-Duration'>                <span class='Ldt-AnnotationsList-Begin'>{{begin}}</span>                <span class='Ldt-AnnotationsList-TcSeparator'>-</span>                <span class='Ldt-AnnotationsList-End'>{{end}}</span>            </div>            <div class='Ldt-AnnotationsList-Title'>            {{! if the url is not present, it means that the annotation exists            in the current project }}                {{title}}            </div>            <div class='Ldt-AnnotationsList-Description'>            {{^url}} <a href='#id={{id}}'> {{/url}}            {{! otherwise link to url }}            {{#url}} <a href='{{url}}'> {{/url}}                {{desc}}                </a>            </div>            {{#tags.length}}            <ul class='Ldt-AnnotationsList-Tags'>                {{#tags}}                <li class='Ldt-AnnotationsList-Tag-Li'>                    <div class='Ldt-AnnotationsList-Tag-Div'>{{.}}</div>                </li>                {{/tags}}            </ul>            {{/tags.length}}        </li>        {{/annotations}}    </ul></div>";
  1093 IriSP.arrowWidget_template = "<div class='Ldt-arrowWidget Ldt-arrowLeftEdge'></div>";
  1109 IriSP.arrowWidget_template = "<div class='Ldt-arrowWidget Ldt-arrowLeftEdge'></div>";
  1094 IriSP.createAnnotationWidget_template = "{{! template for the annotation creation widget }}<div class='Ldt-createAnnotationWidget'>    <!-- ugly div because we want to have a double border -->    <div class='Ldt-createAnnotation-DoubleBorder'>        <div class='Ldt-createAnnotation-screen Ldt-createAnnotation-startScreen'>            <div style='margin-bottom: 7px; overflow: auto;'>                <div class='Ldt-createAnnotation-Title'></div>                <div class='Ldt-createAnnotation-TimeFrame'></div>                {{^cinecast_version}} <div class='Ldt-createAnnotation-Minimize Ldt-TraceMe' title='Cancel'></div>                {{/cinecast_version}}            </div>            <div class='Ldt-createAnnotation-Container'>                {{#show_from_field}}                <label>{{l10n.your_name}}&nbsp;: </label><input class='Ldt-createAnnotation-userName Ldt-TraceMe' value='{{user_name}}' />                {{/show_from_field}}                <textarea class='Ldt-createAnnotation-Description Ldt-TraceMe'></textarea>                <div class='Ldt-createAnnotation-userAvatar Ldt-TraceMe'>                    {{^user_avatar}} <img src='https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png'></img>                    {{/user_avatar}}                    {{#user_avatar}} <img src='{{ user_avatar }}'></img>                    {{/user_avatar}}                </div>                <div class='Ldt-createAnnotation-profileArrow'></div>            </div>            <button class='Ldt-createAnnotation-submitButton Ldt-TraceMe'>{{l10n.submit}}</button>            {{#keywords.length}}            <div class='Ldt-createAnnotation-btnblock Ldt-createAnnotation-keywords'>                <label>{{l10n.add_keywords}} :</label>                <ul class='Ldt-floatList'>                {{#keywords}}                    <li><button class='Ldt-createAnnotation-keyword-button Ldt-TraceMe'>{{.}}</button></li>                {{/keywords}}                </ul>            </div>            {{#random_keywords}}                <button class='Ldt-createAnnotation-moar-keywordz'>{{l10n.moar_tagz}}</button>            {{/random_keywords}}            {{/keywords.length}}            {{#polemic_mode}}            {{#polemics.length}}            <div class='Ldt-createAnnotation-btnblock Ldt-createAnnotation-polemics'>                <label>{{l10n.add_polemic_keywords}} :</label>                <ul class='Ldt-floatList'>                {{#polemics}}                    <li><button class='Ldt-createAnnotation-polemic-{{className}} Ldt-createAnnotation-polemic-button Ldt-TraceMe'>{{keyword}}</button></li>                {{/polemics}}                </ul>            </div>            {{/polemics.length}}            {{/polemic_mode}}        </div>        <div class='Ldt-createAnnotation-screen Ldt-createAnnotation-waitScreen' style='display: none; text-align: center'>            <div class='Ldt-createAnnotation-spinner'></div>            {{l10n.wait_while_processed}}        </div>        <div class='Ldt-createAnnotation-screen Ldt-createAnnotation-errorScreen' style='display: none; text-align: center'>            <div class='Ldt-createAnnotation-Minimize' title='Hide'></div>            {{l10n.error_while_contacting}}        </div>        <div class='Ldt-createAnnotation-screen Ldt-createAnnotation-endScreen' style='display: none'>            <div class='Ldt-createAnnotation-Minimize' title='Hide'></div>            {{l10n.annotation_saved}}            <br>            {{^disable_share}}            {{l10n.share_annotation}}            <div style='margin-top: 12px; text-align: center;'>                <a target='_blank' class='Ldt-createAnnotation-endScreen-TweetLink Ldt-TraceMe'></a>                <a target='_blank' class='Ldt-createAnnotation-endScreen-FbLink Ldt-TraceMe'></a>                <a target='_blank' class='Ldt-createAnnotation-endScreen-GplusLink Ldt-TraceMe'></a>            </div>            {{/disable_share}}        </div>        <div class='Ldt-floatClear'></div>    </div></div>";
  1110 IriSP.createAnnotationWidget_template = "{{! template for the annotation creation widget }}<div class='Ldt-createAnnotationWidget'>    <!-- ugly div because we want to have a double border -->    <div class='Ldt-createAnnotation-DoubleBorder'>        <div class='Ldt-createAnnotation-screen Ldt-createAnnotation-startScreen'>            <div style='margin-bottom: 7px; overflow: auto;'>                <div class='Ldt-createAnnotation-Title'></div>                <div class='Ldt-createAnnotation-TimeFrame'></div>                {{^cinecast_version}} <div class='Ldt-createAnnotation-Minimize Ldt-TraceMe' title='Cancel'></div>                {{/cinecast_version}}            </div>            <div class='Ldt-createAnnotation-Container'>                {{#show_from_field}}                <label>{{l10n.your_name}}&nbsp;: </label><input class='Ldt-createAnnotation-userName Ldt-TraceMe' value='{{user_name}}' />                {{/show_from_field}}                <textarea class='Ldt-createAnnotation-Description Ldt-TraceMe'></textarea>                <div class='Ldt-createAnnotation-userAvatar Ldt-TraceMe'>                    {{^user_avatar}} <img src='https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png'></img>                    {{/user_avatar}}                    {{#user_avatar}} <img src='{{ user_avatar }}'></img>                    {{/user_avatar}}                </div>                <div class='Ldt-createAnnotation-profileArrow'></div>            </div>            <button class='Ldt-createAnnotation-submitButton Ldt-TraceMe'>{{l10n.submit}}</button>            {{#tags.length}}            <div class='Ldt-createAnnotation-btnblock Ldt-createAnnotation-keywords'>                <label>{{l10n.add_keywords}} :</label>                <ul class='Ldt-floatList'>                {{#tags}}                    <li><button class='Ldt-createAnnotation-keyword-button Ldt-TraceMe' tag-id='{{id}}'>{{meta.description}}</button></li>                {{/tags}}                </ul>            </div>            {{#random_tags}}                <button class='Ldt-createAnnotation-moar-keywordz'>{{l10n.more_tags}}</button>            {{/random_tags}}            {{/tags.length}}            {{#polemic_mode}}            {{#polemics.length}}            <div class='Ldt-createAnnotation-btnblock Ldt-createAnnotation-polemics'>                <label>{{l10n.add_polemic_keywords}} :</label>                <ul class='Ldt-floatList'>                {{#polemics}}                    <li><button class='Ldt-createAnnotation-polemic-{{className}} Ldt-createAnnotation-polemic-button Ldt-TraceMe'>{{keyword}}</button></li>                {{/polemics}}                </ul>            </div>            {{/polemics.length}}            {{/polemic_mode}}        </div>        <div class='Ldt-createAnnotation-screen Ldt-createAnnotation-waitScreen' style='display: none; text-align: center'>            <div class='Ldt-createAnnotation-spinner'></div>            {{l10n.wait_while_processed}}        </div>        <div class='Ldt-createAnnotation-screen Ldt-createAnnotation-errorScreen' style='display: none; text-align: center'>            <div class='Ldt-createAnnotation-Minimize' title='Hide'></div>            {{l10n.error_while_contacting}}        </div>        <div class='Ldt-createAnnotation-screen Ldt-createAnnotation-endScreen' style='display: none'>            <div class='Ldt-createAnnotation-Minimize' title='Hide'></div>            {{l10n.annotation_saved}}            <br>            {{^disable_share}}            {{l10n.share_annotation}}            <div style='margin-top: 12px; text-align: center;'>                <a target='_blank' class='Ldt-createAnnotation-endScreen-TweetLink Ldt-TraceMe'></a>                <a target='_blank' class='Ldt-createAnnotation-endScreen-FbLink Ldt-TraceMe'></a>                <a target='_blank' class='Ldt-createAnnotation-endScreen-GplusLink Ldt-TraceMe'></a>            </div>            {{/disable_share}}        </div>        <div class='Ldt-floatClear'></div>    </div></div>";
  1095 IriSP.createAnnotation_errorMessage_template = "<p class='Ldt-createAnnotation-errorMessage'>  {{l10n.empty_annotation}}</p>";
  1111 IriSP.createAnnotation_errorMessage_template = "<p class='Ldt-createAnnotation-errorMessage'>  {{l10n.empty_annotation}}</p>";
  1096 IriSP.loading_template = "<div id='Ldt-loader' style='width: {{width}}px; height: {{height}}px;'>{{l10n.loading_wait}}</div>";
  1112 IriSP.loading_template = "<div id='Ldt-loader' style='width: {{width}}px; height: {{height}}px;'>{{l10n.loading_wait}}</div>";
  1097 IriSP.overlay_marker_template = "{{! the template for the small bars which is z-indexed over our segment widget }}<div class='Ldt-SegmentPositionMarker' style='background-color: #F7268E;'></div>";
  1113 IriSP.overlay_marker_template = "{{! the template for the small bars which is z-indexed over our segment widget }}<div class='Ldt-SegmentPositionMarker' style='background-color: #F7268E;'></div>";
  1098 IriSP.player_template = "{{! template for the radio player }}<div class='Ldt-controler'>	<div class='Ldt-LeftPlayerControls'>        <div class='Ldt-Ctrl-button Ldt-CtrlPlay Ldt-CtrlPlay-PlayState Ldt-TraceMe' title='{{l10n.play_pause}}'></div>        <div class='Ldt-Ctrl-spacer'></div>        {{^disable_annotate_btn}}    	<div class='Ldt-Ctrl-button Ldt-CtrlAnnotate Ldt-TraceMe' title='{{l10n.annotate}}'></div>        <div class='Ldt-Ctrl-spacer'></div>        {{/disable_annotate_btn}}        {{^disable_search_btn}}        <div class='Ldt-Ctrl-button Ldt-CtrlSearch Ldt-TraceMe' title='{{l10n.search}}'></div>        <div class='Ldt-Ctrl-spacer'></div>        {{/disable_search_btn}}        <div class='LdtSearch'>          <input class='LdtSearchInput Ldt-TraceMe'></input>        </div>	</div>	<div class='Ldt-RightPlayerControls'>        <div class='Ldt-Ctrl-spacer'></div>        <div class='Ldt-Time'>          <div class='Ldt-ElapsedTime' title='{{l10n.elapsed_time}}'>00:00</div>          <div class='Ldt-TimeSeparator'>/</div>          <div class='Ldt-TotalTime' title='{{l10n.total_time}}'>00:00</div>        </div>        <div class='Ldt-Ctrl-spacer'></div>		<div class='Ldt-Ctrl-button Ldt-CtrlSound Ldt-CtrlSound-Full Ldt-TraceMe' title='{{l10n.mute_unmute}}'></div>	</div>	<div class='Ldt-Ctrl-Volume-Control' title='{{l10n.volume_control}}'>	    <div class='Ldt-Ctrl-Volume-Bar'></div>	    <div class='Ldt-Ctrl-Volume-Cursor'></div>	</div></div>";
  1114 IriSP.player_template = "{{! template for the radio player }}<div class='Ldt-controler'>	<div class='Ldt-LeftPlayerControls'>        <div class='Ldt-Ctrl-button Ldt-CtrlPlay Ldt-CtrlPlay-PlayState Ldt-TraceMe' title='{{l10n.play_pause}}'></div>        <div class='Ldt-Ctrl-spacer'></div>        {{^disable_annotate_btn}}    	<div class='Ldt-Ctrl-button Ldt-CtrlAnnotate Ldt-TraceMe' title='{{l10n.annotate}}'></div>        <div class='Ldt-Ctrl-spacer'></div>        {{/disable_annotate_btn}}        {{^disable_search_btn}}        <div class='Ldt-Ctrl-button Ldt-CtrlSearch Ldt-TraceMe' title='{{l10n.search}}'></div>        <div class='Ldt-Ctrl-spacer'></div>        {{/disable_search_btn}}        <div class='LdtSearch'>          <input class='LdtSearchInput Ldt-TraceMe'></input>        </div>	</div>	<div class='Ldt-RightPlayerControls'>        <div class='Ldt-Ctrl-spacer'></div>        <div class='Ldt-Time'>          <div class='Ldt-ElapsedTime' title='{{l10n.elapsed_time}}'>00:00</div>          <div class='Ldt-TimeSeparator'>/</div>          <div class='Ldt-TotalTime' title='{{l10n.total_time}}'>00:00</div>        </div>        <div class='Ldt-Ctrl-spacer'></div>		<div class='Ldt-Ctrl-button Ldt-CtrlSound Ldt-CtrlSound-Full Ldt-TraceMe' title='{{l10n.mute_unmute}}'></div>	</div>	<div class='Ldt-Ctrl-Volume-Control' title='{{l10n.volume_control}}'>	    <div class='Ldt-Ctrl-Volume-Bar'></div>	    <div class='Ldt-Ctrl-Volume-Cursor'></div>	</div></div>";
  1099 IriSP.search_template = "{{! template for the search container }}<div class='LdtSearchContainer'	style='margin-left: {{margin_left}}; position: absolute; margin-top: -60px;'>	<div class='LdtSearch'		style='display: none; background-color: #EEE; width: 165px; border-color: #CFCFCF; position: absolute; text-align: center;'>		<input class='LdtSearchInput'			style='margin-top: 1px; margin-bottom: 2px;' />	</div></div><div class='cleaner'></div>";
  1115 IriSP.search_template = "{{! template for the search container }}<div class='LdtSearchContainer'	style='margin-left: {{margin_left}}; position: absolute; margin-top: -60px;'>	<div class='LdtSearch'		style='display: none; background-color: #EEE; width: 165px; border-color: #CFCFCF; position: absolute; text-align: center;'>		<input class='LdtSearchInput'			style='margin-top: 1px; margin-bottom: 2px;' />	</div></div><div class='cleaner'></div>";
  1554     received yet.
  1570     received yet.
  1555   */
  1571   */
  1556   this._callbacks = {};
  1572   this._callbacks = {};
  1557 };
  1573 };
  1558 
  1574 
  1559 IriSP.DataLoader.prototype.get = function(url, callback) {
  1575 IriSP.DataLoader.prototype.get = function(url, callback, force_reload) {
  1560 
  1576   var base_url = url.split("&")[0];
  1561   var base_url = url.split("&")[0]
  1577   if (typeof force_reload != "undefined" && force_reload && this._cache.hasOwnProperty(base_url)) {
       
  1578       delete this._cache[base_url]
       
  1579   }
  1562   if (this._cache.hasOwnProperty(base_url)) {
  1580   if (this._cache.hasOwnProperty(base_url)) {
  1563     callback(this._cache[base_url]);
  1581     callback(this._cache[base_url]);
  1564   } else {  
  1582   } else {  
  1565     if (!this._callbacks.hasOwnProperty(base_url)) {
  1583     if (!this._callbacks.hasOwnProperty(base_url)) {
  1566       this._callbacks[base_url] = [];
  1584       this._callbacks[base_url] = [callback];
  1567       this._callbacks[base_url].push(callback);   
       
  1568       /* we need a closure because this gets lost when it's called back */
  1585       /* we need a closure because this gets lost when it's called back */
  1569   
  1586   
  1570       // uncomment you don't want to use caching.
  1587       // uncomment you don't want to use caching.
  1571       // IriSP.jQuery.get(url, callback);
  1588       // IriSP.jQuery.get(url, callback);
  1572       
  1589       
  1575                   var i = 0;
  1592                   var i = 0;
  1576                   
  1593                   
  1577                   for (i = 0; i < this._callbacks[base_url].length; i++) {
  1594                   for (i = 0; i < this._callbacks[base_url].length; i++) {
  1578                     this._callbacks[base_url][i](this._cache[base_url]);                                  
  1595                     this._callbacks[base_url][i](this._cache[base_url]);                                  
  1579                   }
  1596                   }
       
  1597                   delete this._callbacks[base_url];
  1580       };
  1598       };
  1581       
  1599       
  1582       /* automagically choose between json and jsonp */
  1600       /* automagically choose between json and jsonp */
  1583       if (url.indexOf(document.location.hostname) === -1 &&
  1601       if (url.indexOf(document.location.hostname) === -1 &&
  1584           url.indexOf("http://") !== -1 /* not a relative url */ ) {
  1602           url.indexOf("http://") !== -1 /* not a relative url */ ) {
  1612 IriSP.Serializer.prototype.deserialize = function(data) {};
  1630 IriSP.Serializer.prototype.deserialize = function(data) {};
  1613 
  1631 
  1614 IriSP.Serializer.prototype.currentMedia = function() {  
  1632 IriSP.Serializer.prototype.currentMedia = function() {  
  1615 };
  1633 };
  1616 
  1634 
  1617 IriSP.Serializer.prototype.sync = function(callback) {  
  1635 IriSP.Serializer.prototype.getDuration = function() {  
  1618   callback.call(this, this._data);  
  1636 };
       
  1637 
       
  1638 IriSP.Serializer.prototype.sync = function(callback) {
       
  1639   this._DataLoader.get(this._url, callback, force_refresh);
  1619 };
  1640 };
  1620 
  1641 
  1621 IriSP.SerializerFactory = function(DataLoader) {
  1642 IriSP.SerializerFactory = function(DataLoader) {
  1622   this._dataloader = DataLoader;
  1643   this._dataloader = DataLoader;
  1623 };
  1644 };
  1646       
  1667       
  1647     default:      
  1668     default:      
  1648       return undefined;
  1669       return undefined;
  1649   }
  1670   }
  1650 };
  1671 };
  1651 /* site.js - all our site-dependent config : player chrome, cdn locations, etc...*/
  1672 IriSP.language = 'en';
  1652 
  1673 
  1653 IriSP.defaults = {};
  1674 IriSP.libFiles = {
  1654 
  1675     defaultDir : "js/libs/",
  1655 /* these objects are filled by configureDefaults. The function doesn't overwrite 
  1676     inDefaultDir : {
  1656    defaults that were originally defined by the user.
  1677         jQuery : "jquery.min.js",
  1657 */
  1678         jQueryUI : "jquery-ui.min.js",
  1658 IriSP.lib = {};
  1679         jQueryToolTip : "jquery.tools.min.js",
  1659 
  1680         swfObject : "swfobject.js",
  1660 /* We need to define those so that the individual settings can be overwritten */
  1681         cssjQueryUI : "jquery-ui.css",
  1661 IriSP.widgetsDefaults = {};
  1682         popcorn : "popcorn.js",
  1662 
  1683         jwplayer : "jwplayer.js",
  1663 IriSP.paths = {};
  1684         raphael : "raphael.js",
  1664 
  1685         "popcorn.mediafragment" : "popcorn.mediafragment.js",
  1665 IriSP.libdir = "/metadataplayer/src/js/libs/";
  1686         "popcorn.code" : "popcorn.code.js",
  1666 IriSP.jwplayer_swf_path = "../test/libs/player.swf";
  1687         "popcorn.jwplayer" : "popcorn.jwplayer.js",
  1667 IriSP.platform_url = "http://192.168.56.101/pf";
  1688         "popcorn.youtube" : "popcorn.youtube.js",
  1668 IriSP.default_templates_vars = { };
  1689         "tracemanager" : "tracemanager.js"
  1669 
  1690     },
  1670 IriSP.language = 'fr';
  1691     locations : {
  1671 
  1692         // use to define locations outside defautl_dir
  1672 /** ugly ugly ugly ugly - returns an object defining 
  1693     },
  1673     the paths to the libs
  1694     cdn : {
  1674     We need it that way cause it's called at runtime by
  1695         jQueryUI : "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.js",
  1675     IriSP.configureDefaults.
  1696         jQueryToolTip : "http://cdn.jquerytools.org/1.2.4/all/jquery.tools.min.js",
  1676 */   
  1697         swfObject : "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
  1677 IriSP.defaults.lib = function(libdir) {
  1698         cssjQueryUI : "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/base/jquery-ui.css"
  1678   if (IriSP.null_or_undefined(libdir))
  1699     },
  1679     libdir = IriSP.libdir;
  1700     useCdn : false
  1680   
  1701 }
  1681   return { 
  1702 
  1682 //      jQuery : "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js",
  1703 IriSP.widgetsDefaults = {
  1683     jQuery : libdir + "jquery.min.js",
  1704     "LayoutManager" : {
  1684 //      jQueryUI : "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.js",
  1705         spacer_div_height : 0
  1685     jQueryUI : libdir + "jquery-ui.min.js",
  1706     },
  1686 //      jQueryToolTip : "http://cdn.jquerytools.org/1.2.4/all/jquery.tools.min.js",
  1707     "PlayerWidget" : {
  1687     jQueryToolTip : libdir + "jquery.tools.min.js",
  1708         
  1688 //      swfObject : "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
  1709     },
  1689     swfObject : libdir + "swfobject.js",
  1710     "AnnotationsWidget" : {
  1690 //      cssjQueryUI : "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/base/jquery-ui.css",
  1711         "share_text" : "I'm watching "
  1691     cssjQueryUI : libdir + "jquery-ui.css",
  1712     },
  1692       popcorn : libdir + "popcorn.js",
       
  1693       jwplayer : libdir + "jwplayer.js",
       
  1694       popcornReplacement: libdir + "pop.js",
       
  1695       raphael: libdir + "raphael.js",
       
  1696       jquery_sparkline: libdir + "jquery.sparkline.js",
       
  1697       "popcorn.mediafragment" : libdir + "popcorn.mediafragment.js",
       
  1698       "popcorn.code" : libdir + "popcorn.code.js",
       
  1699       "popcorn.jwplayer": libdir + "popcorn.jwplayer.js",
       
  1700       "popcorn.youtube": libdir + "popcorn.youtube.js",
       
  1701       "tracemanager": libdir + "tracemanager.js"
       
  1702   };
       
  1703 };
       
  1704 
       
  1705 //Configuration for the player and utility functions.
       
  1706 // No need to have them configured at runtime
       
  1707 IriSP.config = {};
       
  1708 
       
  1709 IriSP.config.shortener = {
       
  1710   // function to call to shorten an url.
       
  1711   //shortening_function : IriSP.platform_shorten_url
       
  1712 };
       
  1713 
       
  1714 IriSP.defaults.widgetsDefaults = function(platform_url) { 
       
  1715   if (IriSP.null_or_undefined(platform_url))
       
  1716     platform_url = IriSP.platform_url;
       
  1717   
       
  1718   return {
       
  1719     "LayoutManager" : {spacer_div_height : "0px" },
       
  1720     "PlayerWidget" : {},
       
  1721     "AnnotationsWidget": {
       
  1722       "share_text" : "I'm watching ",     
       
  1723       "fb_link" : "http://www.facebook.com/share.php?u=",
       
  1724       "tw_link" : "http://twitter.com/home?status=",
       
  1725       "gplus_link" : ""
       
  1726       },
       
  1727     
       
  1728     "TweetsWidget" : {
  1713     "TweetsWidget" : {
  1729         default_profile_picture : "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png",
  1714         default_profile_picture : "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png",
  1730         tweet_display_period: 10000 // how long do we show a tweet ?
  1715         tweet_display_period : 10000 // how long do we show a tweet ?
  1731         
       
  1732     },
  1716     },
  1733     "SliderWidget" : {
  1717     "SliderWidget" : {
  1734         minimize_period: 850 // how long does the slider stays maximized after the user leaves the zone ?
  1718         minimize_period : 850 // how long does the slider stays maximized after the user leaves the zone ?
       
  1719     },
       
  1720     "SegmentsWidget" : {
       
  1721         cinecast_version : false
  1735     },
  1722     },
  1736     "createAnnotationWidget" : {
  1723     "createAnnotationWidget" : {
  1737         keywords: ["#amateur", "#digital-studies"],
  1724         tags : [
  1738         polemic_mode: true, /* enable polemics ? */
  1725             {
  1739         /* polemics - the corresponding class names defined in the css should be for instance :
  1726                 "id" : "digitalstudies",
  1740            Ldt-createAnnotation-polemic-positive for positive
  1727                 "meta" : {
  1741            Ldt-createAnnotation-polemic-equalequal for equalequal, etc.
  1728                     "description" : "#digital-studies"
  1742         */
  1729                 }
  1743         polemics: [ { "className" : "positive", "keyword" : "++" }, { "className" : "negative", "keyword" : "--" }, { "className" : "reference", "keyword" : "==" }, { "className" : "question", "keyword" : "??" } ], 
  1730             },
  1744         cinecast_version: false, /* put to false to enable the platform version, true for the festival cinecast one. */
  1731             {
  1745         
  1732                 "id" : "amateur",
       
  1733                 "meta" : {
       
  1734                     "description" : "#amateur"
       
  1735                 },
       
  1736             }
       
  1737         ],
       
  1738         remote_tags : false,
       
  1739         random_tags : false,
       
  1740         show_from_field : false,
       
  1741         polemic_mode : true, /* enable polemics ? */
       
  1742         polemics : [{
       
  1743             "className" : "positive",
       
  1744             "keyword" : "++"
       
  1745         }, {
       
  1746             "className" : "negative",
       
  1747             "keyword" : "--"
       
  1748         }, {
       
  1749             "className" : "reference",
       
  1750             "keyword" : "=="
       
  1751         }, {
       
  1752             "className" : "question",
       
  1753             "keyword" : "??"
       
  1754         }],
       
  1755         cinecast_version : false, /* put to false to enable the platform version, true for the festival cinecast one. */
       
  1756 
  1746         /* where does the widget PUT the annotations - this is a mustache template. id refers to the id of the media ans is filled
  1757         /* where does the widget PUT the annotations - this is a mustache template. id refers to the id of the media ans is filled
  1747            by the widget. 
  1758          by the widget.
  1748         */
  1759          */
  1749         api_endpoint_template: platform_url + "/ldtplatform/api/ldt/annotations/{{id}}.json",
  1760         api_endpoint_template : "", // platform_url + "/ldtplatform/api/ldt/annotations/{{id}}.json",
  1750         api_method: "PUT"
  1761         api_method : "PUT"
  1751     },
  1762     },
  1752     "SparklineWidget" : {
  1763     "SparklineWidget" : {
  1753         column_width: 10 // the width of a column in pixels.
  1764        lineColor : "#7492b4",
  1754     },
  1765        fillColor : "#aeaeb8",
  1755     "Main" : {
  1766        lineWidth : 2
  1756         autoplay: true
       
  1757     },
  1767     },
  1758     "AnnotationsListWidget" : {
  1768     "AnnotationsListWidget" : {
  1759         ajax_mode: true, /* use ajax to get information about the annotations.
  1769         ajax_mode : true, /* use ajax to get information about the annotations.
  1760                            if set to false, only search in the annotations for the
  1770          if set to false, only search in the annotations for the
  1761                            current project. */
  1771          current project. */
  1762         /* the platform generates some funky urls. We replace them afterwards to point to the
  1772         /* the platform generates some funky urls. We replace them afterwards to point to the
  1763            correct place - this setting will probably be overwritten by the platform 
  1773          correct place - this setting will probably be overwritten by the platform
  1764            implementers.
  1774          implementers.
  1765            Note that the player has to replace the variables between {{ and }} by its own values.
  1775          Note that the player has to replace the variables between {{ and }} by its own values.
  1766         */
  1776          */
  1767         ajax_url: platform_url + "/ldtplatform/api/ldt/segments/{media}/{begin}/{end}", 
  1777         ajax_url : "", //platform_url + "/ldtplatform/api/ldt/segments/{{media}}/{{begin}}/{{end}}",
  1768         
  1778         ajax_granularity : 10000, /* how much ms should we look before and after the current timecode */
  1769         ajax_granularity: 10000, /* how much ms should we look before and after the
  1779         default_thumbnail : "http://ldt.iri.centrepompidou.fr/static/site/ldt/css/imgs/video_sequence.png",
  1770                                    current timecode */
  1780         project_url : "", //platform_url + "/ldtplatform/ldt/front/player/"
  1771       
  1781         /* the beginning of a link to the new front */
  1772         default_thumbnail: "/metadataplayer/src/css/imgs/video_sequence.png",
  1782         cinecast_version : false,
  1773         
  1783         refresh_interval : 10000
  1774         project_url: platform_url + "/ldtplatform/ldt/front/player/" /* the beginning 
  1784     },
  1775                                                                         of a link to the
  1785     "StackGraphWidget" : {
  1776                                                                         new front */
  1786          defaultcolor : "#585858",
  1777     } 
  1787          tags : [
  1778   };
  1788             {
  1779 };
  1789                 "keywords" : [ "++" ],
  1780 
  1790                 "description" : "positif",
  1781 /*
  1791                 "color" : "#1D973D"
  1782 Override this if you want to change the info the player receives about the user.
  1792             },
  1783 It's typically overrided in server-side templates with user-specific data.
  1793             {
  1784 */
  1794                 "keywords" : [ "--" ],
  1785 IriSP.defaults.user = function() { return {
  1795                 "description" : "negatif",
  1786       "name" : "Anonymous user",
  1796                 "color" : "#CE0A15"
  1787       "avatar" : IriSP.paths.imgs + "/user_default_icon.png"
  1797             },
  1788     }
  1798             {
  1789 };
  1799                 "keywords" : [ "==" ],
  1790 
  1800                 "description" : "reference",
  1791 
  1801                 "color" : "#C5A62D"  
  1792 IriSP.defaults.paths = {
  1802             },
  1793 //  "imgs": "/tweetlive/res/metadataplayer/src/css/imgs"
  1803             {
  1794   "imgs": "/metadataplayer/src/css/imgs"
  1804                 "keywords" : [ "??" ],
  1795 };
  1805                 "description" : "question",
  1796 
  1806                 "color" : "#036AAE"
  1797 
  1807             }
  1798 IriSP.defaults.default_templates_vars = function() { 
  1808         ],
  1799   return {
  1809         streamgraph : false
  1800   "img_dir" : IriSP.paths.imgs 
  1810     }
  1801   };
       
  1802 }/* the widget classes and definitions */
  1811 }/* the widget classes and definitions */
  1803 
  1812 
  1804 /**
  1813 /**
  1805   * @class Widget is an "abstract" class. It's mostly used to define some properties common to every widget.
  1814   * @class Widget is an "abstract" class. It's mostly used to define some properties common to every widget.
  1806   *
  1815   *
  1856   if (typeof this.selector != "undefined") {
  1865   if (typeof this.selector != "undefined") {
  1857       this.selector.addClass("Ldt-TraceMe").addClass("Ldt-Widget");
  1866       this.selector.addClass("Ldt-TraceMe").addClass("Ldt-Widget");
  1858       this.selector.attr("widget-type", this._config.type);
  1867       this.selector.attr("widget-type", this._config.type);
  1859   }
  1868   }
  1860   
  1869   
  1861 };
  1870   // Parsing Widget Defaults
  1862 
  1871   var _this = this;
  1863 // This functions checks for configuration options
  1872   
  1864 
  1873   if (typeof config.type == "string" && typeof IriSP.widgetsDefaults[config.type] == "object") {
  1865 IriSP.Widget.prototype.checkOption = function(_name, _default) {
  1874       IriSP._(IriSP.widgetsDefaults[config.type]).each(function(_v, _k) {
  1866     this[_name] = (
  1875           if (typeof config[_k] != "undefined") {
  1867         typeof this._config[_name] != "undefined"
  1876               _this[_k] = config[_k];
  1868         ? this._config[_name]
  1877           } else {
  1869         : (
  1878               _this[_k] = _v;
  1870             (typeof IriSP.widgetsDefaults[this._config.type] != "undefined" && IriSP.widgetsDefaults[this._config.type][_name] != "undefined")
  1879           }
  1871             ? IriSP.widgetsDefaults[this._config.type][_name]
  1880       });
  1872             : (
  1881   }
  1873                 typeof _default != "undefined"
  1882   
  1874                 ? _default
  1883 };
  1875                 : null
  1884 
  1876             )
  1885 
  1877         )
  1886 IriSP.Widget.prototype.currentMedia = function() {
  1878     )
  1887     return this._serializer.currentMedia();
       
  1888 }
       
  1889 
       
  1890 IriSP.Widget.prototype.getDuration = function() {
       
  1891     return this._serializer.getDuration();
  1879 }
  1892 }
  1880 
  1893 
  1881 /**
  1894 /**
  1882   * This method responsible of drawing a widget on screen.
  1895   * This method responsible of drawing a widget on screen.
  1883   */
  1896   */
  1967     var newDiv = IriSP.guid(this._div + "_widget_" + widgetName + "_");
  1980     var newDiv = IriSP.guid(this._div + "_widget_" + widgetName + "_");
  1968     var spacerDiv = IriSP.guid("LdtPlayer_spacer_");
  1981     var spacerDiv = IriSP.guid("LdtPlayer_spacer_");
  1969     this._widgets.push([widgetName, newDiv]);    
  1982     this._widgets.push([widgetName, newDiv]);    
  1970 
  1983 
  1971     var divTempl = "<div id='{{id}}' style='width: {{width}}px; position: relative; clear: both;'></div";
  1984     var divTempl = "<div id='{{id}}' style='width: {{width}}px; position: relative; clear: both;'></div";
  1972     var spacerTempl = "<div id='{{spacer_id}}' style='width: {{width}}px; position: relative; height: {{spacer_div_height}};'></div";
  1985     var spacerTempl = "<div id='{{spacer_id}}' style='width: {{width}}px; position: relative; height: {{spacer_div_height}}px;'></div";
  1973     
  1986     
  1974     var divCode = Mustache.to_html(divTempl, {id: newDiv, width: this._width});
  1987     var divCode = Mustache.to_html(divTempl, {id: newDiv, width: this._width});
  1975     var spacerCode = Mustache.to_html(spacerTempl, {spacer_id: spacerDiv, width: this._width,
  1988     var spacerCode = Mustache.to_html(spacerTempl, {spacer_id: spacerDiv, width: this._width,
  1976                                                     spacer_div_height: IriSP.widgetsDefaults.LayoutManager.spacer_div_height });
  1989                                                     spacer_div_height: IriSP.widgetsDefaults.LayoutManager.spacer_div_height });
  1977 
  1990 
  2219      
  2232      
  2220     serializer.sync(IriSP.wrap(widget, function() { this.draw(); }));
  2233     serializer.sync(IriSP.wrap(widget, function() { this.draw(); }));
  2221     return widget;
  2234     return widget;
  2222 };
  2235 };
  2223 
  2236 
  2224 /** Go through the defaults to set a reasonable value */
       
  2225 IriSP.configureDefaults = function(libdir, platform_url) {
       
  2226   /* the defaults configuration is messy and complicated. There are two things to know :
       
  2227      - we want to allow overwriting of defaults - that's why we have IriSP.widgetDefaults
       
  2228        and IriSP.defaults.widgetDefaults. The first is filled by the embedder and then fleshed out
       
  2229        with the contents of the first. We use underscore.defaults for that, but there's one problem with
       
  2230        this function : it doesn't work recursively.
       
  2231      - we need to compute some values at runtime instead of at compile time
       
  2232   */
       
  2233     
       
  2234   IriSP.lib = IriSP.underscore.defaults(IriSP.lib, IriSP.defaults.lib(libdir));
       
  2235   
       
  2236   /* get the factory defaults for the widgets and merge them with the default the user
       
  2237      may have defined 
       
  2238   */
       
  2239   var factory_defaults = IriSP.defaults.widgetsDefaults(platform_url);
       
  2240   for(var widget in factory_defaults) {
       
  2241   
       
  2242       /* create the object if it doesn't exists */
       
  2243       if (IriSP.null_or_undefined(IriSP.widgetsDefaults[widget]))
       
  2244         IriSP.widgetsDefaults[widget] = {};
       
  2245         
       
  2246       IriSP.widgetsDefaults[widget] = IriSP.underscore.defaults(IriSP.widgetsDefaults[widget], factory_defaults[widget]);
       
  2247   }
       
  2248   
       
  2249   IriSP.paths = IriSP.underscore.defaults(IriSP.paths, IriSP.defaults.paths);
       
  2250   IriSP.default_templates_vars = IriSP.underscore.defaults(IriSP.default_templates_vars, 
       
  2251                                        IriSP.defaults.default_templates_vars());
       
  2252 
       
  2253   if (IriSP.null_or_undefined(IriSP.user))
       
  2254     IriSP.user = {};
       
  2255   
       
  2256   IriSP.user = IriSP.underscore.defaults(IriSP.user, IriSP.defaults.user());
       
  2257 };
       
  2258 
       
  2259 /** single point of entry for the metadataplayer */
  2237 /** single point of entry for the metadataplayer */
  2260 IriSP.initPlayer = function(config, metadata_url, libdir, platform_url) {
  2238 IriSP.initPlayer = function(config, metadata_url) {
  2261     document.getElementById(config.gui.container).innerHTML = IriSP.templToHTML(IriSP.loading_template, config.gui);
  2239     document.getElementById(config.gui.container).innerHTML = IriSP.templToHTML(IriSP.loading_template, config.gui);
  2262     IriSP.configureDefaults(libdir, platform_url);
  2240     IriSP.loadLibs(config, metadata_url,
  2263     IriSP.loadLibs(IriSP.lib, config, metadata_url,
       
  2264       function() {   
  2241       function() {   
  2265               
  2242               
  2266               var layoutManager = new IriSP.LayoutManager(config.gui);
  2243               var layoutManager = new IriSP.LayoutManager(config.gui);
  2267 
  2244 
  2268               var pop = IriSP.configurePopcorn(layoutManager, config.player);
  2245               var pop = IriSP.configurePopcorn(layoutManager, config.player);
  2382     var _videoUrl = (
  2359     var _videoUrl = (
  2383         typeof options.directVideoPath == "string"
  2360         typeof options.directVideoPath == "string"
  2384         ? options.directVideoPath
  2361         ? options.directVideoPath
  2385         : IriSP.get_aliased(IriSP.__jsonMetadata["medias"][0], ["href","url"])
  2362         : IriSP.get_aliased(IriSP.__jsonMetadata["medias"][0], ["href","url"])
  2386     );
  2363     );
  2387     
  2364     var _flashVars = {
  2388     var fv = "streamFMS=true&adVast=false&lg=fr_cinecast&autoPlay=" + options.autoPlay + "&directVideoTitle=&urlAcData=" + options.urlAcData + "&directVideoPath=" + _videoUrl + "&host=http://allocine.fr";
  2365         "streamFMS" : true,
  2389 //    console.log("fv = " + fv);
  2366         "adVast" : false,
  2390     
  2367         "lg" : "fr_cinecast",
       
  2368         "autoPlay" : options.autoPlay,
       
  2369         "directVideoTitle" : "",
       
  2370         "urlAcData" : options.urlAcData,
       
  2371         "directVideoPath" : _videoUrl,
       
  2372         "host" : "http://allocine.fr"
       
  2373     }
       
  2374     
       
  2375     if (typeof IriSP.__jsonMetadata["medias"][0].meta == "object" && typeof IriSP.__jsonMetadata["medias"][0].meta.subtitles == "string") {
       
  2376         _flashVars.subTitlePath = IriSP.__jsonMetadata["medias"][0].meta.subtitles;
       
  2377     }
       
  2378     
       
  2379 
  2391     var params = {
  2380     var params = {
  2392         "allowScriptAccess" : "always",
  2381         "allowScriptAccess" : "always",
  2393         "wmode": "opaque",
  2382         "wmode": "opaque",
  2394         "flashvars" : fv,
  2383         "flashvars" : IriSP.jQuery.param(_flashVars),
  2395         "allowfullscreen" : true
  2384         "allowfullscreen" : true
  2396     };
  2385     };
  2397     var atts = {
  2386     var atts = {
  2398         id : this.container
  2387         id : this.container
  2399     };
  2388     };
  2761 };
  2750 };
  2762 IriSP.AnnotationsListWidget = function(Popcorn, config, Serializer) {
  2751 IriSP.AnnotationsListWidget = function(Popcorn, config, Serializer) {
  2763   IriSP.Widget.call(this, Popcorn, config, Serializer);
  2752   IriSP.Widget.call(this, Popcorn, config, Serializer);
  2764   this.__counter = 0;
  2753   this.__counter = 0;
  2765   this.__oldList = [];
  2754   this.__oldList = [];
  2766  
       
  2767   this.checkOption('ajax_mode');
       
  2768   this.checkOption('project_url');
       
  2769   this.checkOption('default_thumbnail');
       
  2770   this.checkOption("cinecast_version", false);
       
  2771   this.searchRe = null;
  2755   this.searchRe = null;
  2772   this._ajax_cache = [];
  2756   this._ajax_cache = [];
  2773   var _this = this;
  2757   var _this = this;
  2774   
  2758   
  2775   this._Popcorn.listen("IriSP.search", function(searchString) {
  2759   this._Popcorn.listen("IriSP.search", function(searchString) {
  2792 IriSP.AnnotationsListWidget.prototype.clearWidget = function() {
  2776 IriSP.AnnotationsListWidget.prototype.clearWidget = function() {
  2793 };
  2777 };
  2794 
  2778 
  2795 IriSP.AnnotationsListWidget.prototype.searchHandler = function(searchString) {
  2779 IriSP.AnnotationsListWidget.prototype.searchHandler = function(searchString) {
  2796   this.searchRe = (searchString && searchString.length) ? IriSP.regexpFromText(searchString) : null;
  2780   this.searchRe = (searchString && searchString.length) ? IriSP.regexpFromText(searchString) : null;
  2797   if (this.ajax_mode) {
  2781   if (this.ajax_mode && !this.cinecast_version) {
  2798       var _this = this,
  2782       var _this = this,
  2799         _annotations = (
  2783         _annotations = (
  2800             this.searchRe === null
  2784             this.searchRe === null
  2801             ? this._ajax_cache
  2785             ? this._ajax_cache
  2802             : IriSP.underscore.filter(this._ajax_cache, function(_a) {
  2786             : IriSP.underscore.filter(this._ajax_cache, function(_a) {
  2822         }),
  2806         }),
  2823         _this = this;
  2807         _this = this;
  2824       
  2808       
  2825     this.selector.html(_html);
  2809     this.selector.html(_html);
  2826     
  2810     
       
  2811     this.selector.find('.Ldt-AnnotationsList-Tag-Li').click(function() {
       
  2812         _this._Popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().trim());
       
  2813     })
       
  2814     
  2827     if (this.searchRe !== null) {
  2815     if (this.searchRe !== null) {
  2828         this.selector.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description")
  2816         this.selector.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description")
  2829             .each(function()  {
  2817             .each(function()  {
  2830                 var _$ = IriSP.jQuery(this);
  2818                 var _$ = IriSP.jQuery(this);
  2831                 _$.html(_$.text().replace(_this.searchRe, '<span class="Ldt-AnnotationsList-highlight">$1</span>'))
  2819                 _$.html(_$.text().trim().replace(_this.searchRe, '<span class="Ldt-AnnotationsList-highlight">$1</span>'))
  2832             })
  2820             })
  2833     }
  2821     }
  2834 };
  2822 };
  2835 
  2823 
  2836 IriSP.AnnotationsListWidget.prototype.transformAnnotation = function(a) {
  2824 IriSP.AnnotationsListWidget.prototype.transformAnnotation = function(a) {
  2837     var _this = this
  2825     var _this = this;
  2838     return {
  2826     return {
  2839         "id" : a.id,
  2827         "id" : a.id,
  2840         "title": this.cinecast_version ? IriSP.get_aliased(a.meta, ['creator_name', 'creator']) : a.content.title,
  2828         "title": this.cinecast_version ? IriSP.get_aliased(a.meta, ['creator_name', 'creator']) : a.content.title,
  2841         "desc" : this.cinecast_version ? a.content.data : a.content.description,
  2829         "desc" : this.cinecast_version ? a.content.data : a.content.description,
  2842         "begin": IriSP.msToTime(a.begin),
  2830         "begin": IriSP.msToTime(a.begin),
  2843         "end" : IriSP.msToTime(a.end),
  2831         "end" : IriSP.msToTime(a.end),
  2844         "thumbnail" : (typeof a.meta == "object" && typeof a.meta.thumbnail == "string") ? a.meta.thumbnail : this.default_thumbnail,
  2832         "thumbnail" : (typeof a.meta == "object" && typeof a.meta.thumbnail == "string") ? a.meta.thumbnail : this.default_thumbnail,
  2845         "url" : (typeof a.meta == "object" && typeof a.meta.url == "string") ? a.meta.url : null,
  2833         "url" : (typeof a.meta == "object" && typeof a.meta.url == "string") ? a.meta.url : null,
       
  2834         "created_at" :(typeof a.meta == "object" && typeof a.meta.created == "string") ? Date.parse(a.meta.created.replace(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}\:\d{2}\:\d{2}).*$/,"$2/$3/$1 $4 UTC+0000")) : null,
  2846         "tags": typeof a.tags == "object"
  2835         "tags": typeof a.tags == "object"
  2847             ? IriSP.underscore(a.tags)
  2836             ? IriSP.underscore(a.tags)
  2848                 .chain()
  2837                 .chain()
  2849                 .map(function(_t) {
  2838                 .map(function(_t) {
  2850                     if (typeof _t == "string") {
  2839                     if (typeof _t == "string") {
  2899             this._Popcorn.trigger("IriSP.search.matchFound");
  2888             this._Popcorn.trigger("IriSP.search.matchFound");
  2900           } else {
  2889           } else {
  2901             this._Popcorn.trigger("IriSP.search.noMatchFound");
  2890             this._Popcorn.trigger("IriSP.search.noMatchFound");
  2902           }
  2891           }
  2903     }
  2892     }
  2904   
       
  2905   list = IriSP.underscore(list)
  2893   list = IriSP.underscore(list)
  2906     .chain()
  2894     .chain()
  2907     .sortBy(function(_o) {
  2895     .sortBy(function(_o) {
  2908         return _o.distance;
  2896         return _o.distance;
  2909     })
  2897     })
  2910     .first(10)
  2898     .first(10)
  2911     .sortBy(function(_o) {
  2899     .sortBy(function(_o) {
  2912         return (typeof _o.is_new != "undefined" && _o.is_new ? -1 : _o.iterator);
  2900         return (_this.cinecast_version ? - _o.created_at : _o.iterator);
  2913     })
  2901     })
  2914     .value();
  2902     .value();
  2915   
       
  2916   var idList = IriSP.underscore.pluck(list, "id").sort();
  2903   var idList = IriSP.underscore.pluck(list, "id").sort();
  2917 
  2904 
  2918   
  2905   
  2919   if (!IriSP.underscore.isEqual(this.__oldList, idList) || typeof(force_redraw) !== "undefined") {
  2906   if (!IriSP.underscore.isEqual(this.__oldList, idList) || this.lastSearch !== this.searchRe || typeof(force_redraw) !== "undefined") {
  2920     this.do_redraw(list);
  2907     this.do_redraw(list);
  2921     this.__oldList = idList;
  2908     this.__oldList = idList;
       
  2909     this.lastSearch = this.searchRe;
  2922   }
  2910   }
  2923    /* save for next call */
  2911    /* save for next call */
  2924   
  2912   
  2925   
  2913   
  2926 };
  2914 };
  2935    } else {
  2923    } else {
  2936      var tcode = timecode;     
  2924      var tcode = timecode;     
  2937   }
  2925   }
  2938    
  2926    
  2939   
  2927   
  2940   /* the platform gives us a special url - of the type : http://path/{media}/{begin}/{end}
  2928   /* the platform gives us a special url - of the type : http://path/{{media}}/{{begin}}/{{end}}
  2941      we double the braces using regexps and we feed it to mustache to build the correct url
  2929      we double the braces using regexps and we feed it to mustache to build the correct url
  2942      we have to do that because the platform only knows at run time what view it's displaying.
  2930      we have to do that because the platform only knows at run time what view it's displaying.
  2943   */
  2931   */
  2944      
  2932      
  2945   var platf_url = IriSP.widgetsDefaults.AnnotationsListWidget.ajax_url
  2933   var media_id = this.currentMedia()["id"];
  2946                                       .replace(/\{/g, '{{').replace(/\}/g, '}}');
  2934   var duration = this.getDuration();
  2947   var media_id = this._serializer.currentMedia()["id"];
       
  2948   var duration = this._serializer.getDuration();
       
  2949   
  2935   
  2950   var begin_timecode = (Math.floor(tcode) - 300) * 1000;
  2936   var begin_timecode = (Math.floor(tcode) - 300) * 1000;
  2951   if (begin_timecode < 0)
  2937   if (begin_timecode < 0)
  2952     begin_timecode = 0;
  2938     begin_timecode = 0;
  2953     
  2939     
  2954   var end_timecode = (Math.floor(tcode) + 300) * 1000;
  2940   var end_timecode = (Math.floor(tcode) + 300) * 1000;
  2955   if (end_timecode > duration)
  2941   if (end_timecode > duration)
  2956     end_timecode = duration;
  2942     end_timecode = duration;
  2957   
  2943   
  2958   var templ = Mustache.to_html(platf_url, {media: media_id, begin: begin_timecode,
  2944   var templ = Mustache.to_html(this.ajax_url, {media: media_id, begin: begin_timecode,
  2959                                  end: end_timecode});
  2945                                  end: end_timecode});
  2960 
  2946 
  2961   /* we create on the fly a serializer to get the ajax */
  2947   /* we create on the fly a serializer to get the ajax */
  2962   var serializer = new IriSP.JSONSerializer(IriSP.__dataloader, templ);
  2948   var serializer = new IriSP.JSONSerializer(IriSP.__dataloader, templ);
  2963   serializer.sync(IriSP.wrap(this, function(json) { this.processJson(json, serializer) }));
  2949   serializer.sync(IriSP.wrap(this, function(json) { this.processJson(json, serializer) }));
  2974   commented in case we wanted to discriminate against some annotation types.
  2960   commented in case we wanted to discriminate against some annotation types.
  2975   var view_types = serializer.getIds("Contributions");
  2961   var view_types = serializer.getIds("Contributions");
  2976   */
  2962   */
  2977   var l = [];
  2963   var l = [];
  2978   
  2964   
  2979   var media = this._serializer.currentMedia()["id"];
  2965   var media = this.currentMedia()["id"];
  2980   
  2966   
  2981   for (i = 0; i < annotations.length; i++) {
  2967   for (i = 0; i < annotations.length; i++) {
  2982     var obj = this.transformAnnotation(annotations[i])
  2968     var obj = this.transformAnnotation(annotations[i])
  2983       if (typeof obj.url == "undefined" || !obj.url) {
  2969       if (typeof obj.url == "undefined" || !obj.url) {
  2984           /* only if the annotation isn't present in the document create an
  2970           /* only if the annotation isn't present in the document create an
  3007     return _a.id.toLowerCase();
  2993     return _a.id.toLowerCase();
  3008   });
  2994   });
  3009   
  2995   
  3010   var _this = this;
  2996   var _this = this;
  3011     
  2997     
  3012     if (!this.ajax_mode) {
  2998     if (!this.ajax_mode || this.cinecast_version) {
  3013         var _throttled = IriSP.underscore.throttle(function() {
  2999         var _throttled = IriSP.underscore.throttle(function() {
  3014             _this.drawList();
  3000             _this.drawList();
  3015         }, 1500);
  3001         }, 1500);
  3016         _throttled();
  3002         _throttled();
  3017         this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", _throttled);
  3003         this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", _throttled);
  3018         this._Popcorn.listen("timeupdate", _throttled);
  3004         this._Popcorn.listen("timeupdate", _throttled);
       
  3005         if (this.cinecast_version) {
       
  3006             window.setInterval(function() {
       
  3007                 var _tmpSerializer = new IriSP.JSONSerializer(IriSP.__dataloader,  _this._config.metadata.src, true);
       
  3008                 _tmpSerializer.sync(function(json) {
       
  3009                     IriSP.underscore(json.annotations).each(function(_a) {
       
  3010                         var _j = _this.annotations_ids.indexOf(_a.id);
       
  3011                         if (_j == -1) {
       
  3012                             _this._serializer._data.annotations.push(_a);
       
  3013                             _this.annotations_ids.push(_a.id);
       
  3014                         } else {
       
  3015                             _this._serializer._data.annotations[_j] = _a;
       
  3016                         }
       
  3017                         _throttled();
       
  3018                     });
       
  3019                 }, true); // true is for force_refresh
       
  3020             },this.refresh_interval);
       
  3021         }
  3019   } else {
  3022   } else {
  3020     /* update the widget when the video has finished loading and when it's seeked and paused */
  3023     /* update the widget when the video has finished loading and when it's seeked and paused */
  3021     this._Popcorn.listen("seeked", IriSP.wrap(this, this.ajaxRedraw));
  3024     this._Popcorn.listen("seeked", IriSP.wrap(this, this.ajaxRedraw));
  3022     this._Popcorn.listen("loadedmetadata", IriSP.wrap(this, this.ajaxRedraw));
  3025     this._Popcorn.listen("loadedmetadata", IriSP.wrap(this, this.ajaxRedraw));
  3023     this._Popcorn.listen("paused", IriSP.wrap(this, this.ajaxRedraw));
  3026     this._Popcorn.listen("paused", IriSP.wrap(this, this.ajaxRedraw));
  3057     var title = annotation.content.title;
  3060     var title = annotation.content.title;
  3058     var description = annotation.content.description;
  3061     var description = annotation.content.description;
  3059     var keywords =  "";
  3062     var keywords =  "";
  3060     var begin = +annotation.begin / 1000;
  3063     var begin = +annotation.begin / 1000;
  3061     var end = +annotation.end / 1000;
  3064     var end = +annotation.end / 1000;
  3062     var duration = this._serializer.getDuration();
  3065     var duration = this.getDuration();
  3063     var tags = "";
  3066     var tags = "";
  3064     
  3067     
  3065     var title_templ = "{{title}} - ( {{begin}} - {{end}} )";
  3068     var title_templ = "{{title}} - ( {{begin}} - {{end}} )";
  3066     var endstr = Mustache.to_html(title_templ, {title: title, begin: IriSP.secondsToTime(begin), end: IriSP.secondsToTime(end)});
  3069     var endstr = Mustache.to_html(title_templ, {title: title, begin: IriSP.secondsToTime(begin), end: IriSP.secondsToTime(end)});
  3067 
  3070 
  3089     tags = IriSP.i18n.getMessage("keywords") + ": " + tags.slice(0, tags.length - 2);
  3092     tags = IriSP.i18n.getMessage("keywords") + ": " + tags.slice(0, tags.length - 2);
  3090     
  3093     
  3091     this.selector.find(".Ldt-SaKeywords").text(tags);
  3094     this.selector.find(".Ldt-SaKeywords").text(tags);
  3092     
  3095     
  3093     // update sharing buttons
  3096     // update sharing buttons
  3094     var defaults = IriSP.widgetsDefaults.AnnotationsWidget;
       
  3095     var text = defaults.share_text;
       
  3096     var fb_link = defaults.fb_link;
       
  3097     var tw_link = defaults.tw_link;
       
  3098     var gplus_link = defaults.gplus_link;
       
  3099     var url = document.location.href + "#id=" + annotation.id;
  3097     var url = document.location.href + "#id=" + annotation.id;
  3100     this.selector.find(".Ldt-fbShare").attr("href", IriSP.mkFbUrl(url, text));
  3098     this.selector.find(".Ldt-fbShare").attr("href", IriSP.mkFbUrl(url, this.share_text));
  3101     this.selector.find(".Ldt-TwShare").attr("href", IriSP.mkTweetUrl(url, text));
  3099     this.selector.find(".Ldt-TwShare").attr("href", IriSP.mkTweetUrl(url, this.share_text));
  3102     this.selector.find(".Ldt-GplusShare").attr("href", IriSP.mkGplusUrl(url, text));
  3100     this.selector.find(".Ldt-GplusShare").attr("href", IriSP.mkGplusUrl(url, this.share_text));
  3103 };
  3101 };
  3104 
  3102 
  3105 IriSP.AnnotationsWidget.prototype.clearWidget = function() {   
  3103 IriSP.AnnotationsWidget.prototype.clearWidget = function() {   
  3106     /* retract the pane between two annotations */
  3104     /* retract the pane between two annotations */
  3107     this.selector.find(".Ldt-SaTitle").text("");
  3105     this.selector.find(".Ldt-SaTitle").text("");
  3211   /* move the arrow only if the current annotation changes */
  3209   /* move the arrow only if the current annotation changes */
  3212   if (currentAnnotation != this._oldAnnotation) {
  3210   if (currentAnnotation != this._oldAnnotation) {
  3213     var begin = (+ currentAnnotation.begin) / 1000;
  3211     var begin = (+ currentAnnotation.begin) / 1000;
  3214     var end = (+ currentAnnotation.end) / 1000;
  3212     var end = (+ currentAnnotation.end) / 1000;
  3215 
  3213 
  3216     var duration = this._serializer.getDuration() / 1000;
  3214     var duration = this.getDuration() / 1000;
  3217     var middle_time = (begin + end) / 2;
  3215     var middle_time = (begin + end) / 2;
  3218     var percents = middle_time / duration;
  3216     var percents = middle_time / duration;
  3219 
  3217 
  3220     // we need to apply a fix because the arrow has a certain length
  3218     // we need to apply a fix because the arrow has a certain length
  3221     // it's half the length of the arrow (27 / 2). We need to convert
  3219     // it's half the length of the arrow (27 / 2). We need to convert
  3273             "error_while_contacting": "An error happened while contacting the server. Your annotation has not been saved.",
  3271             "error_while_contacting": "An error happened while contacting the server. Your annotation has not been saved.",
  3274             "empty_annotation": "Your annotation is empty. Please write something before submitting.",
  3272             "empty_annotation": "Your annotation is empty. Please write something before submitting.",
  3275             "annotation_saved": "Thank you, your annotation has been saved.",
  3273             "annotation_saved": "Thank you, your annotation has been saved.",
  3276             "share_annotation": "Would you like to share it on social networks ?",
  3274             "share_annotation": "Would you like to share it on social networks ?",
  3277             "share_on": "Share on",
  3275             "share_on": "Share on",
  3278             "moar_tags": "More tags"
  3276             "more_tags": "More tags"
  3279         },
  3277         },
  3280         "fr": {
  3278         "fr": {
  3281             "submit": "Envoyer",
  3279             "submit": "Envoyer",
  3282             "add_keywords": "Ajouter des mots-clés",
  3280             "add_keywords": "Ajouter des mots-clés",
  3283             "add_polemic_keywords": "Ajouter des mots-clés polémiques",
  3281             "add_polemic_keywords": "Ajouter des mots-clés polémiques",
  3287             "error_while_contacting": "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée",
  3285             "error_while_contacting": "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée",
  3288             "empty_annotation": "Votre annotation est vide. Merci de rédiger un texte avant de l'envoyer.",
  3286             "empty_annotation": "Votre annotation est vide. Merci de rédiger un texte avant de l'envoyer.",
  3289             "annotation_saved": "Merci, votre annotation a été enregistrée.",
  3287             "annotation_saved": "Merci, votre annotation a été enregistrée.",
  3290             "share_annotation": "Souhaitez-vous la partager sur les réseaux sociaux ?",
  3288             "share_annotation": "Souhaitez-vous la partager sur les réseaux sociaux ?",
  3291             "share_on": "Partager sur",
  3289             "share_on": "Partager sur",
  3292             "moar_tagz": "Plus de mots-clés"
  3290             "more_tags": "Plus de mots-clés"
  3293         }
  3291         }
  3294     }
  3292     }
  3295 );
  3293 );
  3296 
  3294 
  3297 IriSP.createAnnotationWidget = function(Popcorn, config, Serializer) {
  3295 IriSP.createAnnotationWidget = function(Popcorn, config, Serializer) {
  3298   IriSP.Widget.call(this, Popcorn, config, Serializer);
  3296   IriSP.Widget.call(this, Popcorn, config, Serializer);
  3299   this._hidden = true;
  3297   this._hidden = true;
  3300   
       
  3301   this.checkOption("keywords");
       
  3302   this.checkOption("polemic_mode", true);
       
  3303   this.checkOption("polemics");
       
  3304   this.checkOption("cinecast_version", false);
       
  3305   this.checkOption("api_endpoint_template");
       
  3306   this.checkOption("show_from_field", true);
       
  3307   this.checkOption("api_method");
       
  3308   this.checkOption("random_keywords");
       
  3309   this.checkOption("disable_share", false);
       
  3310                          
  3298                          
  3311   if (!IriSP.null_or_undefined(IriSP.user)) {
  3299   if (!IriSP.null_or_undefined(IriSP.user)) {
  3312       if (!IriSP.null_or_undefined(IriSP.user.avatar)) {
  3300       if (!IriSP.null_or_undefined(IriSP.user.avatar)) {
  3313         this.user_avatar = IriSP.user.avatar;
  3301         this.user_avatar = IriSP.user.avatar;
  3314       }
  3302       }
  3333     this.selector.find(".Ldt-SaKeywordText").text("");
  3321     this.selector.find(".Ldt-SaKeywordText").text("");
  3334 };
  3322 };
  3335 
  3323 
  3336 IriSP.createAnnotationWidget.prototype.draw = function() {
  3324 IriSP.createAnnotationWidget.prototype.draw = function() {
  3337     var _this = this;
  3325     var _this = this;
  3338     if (typeof this._config.remote_keywords != "undefined" && typeof this._config.remote_keywords) {
  3326     if (typeof this.remote_tags == "object") {
  3339         IriSP.jQuery.getJSON(this._config.remote_keywords, function(_json) {
  3327         IriSP.jQuery.getJSON((typeof this.remote_tags.alias == "string" ? this.remote_tags.alias : this.remote_tags.url), function(_json) {
  3340             _this.keywords = IriSP.underscore(_json.tags).map(function(_tag) {
  3328             _this.tags = _json.tags;
  3341                 return _tag.meta.description;
       
  3342             });
       
  3343             _this.drawCallback();
  3329             _this.drawCallback();
  3344         });
  3330         });
  3345     } else {
  3331     } else {
  3346         this.drawCallback();
  3332         this.drawCallback();
  3347     }
  3333     }
  3359     this.selector.hide();
  3345     this.selector.hide();
  3360   else {
  3346   else {
  3361     this.showStartScreen();
  3347     this.showStartScreen();
  3362   }
  3348   }
  3363   
  3349   
  3364   if (this.random_keywords) {
  3350   if (this.random_tags) {
  3365       this.selector.find(".Ldt-createAnnotation-keywords li").hide();
  3351       this.selector.find(".Ldt-createAnnotation-keywords li").hide();
  3366       this.showMoarTagz();
  3352       this.showMoreTags();
  3367       this.selector.find('.Ldt-createAnnotation-moar-keywordz').click(function() {
  3353       this.selector.find('.Ldt-createAnnotation-moar-keywordz').click(function() {
  3368           _this.showMoarTagz();
  3354           _this.showMoreTags();
  3369       })
  3355       })
  3370   }
  3356   }
  3371   // Add onclick event to both polemic and keywords buttons
  3357   // Add onclick event to both polemic and keywords buttons
  3372   
  3358   
  3373   this.selector.find(".Ldt-createAnnotation-keyword-button, .Ldt-createAnnotation-polemic-button").click(function() {
  3359   this.selector.find(".Ldt-createAnnotation-keyword-button, .Ldt-createAnnotation-polemic-button").click(function() {
  3376   });
  3362   });
  3377   
  3363   
  3378   // js_mod is a custom event because there's no simple way to test for a js
  3364   // js_mod is a custom event because there's no simple way to test for a js
  3379   // change in a textfield.                    
  3365   // change in a textfield.                    
  3380   this.selector.find(".Ldt-createAnnotation-Description")
  3366   this.selector.find(".Ldt-createAnnotation-Description")
  3381                .bind("propertychange keyup input paste click js_mod", IriSP.wrap(this, this.handleTextChanges));
  3367                .bind("propertychange keyup input paste click js_mod", IriSP.wrap(this, this.handleTextChanges))
       
  3368           .keyup(function(_e) {
       
  3369               console.log(_e);
       
  3370           });
  3382                
  3371                
  3383   /* the cinecast version of the player is supposed to pause when the user clicks on the button */
  3372   /* the cinecast version of the player is supposed to pause when the user clicks on the button */
  3384 
  3373 
  3385   /* the cinecast version expects the user to comment on a defined segment.
  3374   /* the cinecast version expects the user to comment on a defined segment.
  3386      As the widget is always shown, we need a way to update it's content as
  3375      As the widget is always shown, we need a way to update it's content as
  3437       }
  3426       }
  3438     ));
  3427     ));
  3439   }
  3428   }
  3440 };
  3429 };
  3441 
  3430 
  3442 IriSP.createAnnotationWidget.prototype.showMoarTagz = function() {
  3431 IriSP.createAnnotationWidget.prototype.showMoreTags = function() {
  3443     for (var j=0; j < this.random_keywords; j++) {
  3432     for (var j=0; j < this.random_tags; j++) {
  3444         var _jq = this.selector.find(".Ldt-createAnnotation-keywords li:hidden");
  3433         var _jq = this.selector.find(".Ldt-createAnnotation-keywords li:hidden");
  3445         if (_jq.length > 1) {
  3434         if (_jq.length > 1) {
  3446             IriSP.jQuery(_jq[Math.floor(_jq.length*Math.random())]).show();
  3435             IriSP.jQuery(_jq[Math.floor(_jq.length*Math.random())]).show();
  3447         } else {
  3436         } else {
  3448             _jq.show();
  3437             _jq.show();
  3487     var currentTime = this._Popcorn.currentTime();
  3476     var currentTime = this._Popcorn.currentTime();
  3488     
  3477     
  3489     // block the arrow.
  3478     // block the arrow.
  3490     this._Popcorn.trigger("IriSP.ArrowWidget.blockArrow");
  3479     this._Popcorn.trigger("IriSP.ArrowWidget.blockArrow");
  3491     
  3480     
  3492     var duration = this._serializer.getDuration();
  3481     var duration = this.getDuration();
  3493         
  3482         
  3494     var currentChapter = this._serializer.currentChapitre(currentTime);
  3483     var currentChapter = this._serializer.currentChapitre(currentTime);
  3495 
  3484 
  3496     if (IriSP.null_or_undefined(currentChapter)) {      
  3485     if (IriSP.null_or_undefined(currentChapter)) {      
  3497       var left = this.selector.width() / 2;
  3486       var left = this.selector.width() / 2;
  3646   this.sliceWidth = params[1];
  3635   this.sliceWidth = params[1];
  3647 };
  3636 };
  3648 
  3637 
  3649 IriSP.createAnnotationWidget.prototype.sendLdtData = function(contents, callback) {
  3638 IriSP.createAnnotationWidget.prototype.sendLdtData = function(contents, callback) {
  3650   var _this = this;
  3639   var _this = this;
  3651   var apiJson = {annotations : [{}], meta: {}};
  3640   var apiJson = {
       
  3641       format : "http://advene.org/ns/cinelab/",
       
  3642       annotations : [
       
  3643         {}
       
  3644         ],
       
  3645         meta: {}};
  3652   var annotation = apiJson.annotations[0];
  3646   var annotation = apiJson.annotations[0];
  3653   
  3647   
  3654   annotation.media = this._serializer.currentMedia()["id"];
  3648   annotation.media = this.currentMedia()["id"];
  3655   
  3649   
  3656   if (this.cinecast_version) {   
  3650   if (this.cinecast_version) {   
  3657       annotation.begin = Math.round(this._Popcorn.currentTime() * 1000);
  3651       annotation.begin = Math.round(this._Popcorn.currentTime() * 1000);
  3658       annotation.end = annotation.begin;      
  3652       annotation.end = annotation.begin;      
  3659   } else {
  3653   } else {
  3660     var duration = this._serializer.getDuration();    
  3654     var duration = this.getDuration();    
  3661     annotation.begin = +((duration * (this.sliceLeft / 100)).toFixed(0));
  3655     annotation.begin = +((duration * (this.sliceLeft / 100)).toFixed(0));
  3662     annotation.end = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0));
  3656     annotation.end = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0));
  3663   }
  3657   }
  3664 
  3658 
  3665   // boundary checks
  3659   // boundary checks
  3666   annotation.begin = Math.max(0, annotation.begin);
  3660   annotation.begin = Math.max(0, annotation.begin);
  3667   annotation.end = Math.min(this._serializer.getDuration(), annotation.end);
  3661   annotation.end = Math.min(this.getDuration(), annotation.end);
  3668   
  3662   
  3669   annotation.type = ( this.cinecast_version ? "cinecast:UserAnnotation" : ( this._serializer.getContributions() || "" ));
  3663   annotation.type = ( this.cinecast_version ? "cinecast:UserAnnotation" : ( this._serializer.getContributions() || "" ));
  3670   if (typeof(annotation.type) === "undefined")
  3664   if (typeof(annotation.type) === "undefined")
  3671     annotation.type = "";
  3665     annotation.type = "";
  3672   
  3666   
  3697       )
  3691       )
  3698   );
  3692   );
  3699   
  3693   
  3700   meta.created = Date().toString();
  3694   meta.created = Date().toString();
  3701   
  3695   
  3702   // All #hashtags are added to tags
  3696   var _tags = [];
  3703   var _tags = contents.toLowerCase().match(/#[^#\s]+\b/gim) || [];
  3697   IriSP._(this.tags).each(function(_v) {
  3704   this.selector.find('.Ldt-createAnnotation-keyword-button').each(function() {
  3698       var _rx = IriSP.regexpFromText(_v.meta.description);
  3705       var _tx = IriSP.jQuery(this).text(),
       
  3706         _rx = IriSP.regexpFromText(_tx);
       
  3707         if (_rx.test(contents)) {
  3699         if (_rx.test(contents)) {
  3708             _tags.push(_tx.toLowerCase())
  3700             _tags.push(_v.id);
  3709         }
  3701         }
  3710   });
  3702   });
  3711   
  3703 
       
  3704   if (typeof this.remote_tags == "object") {
       
  3705      _tags = IriSP._(_tags).map(function(_t) {
       
  3706          return _this.remote_tags.id + ':' + _t
       
  3707      });
       
  3708     if (typeof apiJson.imports == "undefined") {
       
  3709        apiJson.imports = [];
       
  3710     }
       
  3711     apiJson.imports.push({
       
  3712         "id" : this.remote_tags.id,
       
  3713         "url" : this.remote_tags.url
       
  3714     })
       
  3715   }
  3712   annotation.tags = IriSP.underscore.uniq(_tags);
  3716   annotation.tags = IriSP.underscore.uniq(_tags);
  3713   
       
  3714   
  3717   
  3715   var jsonString = JSON.stringify(apiJson);
  3718   var jsonString = JSON.stringify(apiJson);
  3716   var project_id = this._serializer._data.meta.id;
  3719   var project_id = this._serializer._data.meta.id;
  3717   
  3720   
  3718   //TODO: extract magic url
  3721   //TODO: extract magic url
  3754                     annotation.is_new = true;
  3757                     annotation.is_new = true;
  3755                     // everything is shared so there's no need to propagate the change
  3758                     // everything is shared so there's no need to propagate the change
  3756                     _this._serializer._data.annotations.push(annotation);
  3759                     _this._serializer._data.annotations.push(annotation);
  3757  
  3760  
  3758                     _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation", annotation);
  3761                     _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation", annotation);
       
  3762                     this.selector.find(".Ldt-createAnnotation-Description").val("");
  3759                     callback(annotation);
  3763                     callback(annotation);
  3760       }), 
  3764       }), 
  3761       error: 
  3765       error: 
  3762               function(jqXHR, textStatus, errorThrown) { 
  3766               function(jqXHR, textStatus, errorThrown) { 
  3763                             console.log("an error occured while contacting " 
  3767                             console.log("an error occured while contacting " 
  3907       return;
  3911       return;
  3908       
  3912       
  3909   }
  3913   }
  3910   
  3914   
  3911   // we get it at each call because it may change.
  3915   // we get it at each call because it may change.
  3912   var duration = this._serializer.getDuration() / 1000; 
  3916   var duration = this.getDuration() / 1000; 
  3913   var totalTime = IriSP.secondsToTime(duration);
  3917   var totalTime = IriSP.secondsToTime(duration);
  3914   var elapsedTime = IriSP.secondsToTime(this._Popcorn.currentTime());
  3918   var elapsedTime = IriSP.secondsToTime(this._Popcorn.currentTime());
  3915   
  3919   
  3916   this.selector.find(".Ldt-ElapsedTime").html(elapsedTime.toString());
  3920   this.selector.find(".Ldt-ElapsedTime").html(elapsedTime.toString());
  3917   this.selector.find(".Ldt-TotalTime").html(totalTime.toString());
  3921   this.selector.find(".Ldt-TotalTime").html(totalTime.toString());
  4115     var frameSize     = 5;             // frame size 
  4119     var frameSize     = 5;             // frame size 
  4116     var margin         = 1;            // marge between frame
  4120     var margin         = 1;            // marge between frame
  4117     var lineSize      = this.width;        // timeline pixel width 
  4121     var lineSize      = this.width;        // timeline pixel width 
  4118     var nbrframes     = lineSize/frameSize;     // frame numbers
  4122     var nbrframes     = lineSize/frameSize;     // frame numbers
  4119     var numberOfTweet   = 0;            // number of tweet overide later 
  4123     var numberOfTweet   = 0;            // number of tweet overide later 
  4120     var duration      = this._serializer.getDuration();      // timescale width 
  4124     var duration      = this.getDuration();      // timescale width 
  4121     var frameLength   = lineSize / frameSize;    // frame timescale  
  4125     var frameLength   = lineSize / frameSize;    // frame timescale  
  4122     var timeline;
  4126     var timeline;
  4123     var colors  = new Array("","#1D973D","#036AAE","#CE0A15","#C5A62D","#585858");
  4127     var colors  = new Array("","#1D973D","#036AAE","#CE0A15","#C5A62D","#585858");
  4124     
  4128     
  4125     // array 
  4129     // array 
  4449 
  4453 
  4450 /** update the positionMarker as time passes */
  4454 /** update the positionMarker as time passes */
  4451 IriSP.PolemicWidget.prototype.sliderUpdater = function() {
  4455 IriSP.PolemicWidget.prototype.sliderUpdater = function() {
  4452 
  4456 
  4453     var time = +this._Popcorn.currentTime();
  4457     var time = +this._Popcorn.currentTime();
  4454     var duration = this._serializer.getDuration();
  4458     var duration = this.getDuration();
  4455     
  4459     
  4456     this.paperSlider.attr("width", time * (this.width / (duration / 1000)));
  4460     this.paperSlider.attr("width", time * (this.width / (duration / 1000)));
  4457         
  4461         
  4458     this.sliderTip.attr("x", time * (this.width / (duration / 1000)));
  4462     this.sliderTip.attr("x", time * (this.width / (duration / 1000)));
  4459 };
  4463 };
  4521   // event handlers
  4525   // event handlers
  4522   this._Popcorn.listen("IriSP.search", function(searchString) { self.searchHandler.call(self, searchString); });
  4526   this._Popcorn.listen("IriSP.search", function(searchString) { self.searchHandler.call(self, searchString); });
  4523   this._Popcorn.listen("IriSP.search.closed", function() { self.searchFieldClosedHandler.call(self); });
  4527   this._Popcorn.listen("IriSP.search.closed", function() { self.searchFieldClosedHandler.call(self); });
  4524   this._Popcorn.listen("IriSP.search.cleared", function() { self.searchFieldClearedHandler.call(self); });
  4528   this._Popcorn.listen("IriSP.search.cleared", function() { self.searchFieldClearedHandler.call(self); });
  4525   
  4529   
  4526   this.checkOption("cinecast_version");
       
  4527   this.defaultColors = ["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"]
  4530   this.defaultColors = ["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"]
  4528 };
  4531 };
  4529 
  4532 
  4530 IriSP.SegmentsWidget.prototype = new IriSP.Widget();
  4533 IriSP.SegmentsWidget.prototype = new IriSP.Widget();
  4531 
  4534 
  4538   this.selector.append(Mustache.to_html(IriSP.overlay_marker_template));
  4541   this.selector.append(Mustache.to_html(IriSP.overlay_marker_template));
  4539   
  4542   
  4540   this.positionMarker = this.selector.find(".Ldt-SegmentPositionMarker");
  4543   this.positionMarker = this.selector.find(".Ldt-SegmentPositionMarker");
  4541   
  4544   
  4542   this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.positionUpdater));
  4545   this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.positionUpdater));
  4543   var duration = this._serializer.getDuration();
  4546   var duration = this.getDuration();
  4544   
  4547   
  4545   if (this.cinecast_version) {
  4548   if (this.cinecast_version) {
  4546       var segments_annotations = IriSP.underscore.filter(
  4549       var segments_annotations = IriSP.underscore.filter(
  4547           this._serializer._data.annotations,
  4550           this._serializer._data.annotations,
  4548           function(_a) {
  4551           function(_a) {
  4705 IriSP.SegmentsWidget.prototype.searchFieldClosedHandler = function() {
  4708 IriSP.SegmentsWidget.prototype.searchFieldClosedHandler = function() {
  4706   this.clear();
  4709   this.clear();
  4707 };
  4710 };
  4708 
  4711 
  4709 IriSP.SegmentsWidget.prototype.positionUpdater = function() {  
  4712 IriSP.SegmentsWidget.prototype.positionUpdater = function() {  
  4710   var duration = this._serializer.getDuration() / 1000;
  4713   var duration = this.getDuration() / 1000;
  4711   var time = this._Popcorn.currentTime();
  4714   var time = this._Popcorn.currentTime();
  4712   //var position 	= ((time / duration) * 100).toFixed(2);
  4715   //var position 	= ((time / duration) * 100).toFixed(2);
  4713   var position 	= ((time / duration) * 100).toFixed(2);
  4716   var position 	= ((time / duration) * 100).toFixed(2);
  4714 
  4717 
  4715   this.positionMarker.css("left", position + "%");  
  4718   this.positionMarker.css("left", position + "%");  
  4932   if(this.draggingOngoing || this._disableUpdate)
  4935   if(this.draggingOngoing || this._disableUpdate)
  4933     return;
  4936     return;
  4934   
  4937   
  4935   var time = this._Popcorn.currentTime();
  4938   var time = this._Popcorn.currentTime();
  4936 
  4939 
  4937   var duration = this._serializer.getDuration() / 1000;
  4940   var duration = this.getDuration() / 1000;
  4938   var percents = time / duration;
  4941   var percents = time / duration;
  4939   
  4942   
  4940   /* we do these complicated calculations to center exactly
  4943   /* we do these complicated calculations to center exactly
  4941      the position Marker */
  4944      the position Marker */
  4942 
  4945 
  4972 
  4975 
  4973   var parentOffset = this.sliderBackground.parent().offset();
  4976   var parentOffset = this.sliderBackground.parent().offset();
  4974   var width = this.sliderBackground.width();
  4977   var width = this.sliderBackground.width();
  4975   var relX = event.pageX - parentOffset.left;
  4978   var relX = event.pageX - parentOffset.left;
  4976 
  4979 
  4977   var duration = this._serializer.getDuration() / 1000;
  4980   var duration = this.getDuration() / 1000;
  4978   var newTime = ((relX / width) * duration).toFixed(2);
  4981   var newTime = ((relX / width) * duration).toFixed(2);
  4979 
  4982 
  4980   this._Popcorn.currentTime(newTime);
  4983   this._Popcorn.currentTime(newTime);
  4981 };
  4984 };
  4982 
  4985 
  4985 IriSP.SliderWidget.prototype.foregroundClickHandler = function(event) {
  4988 IriSP.SliderWidget.prototype.foregroundClickHandler = function(event) {
  4986   var parentOffset = this.sliderForeground.parent().offset();
  4989   var parentOffset = this.sliderForeground.parent().offset();
  4987   var width = this.sliderBackground.width();
  4990   var width = this.sliderBackground.width();
  4988   var relX = event.pageX - parentOffset.left;
  4991   var relX = event.pageX - parentOffset.left;
  4989 
  4992 
  4990   var duration = this._serializer.getDuration() / 1000;
  4993   var duration = this.getDuration() / 1000;
  4991   var newTime = ((relX / width) * duration).toFixed(2);
  4994   var newTime = ((relX / width) * duration).toFixed(2);
  4992 
  4995 
  4993   this._Popcorn.currentTime(newTime);
  4996   this._Popcorn.currentTime(newTime);
  4994 };
  4997 };
  4995 
  4998 
  5013 
  5016 
  5014 /* handles when the mouse leaves the slider */
  5017 /* handles when the mouse leaves the slider */
  5015 IriSP.SliderWidget.prototype.mouseOutHandler = function(event) {
  5018 IriSP.SliderWidget.prototype.mouseOutHandler = function(event) {
  5016 
  5019 
  5017   this.timeOutId = window.setTimeout(IriSP.wrap(this, this.minimizeOnTimeout),
  5020   this.timeOutId = window.setTimeout(IriSP.wrap(this, this.minimizeOnTimeout),
  5018                                      IriSP.widgetsDefaults.SliderWidget.minimize_period);
  5021                                      this.minimize_period);
  5019 };
  5022 };
  5020 
  5023 
  5021 IriSP.SliderWidget.prototype.minimizeOnTimeout = function(event) {
  5024 IriSP.SliderWidget.prototype.minimizeOnTimeout = function(event) {
  5022   this.sliderBackground.animate({"height": "5px"}, 100);
  5025   this.sliderBackground.animate({"height": "5px"}, 100);
  5023   this.sliderForeground.animate({"height": "5px"}, 100);
  5026   this.sliderForeground.animate({"height": "5px"}, 100);
  5042 */
  5045 */
  5043   var parentOffset = this.sliderForeground.parent().offset();
  5046   var parentOffset = this.sliderForeground.parent().offset();
  5044   var width = this.sliderBackground.width();
  5047   var width = this.sliderBackground.width();
  5045   var relX = event.originalEvent.pageX - parentOffset.left;
  5048   var relX = event.originalEvent.pageX - parentOffset.left;
  5046 
  5049 
  5047   var duration = this._serializer.getDuration() / 1000;
  5050   var duration = this.getDuration() / 1000;
  5048   var newTime = ((relX / width) * duration).toFixed(2);
  5051   var newTime = ((relX / width) * duration).toFixed(2);
  5049   this._Popcorn.currentTime(newTime);
  5052   this._Popcorn.currentTime(newTime);
  5050   
  5053   
  5051   this.draggingOngoing = false;
  5054   this.draggingOngoing = false;
  5052 };
  5055 };
  5056   IriSP.Widget.call(this, Popcorn, config, Serializer);
  5059   IriSP.Widget.call(this, Popcorn, config, Serializer);
  5057 
  5060 
  5058   this._oldAnnotation = null;
  5061   this._oldAnnotation = null;
  5059   this._results = [];
  5062   this._results = [];
  5060   
  5063   
  5061   this.lineColor = this._config.lineColor || "#7492b4";
       
  5062   this.fillColor = this._config.fillColor || "#aeaeb8";
       
  5063   this.lineWidth = this._config.lineWidth || 2;
       
  5064   this.slices = this._config.slices || Math.floor(this.width/20);
  5064   this.slices = this._config.slices || Math.floor(this.width/20);
  5065   if (!this.width) {
  5065   if (!this.width) {
  5066       this.width = this.selector.width();
  5066       this.width = this.selector.width();
  5067   }
  5067   }
  5068   if (!this.height) {
  5068   if (!this.height) {
  5070   }
  5070   }
  5071   this.selector.css("height", this.height + "px");
  5071   this.selector.css("height", this.height + "px");
  5072   if (this._config.background) {
  5072   if (this._config.background) {
  5073       this.selector.css("background", this._config.background);
  5073       this.selector.css("background", this._config.background);
  5074   }
  5074   }
  5075   this.checkOption('cinecast_version');
       
  5076 };
  5075 };
  5077 
  5076 
  5078 
  5077 
  5079 IriSP.SparklineWidget.prototype = new IriSP.Widget();
  5078 IriSP.SparklineWidget.prototype = new IriSP.Widget();
  5080 
  5079 
  5082 
  5081 
  5083 };
  5082 };
  5084 
  5083 
  5085 /** draw the sparkline using jquery sparkline */
  5084 /** draw the sparkline using jquery sparkline */
  5086 IriSP.SparklineWidget.prototype.draw = function() {
  5085 IriSP.SparklineWidget.prototype.draw = function() {
  5087     this.duration = this._serializer.getDuration();
  5086     this.duration = this.getDuration();
  5088     this.paper = new Raphael(this.selector[0], this.width, this.height);
  5087     this.paper = new Raphael(this.selector[0], this.width, this.height);
  5089     var _this = this;
  5088     var _this = this;
  5090   
  5089   
  5091   var views = this._serializer._data.views;
  5090   var views = this._serializer._data.views;
  5092   var stat_view;
  5091   var stat_view;
  5109     } else {
  5108     } else {
  5110         var _annotations = this._serializer._data.annotations,
  5109         var _annotations = this._serializer._data.annotations,
  5111             _sliceDuration = Math.floor( this.duration / this.slices),
  5110             _sliceDuration = Math.floor( this.duration / this.slices),
  5112             _results = _(_.range(this.slices)).map(function(_i) {
  5111             _results = _(_.range(this.slices)).map(function(_i) {
  5113                 return _(_annotations).filter(function(_a){
  5112                 return _(_annotations).filter(function(_a){
  5114                     return (_a.begin <= (1 + _i) * _sliceDuration) && (_a.end >= _i * _sliceDuration) && (!_this.cinecast_version || _a.type == "cinecast:UserAnnotation")
  5113                     return (_a.begin <= (1 + _i) * _sliceDuration) && (_a.end >= _i * _sliceDuration)
  5115                 }).length;
  5114                 }).length;
  5116             });
  5115             });
  5117     }
  5116     }
  5118     var _max = Math.max(1, _(_results).max()),
  5117     var _max = Math.max(1, _(_results).max()),
  5119         _h = this.height,
  5118         _h = this.height,
  5202 }
  5201 }
  5203 
  5202 
  5204 IriSP.StackGraphWidget.prototype = new IriSP.Widget();
  5203 IriSP.StackGraphWidget.prototype = new IriSP.Widget();
  5205 
  5204 
  5206 IriSP.StackGraphWidget.prototype.draw = function() {
  5205 IriSP.StackGraphWidget.prototype.draw = function() {
  5207     var _ = IriSP._,
  5206     var _ = IriSP._;
  5208         _defaultTags = [
       
  5209             {
       
  5210                 "keywords" : [ "++" ],
       
  5211                 "description" : "positif",
       
  5212                 "color" : "#1D973D"
       
  5213             },
       
  5214             {
       
  5215                 "keywords" : [ "--" ],
       
  5216                 "description" : "negatif",
       
  5217                 "color" : "#CE0A15"
       
  5218             },
       
  5219             {
       
  5220                 "keywords" : [ "==" ],
       
  5221                 "description" : "reference",
       
  5222                 "color" : "#C5A62D"  
       
  5223             },
       
  5224             {
       
  5225                 "keywords" : [ "??" ],
       
  5226                 "description" : "question",
       
  5227                 "color" : "#036AAE"
       
  5228             }
       
  5229         ],
       
  5230         _defaultDefColor = "#585858";
       
  5231     this.height =  this._config.height || 50;
  5207     this.height =  this._config.height || 50;
  5232     this.width = this.selector.width();
  5208     this.width = this.selector.width();
  5233     this.isStreamGraph = this._config.streamgraph || false;
  5209     this.slices = this._config.slices || ~~(this.width/(this.streamgraph ? 20 : 5));
  5234     this.sliceCount = this._config.slices || ~~(this.width/(this.isStreamGraph ? 20 : 5));
  5210     _(this.tags).each(function(_a) {
  5235     this.tagconf = (this._config.tags
       
  5236         ? this._config.tags
       
  5237         : _defaultTags);
       
  5238     IriSP._(this.tagconf).each(function(_a) {
       
  5239         _a.regexp = new RegExp(_(_a.keywords).map(function(_k) {
  5211         _a.regexp = new RegExp(_(_a.keywords).map(function(_k) {
  5240             return _k.replace(/([\W])/gm,'\\$1');
  5212             return _k.replace(/([\W])/gm,'\\$1');
  5241         }).join("|"),"im")
  5213         }).join("|"),"im")
  5242     });
  5214     });
  5243     this.defaultcolorconf = (this._config.defaultcolor
       
  5244         ? this._config.defaultcolor
       
  5245         : _defaultDefColor);
       
  5246     this.paper = new Raphael(this.selector[0], this.width, this.height);
  5215     this.paper = new Raphael(this.selector[0], this.width, this.height);
  5247     this.groups = [];
  5216     this.groups = [];
  5248     this.duration = this._serializer.getDuration();
  5217     this.duration = this.getDuration();
  5249     
  5218     
  5250     var _annotationType = this._serializer.getTweets(),
  5219     var _annotationType = this._serializer.getTweets(),
  5251         _sliceDuration = ~~ ( this.duration / this.sliceCount),
  5220         _sliceDuration = ~~ ( this.duration / this.slices),
  5252         _annotations = this._serializer._data.annotations,
  5221         _annotations = this._serializer._data.annotations,
  5253         _groupedAnnotations = _(_.range(this.sliceCount)).map(function(_i) {
  5222         _groupedAnnotations = _(_.range(this.slices)).map(function(_i) {
  5254             return _(_annotations).filter(function(_a){
  5223             return _(_annotations).filter(function(_a){
  5255                 return (_a.begin <= (1 + _i) * _sliceDuration) && (_a.end >= _i * _sliceDuration)
  5224                 return (_a.begin <= (1 + _i) * _sliceDuration) && (_a.end >= _i * _sliceDuration)
  5256             });
  5225             });
  5257         }),
  5226         }),
  5258         _max = IriSP._(_groupedAnnotations).max(function(_g) {
  5227         _max = IriSP._(_groupedAnnotations).max(function(_g) {
  5259             return _g.length
  5228             return _g.length
  5260         }).length,
  5229         }).length,
  5261         _scale = this.height / _max,
  5230         _scale = this.height / _max,
  5262         _width = this.width / this.sliceCount,
  5231         _width = this.width / this.slices,
  5263         _showTitle = !this._config.excludeTitle,
  5232         _showTitle = !this._config.excludeTitle,
  5264         _showDescription = !this._config.excludeDescription;
  5233         _showDescription = !this._config.excludeDescription;
  5265     
  5234     
  5266     
  5235     
  5267     var _paths = _(this.tagconf).map(function() {
  5236     var _paths = _(this.tags).map(function() {
  5268         return [];
  5237         return [];
  5269     });
  5238     });
  5270     _paths.push([]);
  5239     _paths.push([]);
  5271     
  5240     
  5272     for (var i = 0; i < this.sliceCount; i++) {
  5241     for (var i = 0; i < this.slices; i++) {
  5273         var _group = _groupedAnnotations[i];
  5242         var _group = _groupedAnnotations[i];
  5274         if (_group) {
  5243         if (_group) {
  5275             var _vol = _(this.tagconf).map(function() {
  5244             var _vol = _(this.tags).map(function() {
  5276                 return 0;
  5245                 return 0;
  5277             });
  5246             });
  5278             for (var j = 0; j < _group.length; j++){
  5247             for (var j = 0; j < _group.length; j++){
  5279            var _txt = (_showTitle ? _group[j].content.title : '') + ' ' + (_showDescription ? _group[j].content.description : '')
  5248            var _txt = (_showTitle ? _group[j].content.title : '') + ' ' + (_showDescription ? _group[j].content.description : '')
  5280                 var _tags = _(this.tagconf).map(function(_tag) {
  5249                 var _tags = _(this.tags).map(function(_tag) {
  5281                         return (_txt.search(_tag.regexp) == -1 ? 0 : 1)
  5250                         return (_txt.search(_tag.regexp) == -1 ? 0 : 1)
  5282                     }),
  5251                     }),
  5283                     _nbtags = _(_tags).reduce(function(_a,_b) {
  5252                     _nbtags = _(_tags).reduce(function(_a,_b) {
  5284                         return _a + _b;
  5253                         return _a + _b;
  5285                     }, 0);
  5254                     }, 0);
  5293                     return _a + _b;
  5262                     return _a + _b;
  5294                 }, 0),
  5263                 }, 0),
  5295                 _nbneutre = _group.length - _nbtags,
  5264                 _nbneutre = _group.length - _nbtags,
  5296                 _h = _nbneutre * _scale,
  5265                 _h = _nbneutre * _scale,
  5297                 _base = this.height - _h;
  5266                 _base = this.height - _h;
  5298             if (!this.isStreamGraph) {
  5267             if (!this.streamgraph) {
  5299                 this.paper.rect(i * _width, _base, _width - 1, _h ).attr({
  5268                 this.paper.rect(i * _width, _base, _width - 1, _h ).attr({
  5300                     "stroke" : "none",
  5269                     "stroke" : "none",
  5301                     "fill" : this.defaultcolorconf
  5270                     "fill" : this.defaultcolor
  5302                 });
  5271                 });
  5303             }
  5272             }
  5304            _paths[0].push(_base);
  5273            _paths[0].push(_base);
  5305             for (var j = 0; j < this.tagconf.length; j++) {
  5274             for (var j = 0; j < this.tags.length; j++) {
  5306                 _h = _vol[j] * _scale;
  5275                 _h = _vol[j] * _scale;
  5307                 _base = _base - _h;
  5276                 _base = _base - _h;
  5308                 if (!this.isStreamGraph) {
  5277                 if (!this.streamgraph) {
  5309                     this.paper.rect(i * _width, _base, _width - 1, _h ).attr({
  5278                     this.paper.rect(i * _width, _base, _width - 1, _h ).attr({
  5310                         "stroke" : "none",
  5279                         "stroke" : "none",
  5311                         "fill" : this.tagconf[j].color
  5280                         "fill" : this.tags[j].color
  5312                     });
  5281                     });
  5313                 }
  5282                 }
  5314                 _paths[j+1].push(_base);
  5283                 _paths[j+1].push(_base);
  5315             }
  5284             }
  5316             this.groups.push(_(_vol).map(function(_v) {
  5285             this.groups.push(_(_vol).map(function(_v) {
  5318             }))
  5287             }))
  5319         } else {
  5288         } else {
  5320             for (var j = 0; j < _paths.length; j++) {
  5289             for (var j = 0; j < _paths.length; j++) {
  5321                 _paths[j].push(this.height);
  5290                 _paths[j].push(this.height);
  5322             }
  5291             }
  5323             this.groups.push(_(this.tagconf).map(function() {
  5292             this.groups.push(_(this.tags).map(function() {
  5324                 return 0;
  5293                 return 0;
  5325             }));
  5294             }));
  5326         }
  5295         }
  5327     }
  5296     }
  5328     
  5297     
  5329     if (this.isStreamGraph) {
  5298     if (this.streamgraph) {
  5330         for (var j = _paths.length - 1; j >= 0; j--) {
  5299         for (var j = _paths.length - 1; j >= 0; j--) {
  5331             var _d = _(_paths[j]).reduce(function(_memo, _v, _k) {
  5300             var _d = _(_paths[j]).reduce(function(_memo, _v, _k) {
  5332                return _memo + ( _k
  5301                return _memo + ( _k
  5333                    ? 'C' + (_k * _width) + ' ' + _paths[j][_k - 1] + ' ' + (_k * _width) + ' ' + _v + ' ' + ((_k + .5) * _width) + ' ' + _v
  5302                    ? 'C' + (_k * _width) + ' ' + _paths[j][_k - 1] + ' ' + (_k * _width) + ' ' + _v + ' ' + ((_k + .5) * _width) + ' ' + _v
  5334                    : 'M0 ' + _v + 'L' + (.5*_width) + ' ' + _v )
  5303                    : 'M0 ' + _v + 'L' + (.5*_width) + ' ' + _v )
  5335             },'') + 'L' + this.width + ' ' + _paths[j][_paths[j].length - 1] + 'L' + this.width + ' ' + this.height + 'L0 ' + this.height;
  5304             },'') + 'L' + this.width + ' ' + _paths[j][_paths[j].length - 1] + 'L' + this.width + ' ' + this.height + 'L0 ' + this.height;
  5336             this.paper.path(_d).attr({
  5305             this.paper.path(_d).attr({
  5337                 "stroke" : "none",
  5306                 "stroke" : "none",
  5338                 "fill" : (j ? this.tagconf[j-1].color : this.defaultcolorconf)
  5307                 "fill" : (j ? this.tags[j-1].color : this.defaultcolor)
  5339             });
  5308             });
  5340         }
  5309         }
  5341     }
  5310     }
  5342     this.rectangleFocus = this.paper.rect(0,0,_width,this.height)
  5311     this.rectangleFocus = this.paper.rect(0,0,_width,this.height)
  5343         .attr({
  5312         .attr({
  5359         .click(IriSP.wrap(this, this.clickHandler))
  5328         .click(IriSP.wrap(this, this.clickHandler))
  5360         .mousemove(function(_e) {
  5329         .mousemove(function(_e) {
  5361             _this.updateTooltip(_e);
  5330             _this.updateTooltip(_e);
  5362             // Trace
  5331             // Trace
  5363             var relX = _e.pageX - _this.selector.offset().left;
  5332             var relX = _e.pageX - _this.selector.offset().left;
  5364             var _duration = _this._serializer.getDuration();
  5333             var _duration = _this.getDuration();
  5365             var _time = parseInt((relX / _this.width) * _duration);
  5334             var _time = parseInt((relX / _this.width) * _duration);
  5366             _this._Popcorn.trigger("IriSP.TraceWidget.MouseEvents", {
  5335             _this._Popcorn.trigger("IriSP.TraceWidget.MouseEvents", {
  5367                 "widget" : "StackGraphWidget",
  5336                 "widget" : "StackGraphWidget",
  5368                 "type": "mousemove",
  5337                 "type": "mousemove",
  5369                 "x": _e.pageX,
  5338                 "x": _e.pageX,
  5400   this._Popcorn.trigger("IriSP.StackGraphWidget.clicked", newTime);
  5369   this._Popcorn.trigger("IriSP.StackGraphWidget.clicked", newTime);
  5401   this._Popcorn.currentTime(newTime);                                 
  5370   this._Popcorn.currentTime(newTime);                                 
  5402 };
  5371 };
  5403 
  5372 
  5404 IriSP.StackGraphWidget.prototype.updateTooltip = function(event) {
  5373 IriSP.StackGraphWidget.prototype.updateTooltip = function(event) {
  5405     var _segment = Math.max(0,Math.min(this.groups.length - 1, Math.floor(this.sliceCount * (event.pageX - this.selector.offset().left)/this.width))),
  5374     var _segment = Math.max(0,Math.min(this.groups.length - 1, Math.floor(this.slices * (event.pageX - this.selector.offset().left)/this.width))),
  5406         _valeurs = this.groups[_segment],
  5375         _valeurs = this.groups[_segment],
  5407         _width = this.width / this.sliceCount,
  5376         _width = this.width / this.slices,
  5408         _html = '<ul style="list-style: none; margin: 0; padding: 0;">' + IriSP._(this.tagconf).map(function(_tag, _i) {
  5377         _html = '<ul style="list-style: none; margin: 0; padding: 0;">' + IriSP._(this.tags).map(function(_tag, _i) {
  5409             return '<li style="clear: both;"><span style="float: left; width: 10px; height: 10px; margin: 2px; background: '
  5378             return '<li style="clear: both;"><span style="float: left; width: 10px; height: 10px; margin: 2px; background: '
  5410                 + _tag.color
  5379                 + _tag.color
  5411                 + ';"></span>'
  5380                 + ';"></span>'
  5412                 + ~~(100 * _valeurs[_i])
  5381                 + ~~(100 * _valeurs[_i])
  5413                 + '% de '
  5382                 + '% de '
  5414                 + _tag.description
  5383                 + _tag.description
  5415                 + '</li>';
  5384                 + '</li>';
  5416         }).join('') + '</ul>';
  5385         }).join('') + '</ul>';
  5417     this.TooltipWidget._shown = false; // Vraiment, on ne peut pas ouvrir le widget s'il n'est pas encore ouvert ?
  5386     this.TooltipWidget._shown = false; // Vraiment, on ne peut pas ouvrir le widget s'il n'est pas encore ouvert ?
  5418     this.TooltipWidget.show('','',(_segment + .5)* this.width / this.sliceCount, 0);
  5387     this.TooltipWidget.show('','',(_segment + .5)* this.width / this.slices, 0);
  5419     this.TooltipWidget.selector.find(".tip").html(_html);
  5388     this.TooltipWidget.selector.find(".tip").html(_html);
  5420     this.rectangleFocus.attr({
  5389     this.rectangleFocus.attr({
  5421         "x" : _segment * _width,
  5390         "x" : _segment * _width,
  5422         "opacity" : .4
  5391         "opacity" : .4
  5423     })
  5392     })
  5727       return;
  5696       return;
  5728     
  5697     
  5729     var title = IriSP.formatTweet(annotation.content.title);
  5698     var title = IriSP.formatTweet(annotation.content.title);
  5730     var img = annotation.content.img.src;
  5699     var img = annotation.content.img.src;
  5731     if (typeof(img) === "undefined" || img === "" || img === "None") {
  5700     if (typeof(img) === "undefined" || img === "" || img === "None") {
  5732       img = IriSP.widgetsDefaults.TweetsWidget.default_profile_picture;
  5701       img = this.default_profile_picture;
  5733     }
  5702     }
  5734 
  5703 
  5735     var imageMarkup = IriSP.templToHTML("<img src='{{src}}' alt='user image'></img>", 
  5704     var imageMarkup = IriSP.templToHTML("<img src='{{src}}' alt='user image'></img>", 
  5736                                        {src : img});
  5705                                        {src : img});
  5737     
  5706     
  5771   }
  5740   }
  5772 
  5741 
  5773   this.drawTweet(annotation);
  5742   this.drawTweet(annotation);
  5774 
  5743 
  5775   var time = this._Popcorn.currentTime();  
  5744   var time = this._Popcorn.currentTime();  
  5776   this._timeoutId = window.setTimeout(IriSP.wrap(this, this.clearPanel), IriSP.widgetsDefaults.TweetsWidget.tweet_display_period);
  5745   this._timeoutId = window.setTimeout(IriSP.wrap(this, this.clearPanel), this.tweet_display_period);
  5777 };
  5746 };
  5778 
  5747 
  5779 
  5748 
  5780 IriSP.TweetsWidget.prototype.clearPanel = function() {  
  5749 IriSP.TweetsWidget.prototype.clearPanel = function() {  
  5781     this._displayingTweet = false;
  5750     this._displayingTweet = false;
  5870 };
  5839 };
  5871 
  5840 
  5872 /** load JSON-cinelab data and also sort the annotations by start time
  5841 /** load JSON-cinelab data and also sort the annotations by start time
  5873     @param callback function to call when the data is ready.
  5842     @param callback function to call when the data is ready.
  5874  */
  5843  */
  5875 IriSP.JSONSerializer.prototype.sync = function(callback) {
  5844 IriSP.JSONSerializer.prototype.sync = function(callback, force_refresh) {
  5876   /* we don't have to do much because jQuery handles json for us */
  5845   /* we don't have to do much because jQuery handles json for us */
  5877 
  5846 
  5878   var self = this;
  5847   var self = this;
  5879 
  5848 
  5880   var fn = function(data) {
  5849   var fn = function(data) {
  5892 	            return a_begin - b_begin;
  5861 	            return a_begin - b_begin;
  5893 	          });
  5862 	          });
  5894 	  }     
  5863 	  }     
  5895       callback(data);      
  5864       callback(data);      
  5896   };
  5865   };
  5897   
  5866   this._DataLoader.get(this._url, fn, force_refresh);
  5898   this._DataLoader.get(this._url, fn);
       
  5899 };
  5867 };
  5900 
  5868 
  5901 /** @return the metadata about the media being read FIXME: always return the first media. */
  5869 /** @return the metadata about the media being read FIXME: always return the first media. */
  5902 IriSP.JSONSerializer.prototype.currentMedia = function() {  
  5870 IriSP.JSONSerializer.prototype.currentMedia = function() {  
  5903   return this._data.medias[0]; /* FIXME: don't hardcode it */
  5871   return (typeof this._data.medias == "object" && this._data.medias.length) ? this._data.medias[0] : IriSP.__jsonMetadata.medias[0];
  5904 };
  5872 };
       
  5873 
       
  5874 IriSP.JSONSerializer.prototype.getDuration = function() {
       
  5875     var _m = this.currentMedia();
       
  5876     if (_m === null || typeof _m.meta == "undefined") {
       
  5877         return 0;
       
  5878     }
       
  5879     return +(IriSP.get_aliased(_m.meta, ["dc:duration", "duration"]) || 0);
       
  5880 }
       
  5881 
  5905 
  5882 
  5906 /** searches for an annotation which matches title, description and keyword 
  5883 /** searches for an annotation which matches title, description and keyword 
  5907    "" matches any field. 
  5884    "" matches any field. 
  5908    Note: it ignores tweets.
  5885    Note: it ignores tweets.
  5909    @return a list of matching ids.
  5886    @return a list of matching ids.
  6282   if (typeof(val) === "undefined")
  6259   if (typeof(val) === "undefined")
  6283     val = this.getId("Publ");
  6260     val = this.getId("Publ");
  6284     
  6261     
  6285   return val;
  6262   return val;
  6286 };
  6263 };
  6287 
       
  6288 IriSP.JSONSerializer.prototype.getDuration = function() {
       
  6289     return +(IriSP.get_aliased(this.currentMedia().meta, ["dc:duration", "duration"]) || 0);
       
  6290 }