web/res/js/LdtPlayer.min.js
author ymh <ymh.work@gmail.com>
Wed, 18 Dec 2024 15:24:41 +0100
changeset 1584 257c14dae52a
parent 1198 ff4b567d51f2
permissions -rw-r--r--
Added tag V09.006 for changeset 459a88818bec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1198
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     1
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     2
/* 
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     3
 *
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     4
  __  __      _            _       _              _                       
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     5
 |  \/  | ___| |_ __ _  __| | __ _| |_ __ _ _ __ | | __ _ _   _  ___ _ __ 
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     6
 | |\/| |/ _ \ __/ _` |/ _` |/ _` | __/ _` | '_ \| |/ _` | | | |/ _ \ '__|
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     7
 | |  | |  __/ || (_| | (_| | (_| | || (_| | |_) | | (_| | |_| |  __/ |   
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     8
 |_|  |_|\___|\__\__,_|\__,_|\__,_|\__\__,_| .__/|_|\__,_|\__, |\___|_|   
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
     9
                                           |_|            |___/         
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    10
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    11
 *  Copyright 2010-2012 Institut de recherche et d'innovation 
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    12
 *	contributor(s) : Karim Hamidou, Samuel Huron, Raphael Velt, Thibaut Cavalie
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    13
 *	 
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    14
 *	contact@iri.centrepompidou.fr
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    15
 *	http://www.iri.centrepompidou.fr 
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    16
 *	 
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    17
 *	This software is a computer program whose purpose is to show and add annotations on a video .
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    18
 *	This software is governed by the CeCILL-C license under French law and
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    19
 *	abiding by the rules of distribution of free software. You can  use, 
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    20
 *	modify and/ or redistribute the software under the terms of the CeCILL-C
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    21
 *	license as circulated by CEA, CNRS and INRIA at the following URL
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    22
 *	"http://www.cecill.info". 
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    23
 *	
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    24
 *	The fact that you are presently reading this means that you have had
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    25
 *	knowledge of the CeCILL-C license and that you accept its terms.
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    26
*/
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    27
(function(a){function e(n,p){var y=/^\w+\:\/\//;if(/^\/\/\/?/.test(n))n=location.protocol+n;else if(!y.test(n)&&n.charAt(0)!="/")n=(p||"")+n;return y.test(n)?n:(n.charAt(0)=="/"?L:O)+n}function g(n,p){for(var y in n)if(n.hasOwnProperty(y))p[y]=n[y];return p}function k(n,p,y,b){n.onload=n.onreadystatechange=function(){if(!(n.readyState&&n.readyState!="complete"&&n.readyState!="loaded"||p[y])){n.onload=n.onreadystatechange=null;b()}}}function l(n){n.ready=n.finished=true;for(var p=0;p<n.finished_listeners.length;p++)n.finished_listeners[p]();
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    28
n.ready_listeners=[];n.finished_listeners=[]}function f(n,p,y,b,c){setTimeout(function(){var d,h=p.real_src,m;if("item"in B){if(!B[0]){setTimeout(arguments.callee,25);return}B=B[0]}d=document.createElement("script");if(p.type)d.type=p.type;if(p.charset)d.charset=p.charset;if(c)if(z){y.elem=d;if(P){d.preload=true;d.onpreload=b}else d.onreadystatechange=function(){d.readyState=="loaded"&&b()};d.src=h}else if(c&&h.indexOf(L)==0&&n[o]){m=new XMLHttpRequest;m.onreadystatechange=function(){if(m.readyState==
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    29
4){m.onreadystatechange=function(){};y.text=m.responseText+"\n//@ sourceURL="+h;b()}};m.open("GET",h);m.send()}else{d.type="text/cache-script";k(d,y,"ready",function(){B.removeChild(d);b()});d.src=h;B.insertBefore(d,B.firstChild)}else{if(C)d.async=false;k(d,y,"finished",b);d.src=h;B.insertBefore(d,B.firstChild)}},0)}function j(){function n(w,s,A){function H(){if(u!=null){u=null;l(A)}}var u;if(!h[s.src].finished){if(!w[I])h[s.src].finished=true;u=A.elem||document.createElement("script");if(s.type)u.type=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    30
s.type;if(s.charset)u.charset=s.charset;k(u,A,"finished",H);if(A.elem)A.elem=null;else if(A.text){u.onload=u.onreadystatechange=null;u.text=A.text}else u.src=s.real_src;B.insertBefore(u,B.firstChild);A.text&&H()}}function p(w,s,A,H){var u,F,N=function(){s.ready_cb(s,function(){n(w,s,u)})},Q=function(){s.finished_cb(s,A)};s.src=e(s.src,w[G]);s.real_src=s.src+(w[v]?(/\?.*$/.test(s.src)?"&_":"?_")+~~(Math.random()*1E9)+"=":"");h[s.src]||(h[s.src]={items:[],finished:false});F=h[s.src].items;if(w[I]||
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    31
F.length==0){u=F[F.length]={ready:false,finished:false,ready_listeners:[N],finished_listeners:[Q]};f(w,s,u,H?function(){u.ready=true;for(var J=0;J<u.ready_listeners.length;J++)u.ready_listeners[J]();u.ready_listeners=[]}:function(){l(u)},H)}else{u=F[0];u.finished?Q():u.finished_listeners.push(Q)}}function y(){function w(D,t){D.ready=true;D.exec_trigger=t;A()}function s(D,t){D.ready=D.finished=true;D.exec_trigger=null;for(var K=0;K<t.scripts.length;K++)if(!t.scripts[K].finished)return;t.finished=true;
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    32
A()}function A(){for(;N<F.length;)if(Object.prototype.toString.call(F[N])=="[object Function]")try{F[N++]()}catch(D){}else{if(!F[N].finished){for(var t=F[N],K=false,M=0;M<t.scripts.length;M++)if(t.scripts[M].ready&&t.scripts[M].exec_trigger){K=true;t.scripts[M].exec_trigger();t.scripts[M].exec_trigger=null}if(K)continue;break}N++}if(N==F.length)J=Q=false}var H,u=g(b,{}),F=[],N=0,Q=false,J;H={script:function(){for(var D=0;D<arguments.length;D++)(function(t,K){var M;Object.prototype.toString.call(t)==
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    33
"[object Array]"||(K=[t]);for(var R=0;R<K.length;R++){if(!J||!J.scripts)F.push(J={scripts:[],finished:true});t=K[R];if(Object.prototype.toString.call(t)=="[object Function]")t=t();if(t)if(Object.prototype.toString.call(t)=="[object Array]"){M=[].slice.call(t);M.unshift(R,1);[].splice.apply(K,M);R--}else{if(typeof t=="string")t={src:t};t=g(t,{ready:false,ready_cb:w,finished:false,finished_cb:s});J.finished=false;J.scripts.push(t);p(u,t,J,c&&Q);Q=true;u[E]&&H.wait()}}})(arguments[D],arguments[D]);return H},
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    34
wait:function(){if(arguments.length>0){for(var D=0;D<arguments.length;D++)F.push(arguments[D]);J=F[F.length-1]}else J=false;A();return H}};return{script:H.script,wait:H.wait,setOptions:function(D){g(D,u);return H}}}var b={},c=z||q,d=[],h={},m;b[o]=true;b[E]=false;b[I]=false;b[v]=false;b[G]="";return m={setGlobalDefaults:function(w){g(w,b);return m},setOptions:function(){return y().setOptions.apply(null,arguments)},script:function(){return y().script.apply(null,arguments)},wait:function(){return y().wait.apply(null,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    35
arguments)},queueScript:function(){d[d.length]={type:"script",args:[].slice.call(arguments)};return m},queueWait:function(){d[d.length]={type:"wait",args:[].slice.call(arguments)};return m},runQueue:function(){for(var w=m,s=d.length,A;--s>=0;){A=d.shift();w=w[A.type].apply(null,A.args)}return w},noConflict:function(){a.$LAB=i;return m},sandbox:function(){return j()}}}var i=a.$LAB,o="UseLocalXHR",E="AlwaysPreserveOrder",I="AllowDuplicates",v="CacheBust",G="BasePath",O=/^[^?#]*\//.exec(location.href)[0],
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    36
L=/^\w+\:\/\/\/?[^\/]+/.exec(O)[0],B=document.head||document.getElementsByTagName("head"),r=a.opera&&Object.prototype.toString.call(a.opera)=="[object Opera]"||"MozAppearance"in document.documentElement.style,x=document.createElement("script"),P=typeof x.preload=="boolean",z=P||x.readyState&&x.readyState=="uninitialized",C=!z&&x.async===true,q=!z&&!C&&!r;a.$LAB=j();(function(n,p,y){if(document.readyState==null&&document[n]){document.readyState="loading";document[n](p,y=function(){document.removeEventListener(p,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    37
y,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);if(typeof window.IriSP==="undefined")window.IriSP={VERSION:"0.3.2"};if(typeof IriSP.jQuery==="undefined"&&typeof window.jQuery!=="undefined"){var jvp=window.jQuery().jquery.split("."),jv=100*parseInt(jvp[0])+parseInt(jvp[1]);if(jv>170)IriSP.jQuery=window.jQuery}if(typeof IriSP._==="undefined"&&typeof window._!=="undefined"&&parseFloat(window._.VERSION)>=1.4)IriSP._=window._;
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    38
IriSP.jqEscape=function(a){return a.replace(/(:|\.)/g,"\\$1")};IriSP.getLib=function(a){if(IriSP.libFiles.useCdn&&typeof IriSP.libFiles.cdn[a]=="string")return IriSP.libFiles.cdn[a];if(typeof IriSP.libFiles.locations[a]=="string")return IriSP.libFiles.locations[a];if(typeof IriSP.libFiles.inDefaultDir[a]=="string")return IriSP.libFiles.defaultDir+"/"+IriSP.libFiles.inDefaultDir[a]};IriSP._cssCache=[];
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    39
IriSP.loadCss=function(a){if(IriSP._(IriSP._cssCache).indexOf(a)===-1){IriSP.jQuery("<link>",{rel:"stylesheet",type:"text/css",href:a}).appendTo("head");IriSP._cssCache.push(a)}};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    40
IriSP.textFieldHtml=function(a,e,g){function k(G,O,L){for(;;){var B=G.exec(j);if(!B)break;var r=G.lastIndex,x=B.index;l.push({start:x,end:r,startHtml:typeof O==="function"?O(B):O,endHtml:typeof L==="function"?L(B):L});f.push(x);f.push(r)}}var l=[],f=[],j=a.replace(/(^\s+|\s+$)/g,"");e&&k(e,'<span class="Ldt-Highlight">',"</span>");k(/(https?:\/\/)?[\w\d\-]+\.[\w\d\-]+\S+/gm,function(G){return'<a href="'+(G[1]?"":"http://")+G[0]+'" target="_blank">'},"</a>");k(/@([\d\w]{1,15})/gm,function(G){return'<a href="http://twitter.com/'+
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    41
G[1]+'" target="_blank">'},"</a>");k(/\*[^*]+\*/gm,"<b>","</b>");k(/[\n\r]+/gm,"","<br />");IriSP._(g).each(function(G){k.apply(null,G)});f=IriSP._(f).chain().uniq().sortBy(function(G){return parseInt(G)}).value();for(var i="",o=0,E=0;E<f.length;E++){var I=f[E];i+=j.substring(o,I);for(o=l.length-1;o>=0;o--){var v=l[o];if(v.start<I&&v.end>=I)i+=v.endHtml}for(o=0;o<l.length;o++){v=l[o];if(v.start<=I&&v.end>I)i+=v.startHtml}o=I}i+=j.substring(o);return i};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    42
IriSP.log=function(){typeof console!=="undefined"&&typeof IriSP.logging!=="undefined"&&IriSP.logging&&console.log.apply(console,arguments)};IriSP.attachDndData=function(a,e){a.attr("draggable","true").on("dragstart",function(g){var k=typeof e==="function"?e.call(this):e;try{IriSP._(k).each(function(f,j){f&&g.originalEvent.dataTransfer.setData("text/x-iri-"+j,f)})}catch(l){g.originalEvent.dataTransfer.setData("Text",JSON.stringify(k))}})};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    43
IriSP.FakeClass=function(a){var e=this,g=function(){};IriSP._(a).each(function(k){e[k]=g})};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    44
IriSP.Model=function(a){function e(b,c,d){d=d||10;for(c=c.toString(d);c.length<b;)c="0"+c;return c}function g(b){return e(b,Math.floor(Math.random()*Math.pow(16,b)),16)}var k=g(8)+"-"+g(4)+"-",l=Math.floor(Math.random()*65536),f=["[a\u00e1\u00e0\u00e2\u00e4]","[c\u00e7]","[e\u00e9\u00e8\u00ea\u00eb]","[i\u00ed\u00ec\u00ee\u00ef]","[o\u00f3\u00f2\u00f4\u00f6]","[u\u00f9\u00fb\u00fc]"],j=[String.fromCharCode(768),String.fromCharCode(769),String.fromCharCode(770),String.fromCharCode(771),String.fromCharCode(807),
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    45
"\uff5b","\uff5d","\uff08","\uff09","\uff3b","\uff3d","\u3010","\u3011","\u3001","\u30fb","\u2025","\u3002","\u300c","\u300d","\u300e","\u300f","\u301c","\uff1a","\uff01","\uff1f","\u3000",","," ",";","(",")",".","*","+","\\","?","|","{","}","[","]","^","#","/"],i={},o=i._SOURCE_STATUS_EMPTY=0,E=i._SOURCE_STATUS_WAITING=1,I=i._SOURCE_STATUS_READY=2,v=i.extendPrototype=function(b,c){var d=c.prototype,h=b.prototype;for(var m in d)if(d.hasOwnProperty(m))h[m]=d[m]},G=i.getUID=function(){return k+e(4,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    46
++l%65536,16)+"-"+g(4)+"-"+g(6)+g(6)},O=i.isLocalURL=function(b){if(b=b.match(/^(\w+:)\/\/([^/]+)/))return b[1]===document.location.protocol&&b[2]===document.location.host;return true},L=i.regexpFromTextOrArray=function(b,c,d){function h(s){return s.replace(/([\\\*\+\?\|\{\[\}\]\(\)\^\$\.\#\/])/gm,"\\$1")}c=c||false;d=d||false;var m=typeof b==="string"?h(b):a._(b).map(h).join("|"),w="im";if(!c){m="("+m+")";w+="g"}if(d)m="^"+m+"$";return RegExp(m,w)},B=i.fullTextRegexps=function(b){var c="[\\"+j.join("\\")+
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    47
"]",d=RegExp(c,"gm");d=b.toLowerCase().replace(d,"");for(var h=a._(f).map(function(A){return RegExp(A)}),m="",w=0;w<d.length;w++){if(w)m+=c+"*";var s=d[w];a._(f).each(function(A,H){s=s.replace(h[H],A)});m+=s}return"("+m+")"};i.isoToDate=function(b){var c=b.match(RegExp("([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?")),d=0,h=new Date(c[1],0,1);c[3]&&h.setMonth(c[3]-1);c[5]&&h.setDate(c[5]);c[7]&&h.setHours(c[7]);c[8]&&h.setMinutes(c[8]);
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    48
c[10]&&h.setSeconds(c[10]);c[12]&&h.setMilliseconds(Number("0."+c[12])*1E3);if(c[14]){d=Number(c[16])*60+Number(c[17]);d*=c[15]=="-"?1:-1}d-=h.getTimezoneOffset();time=Number(h)+d*60*1E3;var m=new Date;m.setTime(Number(time));return m};i.dateToIso=function(b){var c=b?new Date(b):new Date;return c.getUTCFullYear()+"-"+e(2,c.getUTCMonth()+1)+"-"+e(2,c.getUTCDate())+"T"+e(2,c.getUTCHours())+":"+e(2,c.getUTCMinutes())+":"+e(2,c.getUTCSeconds())+"Z"};var r=i.List=function(b){Array.call(this);this.directory=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    49
b;this.idIndex=[];this.__events={};if(typeof b=="undefined"){console.trace();throw"Error : new List(directory): directory is undefined";}var c=this;this.on("clear-search",function(){c.searching=false;c.regexp=undefined;c.forEach(function(d){d.found=undefined});c.trigger("search-cleared")})};r.prototype=[];r.prototype.hasId=function(b){return a._(this.idIndex).include(b)};if(typeof Array.prototype.forEach==="undefined")r.prototype.forEach=function(b){var c=this;a._(this).forEach(function(d,h){b(d,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    50
h,c)})};if(typeof Array.prototype.map==="undefined")r.prototype.map=function(b){var c=this;return a._(this).map(function(d,h){return b(d,h,c)})};r.prototype.pluck=function(b){return this.map(function(c){return c[b]})};r.prototype.filter=function(b){var c=this,d=new r(this.directory);d.addElements(a._(this).filter(function(h,m){return b(h,m,c)}));return d};r.prototype.slice=function(b,c){var d=new r(this.directory);d.addElements(Array.prototype.slice.call(this,b,c));return d};r.prototype.splice=function(b,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    51
c){var d=new r(this.directory);d.addElements(Array.prototype.splice.call(this,b,c));this.idIndex.splice(b,c);return d};r.prototype.sortBy=function(b){var c=this,d=new r(this.directory);d.addElements(a._(this).sortBy(function(h,m){return b(h,m,c)}));return d};r.prototype.searchByTitle=function(b,c){c=c||false;var d=L(b,true,c);return this.filter(function(h){return d.test(h.title)})};r.prototype.searchByDescription=function(b,c){c=c||false;var d=L(b,true,c);return this.filter(function(h){return d.test(h.description)})};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    52
r.prototype.searchByTextFields=function(b,c){c=c||false;var d=L(b,true,c);return this.filter(function(h){var m=(h.keywords||h.getTagTexts()||[]).join(", ");return d.test(h.description)||d.test(h.title)||d.test(m)})};r.prototype.search=function(b){if(!b){this.trigger("clear-search");return this}this.searching=true;this.trigger("search",b);var c=B(b),d=RegExp(c,"im");this.regexp=RegExp(c,"gim");c=this.filter(function(h){var m=d.test(h.title),w=d.test(h.description),s=!!(m||w);h.found=s;h.trigger(s?
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    53
"found":"not-found");return s});this.trigger(c.length?"found":"not-found",c);return c};r.prototype.searchByTags=function(b){if(!b){this.trigger("clear-search");return this}this.searching=true;this.trigger("search",b);var c=B(b),d=RegExp(c,"im");this.regexp=RegExp(c,"gim");c=this.filter(function(h){var m=d.test(h.getTagTexts());h.found=m;h.trigger(m?"found":"not-found");return m});this.trigger(c.length?"found":"not-found",c);return c};r.prototype.getTitles=function(){return this.map(function(b){return b.title})};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    54
r.prototype.addId=function(b){var c=this.directory.getElement(b);if(!this.hasId(b)&&typeof c!=="undefined"){this.idIndex.push(b);Array.prototype.push.call(this,c)}};r.prototype.push=function(b){if(typeof b!=="undefined"){var c=a._(this.idIndex).indexOf(b.id);if(c===-1){this.idIndex.push(b.id);Array.prototype.push.call(this,b)}else this[c]=b}};r.prototype.addIds=function(b){var c=this;a._(b).forEach(function(d){c.addId(d)})};r.prototype.addElements=function(b){var c=this;a._(b).forEach(function(d){c.push(d)})};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    55
r.prototype.removeId=function(b,c){c=c||false;var d=a._(this.idIndex).indexOf(b);d!==-1&&this.splice(d,1);c&&delete this.directory.elements[b]};r.prototype.removeElement=function(b,c){c=c||false;this.removeId(b.id)};r.prototype.removeIds=function(b,c){c=c||false;var d=this;a._(b).forEach(function(h){d.removeId(h)})};r.prototype.removeElements=function(b,c){c=c||false;var d=this;a._(b).forEach(function(h){d.removeElement(h)})};r.prototype.on=function(b,c){if(typeof this.__events[b]==="undefined")this.__events[b]=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    56
[];this.__events[b].push(c)};r.prototype.off=function(b,c){if(typeof this.__events[b]!=="undefined")this.__events[b]=a._(this.__events[b]).reject(function(d){return d===c})};r.prototype.trigger=function(b,c){var d=this;a._(this.__events[b]).each(function(h){h.call(d,c)})};var x=i.Time=function(b){this.milliseconds=0;this.setMilliseconds(b)};x.prototype.setMilliseconds=function(b){var c=this.milliseconds;switch(typeof b){case "string":this.milliseconds=parseInt(b);break;case "number":this.milliseconds=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    57
Math.floor(b);break;case "object":this.milliseconds=parseInt(b.valueOf());break;default:this.milliseconds=0}if(this.milliseconds===NaN)this.milliseconds=c};x.prototype.setSeconds=function(b){this.milliseconds=1E3*b};x.prototype.getSeconds=function(){return this.milliseconds/1E3};x.prototype.getHMS=function(){var b=Math.abs(Math.floor(this.getSeconds()));return{hours:Math.floor(b/3600),minutes:Math.floor(b/60)%60,seconds:b%60,milliseconds:this.milliseconds%1E3}};x.prototype.add=function(b){this.milliseconds+=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    58
(new x(b)).milliseconds};x.prototype.valueOf=function(){return this.milliseconds};x.prototype.toString=function(b){var c=this.getHMS(),d="";if(c.hours)d+=c.hours+":";d+=e(2,c.minutes)+":"+e(2,c.seconds);if(b)d+="."+Math.floor(c.milliseconds/100);return d};var P=i.Reference=function(b,c){this.source=b;this.id=c;this.isList=typeof c==="object"?true:false;this.refresh()};P.prototype.refresh=function(){if(this.isList){this.contents=new r(this.source.directory);this.contents.addIds(this.id)}else this.contents=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    59
this.source.getElement(this.id)};P.prototype.getContents=function(){if(typeof this.contents==="undefined"||this.isList&&this.contents.length!=this.id.length)this.refresh();return this.contents};P.prototype.isOrHasId=function(b){return this.isList?a._(this.id).indexOf(b)!==-1:this.id==b};var z=i.Element=function(b,c){this.elementType="element";this.description=this.title="";this.__events={};if(typeof c!=="undefined"){if(typeof b==="undefined"||!b)b=G();this.id=b;this.source=c;c!==this&&this.source.directory.addElement(this)}};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    60
z.prototype.toString=function(){return this.elementType+(this.elementType!=="element"?", id="+this.id+', title="'+this.title+'"':"")};z.prototype.setReference=function(b,c){this[b]=new P(this.source,c)};z.prototype.getReference=function(b){if(typeof this[b]!=="undefined")return this[b].getContents()};z.prototype.getRelated=function(b,c){c=typeof c!=="undefined"&&c;var d=this;return this.source.getList(b,c).filter(function(h){var m=h[d.elementType];return m&&m.isOrHasId(d.id)})};z.prototype.on=function(b,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    61
c){if(typeof this.__events[b]==="undefined")this.__events[b]=[];this.__events[b].push(c)};z.prototype.off=function(b,c){if(typeof this.__events[b]!=="undefined")this.__events[b]=a._(this.__events[b]).reject(function(d){return d===c})};z.prototype.trigger=function(b,c){var d=this;a._(this.__events[b]).each(function(h){h.call(d,c)})};var C=i.Playable=function(b,c){z.call(this,b,c);if(typeof c!=="undefined"){this.elementType="playable";this.currentTime=new x;this.volume=0.5;this.paused=true;this.loadedMetadata=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    62
this.muted=false;var d=this;this.on("play",function(){d.paused=false});this.on("pause",function(){d.paused=true});this.on("timeupdate",function(h){d.currentTime=h;d.getAnnotations().filter(function(m){return(m.end<=h||m.begin>h)&&m.playing}).forEach(function(m){m.playing=false;m.trigger("leave");d.trigger("leave-annotation",m)});d.getAnnotations().filter(function(m){return m.begin<=h&&m.end>h&&!m.playing}).forEach(function(m){m.playing=true;m.trigger("enter");d.trigger("enter-annotation",m)})});this.on("loadedmetadata",
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    63
function(){d.loadedMetadata=true})}};v(C,z);C.prototype.getCurrentTime=function(){return this.currentTime};C.prototype.getVolume=function(){return this.volume};C.prototype.getPaused=function(){return this.paused};C.prototype.getMuted=function(){return this.muted};C.prototype.setCurrentTime=function(b){this.trigger("setcurrenttime",b)};C.prototype.setVolume=function(b){this.trigger("setvolume",b)};C.prototype.setMuted=function(b){this.trigger("setmuted",b)};C.prototype.play=function(){this.trigger("setplay")};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    64
C.prototype.pause=function(){this.trigger("setpause")};C.prototype.show=function(){};C.prototype.hide=function(){};var q=i.Media=function(b,c){C.call(this,b,c);this.elementType="media";this.duration=new x;this.video=""};v(q,C);q.prototype.setDuration=function(b){this.duration.setMilliseconds(b)};q.prototype.getAnnotations=function(){return this.getRelated("annotation")};q.prototype.getAnnotationsByTypeTitle=function(b){var c=this.source.getAnnotationTypes().searchByTitle(b).pluck("id");return c.length?
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    65
this.getAnnotations().filter(function(d){return a._(c).indexOf(d.getAnnotationType().id)!==-1}):new r(this.source.directory)};q=i.Tag=function(b,c){z.call(this,b,c);this.elementType="tag"};v(q,z);q.prototype.getAnnotations=function(){return this.getRelated("annotation")};q=i.AnnotationType=function(b,c){z.call(this,b,c);this.elementType="annotationType"};v(q,z);q.prototype.getAnnotations=function(){return this.getRelated("annotation")};q=i.Annotation=function(b,c){z.call(this,b,c);this.elementType=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    66
"annotation";this.begin=new x;this.end=new x;this.tag=new P(c,[]);this.playing=false;var d=this;this.on("click",function(){d.getMedia().setCurrentTime(d.begin)})};v(q,z);q.prototype.setBegin=function(b){this.begin.setMilliseconds(Math.max(0,b));this.trigger("change-begin");this.end<this.begin&&this.setEnd(this.begin)};q.prototype.setEnd=function(b){this.end.setMilliseconds(Math.min(b,this.getMedia().duration.milliseconds));this.trigger("change-end");this.end<this.begin&&this.setBegin(this.end)};q.prototype.setDuration=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    67
function(b){this.setEnd(b+this.begin.milliseconds)};q.prototype.setMedia=function(b){this.setReference("media",b)};q.prototype.getMedia=function(){return this.getReference("media")};q.prototype.setAnnotationType=function(b){this.setReference("annotationType",b)};q.prototype.getAnnotationType=function(){return this.getReference("annotationType")};q.prototype.setTags=function(b){this.setReference("tag",b)};q.prototype.getTags=function(){return this.getReference("tag")};q.prototype.getTagTexts=function(){return this.getTags().getTitles()};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    68
q.prototype.getDuration=function(){return new x(this.end.milliseconds-this.begin.milliseconds)};var n=i.MashedAnnotation=function(b,c){z.call(this,b.id+"_"+c.id,c.source);this.elementType="mashedAnnotation";this.annotation=c;this.begin=new x;this.end=new x;this.duration=new x;this.title=this.annotation.title;this.description=this.annotation.description;this.color=this.annotation.color;var d=this;this.on("click",function(){b.setCurrentTime(d.begin)});this.on("enter",function(){d.annotation.trigger("enter")});
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    69
this.on("leave",function(){d.annotation.trigger("leave")})};v(n,z);n.prototype.getMedia=function(){return this.annotation.getReference("media")};n.prototype.getAnnotationType=function(){return this.annotation.getReference("annotationType")};n.prototype.getTags=function(){return this.annotation.getReference("tag")};n.prototype.getTagTexts=function(){return this.annotation.getTags().getTitles()};n.prototype.getDuration=function(){return this.annotation.getDuration()};n.prototype.setBegin=function(b){this.begin.setMilliseconds(b);
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    70
this.duration.setMilliseconds(this.annotation.getDuration());this.end.setMilliseconds(b+this.duration)};q=i.Mashup=function(b,c){C.call(this,b,c);this.elementType="mashup";this.duration=new x;this.segments=new r(c.directory);this.loaded=false;var d=this;this._updateTimes=function(){d.updateTimes();d.trigger("change")};this.on("add",this._updateTimes);this.on("remove",this._updateTimes)};v(q,C);q.prototype.updateTimes=function(){var b=0;this.segments.forEach(function(c){c.setBegin(b);b=c.end});this.duration.setMilliseconds(b)};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    71
q.prototype.addAnnotation=function(b,c){var d=new n(this,b);c=c||false;this.segments.push(d);b.on("change-begin",this._updateTimes);b.on("change-end",this._updateTimes);c||this.trigger("add")};q.prototype.addAnnotationById=function(b,c){var d=this.source.getElement(b);c=c||false;typeof d!=="undefined"&&this.addAnnotation(d,c)};q.prototype.addAnnotations=function(b){var c=this;a._(b).forEach(function(d){c.addAnnotation(d,true)});this.trigger("add")};q.prototype.addAnnotationsById=function(b){var c=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    72
this;a._(b).forEach(function(d){c.addAnnotationById(d,true)});this.trigger("add")};q.prototype.removeAnnotation=function(b,c){c=c||false;b.off("change-begin",this._updateTimes);b.off("change-end",this._updateTimes);this.segments.removeId(this.id+"_"+b.id);c||this.trigger("remove")};q.prototype.removeAnnotationById=function(b,c){c=c||false;var d=this.source.getElement(b);d&&this.removeAnnotation(d,c);c||this.trigger("remove")};q.prototype.setAnnotations=function(b){for(;this.segments.length;)this.removeAnnotation(this.segments[0].annotation,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    73
true);this.addAnnotations(b)};q.prototype.setAnnotationsById=function(b){for(;this.segments.length;)this.removeAnnotation(this.segments[0].annotation,true);this.addAnnotationsById(b)};q.prototype.hasAnnotation=function(b){return!!a._(this.segments).find(function(c){return c.annotation===b})};q.prototype.getAnnotation=function(b){return a._(this.segments).find(function(c){return c.annotation===b})};q.prototype.getAnnotationById=function(b){return a._(this.segments).find(function(c){return c.annotation.id===
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    74
b})};q.prototype.getAnnotations=function(){return this.segments};q.prototype.getOriginalAnnotations=function(){var b=new r(this.source.directory);this.segments.forEach(function(c){b.push(c.annotation)});return b};q.prototype.getMedias=function(){var b=new r(this.source.directory);this.segments.forEach(function(c){b.push(c.getMedia())});return b};q.prototype.getAnnotationsByTypeTitle=function(b){var c=this.source.getAnnotationTypes().searchByTitle(b).pluck("id");return c.length?this.getAnnotations().filter(function(d){return a._(c).indexOf(d.getAnnotationType().id)!==
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    75
-1}):new r(this.source.directory)};q.prototype.getAnnotationAtTime=function(b){var c=this.segments.filter(function(d){return d.begin<=b&&d.end>b});if(c.length)return c[0]};q.prototype.getMediaAtTime=function(b){var c=this.getAnnotationAtTime(b);if(typeof c!=="undefined")return c.getMedia()};var p=i.Source=function(b){z.call(this,false,this);this.status=o;this.elementType="source";if(typeof b!=="undefined"){var c=this;a._(b).forEach(function(d,h){c[h]=d});this.callbackQueue=[];this.contents={};this.get()}};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    76
v(p,z);p.prototype.addList=function(b,c){if(typeof this.contents[b]==="undefined")this.contents[b]=new r(this.directory);this.contents[b].addElements(c)};p.prototype.getList=function(b,c){if(c=typeof c!=="undefined"&&c)return this.directory.getGlobalList().filter(function(d){return d.elementType===b});else{if(typeof this.contents[b]==="undefined")this.contents[b]=new r(this.directory);return this.contents[b]}};p.prototype.forEach=function(b){var c=this;a._(this.contents).forEach(function(d,h){b.call(c,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    77
d,h)})};p.prototype.getElement=function(b){return this.directory.getElement(b)};p.prototype.get=function(){this.status=E;this.handleCallbacks()};p.prototype.deferCallback=function(b){var c=this;a._.defer(function(){b.call(c)})};p.prototype.handleCallbacks=function(){for(this.status=I;this.callbackQueue.length;)this.deferCallback(this.callbackQueue.splice(0,1)[0])};p.prototype.onLoad=function(b){this.status===I?this.deferCallback(b):this.callbackQueue.push(b)};p.prototype.serialize=function(){return this.serializer.serialize(this)};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    78
p.prototype.deSerialize=function(b){this.serializer.deSerialize(b,this)};p.prototype.getAnnotations=function(b){b=typeof b!=="undefined"&&b;return this.getList("annotation",b)};p.prototype.getMedias=function(b){b=typeof b!=="undefined"&&b;return this.getList("media",b)};p.prototype.getTags=function(b){b=typeof b!=="undefined"&&b;return this.getList("tag",b)};p.prototype.getMashups=function(b){b=typeof b!=="undefined"&&b;return this.getList("mashup",b)};p.prototype.getAnnotationTypes=function(b){b=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    79
typeof b!=="undefined"&&b;return this.getList("annotationType",b)};p.prototype.getAnnotationsByTypeTitle=function(b,c){c=typeof c!=="undefined"&&c;var d=new r(this.directory),h=this.getAnnotationTypes(c).searchByTitle(b);h.forEach(function(m){d.addElements(m.getAnnotations(c))});return d};p.prototype.getDuration=function(){var b=this.currentMedia;if(typeof b!=="undefined")return this.currentMedia.duration};p.prototype.getCurrentMedia=function(b){if(typeof this.currentMedia==="undefined")if(b.is_mashup){var c=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    80
this.getMashups();if(c.length)this.currentMedia=c[0]}else{var d=this.getMedias();if(d.length)this.currentMedia=d[0]}return this.currentMedia};p.prototype.merge=function(b){var c=this;b.forEach(function(d,h){c.getList(h).addElements(d)})};var y=i.RemoteSource=function(b){p.call(this,b)};v(y,p);y.prototype.get=function(){this.status=E;var b=this,c=this.url_params||{},d=O(this.url)?"json":"jsonp";c.format=d;a.jQuery.ajax({url:this.url,dataType:d,data:c,traditional:true,success:function(h){b.deSerialize(h);
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    81
b.handleCallbacks()}})};v=i.Directory=function(){this.remoteSources={};this.elements={}};v.prototype.remoteSource=function(b){if(typeof b!=="object"||typeof b.url==="undefined")throw"Error : Directory.remoteSource(configuration): configuration.url is undefined";var c=a._({directory:this}).extend(b);c.url_params=c.url_params||{};var d=c.url+"?"+a.jQuery.param(c.url_params);if(typeof this.remoteSources[d]==="undefined")this.remoteSources[d]=new y(c);return this.remoteSources[d]};v.prototype.newLocalSource=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    82
function(b){var c=a._({directory:this}).extend(b),d=new p(c);return d};v.prototype.getElement=function(b){return this.elements[b]};v.prototype.addElement=function(b){this.elements[b.id]=b};v.prototype.getGlobalList=function(){var b=new r(this);b.addIds(a._(this.elements).keys());return b};return i}(IriSP);
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    83
IriSP.htmlPlayer=function(a,e,g){var k=g||{};g=k.video||a.video;if(typeof k.url_transform==="function")g=k.url_transform(g);var l=IriSP.jQuery("<video>");l.attr({width:k.width||undefined,height:k.height||undefined,controls:k.controls||undefined,autoplay:k.autostart||k.autoplay||undefined});if(typeof g==="string")l.attr("src",g);else for(k=0;k<g.length;k++){var f=IriSP.jQuery("<source>");f.attr({src:g[k].src,type:g[k].type});l.append(f)}e.html(l);var j=l[0];a.on("setcurrenttime",function(i){try{j.currentTime=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    84
i/1E3}catch(o){}});a.on("setvolume",function(i){a.volume=i;try{j.volume=i}catch(o){}});a.on("setmuted",function(i){a.muted=i;try{j.muted=i}catch(o){}});a.on("setplay",function(){try{j.play()}catch(i){}});a.on("setpause",function(){try{j.pause()}catch(i){}});l.on("loadedmetadata",function(){a.muted=j.muted;a.volume=j.volume;a.trigger("loadedmetadata");a.trigger("volumechange")});l.on("timeupdate",function(){a.trigger("timeupdate",new IriSP.Model.Time(1E3*j.currentTime))});l.on("volumechange",function(){a.muted=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    85
j.muted;a.volume=j.volume;a.trigger("volumechange")});l.on("play",function(){a.trigger("play")});l.on("pause",function(){a.trigger("pause")});l.on("seeking",function(){a.trigger("seeking")});l.on("seeked",function(){a.trigger("seeked")})};if(typeof IriSP.serializers==="undefined")IriSP.serializers={};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    86
IriSP.serializers.content={deSerialize:function(a,e){function g(l,f){var j=new IriSP.Model.Media(l.iri_id,e);j.video=l.media_url;j.title=l.title;j.description=l.description;j.setDuration(l.duration);j.thumbnail=l.image;j.color=IriSP.vizcolors[f%IriSP.vizcolors.length];j.keywords=l.tags;k.push(j)}var k=new IriSP.Model.List(e.directory);typeof a.objects!=="undefined"?IriSP._(a.objects).each(g):g(a,0);e.addList("media",k)}};if(typeof IriSP.serializers==="undefined")IriSP.serializers={};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    87
IriSP.serializers.ldt={types:{media:{serialized_name:"medias",deserializer:function(a,e){var g=new IriSP.Model.Media(a.id,e);g.video=typeof a.url!=="undefined"?a.url:typeof a.href!=="undefined"?a.href:null;if(typeof a.meta.item!=="undefined"&&a.meta.item.name==="streamer")g.streamer=a.meta.item.value;g.title=a.meta["dc:title"];g.description=a.meta["dc:description"];g.setDuration(a.meta["dc:duration"]);g.url=a.meta.url;if(typeof a.meta.img!=="undefined"&&a.meta.img.src!=="undefined")g.thumbnail=a.meta.img.src;
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    88
return g},serializer:function(a,e,g){var k={id:a.id,url:a.video,meta:{"dc:title":a.title||"","dc:description":a.description||"","dc:created":IriSP.Model.dateToIso(a.created||e.created),"dc:modified":IriSP.Model.dateToIso(a.modified||e.modified),"dc:creator":a.creator||e.creator,"dc:contributor":a.contributor||e.contributor||a.creator||e.creator,"dc:duration":a.duration.milliseconds}};g.medias.push(k);var l={id:IriSP.Model.getUID(),meta:{"dc:title":a.title||"","dc:description":a.description||"","dc:created":IriSP.Model.dateToIso(a.created||
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    89
e.created),"dc:modified":IriSP.Model.dateToIso(a.modified||e.modified),"dc:creator":a.creator||e.creator,"dc:contributor":a.contributor||e.contributor||a.creator||e.creator,"id-ref":a.id},items:e.getAnnotationTypes().filter(function(f){switch(typeof f.media){case "object":return f.media===a;case "string":return f.media===a.id;default:var j=f.getAnnotations();if(j)for(var i=0;i<j.length;i++)if(j[i].getMedia()===a)return true}return false}).map(function(f){return{"id-ref":f.id}})};g.lists.push(l);g.views[0].contents.push(a.id)}},
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    90
tag:{serialized_name:"tags",deserializer:function(a,e){var g=new IriSP.Model.Tag(a.id,e);g.title=a.meta["dc:title"];return g},serializer:function(a,e,g){if(!(e.regenerateTags&&!a.regenerated)){var k={id:a.id,meta:{"dc:title":a.title||"","dc:description":a.description||"","dc:created":IriSP.Model.dateToIso(a.created||e.created),"dc:modified":IriSP.Model.dateToIso(a.modified||e.modified),"dc:creator":a.creator||e.creator,"dc:contributor":a.contributor||e.contributor||a.creator||e.creator}};g.tags.push(k)}}},
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    91
annotationType:{serialized_name:"annotation-types",deserializer:function(a,e){var g=new IriSP.Model.AnnotationType(a.id,e);g.title=a["dc:title"];g.description=a["dc:description"];return g},serializer:function(a,e,g){var k={id:a.id,"dc:title":a.title||"","dc:description":a.description||"","dc:created":IriSP.Model.dateToIso(a.created||e.created),"dc:modified":IriSP.Model.dateToIso(a.modified||e.modified),"dc:creator":a.creator||e.creator,"dc:contributor":a.contributor||e.contributor||a.creator||e.creator};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    92
g["annotation-types"].push(k);g.views[0].annotation_types.push(a.id)}},annotation:{serialized_name:"annotations",deserializer:function(a,e){var g=new IriSP.Model.Annotation(a.id,e);g.title=a.content.title||"";g.description=a.content.description||"";if(typeof a.content.img!=="undefined"&&a.content.img.src!=="undefined")g.thumbnail=a.content.img.src;g.created=IriSP.Model.isoToDate(a.meta["dc:created"]);if(typeof a.color!=="undefined"){for(var k=parseInt(a.color).toString(16);k.length<6;)k="0"+k;g.color=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    93
"#"+k}g.content=a.content;g.setMedia(a.media);g.setAnnotationType(a.meta["id-ref"]);g.setTags(IriSP._(a.tags).pluck("id-ref"));g.keywords=g.getTagTexts();g.setBegin(a.begin);g.setEnd(a.end);g.creator=a.meta["dc:creator"]||"";g.project=a.meta.project||"";if(typeof a.meta["dc:source"]!=="undefined"&&typeof a.meta["dc:source"].content!=="undefined")g.source=JSON.parse(a.meta["dc:source"].content);if(typeof a.content.audio!=="undefined"&&a.content.audio.href)g.audio=a.content.audio;return g},serializer:function(a,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    94
e,g){var k=parseInt(a.color.replace(/^#/,""),16).toString(),l={id:a.id,begin:a.begin.milliseconds,end:a.end.milliseconds,content:IriSP._.defaults({},{title:a.title,description:a.description,audio:a.audio,img:{src:a.thumbnail}},a.content,{title:"",description:""}),color:k,media:a.media.id,meta:{"id-ref":a.getAnnotationType().id,"dc:created":IriSP.Model.dateToIso(a.created||e.created),"dc:modified":IriSP.Model.dateToIso(a.modified||e.modified),"dc:creator":a.creator||e.creator,"dc:contributor":a.contributor||
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    95
e.contributor||a.creator||e.creator}};l.tags=e.regenerateTags?IriSP._(a.keywords).map(function(f){return{"id-ref":e.__keywords[f.toLowerCase()].id}}):IriSP._(a.tag.id).map(function(f){return{"id-ref":f}});l.content.title=a.title||l.content.title||"";g.annotations.push(l)}},mashup:{serialized_name:"lists",deserializer:function(a,e){if(!(typeof a.meta!=="object"||typeof a.meta.listtype!=="string"||a.meta.listtype!=="mashup")){var g=new IriSP.Model.Mashup(a.id,e);g.title=a.meta["dc:title"];g.description=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    96
a.meta["dc:description"];g.creator=a.meta["dc:creator"];g.setAnnotationsById(a.items);return g}},serializer:function(a,e,g){var k={meta:{"dc:title":a.title||"","dc:description":a.description||"","dc:created":IriSP.Model.dateToIso(a.created||e.created),"dc:modified":IriSP.Model.dateToIso(a.modified||e.modified),"dc:creator":a.creator||e.creator,"dc:contributor":a.contributor||e.contributor||a.creator||e.creator,listtype:"mashup"},items:a.segments.map(function(l){return l.annotation.id}),id:a.id};g.lists.push(k)}}},
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    97
serialize:function(a){var e={meta:{"dc:creator":a.creator,"dc:contributor":a.contributor||a.creator,"dc:created":IriSP.Model.dateToIso(a.created),"dc:modified":IriSP.Model.dateToIso(a.modified),"dc:title":a.title||"","dc:description":a.description||"",id:a.projectId||a.id},views:[{id:IriSP.Model.getUID(),contents:[],annotation_types:[]}],lists:[],"annotation-types":[],medias:[],tags:[],annotations:[]},g=this;if(a.regenerateTags){a.__keywords={};a.getAnnotations().forEach(function(k){IriSP._(k.keywords).each(function(l){var f=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    98
l.toLowerCase();if(typeof a.__keywords[f]==="undefined")a.__keywords[f]={id:IriSP.Model.getUID(),title:l,regenerated:true}})});IriSP._(a.__keywords).each(function(k){g.types.tag.serializer(k,a,e)})}a.forEach(function(k,l){typeof g.types[l]!=="undefined"&&k.forEach(function(f){g.types[l].serializer(f,a,e)})});return JSON.stringify(e)},deSerialize:function(a,e){if(!(typeof a!=="object"||a===null)){IriSP._(this.types).forEach(function(g,k){var l=a[g.serialized_name],f=new IriSP.Model.List(e.directory);
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    99
if(typeof l!=="undefined"&&l!==null)if(l.hasOwnProperty("length"))for(var j=l.length,i=0;i<j;i++){var o=g.deserializer(l[i],e);typeof o!=="undefined"&&o&&f.push(o)}else{o=g.deserializer(l,e);typeof o!=="undefined"&&o&&f.push(o)}e.addList(k,f)});if(typeof a.meta!=="undefined"){e.projectId=a.meta.id;e.title=a.meta["dc:title"]||a.meta.title||"";e.description=a.meta["dc:description"]||a.meta.description||"";e.creator=a.meta["dc:creator"]||a.meta.creator||"";e.contributor=a.meta["dc:contributor"]||a.meta.contributor||
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   100
e.creator;e.created=IriSP.Model.isoToDate(a.meta["dc:created"]||a.meta.created)}if(typeof a.meta!=="undefined"&&typeof a.meta.main_media!=="undefined"&&typeof a.meta.main_media["id-ref"]!=="undefined")e.currentMedia=e.getElement(a.meta.main_media["id-ref"])}}};if(typeof IriSP.serializers==="undefined")IriSP.serializers={};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   101
IriSP.serializers.ldt_annotate={serializeAnnotation:function(a){var e=a.getAnnotationType();return{begin:a.begin.milliseconds,end:a.end.milliseconds,content:{description:a.description,title:a.title,audio:a.audio},tags:a.getTagTexts(),media:a.getMedia().id,type_title:e.title,type:typeof e.dont_send_id!=="undefined"&&e.dont_send_id?"":e.id,meta:{created:a.created,creator:a.creator}}},deserializeAnnotation:function(a,e){var g=new IriSP.Model.Annotation(a.id,e);g.description=a.content.description||"";
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   102
g.title=a.content.title||"";g.creator=a.meta.creator||"";g.created=new Date(a.meta.created);g.setMedia(a.media,e);var k=e.getElement(a.type);if(!k){k=new IriSP.Model.AnnotationType(a.type,e);k.title=a.type_title;e.getAnnotationTypes().push(k)}g.setAnnotationType(k.id);var l=IriSP._(a.tags).map(function(f){var j=e.getTags(true).searchByTitle(f,true);if(j.length)var i=j[0];else{i=new IriSP.Model.Tag(f.replace(/\W/g,"_"),e);i.title=f;e.getTags().push(i)}return i.id});g.setTags(l);g.setBegin(a.begin);
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   103
g.setEnd(a.end);if(typeof a.content.audio!=="undefined"&&a.content.audio.href)g.audio=a.content.audio;e.getAnnotations().push(g)},serialize:function(a){return JSON.stringify(this.serializeAnnotation(a.getAnnotations()[0],a))},deSerialize:function(a,e){if(typeof a=="string")a=JSON.parse(a);e.addList("tag",new IriSP.Model.List(e.directory));e.addList("annotationType",new IriSP.Model.List(e.directory));e.addList("annotation",new IriSP.Model.List(e.directory));this.deserializeAnnotation(a,e)}};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   104
if(typeof IriSP.serializers==="undefined")IriSP.serializers={};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   105
IriSP.serializers.segmentapi={deSerialize:function(a,e){function g(f){var j=new IriSP.Model.Annotation(f.element_id,e),i=e.getElement(f.iri_id);if(!i){i=new IriSP.Model.Media(f.iri_id,e);e.getMedias().push(i)}j.setMedia(f.iri_id);j.title=f.title;j.description=f["abstract"];j.begin=new IriSP.Model.Time(f.start_ts);j.end=new IriSP.Model.Time(f.start_ts+f.duration);j.keywords=f.tags?f.tags.split(","):[];j.project_id=f.project_id;k.push(j)}var k=new IriSP.Model.List(e.directory),l=new IriSP.Model.List(e.directory);
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   106
e.addList("media",l);typeof a.objects!=="undefined"?IriSP._(a.objects).each(g):g(a);e.addList("annotation",k)}};IriSP.language="en";
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   107
IriSP.libFiles={defaultDir:"js/libs/",inDefaultDir:{underscore:"underscore-min.js",Mustache:"mustache.js",jQuery:"jquery.min.js",jQueryUI:"jquery-ui.min.js",swfObject:"swfobject.js",cssjQueryUI:"jquery-ui.css",popcorn:"popcorn-complete.min.js",jwplayer:"jwplayer.js",raphael:"raphael-min.js",tracemanager:"tracemanager.js",jwPlayerSWF:"player.swf",json:"json2.js",zeroClipboardJs:"ZeroClipboard.js",zeroClipboardSwf:"ZeroClipboard.swf",backbone:"backbone.js",backboneRelational:"backbone-relational.js",
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   108
paper:"paper.js",jqueryMousewheel:"jquery.mousewheel.min.js",renkanPublish:"renkan.js",processing:"processing-1.3.6.min.js",recordMicSwf:"record_mic.swf"},locations:{},cdn:{jQuery:"http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js",jQueryUI:"http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.min.js",swfObject:"http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",cssjQueryUI:"http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/themes/ui-lightness/jquery-ui.css",underscore:"http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js",
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   109
Mustache:"http://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.5.0-dev/mustache.min.js",raphael:"http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js",json:"http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js",popcorn:"http://cdn.popcornjs.org/code/dist/popcorn-complete.min.js"},useCdn:false};IriSP.widgetsDir="widgets";
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   110
IriSP.widgetsRequirements={PopcornPlayer:{noCss:true,requires:["popcorn"]},HtmlPlayer:{noCss:true},JwpPlayer:{noCss:true,requires:["jwplayer"]},DailymotionPlayer:{noCss:true,requires:["swfObject"]},AdaptivePlayer:{noCss:true},AutoPlayer:{noCss:true},AnnotationsList:{requires:["jwplayer"]},Sparkline:{noCss:true,requires:["raphael"]},Arrow:{noCss:true,requires:["raphael"]},Mediafragment:{noCss:true},Trace:{noCss:true,requires:["tracemanager"]},Slideshare:{requires:["swfObject"]},Social:{requires:["zeroClipboardJs"]},
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   111
Renkan:{requires:["backbone","backboneRelational","paper","jqueryMousewheel","renkanPublish"]},KnowledgeConcierge:{requires:["processing"]},MultiSegments:{noCss:true}};IriSP.guiDefaults={width:640,container:"LdtPlayer",spacer_div_height:0,widgets:[]};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   112
(function(a){var e,g,k,l=a.Metadataplayer=function(f){a.log("IriSP.Metadataplayer constructor");for(var j in a.guiDefaults)if(a.guiDefaults.hasOwnProperty(j)&&!f.hasOwnProperty(j))f[j]=a.guiDefaults[j];var i=document.getElementById(f.container);i.innerHTML='<h3 class="Ldt-Loader">Loading... Chargement...</h3>';this.sourceManager=new a.Model.Directory;this.config=f;this.__events={};this.loadLibs()};l.prototype.toString=function(){return"Metadataplayer in #"+this.config.container};l.prototype.on=function(f,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   113
j){if(typeof this.__events[f]==="undefined")this.__events[f]=[];this.__events[f].push(j)};l.prototype.trigger=function(f,j){var i=this;a._(this.__events[f]).each(function(o){o.call(i,j)})};l.prototype.loadLibs=function(){a.log("IriSP.Metadataplayer.prototype.loadLibs");var f=$LAB.script(a.getLib("Mustache"));e=!!window.jQuery;k=!!window.$;g=!!window._;typeof a.jQuery==="undefined"&&f.script(a.getLib("jQuery"));typeof a._==="undefined"&&f.script(a.getLib("underscore"));typeof window.JSON=="undefined"&&
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   114
f.script(a.getLib("json"));f.wait().script(a.getLib("jQueryUI"));for(var j=0;j<this.config.widgets.length;j++){var i=this.config.widgets[j].type;if(typeof a.widgetsRequirements[i]!=="undefined"&&typeof a.widgetsRequirements[i].requires!=="undefined")for(var o=0;o<a.widgetsRequirements[i].requires.length;o++)f.script(a.getLib(a.widgetsRequirements[i].requires[o]))}var E=this;f.wait(function(){E.onLibsLoaded()})};l.prototype.onLibsLoaded=function(){a.log("IriSP.Metadataplayer.prototype.onLibsLoaded");
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   115
if(typeof a.jQuery==="undefined"&&typeof window.jQuery!=="undefined"){a.jQuery=window.jQuery;if(k||e)window.jQuery.noConflict(e)}if(typeof a._==="undefined"&&typeof window._!=="undefined"){a._=window._;g&&_.noConflict()}a.loadCss(a.getLib("cssjQueryUI"));a.loadCss(this.config.css);this.$=a.jQuery("#"+this.config.container);this.$.css({width:this.config.width,clear:"both"});typeof this.config.height!=="undefined"&&this.$.css("height",this.config.height);this.widgets=[];var f=this;a._(this.config.widgets).each(function(j,
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   116
i){f.widgets.push(null);f.loadWidget(j,function(o){f.widgets[i]=o;o.isLoaded()&&f.trigger("widget-loaded")})});this.$.find(".Ldt-Loader").detach();this.widgetsLoaded=false;this.on("widget-loaded",function(){if(!f.widgetsLoaded)if(!a._(f.widgets).any(function(j){return!(j&&j.isLoaded())})){f.widgetsLoaded=true;f.trigger("widgets-loaded")}})};l.prototype.loadMetadata=function(f){if(f.elementType==="source")return f;if(typeof f.serializer==="undefined"&&typeof f.format!=="undefined")f.serializer=a.serializers[f.format];
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   117
return typeof f.url!=="undefined"&&typeof f.serializer!=="undefined"?this.sourceManager.remoteSource(f):this.sourceManager.newLocalSource(f)};l.prototype.loadWidget=function(f,j){if(typeof f.container==="undefined"){var i=this.layoutDivs(f.type);f.container=i[0]}var o=this;if(typeof a.Widgets[f.type]!=="undefined")a._.defer(function(){j(new a.Widgets[f.type](o,f))});else{if(typeof a.widgetsRequirements[f.type]==="undefined"||typeof a.widgetsRequirements[f.type].noCss==="undefined"||!a.widgetsRequirements[f.type].noCss)a.loadCss(a.widgetsDir+
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   118
"/"+f.type+".css");$LAB.script(a.widgetsDir+"/"+f.type+".js").wait(function(){j(new a.Widgets[f.type](o,f))})}};l.prototype.layoutDivs=function(f,j){if(typeof f==="undefined")f="";var i=a._.uniqueId(this.config.container+"_widget_"+f+"_"),o=a._.uniqueId("LdtPlayer_spacer_"),E=a.jQuery("<div>").attr("id",i).css({width:this.config.width+"px",position:"relative",clear:"both"}),I=a.jQuery("<div>").attr("id",o).css({width:this.config.width+"px",height:this.config.spacer_div_height+"px",position:"relative",
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   119
clear:"both"});typeof j!=="undefined"&&E.css("height",j);this.$.append(E);this.$.append(I);return[i,o]}})(IriSP);if(typeof IriSP.Widgets==="undefined")IriSP.Widgets={};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   120
IriSP.Widgets.Widget=function(a,e){function g(){if(f.media_id)f.media=this.getElement(f.media_id);else{var j={is_mashup:f.is_mashup||false};f.media=f.source.getCurrentMedia(j)}f.draw();f.player.trigger("widget-loaded")}if(typeof a!=="undefined"){this.__subwidgets=[];var k=e.type||"(unknown)",l=IriSP._.defaults({},e,a&&a.config?a.config.default_options:{},this.defaults),f=this;IriSP._(l).forEach(function(j,i){f[i]=j});this.$=IriSP.jQuery("#"+this.container);if(typeof this.width==="undefined")this.width=
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   121
this.$.width();else this.$.css("width",this.width);typeof this.height!=="undefined"&&this.$.css("height",this.height);this.player=a||new IriSP.FakeClass(["on","trigger","off","loadWidget","loadMetadata"]);this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type",k);this.l10n=typeof this.messages[IriSP.language]!=="undefined"?this.messages[IriSP.language]:IriSP.language.length>2&&typeof this.messages[IriSP.language.substr(0,2)]!=="undefined"?this.messages[IriSP.language.substr(0,2)]:this.messages.en;
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   122
if(this.metadata){this.source=a.loadMetadata(this.metadata);this.source.onLoad(g)}else this.source&&g()}};IriSP.Widgets.Widget.prototype.defaults={};IriSP.Widgets.Widget.prototype.template="";IriSP.Widgets.Widget.prototype.messages={en:{}};IriSP.Widgets.Widget.prototype.toString=function(){return"Widget "+this.type};IriSP.Widgets.Widget.prototype.templateToHtml=function(a){return Mustache.to_html(a,this)};IriSP.Widgets.Widget.prototype.renderTemplate=function(){this.$.append(this.templateToHtml(this.template))};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   123
IriSP.Widgets.Widget.prototype.functionWrapper=function(a){var e=this,g=this[a];if(typeof g!=="undefined")return function(){return g.apply(e,Array.prototype.slice.call(arguments,0))};else console.log("Error, Unknown function IriSP.Widgets."+this.type+"."+a)};IriSP.Widgets.Widget.prototype.getFunctionOrName=function(a){switch(typeof a){case "function":return a;case "string":return this.functionWrapper(a);default:return}};IriSP.Widgets.Widget.prototype.onMdpEvent=function(a,e){this.player.on(a,this.getFunctionOrName(e))};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   124
IriSP.Widgets.Widget.prototype.onMediaEvent=function(a,e){this.media.on(a,this.getFunctionOrName(e))};IriSP.Widgets.Widget.prototype.getWidgetAnnotations=function(){if(typeof this.annotation_type==="undefined")return this.media.getAnnotations();if(this.annotation_type.elementType==="annotationType")return this.annotation_type.getAnnotations();return this.media.getAnnotationsByTypeTitle(this.annotation_type)};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   125
IriSP.Widgets.Widget.prototype.getWidgetAnnotationsAtTime=function(){var a=this.media.getCurrentTime();return this.getWidgetAnnotations().filter(function(e){return e.begin<=a&&e.end>a})};IriSP.Widgets.Widget.prototype.isLoaded=function(){return!IriSP._(this.__subwidgets).any(function(a){return!(a&&a.isLoaded())})};
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   126
IriSP.Widgets.Widget.prototype.insertSubwidget=function(a,e,g){var k=a.attr("id"),l=this,f=e.type,j=$LAB,i=this.__subwidgets.length;this.__subwidgets.push(null);if(typeof k=="undefined"){k=IriSP._.uniqueId(this.container+"_sub_widget_"+e.type);a.attr("id",k)}e.container=k;if(typeof IriSP.widgetsRequirements[f]!=="undefined"&&typeof IriSP.widgetsRequirements[f].requires!=="undefined")for(var o=0;o<IriSP.widgetsRequirements[f].requires.length;o++)j.script(IriSP.getLib(IriSP.widgetsRequirements[f].requires[o]));
ff4b567d51f2 upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
   127
j.wait(function(){l.player.loadWidget(e,function(E){if(g)l[g]=E;l.__subwidgets[i]=E})})};IriSP.Widgets.Widget.prototype.draw=function(){};