| author | Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com> |
| Tue, 29 Dec 2015 13:25:14 +0100 | |
| changeset 1304 | 10974bff4dae |
| parent 1198 | ff4b567d51f2 |
| child 1308 | ef42d4f12cfc |
| permissions | -rw-r--r-- |
| 898 | 1 |
/*! LAB.js (LABjs :: Loading And Blocking JavaScript) |
2 |
v2.0.3 (c) Kyle Simpson |
|
3 |
MIT License |
|
4 |
*/ |
|
5 |
(function(o){var K=o.$LAB,y="UseLocalXHR",z="AlwaysPreserveOrder",u="AllowDuplicates",A="CacheBust",B="BasePath",C=/^[^?#]*\//.exec(location.href)[0],D=/^\w+\:\/\/\/?[^\/]+/.exec(C)[0],i=document.head||document.getElementsByTagName("head"),L=(o.opera&&Object.prototype.toString.call(o.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),q=document.createElement("script"),E=typeof q.preload=="boolean",r=E||(q.readyState&&q.readyState=="uninitialized"),F=!r&&q.async===true,M=!r&&!F&&!L;function G(a){return Object.prototype.toString.call(a)=="[object Function]"}function H(a){return Object.prototype.toString.call(a)=="[object Array]"}function N(a,c){var b=/^\w+\:\/\//;if(/^\/\/\/?/.test(a)){a=location.protocol+a}else if(!b.test(a)&&a.charAt(0)!="/"){a=(c||"")+a}return b.test(a)?a:((a.charAt(0)=="/"?D:C)+a)}function s(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function O(a){var c=false;for(var b=0;b<a.scripts.length;b++){if(a.scripts[b].ready&&a.scripts[b].exec_trigger){c=true;a.scripts[b].exec_trigger();a.scripts[b].exec_trigger=null}}return c}function t(a,c,b,d){a.onload=a.onreadystatechange=function(){if((a.readyState&&a.readyState!="complete"&&a.readyState!="loaded")||c[b])return;a.onload=a.onreadystatechange=null;d()}}function I(a){a.ready=a.finished=true;for(var c=0;c<a.finished_listeners.length;c++){a.finished_listeners[c]()}a.ready_listeners=[];a.finished_listeners=[]}function P(d,f,e,g,h){setTimeout(function(){var a,c=f.real_src,b;if("item"in i){if(!i[0]){setTimeout(arguments.callee,25);return}i=i[0]}a=document.createElement("script");if(f.type)a.type=f.type;if(f.charset)a.charset=f.charset;if(h){if(r){e.elem=a;if(E){a.preload=true;a.onpreload=g}else{a.onreadystatechange=function(){if(a.readyState=="loaded")g()}}a.src=c}else if(h&&c.indexOf(D)==0&&d[y]){b=new XMLHttpRequest();b.onreadystatechange=function(){if(b.readyState==4){b.onreadystatechange=function(){};e.text=b.responseText+"\n//@ sourceURL="+c;g()}};b.open("GET",c);b.send()}else{a.type="text/cache-script";t(a,e,"ready",function(){i.removeChild(a);g()});a.src=c;i.insertBefore(a,i.firstChild)}}else if(F){a.async=false;t(a,e,"finished",g);a.src=c;i.insertBefore(a,i.firstChild)}else{t(a,e,"finished",g);a.src=c;i.insertBefore(a,i.firstChild)}},0)}function J(){var l={},Q=r||M,n=[],p={},m;l[y]=true;l[z]=false;l[u]=false;l[A]=false;l[B]="";function R(a,c,b){var d;function f(){if(d!=null){d=null;I(b)}}if(p[c.src].finished)return;if(!a[u])p[c.src].finished=true;d=b.elem||document.createElement("script");if(c.type)d.type=c.type;if(c.charset)d.charset=c.charset;t(d,b,"finished",f);if(b.elem){b.elem=null}else if(b.text){d.onload=d.onreadystatechange=null;d.text=b.text}else{d.src=c.real_src}i.insertBefore(d,i.firstChild);if(b.text){f()}}function S(c,b,d,f){var e,g,h=function(){b.ready_cb(b,function(){R(c,b,e)})},j=function(){b.finished_cb(b,d)};b.src=N(b.src,c[B]);b.real_src=b.src+(c[A]?((/\?.*$/.test(b.src)?"&_":"?_")+~~(Math.random()*1E9)+"="):"");if(!p[b.src])p[b.src]={items:[],finished:false};g=p[b.src].items;if(c[u]||g.length==0){e=g[g.length]={ready:false,finished:false,ready_listeners:[h],finished_listeners:[j]};P(c,b,e,((f)?function(){e.ready=true;for(var a=0;a<e.ready_listeners.length;a++){e.ready_listeners[a]()}e.ready_listeners=[]}:function(){I(e)}),f)}else{e=g[0];if(e.finished){j()}else{e.finished_listeners.push(j)}}}function v(){var e,g=s(l,{}),h=[],j=0,w=false,k;function T(a,c){a.ready=true;a.exec_trigger=c;x()}function U(a,c){a.ready=a.finished=true;a.exec_trigger=null;for(var b=0;b<c.scripts.length;b++){if(!c.scripts[b].finished)return}c.finished=true;x()}function x(){while(j<h.length){if(G(h[j])){try{h[j++]()}catch(err){}continue}else if(!h[j].finished){if(O(h[j]))continue;break}j++}if(j==h.length){w=false;k=false}}function V(){if(!k||!k.scripts){h.push(k={scripts:[],finished:true})}}e={script:function(){for(var f=0;f<arguments.length;f++){(function(a,c){var b;if(!H(a)){c=[a]}for(var d=0;d<c.length;d++){V();a=c[d];if(G(a))a=a();if(!a)continue;if(H(a)){b=[].slice.call(a);b.unshift(d,1);[].splice.apply(c,b);d--;continue}if(typeof a=="string")a={src:a};a=s(a,{ready:false,ready_cb:T,finished:false,finished_cb:U});k.finished=false;k.scripts.push(a);S(g,a,k,(Q&&w));w=true;if(g[z])e.wait()}})(arguments[f],arguments[f])}return e},wait:function(){if(arguments.length>0){for(var a=0;a<arguments.length;a++){h.push(arguments[a])}k=h[h.length-1]}else k=false;x();return e}};return{script:e.script,wait:e.wait,setOptions:function(a){s(a,g);return e}}}m={setGlobalDefaults:function(a){s(a,l);return m},setOptions:function(){return v().setOptions.apply(null,arguments)},script:function(){return v().script.apply(null,arguments)},wait:function(){return v().wait.apply(null,arguments)},queueScript:function(){n[n.length]={type:"script",args:[].slice.call(arguments)};return m},queueWait:function(){n[n.length]={type:"wait",args:[].slice.call(arguments)};return m},runQueue:function(){var a=m,c=n.length,b=c,d;for(;--b>=0;){d=n.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){o.$LAB=K;return m},sandbox:function(){return J()}};return m}o.$LAB=J();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this); |
|
| 598 | 6 |
/* |
| 898 | 7 |
* |
8 |
__ __ _ _ _ _ |
|
9 |
| \/ | ___| |_ __ _ __| | __ _| |_ __ _ _ __ | | __ _ _ _ ___ _ __ |
|
10 |
| |\/| |/ _ \ __/ _` |/ _` |/ _` | __/ _` | '_ \| |/ _` | | | |/ _ \ '__| |
|
11 |
| | | | __/ || (_| | (_| | (_| | || (_| | |_) | | (_| | |_| | __/ | |
|
12 |
|_| |_|\___|\__\__,_|\__,_|\__,_|\__\__,_| .__/|_|\__,_|\__, |\___|_| |
|
13 |
|_| |___/ |
|
14 |
||
15 |
* Copyright 2010-2012 Institut de recherche et d'innovation |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
16 |
* contributor(s) : Karim Hamidou, Samuel Huron, Raphael Velt, Thibaut Cavalie, Yves-Marie Haussonne, Nicolas Durand, Olivier Aubert |
| 598 | 17 |
* |
18 |
* contact@iri.centrepompidou.fr |
|
19 |
* http://www.iri.centrepompidou.fr |
|
20 |
* |
|
21 |
* This software is a computer program whose purpose is to show and add annotations on a video . |
|
22 |
* This software is governed by the CeCILL-C license under French law and |
|
23 |
* abiding by the rules of distribution of free software. You can use, |
|
24 |
* modify and/ or redistribute the software under the terms of the CeCILL-C |
|
25 |
* license as circulated by CEA, CNRS and INRIA at the following URL |
|
26 |
* "http://www.cecill.info". |
|
27 |
* |
|
28 |
* The fact that you are presently reading this means that you have had |
|
29 |
* knowledge of the CeCILL-C license and that you accept its terms. |
|
30 |
*/ |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
31 |
// Metadataplayer - version 0.2 |
| 898 | 32 |
/* Initialization of the namespace */ |
| 598 | 33 |
|
34 |
if (typeof window.IriSP === "undefined") { |
|
| 940 | 35 |
window.IriSP = { |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
36 |
VERSION: "0.3.2" |
| 940 | 37 |
}; |
| 598 | 38 |
} |
39 |
||
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
40 |
if (typeof IriSP.jQuery === "undefined" && typeof window.jQuery !== "undefined") { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
41 |
var jvp = window.jQuery().jquery.split("."), |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
42 |
jv = 100 * parseInt(jvp[0]) + parseInt(jvp[1]); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
43 |
if (jv > 170) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
44 |
IriSP.jQuery = window.jQuery; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
45 |
} |
| 598 | 46 |
} |
47 |
||
| 898 | 48 |
if (typeof IriSP._ === "undefined" && typeof window._ !== "undefined" && parseFloat(window._.VERSION) >= 1.4) { |
49 |
IriSP._ = window._; |
|
| 598 | 50 |
} |
51 |
/* utils.js - various utils that don't belong anywhere else */ |
|
52 |
||
53 |
IriSP.jqEscape = function(_text) { |
|
| 623 | 54 |
return _text.replace(/(:|\.)/g,'\\$1'); |
| 898 | 55 |
}; |
| 598 | 56 |
|
57 |
IriSP.getLib = function(lib) { |
|
58 |
if (IriSP.libFiles.useCdn && typeof IriSP.libFiles.cdn[lib] == "string") { |
|
59 |
return IriSP.libFiles.cdn[lib]; |
|
60 |
} |
|
61 |
if (typeof IriSP.libFiles.locations[lib] == "string") { |
|
62 |
return IriSP.libFiles.locations[lib]; |
|
63 |
} |
|
64 |
if (typeof IriSP.libFiles.inDefaultDir[lib] == "string") { |
|
65 |
return IriSP.libFiles.defaultDir + '/' + IriSP.libFiles.inDefaultDir[lib]; |
|
66 |
} |
|
| 955 | 67 |
}; |
| 598 | 68 |
|
| 623 | 69 |
IriSP._cssCache = []; |
70 |
||
| 598 | 71 |
IriSP.loadCss = function(_cssFile) { |
| 623 | 72 |
if (IriSP._(IriSP._cssCache).indexOf(_cssFile) === -1) { |
73 |
IriSP.jQuery("<link>", { |
|
74 |
rel : "stylesheet", |
|
75 |
type : "text/css", |
|
76 |
href : _cssFile |
|
77 |
}).appendTo('head'); |
|
78 |
IriSP._cssCache.push(_cssFile); |
|
79 |
} |
|
| 898 | 80 |
}; |
| 623 | 81 |
|
| 778 | 82 |
IriSP.textFieldHtml = function(_text, _regexp, _extend) { |
83 |
var list = [], |
|
84 |
positions = [], |
|
85 |
text = _text.replace(/(^\s+|\s+$)/g,''); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
86 |
|
| 778 | 87 |
function addToList(_rx, _startHtml, _endHtml) { |
88 |
while(true) { |
|
89 |
var result = _rx.exec(text); |
|
90 |
if (!result) { |
|
91 |
break; |
|
92 |
} |
|
93 |
var end = _rx.lastIndex, |
|
94 |
start = result.index; |
|
95 |
list.push({ |
|
96 |
start: start, |
|
97 |
end: end, |
|
98 |
startHtml: (typeof _startHtml === "function" ? _startHtml(result) : _startHtml), |
|
99 |
endHtml: (typeof _endHtml === "function" ? _endHtml(result) : _endHtml) |
|
100 |
}); |
|
101 |
positions.push(start); |
|
102 |
positions.push(end); |
|
103 |
} |
|
104 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
105 |
|
| 778 | 106 |
if (_regexp) { |
107 |
addToList(_regexp, '<span class="Ldt-Highlight">', '</span>'); |
|
108 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
109 |
|
| 940 | 110 |
addToList(/(https?:\/\/)?[\w\d\-]+\.[\w\d\-]+\S+/gm, function(matches) { |
| 955 | 111 |
return '<a href="' + (matches[1] ? '' : 'http://') + matches[0] + '" target="_blank">'; |
| 778 | 112 |
}, '</a>'); |
113 |
addToList(/@([\d\w]{1,15})/gm, function(matches) { |
|
| 955 | 114 |
return '<a href="http://twitter.com/' + matches[1] + '" target="_blank">'; |
| 778 | 115 |
}, '</a>'); |
116 |
addToList(/\*[^*]+\*/gm, '<b>', '</b>'); |
|
117 |
addToList(/[\n\r]+/gm, '', '<br />'); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
118 |
|
| 778 | 119 |
IriSP._(_extend).each(function(x) { |
120 |
addToList.apply(null, x); |
|
121 |
}); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
122 |
|
| 778 | 123 |
positions = IriSP._(positions) |
124 |
.chain() |
|
125 |
.uniq() |
|
| 955 | 126 |
.sortBy(function(p) { return parseInt(p); }) |
| 778 | 127 |
.value(); |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
128 |
|
| 778 | 129 |
var res = "", lastIndex = 0; |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
130 |
|
| 778 | 131 |
for (var i = 0; i < positions.length; i++) { |
132 |
var pos = positions[i]; |
|
133 |
res += text.substring(lastIndex, pos); |
|
134 |
for (var j = list.length - 1; j >= 0; j--) { |
|
135 |
var item = list[j]; |
|
136 |
if (item.start < pos && item.end >= pos) { |
|
137 |
res += item.endHtml; |
|
138 |
} |
|
139 |
} |
|
140 |
for (var j = 0; j < list.length; j++) { |
|
141 |
var item = list[j]; |
|
142 |
if (item.start <= pos && item.end > pos) { |
|
143 |
res += item.startHtml; |
|
144 |
} |
|
145 |
} |
|
146 |
lastIndex = pos; |
|
147 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
148 |
|
| 778 | 149 |
res += text.substring(lastIndex); |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
150 |
|
| 778 | 151 |
return res; |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
152 |
|
| 898 | 153 |
}; |
| 778 | 154 |
|
| 623 | 155 |
IriSP.log = function() { |
156 |
if (typeof console !== "undefined" && typeof IriSP.logging !== "undefined" && IriSP.logging) { |
|
157 |
console.log.apply(console, arguments); |
|
158 |
} |
|
| 898 | 159 |
}; |
| 828 | 160 |
|
161 |
IriSP.attachDndData = function(jqSel, data) { |
|
162 |
jqSel.attr("draggable", "true").on("dragstart", function(_event) { |
|
163 |
var d = (typeof data === "function" ? data.call(this) : data); |
|
164 |
try { |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
165 |
if (d.html === undefined && d.uri && d.text) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
166 |
d.html = '<a href="' + d.uri + '">' + d.text + '</a>'; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
167 |
} |
| 828 | 168 |
IriSP._(d).each(function(v, k) { |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
169 |
if (v && k != 'text' && k != 'html') { |
| 828 | 170 |
_event.originalEvent.dataTransfer.setData("text/x-iri-" + k, v); |
171 |
} |
|
172 |
}); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
173 |
if (d.uri && d.text) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
174 |
_event.originalEvent.dataTransfer.setData("text/x-moz-url", d.uri + "\n" + d.text.replace("\n", " ")); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
175 |
_event.originalEvent.dataTransfer.setData("text/plain", d.text + " " + d.uri); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
176 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
177 |
// Define generic text/html and text/plain last (least |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
178 |
// specific types, see |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
179 |
// https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Drag_operations#Drag_Data) |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
180 |
if (d.html !== undefined) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
181 |
_event.originalEvent.dataTransfer.setData("text/html", d.html); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
182 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
183 |
if (d.text !== undefined && ! d.uri) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
184 |
_event.originalEvent.dataTransfer.setData("text/plain", d.text); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
185 |
} |
| 828 | 186 |
} catch(err) { |
187 |
_event.originalEvent.dataTransfer.setData("Text", JSON.stringify(d)); |
|
188 |
} |
|
189 |
}); |
|
| 898 | 190 |
}; |
| 638 | 191 |
|
| 940 | 192 |
IriSP.FakeClass = function(properties) { |
193 |
var _this = this, |
|
194 |
noop = (function() {}); |
|
195 |
IriSP._(properties).each(function(p) { |
|
| 955 | 196 |
_this[p] = noop; |
| 940 | 197 |
}); |
| 955 | 198 |
}; |
| 940 | 199 |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
200 |
IriSP.timestamp2ms = function(t) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
201 |
// Convert timestamp to numeric value |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
202 |
// It accepts the following forms: |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
203 |
// [h:mm:ss] [mm:ss] [ss] |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
204 |
var s = t.split(":").reverse(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
205 |
while (s.length < 3) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
206 |
s.push("0"); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
207 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
208 |
return 1000 * (3600 * parseInt(s[2], 10) + 60 * parseInt(s[1], 10) + parseInt(s[0], 10)); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
209 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
210 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
211 |
IriSP.setFullScreen= function(elem, value) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
212 |
// Set fullscreen on or off |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
213 |
if (value) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
214 |
if (elem.requestFullscreen) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
215 |
elem.requestFullscreen(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
216 |
} else if (elem.mozRequestFullScreen) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
217 |
elem.mozRequestFullScreen(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
218 |
} else if (elem.webkitRequestFullscreen) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
219 |
elem.webkitRequestFullscreen(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
220 |
} else if (elem.msRequestFullscreen) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
221 |
elem.msRequestFullscreen(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
222 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
223 |
} else { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
224 |
if (document.exitFullscreen) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
225 |
document.exitFullscreen(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
226 |
} else if (document.msExitFullscreen) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
227 |
document.msExitFullscreen(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
228 |
} else if (document.mozCancelFullScreen) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
229 |
document.mozCancelFullScreen(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
230 |
} else if (document.webkitExitFullscreen) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
231 |
document.webkitExitFullscreen(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
232 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
233 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
234 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
235 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
236 |
IriSP.isFullscreen = function() { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
237 |
return (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
238 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
239 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
240 |
IriSP.getFullscreenElement = function () { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
241 |
return (document.fullscreenElement |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
242 |
|| document.webkitFullscreenElement |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
243 |
|| document.mozFullScreenElement |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
244 |
|| document.msFullscreenElement |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
245 |
|| undefined); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
246 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
247 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
248 |
IriSP.getFullscreenEventname = function () { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
249 |
return ((document.exitFullscreen && "fullscreenchange") |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
250 |
|| (document.webkitExitFullscreen && "webkitfullscreenchange") |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
251 |
|| (document.mozExitFullScreen && "mozfullscreenchange") |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
252 |
|| (document.msExitFullscreen && "msfullscreenchange") |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
253 |
|| ""); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
254 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
255 |
|
| 898 | 256 |
/* js is where data is stored in a standard form, whatever the serializer */ |
257 |
||
258 |
//TODO: Separate Project-specific data from Source |
|
259 |
||
| 719 | 260 |
IriSP.Model = (function (ns) { |
261 |
|
|
262 |
function pad(n, x, b) { |
|
263 |
b = b || 10; |
|
264 |
var s = (x).toString(b); |
|
265 |
while (s.length < n) { |
|
266 |
s = "0" + s; |
|
267 |
} |
|
268 |
return s; |
|
269 |
} |
|
270 |
|
|
271 |
function rand16(n) { |
|
272 |
return pad(n, Math.floor(Math.random()*Math.pow(16,n)), 16); |
|
273 |
} |
|
274 |
|
|
275 |
var uidbase = rand16(8) + "-" + rand16(4) + "-", uidincrement = Math.floor(Math.random()*0x10000); |
|
276 |
|
|
277 |
var charsub = [ |
|
| 778 | 278 |
'[aáàâä]', |
279 |
'[cç]', |
|
280 |
'[eéèêë]', |
|
281 |
'[iíìîï]', |
|
282 |
'[oóòôö]', |
|
283 |
'[uùûü]' |
|
| 719 | 284 |
]; |
285 |
|
|
286 |
var removeChars = [ |
|
287 |
String.fromCharCode(768), String.fromCharCode(769), String.fromCharCode(770), String.fromCharCode(771), String.fromCharCode(807), |
|
288 |
"{", "}", "(", ")", "[", "]", "【", "】", "、", "・", "‥", "。", "「", "」", "『", "』", "〜", ":", "!", "?", " ", |
|
289 |
",", " ", ";", "(", ")", ".", "*", "+", "\\", "?", "|", "{", "}", "[", "]", "^", "#", "/" |
|
| 898 | 290 |
]; |
| 719 | 291 |
|
| 898 | 292 |
var Model = {}, |
293 |
_SOURCE_STATUS_EMPTY = Model._SOURCE_STATUS_EMPTY = 0, |
|
294 |
_SOURCE_STATUS_WAITING = Model._SOURCE_STATUS_WAITING = 1, |
|
295 |
_SOURCE_STATUS_READY = Model._SOURCE_STATUS_READY = 2, |
|
296 |
extendPrototype = Model.extendPrototype = function(toClass, fromClass) { |
|
297 |
var fromP = fromClass.prototype, |
|
298 |
toP = toClass.prototype; |
|
299 |
for (var k in fromP) { |
|
300 |
if (fromP.hasOwnProperty(k)) { |
|
301 |
toP[k] = fromP[k]; |
|
302 |
} |
|
303 |
} |
|
304 |
}, |
|
305 |
getUID = Model.getUID = function() { |
|
| 719 | 306 |
return uidbase + pad(4, (++uidincrement % 0x10000), 16) + "-" + rand16(4) + "-" + rand16(6) + rand16(6); |
307 |
}, |
|
| 898 | 308 |
isLocalURL = Model.isLocalURL = function(url) { |
| 719 | 309 |
var matches = url.match(/^(\w+:)\/\/([^/]+)/); |
310 |
if (matches) { |
|
| 955 | 311 |
return(matches[1] === document.location.protocol && matches[2] === document.location.host); |
| 638 | 312 |
} |
| 719 | 313 |
return true; |
| 598 | 314 |
}, |
| 898 | 315 |
regexpFromTextOrArray = Model.regexpFromTextOrArray = function(_textOrArray, _testOnly, _iexact) { |
| 719 | 316 |
var _testOnly = _testOnly || false, |
317 |
_iexact = _iexact || false; |
|
| 598 | 318 |
function escapeText(_text) { |
319 |
return _text.replace(/([\\\*\+\?\|\{\[\}\]\(\)\^\$\.\#\/])/gm, '\\$1'); |
|
320 |
} |
|
|
654
a5977736d2b0
Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
321 |
var _source = |
|
a5977736d2b0
Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
322 |
typeof _textOrArray === "string" |
|
a5977736d2b0
Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
323 |
? escapeText(_textOrArray) |
| 719 | 324 |
: ns._(_textOrArray).map(escapeText).join("|"), |
325 |
_flags = 'im'; |
|
326 |
if (!_testOnly) { |
|
327 |
_source = '(' + _source + ')'; |
|
328 |
_flags += 'g'; |
|
329 |
} |
|
330 |
if (_iexact) { |
|
331 |
_source = '^' + _source + '$'; |
|
|
654
a5977736d2b0
Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
652
diff
changeset
|
332 |
} |
| 719 | 333 |
return new RegExp( _source, _flags); |
334 |
}, |
|
| 898 | 335 |
fullTextRegexps = Model.fullTextRegexps = function(_text) { |
| 719 | 336 |
var remsrc = "[\\" + removeChars.join("\\") + "]", |
337 |
remrx = new RegExp(remsrc,"gm"), |
|
| 955 | 338 |
txt = _text.toLowerCase().replace(remrx,""), |
| 719 | 339 |
res = [], |
| 778 | 340 |
charsrx = ns._(charsub).map(function(c) { |
| 719 | 341 |
return new RegExp(c); |
342 |
}), |
|
343 |
src = ""; |
|
344 |
for (var j = 0; j < txt.length; j++) { |
|
345 |
if (j) { |
|
346 |
src += remsrc + "*"; |
|
347 |
} |
|
348 |
var l = txt[j]; |
|
| 778 | 349 |
ns._(charsub).each(function(v, k) { |
| 719 | 350 |
l = l.replace(charsrx[k], v); |
351 |
}); |
|
352 |
src += l; |
|
353 |
} |
|
354 |
return "(" + src + ")"; |
|
| 598 | 355 |
}, |
| 898 | 356 |
isoToDate = Model.isoToDate = function(_str) { |
| 598 | 357 |
// http://delete.me.uk/2005/03/iso8601.html |
358 |
var 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})))?)?)?)?"; |
|
359 |
var d = _str.match(new RegExp(regexp)); |
|
360 |
|
|
361 |
var offset = 0; |
|
362 |
var date = new Date(d[1], 0, 1); |
|
363 |
|
|
364 |
if (d[3]) { date.setMonth(d[3] - 1); } |
|
365 |
if (d[5]) { date.setDate(d[5]); } |
|
366 |
if (d[7]) { date.setHours(d[7]); } |
|
367 |
if (d[8]) { date.setMinutes(d[8]); } |
|
368 |
if (d[10]) { date.setSeconds(d[10]); } |
|
369 |
if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); } |
|
370 |
if (d[14]) { |
|
371 |
offset = (Number(d[16]) * 60) + Number(d[17]); |
|
372 |
offset *= ((d[15] == '-') ? 1 : -1); |
|
373 |
} |
|
374 |
|
|
375 |
offset -= date.getTimezoneOffset(); |
|
376 |
time = (Number(date) + (offset * 60 * 1000)); |
|
377 |
var _res = new Date(); |
|
378 |
_res.setTime(Number(time)); |
|
379 |
return _res; |
|
380 |
}, |
|
| 898 | 381 |
dateToIso = Model.dateToIso = function(_d) { |
| 719 | 382 |
var d = _d ? new Date(_d) : new Date(); |
| 598 | 383 |
return d.getUTCFullYear()+'-' |
| 719 | 384 |
+ pad(2, d.getUTCMonth()+1)+'-' |
385 |
+ pad(2, d.getUTCDate())+'T' |
|
386 |
+ pad(2, d.getUTCHours())+':' |
|
387 |
+ pad(2, d.getUTCMinutes())+':' |
|
| 955 | 388 |
+ pad(2, d.getUTCSeconds())+'Z' ; |
| 898 | 389 |
}; |
| 598 | 390 |
|
391 |
/* |
|
| 898 | 392 |
* List is a class for a list of elements (e.g. annotations, medias, etc. that each have a distinct ID) |
| 598 | 393 |
*/ |
| 898 | 394 |
var List = Model.List = function(_directory) { |
| 598 | 395 |
Array.call(this); |
396 |
this.directory = _directory; |
|
397 |
this.idIndex = []; |
|
| 694 | 398 |
this.__events = {}; |
| 598 | 399 |
if (typeof _directory == "undefined") { |
| 623 | 400 |
console.trace(); |
| 898 | 401 |
throw "Error : new List(directory): directory is undefined"; |
| 598 | 402 |
} |
| 719 | 403 |
var _this = this; |
404 |
this.on("clear-search", function() { |
|
405 |
_this.searching = false; |
|
406 |
_this.regexp = undefined; |
|
407 |
_this.forEach(function(_element) { |
|
408 |
_element.found = undefined; |
|
409 |
}); |
|
410 |
_this.trigger("search-cleared"); |
|
| 955 | 411 |
}); |
| 898 | 412 |
}; |
| 598 | 413 |
|
| 898 | 414 |
List.prototype = new Array(); |
| 598 | 415 |
|
| 898 | 416 |
List.prototype.hasId = function(_id) { |
| 719 | 417 |
return ns._(this.idIndex).include(_id); |
| 898 | 418 |
}; |
| 598 | 419 |
|
420 |
/* On recent browsers, forEach and map are defined and do what we want. |
|
421 |
* Otherwise, we'll use the Underscore.js functions |
|
422 |
*/ |
|
423 |
if (typeof Array.prototype.forEach === "undefined") { |
|
| 898 | 424 |
List.prototype.forEach = function(_callback) { |
| 598 | 425 |
var _this = this; |
| 719 | 426 |
ns._(this).forEach(function(_value, _key) { |
| 598 | 427 |
_callback(_value, _key, _this); |
428 |
}); |
|
| 955 | 429 |
}; |
| 898 | 430 |
}; |
| 598 | 431 |
|
432 |
if (typeof Array.prototype.map === "undefined") { |
|
| 898 | 433 |
List.prototype.map = function(_callback) { |
| 598 | 434 |
var _this = this; |
| 719 | 435 |
return ns._(this).map(function(_value, _key) { |
| 598 | 436 |
return _callback(_value, _key, _this); |
437 |
}); |
|
| 955 | 438 |
}; |
| 898 | 439 |
}; |
| 598 | 440 |
|
| 898 | 441 |
List.prototype.pluck = function(_key) { |
| 623 | 442 |
return this.map(function(_value) { |
443 |
return _value[_key]; |
|
444 |
}); |
|
| 898 | 445 |
}; |
| 623 | 446 |
|
| 898 | 447 |
/* We override Array's filter function because it doesn't return an List |
| 598 | 448 |
*/ |
| 898 | 449 |
List.prototype.filter = function(_callback) { |
| 598 | 450 |
var _this = this, |
| 898 | 451 |
_res = new List(this.directory); |
| 719 | 452 |
_res.addElements(ns._(this).filter(function(_value, _key) { |
| 598 | 453 |
return _callback(_value, _key, _this); |
454 |
})); |
|
455 |
return _res; |
|
| 898 | 456 |
}; |
| 598 | 457 |
|
| 898 | 458 |
List.prototype.slice = function(_start, _end) { |
459 |
var _res = new List(this.directory); |
|
| 598 | 460 |
_res.addElements(Array.prototype.slice.call(this, _start, _end)); |
461 |
return _res; |
|
| 898 | 462 |
}; |
| 598 | 463 |
|
| 898 | 464 |
List.prototype.splice = function(_start, _end) { |
465 |
var _res = new List(this.directory); |
|
| 598 | 466 |
_res.addElements(Array.prototype.splice.call(this, _start, _end)); |
467 |
this.idIndex.splice(_start, _end); |
|
468 |
return _res; |
|
| 898 | 469 |
}; |
| 598 | 470 |
|
471 |
/* Array has a sort function, but it's not as interesting as Underscore.js's sortBy |
|
| 898 | 472 |
* and won't return a new List |
| 598 | 473 |
*/ |
| 898 | 474 |
List.prototype.sortBy = function(_callback) { |
| 598 | 475 |
var _this = this, |
| 898 | 476 |
_res = new List(this.directory); |
| 719 | 477 |
_res.addElements(ns._(this).sortBy(function(_value, _key) { |
| 598 | 478 |
return _callback(_value, _key, _this); |
479 |
})); |
|
480 |
return _res; |
|
| 898 | 481 |
}; |
| 598 | 482 |
|
483 |
/* Title and Description are basic information for (almost) all element types, |
|
484 |
* here we can search by these criteria |
|
485 |
*/ |
|
| 898 | 486 |
List.prototype.searchByTitle = function(_text, _iexact) { |
| 719 | 487 |
var _iexact = _iexact || false, |
| 898 | 488 |
_rgxp = regexpFromTextOrArray(_text, true, _iexact); |
| 598 | 489 |
return this.filter(function(_element) { |
490 |
return _rgxp.test(_element.title); |
|
491 |
}); |
|
| 898 | 492 |
}; |
| 598 | 493 |
|
| 898 | 494 |
List.prototype.searchByDescription = function(_text, _iexact) { |
| 719 | 495 |
var _iexact = _iexact || false, |
| 898 | 496 |
_rgxp = regexpFromTextOrArray(_text, true, _iexact); |
| 598 | 497 |
return this.filter(function(_element) { |
498 |
return _rgxp.test(_element.description); |
|
499 |
}); |
|
| 898 | 500 |
}; |
| 598 | 501 |
|
| 898 | 502 |
List.prototype.searchByTextFields = function(_text, _iexact) { |
| 719 | 503 |
var _iexact = _iexact || false, |
| 898 | 504 |
_rgxp = regexpFromTextOrArray(_text, true, _iexact); |
| 598 | 505 |
return this.filter(function(_element) { |
| 755 | 506 |
var keywords = (_element.keywords || _element.getTagTexts() || []).join(", "); |
507 |
return _rgxp.test(_element.description) || _rgxp.test(_element.title) || _rgxp.test(keywords); |
|
| 598 | 508 |
}); |
| 898 | 509 |
}; |
| 598 | 510 |
|
| 898 | 511 |
List.prototype.search = function(_text) { |
| 719 | 512 |
if (!_text) { |
513 |
this.trigger("clear-search"); |
|
514 |
return this; |
|
515 |
} |
|
516 |
this.searching = true; |
|
517 |
this.trigger("search", _text); |
|
| 955 | 518 |
var rxsource = fullTextRegexps(_text), |
519 |
rgxp = new RegExp(rxsource,"im"); |
|
520 |
this.regexp = new RegExp(rxsource,"gim"); |
|
| 719 | 521 |
var res = this.filter(function(_element, _k) { |
522 |
var titlematch = rgxp.test(_element.title), |
|
523 |
descmatch = rgxp.test(_element.description), |
|
524 |
_isfound = !!(titlematch || descmatch); |
|
525 |
_element.found = _isfound; |
|
526 |
_element.trigger(_isfound ? "found" : "not-found"); |
|
527 |
return _isfound; |
|
528 |
}); |
|
529 |
this.trigger(res.length ? "found" : "not-found",res); |
|
530 |
return res; |
|
| 898 | 531 |
}; |
| 719 | 532 |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
533 |
List.prototype.searchByTags = function(_text) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
534 |
if (!_text) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
535 |
this.trigger("clear-search"); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
536 |
return this; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
537 |
} |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
538 |
this.searching = true; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
539 |
this.trigger("search", _text); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
540 |
var rxsource = fullTextRegexps(_text), |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
541 |
rgxp = new RegExp(rxsource,"im"); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
542 |
this.regexp = new RegExp(rxsource,"gim"); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
543 |
var res = this.filter(function(_element, _k) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
544 |
var _isfound = rgxp.test(_element.getTagTexts()); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
545 |
_element.found = _isfound; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
546 |
_element.trigger(_isfound ? "found" : "not-found"); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
547 |
return _isfound; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
548 |
}); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
549 |
this.trigger(res.length ? "found" : "not-found",res); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
550 |
return res; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
551 |
}; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
552 |
|
| 898 | 553 |
List.prototype.getTitles = function() { |
| 598 | 554 |
return this.map(function(_el) { |
555 |
return _el.title; |
|
556 |
}); |
|
| 898 | 557 |
}; |
| 598 | 558 |
|
| 898 | 559 |
List.prototype.addId = function(_id) { |
| 955 | 560 |
var _el = this.directory.getElement(_id); |
| 598 | 561 |
if (!this.hasId(_id) && typeof _el !== "undefined") { |
562 |
this.idIndex.push(_id); |
|
563 |
Array.prototype.push.call(this, _el); |
|
564 |
} |
|
| 898 | 565 |
}; |
| 598 | 566 |
|
| 898 | 567 |
List.prototype.push = function(_el) { |
| 598 | 568 |
if (typeof _el === "undefined") { |
569 |
return; |
|
570 |
} |
|
| 719 | 571 |
var _index = (ns._(this.idIndex).indexOf(_el.id)); |
| 598 | 572 |
if (_index === -1) { |
573 |
this.idIndex.push(_el.id); |
|
574 |
Array.prototype.push.call(this, _el); |
|
575 |
} else { |
|
576 |
this[_index] = _el; |
|
577 |
} |
|
| 898 | 578 |
}; |
| 598 | 579 |
|
| 898 | 580 |
List.prototype.addIds = function(_array) { |
| 598 | 581 |
var _l = _array.length, |
582 |
_this = this; |
|
| 719 | 583 |
ns._(_array).forEach(function(_id) { |
| 598 | 584 |
_this.addId(_id); |
585 |
}); |
|
| 898 | 586 |
}; |
| 598 | 587 |
|
| 898 | 588 |
List.prototype.addElements = function(_array) { |
| 598 | 589 |
var _this = this; |
| 719 | 590 |
ns._(_array).forEach(function(_el) { |
| 598 | 591 |
_this.push(_el); |
592 |
}); |
|
| 898 | 593 |
}; |
| 598 | 594 |
|
| 898 | 595 |
List.prototype.removeId = function(_id, _deleteFromDirectory) { |
| 638 | 596 |
var _deleteFromDirectory = _deleteFromDirectory || false, |
| 719 | 597 |
_index = (ns._(this.idIndex).indexOf(_id)); |
| 598 | 598 |
if (_index !== -1) { |
599 |
this.splice(_index,1); |
|
600 |
} |
|
| 638 | 601 |
if (_deleteFromDirectory) { |
602 |
delete this.directory.elements[_id]; |
|
603 |
} |
|
| 898 | 604 |
}; |
| 598 | 605 |
|
| 898 | 606 |
List.prototype.removeElement = function(_el, _deleteFromDirectory) { |
| 638 | 607 |
var _deleteFromDirectory = _deleteFromDirectory || false; |
| 598 | 608 |
this.removeId(_el.id); |
| 898 | 609 |
}; |
| 598 | 610 |
|
| 898 | 611 |
List.prototype.removeIds = function(_list, _deleteFromDirectory) { |
| 638 | 612 |
var _deleteFromDirectory = _deleteFromDirectory || false, |
613 |
_this = this; |
|
| 719 | 614 |
ns._(_list).forEach(function(_id) { |
| 598 | 615 |
_this.removeId(_id); |
616 |
}); |
|
| 898 | 617 |
}; |
| 598 | 618 |
|
| 898 | 619 |
List.prototype.removeElements = function(_list, _deleteFromDirectory) { |
| 638 | 620 |
var _deleteFromDirectory = _deleteFromDirectory || false, |
621 |
_this = this; |
|
| 719 | 622 |
ns._(_list).forEach(function(_el) { |
| 598 | 623 |
_this.removeElement(_el); |
624 |
}); |
|
| 898 | 625 |
}; |
| 598 | 626 |
|
| 898 | 627 |
List.prototype.on = function(_event, _callback) { |
| 694 | 628 |
if (typeof this.__events[_event] === "undefined") { |
629 |
this.__events[_event] = []; |
|
630 |
} |
|
631 |
this.__events[_event].push(_callback); |
|
| 898 | 632 |
}; |
| 694 | 633 |
|
| 898 | 634 |
List.prototype.off = function(_event, _callback) { |
| 719 | 635 |
if (typeof this.__events[_event] !== "undefined") { |
636 |
this.__events[_event] = ns._(this.__events[_event]).reject(function(_fn) { |
|
637 |
return _fn === _callback; |
|
638 |
}); |
|
639 |
} |
|
| 898 | 640 |
}; |
| 719 | 641 |
|
| 898 | 642 |
List.prototype.trigger = function(_event, _data) { |
| 694 | 643 |
var _list = this; |
| 719 | 644 |
ns._(this.__events[_event]).each(function(_callback) { |
| 694 | 645 |
_callback.call(_list, _data); |
646 |
}); |
|
| 898 | 647 |
}; |
| 694 | 648 |
|
| 598 | 649 |
/* A simple time management object, that helps converting millisecs to seconds and strings, |
650 |
* without the clumsiness of the original Date object. |
|
651 |
*/ |
|
652 |
||
| 898 | 653 |
var Time = Model.Time = function(_milliseconds) { |
| 623 | 654 |
this.milliseconds = 0; |
655 |
this.setMilliseconds(_milliseconds); |
|
| 898 | 656 |
}; |
| 623 | 657 |
|
| 898 | 658 |
Time.prototype.setMilliseconds = function(_milliseconds) { |
| 719 | 659 |
var _ante = this.milliseconds; |
| 623 | 660 |
switch(typeof _milliseconds) { |
661 |
case "string": |
|
| 719 | 662 |
this.milliseconds = parseInt(_milliseconds); |
| 623 | 663 |
break; |
664 |
case "number": |
|
| 719 | 665 |
this.milliseconds = Math.floor(_milliseconds); |
| 623 | 666 |
break; |
667 |
case "object": |
|
| 719 | 668 |
this.milliseconds = parseInt(_milliseconds.valueOf()); |
| 623 | 669 |
break; |
670 |
default: |
|
671 |
this.milliseconds = 0; |
|
672 |
} |
|
673 |
if (this.milliseconds === NaN) { |
|
674 |
this.milliseconds = _ante; |
|
675 |
} |
|
| 898 | 676 |
}; |
| 598 | 677 |
|
| 898 | 678 |
Time.prototype.setSeconds = function(_seconds) { |
| 598 | 679 |
this.milliseconds = 1000 * _seconds; |
| 898 | 680 |
}; |
| 598 | 681 |
|
| 898 | 682 |
Time.prototype.getSeconds = function() { |
| 638 | 683 |
return this.milliseconds / 1000; |
| 898 | 684 |
}; |
| 598 | 685 |
|
| 898 | 686 |
Time.prototype.getHMS = function() { |
| 638 | 687 |
var _totalSeconds = Math.abs(Math.floor(this.getSeconds())); |
| 598 | 688 |
return { |
689 |
hours : Math.floor(_totalSeconds / 3600), |
|
690 |
minutes : (Math.floor(_totalSeconds / 60) % 60), |
|
| 719 | 691 |
seconds : _totalSeconds % 60, |
692 |
milliseconds: this.milliseconds % 1000 |
|
| 955 | 693 |
}; |
| 898 | 694 |
}; |
| 598 | 695 |
|
| 898 | 696 |
Time.prototype.add = function(_milliseconds) { |
697 |
this.milliseconds += new Time(_milliseconds).milliseconds; |
|
698 |
}; |
|
| 623 | 699 |
|
| 898 | 700 |
Time.prototype.valueOf = function() { |
| 598 | 701 |
return this.milliseconds; |
| 898 | 702 |
}; |
| 598 | 703 |
|
| 898 | 704 |
Time.prototype.toString = function(showCs) { |
| 598 | 705 |
var _hms = this.getHMS(), |
706 |
_res = ''; |
|
707 |
if (_hms.hours) { |
|
| 955 | 708 |
_res += _hms.hours + ':'; |
| 598 | 709 |
} |
| 719 | 710 |
_res += pad(2, _hms.minutes) + ':' + pad(2, _hms.seconds); |
711 |
if (showCs) { |
|
| 955 | 712 |
_res += "." + Math.floor(_hms.milliseconds / 100); |
| 719 | 713 |
} |
| 598 | 714 |
return _res; |
| 898 | 715 |
}; |
| 598 | 716 |
|
| 898 | 717 |
/* Reference handles references between elements |
| 598 | 718 |
*/ |
719 |
||
| 898 | 720 |
var Reference = Model.Reference = function(_source, _idRef) { |
| 598 | 721 |
this.source = _source; |
| 638 | 722 |
this.id = _idRef; |
| 598 | 723 |
if (typeof _idRef === "object") { |
724 |
this.isList = true; |
|
725 |
} else { |
|
726 |
this.isList = false; |
|
727 |
} |
|
728 |
this.refresh(); |
|
| 898 | 729 |
}; |
| 598 | 730 |
|
| 898 | 731 |
Reference.prototype.refresh = function() { |
| 598 | 732 |
if (this.isList) { |
| 898 | 733 |
this.contents = new List(this.source.directory); |
| 598 | 734 |
this.contents.addIds(this.id); |
735 |
} else { |
|
| 694 | 736 |
this.contents = this.source.getElement(this.id); |
| 598 | 737 |
} |
738 |
|
|
| 898 | 739 |
}; |
| 598 | 740 |
|
| 898 | 741 |
Reference.prototype.getContents = function() { |
| 598 | 742 |
if (typeof this.contents === "undefined" || (this.isList && this.contents.length != this.id.length)) { |
743 |
this.refresh(); |
|
744 |
} |
|
745 |
return this.contents; |
|
| 898 | 746 |
}; |
| 598 | 747 |
|
| 898 | 748 |
Reference.prototype.isOrHasId = function(_idRef) { |
| 598 | 749 |
if (this.isList) { |
| 955 | 750 |
return (ns._(this.id).indexOf(_idRef) !== -1); |
| 598 | 751 |
} else { |
752 |
return (this.id == _idRef); |
|
753 |
} |
|
| 898 | 754 |
}; |
| 598 | 755 |
|
756 |
/* */ |
|
757 |
||
| 898 | 758 |
var BaseElement = Model.Element = function(_id, _source) { |
| 598 | 759 |
this.elementType = 'element'; |
| 719 | 760 |
this.title = ""; |
761 |
this.description = ""; |
|
| 955 | 762 |
this.__events = {}; |
| 598 | 763 |
if (typeof _source === "undefined") { |
764 |
return; |
|
765 |
} |
|
766 |
if (typeof _id === "undefined" || !_id) { |
|
| 898 | 767 |
_id = getUID(); |
| 598 | 768 |
} |
| 638 | 769 |
this.id = _id; |
| 719 | 770 |
this.source = _source; |
771 |
if (_source !== this) { |
|
772 |
this.source.directory.addElement(this); |
|
773 |
} |
|
| 898 | 774 |
}; |
| 598 | 775 |
|
| 898 | 776 |
BaseElement.prototype.toString = function() { |
| 598 | 777 |
return this.elementType + (this.elementType !== 'element' ? ', id=' + this.id + ', title="' + this.title + '"' : ''); |
| 898 | 778 |
}; |
| 598 | 779 |
|
| 898 | 780 |
BaseElement.prototype.setReference = function(_elementType, _idRef) { |
781 |
this[_elementType] = new Reference(this.source, _idRef); |
|
782 |
}; |
|
| 598 | 783 |
|
| 898 | 784 |
BaseElement.prototype.getReference = function(_elementType) { |
| 598 | 785 |
if (typeof this[_elementType] !== "undefined") { |
786 |
return this[_elementType].getContents(); |
|
787 |
} |
|
| 898 | 788 |
}; |
| 598 | 789 |
|
| 898 | 790 |
BaseElement.prototype.getRelated = function(_elementType, _global) { |
| 598 | 791 |
_global = (typeof _global !== "undefined" && _global); |
792 |
var _this = this; |
|
793 |
return this.source.getList(_elementType, _global).filter(function(_el) { |
|
794 |
var _ref = _el[_this.elementType]; |
|
| 719 | 795 |
return _ref && _ref.isOrHasId(_this.id); |
| 598 | 796 |
}); |
| 898 | 797 |
}; |
| 598 | 798 |
|
| 898 | 799 |
BaseElement.prototype.on = function(_event, _callback) { |
| 694 | 800 |
if (typeof this.__events[_event] === "undefined") { |
801 |
this.__events[_event] = []; |
|
802 |
} |
|
803 |
this.__events[_event].push(_callback); |
|
| 898 | 804 |
}; |
| 694 | 805 |
|
| 898 | 806 |
BaseElement.prototype.off = function(_event, _callback) { |
| 719 | 807 |
if (typeof this.__events[_event] !== "undefined") { |
808 |
this.__events[_event] = ns._(this.__events[_event]).reject(function(_fn) { |
|
809 |
return _fn === _callback; |
|
810 |
}); |
|
811 |
} |
|
| 898 | 812 |
}; |
| 719 | 813 |
|
| 898 | 814 |
BaseElement.prototype.trigger = function(_event, _data) { |
| 694 | 815 |
var _element = this; |
| 719 | 816 |
ns._(this.__events[_event]).each(function(_callback) { |
| 694 | 817 |
_callback.call(_element, _data); |
818 |
}); |
|
| 898 | 819 |
}; |
| 694 | 820 |
|
| 598 | 821 |
/* */ |
822 |
||
| 898 | 823 |
var Playable = Model.Playable = function(_id, _source) { |
824 |
BaseElement.call(this, _id, _source); |
|
| 719 | 825 |
if (typeof _source === "undefined") { |
826 |
return; |
|
827 |
} |
|
828 |
this.elementType = 'playable'; |
|
| 898 | 829 |
this.currentTime = new Time(); |
| 719 | 830 |
this.volume = .5; |
831 |
this.paused = true; |
|
832 |
this.muted = false; |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
833 |
this.timeRange = false; |
| 765 | 834 |
this.loadedMetadata = false; |
| 694 | 835 |
var _this = this; |
| 719 | 836 |
this.on("play", function() { |
837 |
_this.paused = false; |
|
838 |
}); |
|
839 |
this.on("pause", function() { |
|
840 |
_this.paused = true; |
|
841 |
}); |
|
| 694 | 842 |
this.on("timeupdate", function(_time) { |
| 719 | 843 |
_this.currentTime = _time; |
| 694 | 844 |
_this.getAnnotations().filter(function(_a) { |
| 955 | 845 |
return (_a.end <= _time || _a.begin > _time) && _a.playing; |
| 694 | 846 |
}).forEach(function(_a) { |
847 |
_a.playing = false; |
|
848 |
_a.trigger("leave"); |
|
| 719 | 849 |
_this.trigger("leave-annotation",_a); |
| 694 | 850 |
}); |
851 |
_this.getAnnotations().filter(function(_a) { |
|
| 955 | 852 |
return _a.begin <= _time && _a.end > _time && !_a.playing; |
| 694 | 853 |
}).forEach(function(_a) { |
854 |
_a.playing = true; |
|
855 |
_a.trigger("enter"); |
|
| 719 | 856 |
_this.trigger("enter-annotation",_a); |
| 694 | 857 |
}); |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
858 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
859 |
if (_this.getTimeRange()){ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
860 |
if (_this.getTimeRange()[0] > _time) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
861 |
_this.pause(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
862 |
_this.setCurrentTime(_this.getTimeRange()[0]); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
863 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
864 |
if (_this.getTimeRange()[1] < _time){ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
865 |
_this.pause(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
866 |
_this.setCurrentTime(_this.getTimeRange()[1]); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
867 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
868 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
869 |
|
| 694 | 870 |
}); |
| 765 | 871 |
this.on("loadedmetadata", function() { |
872 |
_this.loadedMetadata = true; |
|
| 898 | 873 |
}); |
874 |
}; |
|
| 598 | 875 |
|
| 898 | 876 |
extendPrototype(Playable, BaseElement); |
| 719 | 877 |
|
| 898 | 878 |
Playable.prototype.getCurrentTime = function() { |
| 719 | 879 |
return this.currentTime; |
| 898 | 880 |
}; |
| 719 | 881 |
|
| 898 | 882 |
Playable.prototype.getVolume = function() { |
| 719 | 883 |
return this.volume; |
| 898 | 884 |
}; |
| 719 | 885 |
|
| 898 | 886 |
Playable.prototype.getPaused = function() { |
| 719 | 887 |
return this.paused; |
| 898 | 888 |
}; |
| 719 | 889 |
|
| 898 | 890 |
Playable.prototype.getMuted = function() { |
| 719 | 891 |
return this.muted; |
| 898 | 892 |
}; |
| 719 | 893 |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
894 |
Playable.prototype.getTimeRange = function() { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
895 |
return this.timeRange; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
896 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
897 |
|
| 898 | 898 |
Playable.prototype.setCurrentTime = function(_time) { |
| 719 | 899 |
this.trigger("setcurrenttime",_time); |
| 898 | 900 |
}; |
| 719 | 901 |
|
| 898 | 902 |
Playable.prototype.setVolume = function(_vol) { |
| 719 | 903 |
this.trigger("setvolume",_vol); |
| 898 | 904 |
}; |
| 719 | 905 |
|
| 898 | 906 |
Playable.prototype.setMuted = function(_muted) { |
| 719 | 907 |
this.trigger("setmuted",_muted); |
| 898 | 908 |
}; |
| 719 | 909 |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
910 |
Playable.prototype.setTimeRange = function(_timeBegin, _timeEnd) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
911 |
if ((_timeBegin < _timeEnd)&&(_timeBegin >= 0)&&(_timeEnd>0)){ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
912 |
return this.trigger("settimerange", [_timeBegin, _timeEnd]); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
913 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
914 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
915 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
916 |
Playable.prototype.resetTimeRange = function() { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
917 |
return this.trigger("resettimerange"); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
918 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
919 |
|
| 898 | 920 |
Playable.prototype.play = function() { |
| 719 | 921 |
this.trigger("setplay"); |
| 898 | 922 |
}; |
| 719 | 923 |
|
| 898 | 924 |
Playable.prototype.pause = function() { |
| 719 | 925 |
this.trigger("setpause"); |
| 898 | 926 |
}; |
| 719 | 927 |
|
| 898 | 928 |
Playable.prototype.show = function() {}; |
| 719 | 929 |
|
| 898 | 930 |
Playable.prototype.hide = function() {}; |
| 719 | 931 |
|
932 |
/* */ |
|
933 |
||
| 898 | 934 |
var Media = Model.Media = function(_id, _source) { |
935 |
Playable.call(this, _id, _source); |
|
| 719 | 936 |
this.elementType = 'media'; |
| 898 | 937 |
this.duration = new Time(); |
| 719 | 938 |
this.video = ''; |
939 |
var _this = this; |
|
| 898 | 940 |
}; |
| 719 | 941 |
|
| 898 | 942 |
extendPrototype(Media, Playable); |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
943 |
/* */ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
944 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
945 |
var Media = Model.Media = function(_id, _source) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
946 |
Playable.call(this, _id, _source); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
947 |
this.elementType = 'media'; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
948 |
this.duration = new Time(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
949 |
this.video = ''; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
950 |
var _this = this; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
951 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
952 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
953 |
extendPrototype(Media, Playable); |
| 598 | 954 |
|
| 694 | 955 |
/* Default functions to be overriden by players */ |
956 |
|
|
| 898 | 957 |
Media.prototype.setDuration = function(_durationMs) { |
| 623 | 958 |
this.duration.setMilliseconds(_durationMs); |
| 898 | 959 |
}; |
| 598 | 960 |
|
| 898 | 961 |
Media.prototype.getAnnotations = function() { |
| 598 | 962 |
return this.getRelated("annotation"); |
| 898 | 963 |
}; |
| 598 | 964 |
|
| 898 | 965 |
Media.prototype.getAnnotationsByTypeTitle = function(_title) { |
| 623 | 966 |
var _annTypes = this.source.getAnnotationTypes().searchByTitle(_title).pluck("id"); |
967 |
if (_annTypes.length) { |
|
968 |
return this.getAnnotations().filter(function(_annotation) { |
|
| 719 | 969 |
return ns._(_annTypes).indexOf(_annotation.getAnnotationType().id) !== -1; |
| 623 | 970 |
}); |
971 |
} else { |
|
| 955 | 972 |
return new List(this.source.directory); |
| 623 | 973 |
} |
| 898 | 974 |
}; |
| 623 | 975 |
|
| 598 | 976 |
/* */ |
977 |
||
| 898 | 978 |
var Tag = Model.Tag = function(_id, _source) { |
979 |
BaseElement.call(this, _id, _source); |
|
| 598 | 980 |
this.elementType = 'tag'; |
| 898 | 981 |
}; |
| 598 | 982 |
|
| 898 | 983 |
extendPrototype(Tag, BaseElement); |
| 598 | 984 |
|
| 898 | 985 |
Tag.prototype.getAnnotations = function() { |
| 598 | 986 |
return this.getRelated("annotation"); |
| 898 | 987 |
}; |
| 598 | 988 |
|
989 |
/* */ |
|
| 898 | 990 |
var AnnotationType = Model.AnnotationType = function(_id, _source) { |
991 |
BaseElement.call(this, _id, _source); |
|
| 598 | 992 |
this.elementType = 'annotationType'; |
| 898 | 993 |
}; |
| 598 | 994 |
|
| 898 | 995 |
extendPrototype(AnnotationType, BaseElement); |
| 598 | 996 |
|
| 898 | 997 |
AnnotationType.prototype.getAnnotations = function() { |
| 598 | 998 |
return this.getRelated("annotation"); |
| 898 | 999 |
}; |
| 598 | 1000 |
|
1001 |
/* Annotation |
|
1002 |
* */ |
|
1003 |
||
| 898 | 1004 |
var Annotation = Model.Annotation = function(_id, _source) { |
1005 |
BaseElement.call(this, _id, _source); |
|
| 598 | 1006 |
this.elementType = 'annotation'; |
| 898 | 1007 |
this.begin = new Time(); |
1008 |
this.end = new Time(); |
|
1009 |
this.tag = new Reference(_source, []); |
|
| 694 | 1010 |
this.playing = false; |
1011 |
var _this = this; |
|
1012 |
this.on("click", function() { |
|
1013 |
_this.getMedia().setCurrentTime(_this.begin); |
|
1014 |
}); |
|
| 898 | 1015 |
}; |
| 598 | 1016 |
|
| 898 | 1017 |
extendPrototype(Annotation, BaseElement); |
| 598 | 1018 |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1019 |
/* Set begin and end in one go, to avoid undesired side-effects in |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1020 |
* setBegin/setEnd interaction */ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1021 |
Annotation.prototype.setBeginEnd = function(_beginMs, _endMs) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1022 |
_beginMs = Math.max(0,_beginMs); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1023 |
_endMs = Math.max(0,_endMs); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1024 |
if (_endMs < _beginMs) |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1025 |
_endMs = _beginMs; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1026 |
this.begin.setMilliseconds(_beginMs); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1027 |
this.end.setMilliseconds(_endMs); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1028 |
this.trigger("change-begin"); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1029 |
this.trigger("change-end"); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1030 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1031 |
|
| 898 | 1032 |
Annotation.prototype.setBegin = function(_beginMs) { |
| 719 | 1033 |
this.begin.setMilliseconds(Math.max(0,_beginMs)); |
1034 |
this.trigger("change-begin"); |
|
1035 |
if (this.end < this.begin) { |
|
1036 |
this.setEnd(this.begin); |
|
1037 |
} |
|
| 898 | 1038 |
}; |
| 598 | 1039 |
|
| 898 | 1040 |
Annotation.prototype.setEnd = function(_endMs) { |
| 719 | 1041 |
this.end.setMilliseconds(Math.min(_endMs, this.getMedia().duration.milliseconds)); |
1042 |
this.trigger("change-end"); |
|
1043 |
if (this.end < this.begin) { |
|
1044 |
this.setBegin(this.end); |
|
1045 |
} |
|
| 898 | 1046 |
}; |
| 598 | 1047 |
|
| 898 | 1048 |
Annotation.prototype.setDuration = function(_durMs) { |
| 719 | 1049 |
this.setEnd(_durMs + this.begin.milliseconds); |
| 898 | 1050 |
}; |
| 719 | 1051 |
|
| 898 | 1052 |
Annotation.prototype.setMedia = function(_idRef) { |
| 598 | 1053 |
this.setReference("media", _idRef); |
| 898 | 1054 |
}; |
| 598 | 1055 |
|
| 898 | 1056 |
Annotation.prototype.getMedia = function() { |
| 598 | 1057 |
return this.getReference("media"); |
| 898 | 1058 |
}; |
| 598 | 1059 |
|
| 898 | 1060 |
Annotation.prototype.setAnnotationType = function(_idRef) { |
| 598 | 1061 |
this.setReference("annotationType", _idRef); |
| 898 | 1062 |
}; |
| 598 | 1063 |
|
| 898 | 1064 |
Annotation.prototype.getAnnotationType = function() { |
| 598 | 1065 |
return this.getReference("annotationType"); |
| 898 | 1066 |
}; |
| 598 | 1067 |
|
| 898 | 1068 |
Annotation.prototype.setTags = function(_idRefs) { |
| 598 | 1069 |
this.setReference("tag", _idRefs); |
| 898 | 1070 |
}; |
| 598 | 1071 |
|
| 898 | 1072 |
Annotation.prototype.getTags = function() { |
| 598 | 1073 |
return this.getReference("tag"); |
| 898 | 1074 |
}; |
| 598 | 1075 |
|
| 898 | 1076 |
Annotation.prototype.getTagTexts = function() { |
| 598 | 1077 |
return this.getTags().getTitles(); |
| 898 | 1078 |
}; |
| 598 | 1079 |
|
| 898 | 1080 |
Annotation.prototype.getDuration = function() { |
| 955 | 1081 |
return new Time(this.end.milliseconds - this.begin.milliseconds); |
| 898 | 1082 |
}; |
| 623 | 1083 |
|
1084 |
/* */ |
|
1085 |
||
| 898 | 1086 |
var MashedAnnotation = Model.MashedAnnotation = function(_mashup, _annotation) { |
1087 |
BaseElement.call(this, _mashup.id + "_" + _annotation.id, _annotation.source); |
|
| 623 | 1088 |
this.elementType = 'mashedAnnotation'; |
1089 |
this.annotation = _annotation; |
|
| 898 | 1090 |
this.begin = new Time(); |
1091 |
this.end = new Time(); |
|
1092 |
this.duration = new Time(); |
|
| 623 | 1093 |
this.title = this.annotation.title; |
1094 |
this.description = this.annotation.description; |
|
1095 |
this.color = this.annotation.color; |
|
| 694 | 1096 |
var _this = this; |
1097 |
this.on("click", function() { |
|
1098 |
_mashup.setCurrentTime(_this.begin); |
|
1099 |
}); |
|
| 719 | 1100 |
this.on("enter", function() { |
1101 |
_this.annotation.trigger("enter"); |
|
1102 |
}); |
|
1103 |
this.on("leave", function() { |
|
1104 |
_this.annotation.trigger("leave"); |
|
1105 |
}); |
|
| 898 | 1106 |
}; |
| 623 | 1107 |
|
| 898 | 1108 |
extendPrototype(MashedAnnotation, BaseElement); |
| 623 | 1109 |
|
| 898 | 1110 |
MashedAnnotation.prototype.getMedia = function() { |
| 623 | 1111 |
return this.annotation.getReference("media"); |
| 898 | 1112 |
}; |
| 623 | 1113 |
|
| 898 | 1114 |
MashedAnnotation.prototype.getAnnotationType = function() { |
| 623 | 1115 |
return this.annotation.getReference("annotationType"); |
| 898 | 1116 |
}; |
| 623 | 1117 |
|
| 898 | 1118 |
MashedAnnotation.prototype.getTags = function() { |
| 623 | 1119 |
return this.annotation.getReference("tag"); |
| 898 | 1120 |
}; |
| 623 | 1121 |
|
| 898 | 1122 |
MashedAnnotation.prototype.getTagTexts = function() { |
| 623 | 1123 |
return this.annotation.getTags().getTitles(); |
| 898 | 1124 |
}; |
| 623 | 1125 |
|
| 898 | 1126 |
MashedAnnotation.prototype.getDuration = function() { |
| 694 | 1127 |
return this.annotation.getDuration(); |
| 898 | 1128 |
}; |
| 694 | 1129 |
|
| 898 | 1130 |
MashedAnnotation.prototype.setBegin = function(_begin) { |
| 719 | 1131 |
this.begin.setMilliseconds(_begin); |
1132 |
this.duration.setMilliseconds(this.annotation.getDuration()); |
|
1133 |
this.end.setMilliseconds(_begin + this.duration); |
|
| 898 | 1134 |
}; |
| 719 | 1135 |
|
| 623 | 1136 |
/* */ |
1137 |
||
| 898 | 1138 |
var Mashup = Model.Mashup = function(_id, _source) { |
1139 |
Playable.call(this, _id, _source); |
|
| 623 | 1140 |
this.elementType = 'mashup'; |
| 898 | 1141 |
this.duration = new Time(); |
1142 |
this.segments = new List(_source.directory); |
|
| 719 | 1143 |
this.loaded = false; |
| 694 | 1144 |
var _this = this; |
| 719 | 1145 |
this._updateTimes = function() { |
1146 |
_this.updateTimes(); |
|
1147 |
_this.trigger("change"); |
|
| 955 | 1148 |
}; |
| 719 | 1149 |
this.on("add", this._updateTimes); |
1150 |
this.on("remove", this._updateTimes); |
|
| 898 | 1151 |
}; |
| 719 | 1152 |
|
| 898 | 1153 |
extendPrototype(Mashup, Playable); |
| 719 | 1154 |
|
| 898 | 1155 |
Mashup.prototype.updateTimes = function() { |
| 719 | 1156 |
var _time = 0; |
1157 |
this.segments.forEach(function(_segment) { |
|
1158 |
_segment.setBegin(_time); |
|
1159 |
_time = _segment.end; |
|
1160 |
}); |
|
1161 |
this.duration.setMilliseconds(_time); |
|
| 898 | 1162 |
}; |
| 719 | 1163 |
|
| 898 | 1164 |
Mashup.prototype.addAnnotation = function(_annotation, _defer) { |
1165 |
var _mashedAnnotation = new MashedAnnotation(this, _annotation), |
|
| 719 | 1166 |
_defer = _defer || false; |
1167 |
this.segments.push(_mashedAnnotation); |
|
1168 |
_annotation.on("change-begin", this._updateTimes); |
|
1169 |
_annotation.on("change-end", this._updateTimes); |
|
1170 |
if (!_defer) { |
|
1171 |
this.trigger("add"); |
|
1172 |
} |
|
| 898 | 1173 |
}; |
| 719 | 1174 |
|
| 898 | 1175 |
Mashup.prototype.addAnnotationById = function(_elId, _defer) { |
| 719 | 1176 |
var _annotation = this.source.getElement(_elId), |
1177 |
_defer = _defer || false; |
|
1178 |
if (typeof _annotation !== "undefined") { |
|
1179 |
this.addAnnotation(_annotation, _defer); |
|
1180 |
} |
|
| 898 | 1181 |
}; |
| 719 | 1182 |
|
| 898 | 1183 |
Mashup.prototype.addAnnotations = function(_segments) { |
| 719 | 1184 |
var _this = this; |
1185 |
ns._(_segments).forEach(function(_segment) { |
|
1186 |
_this.addAnnotation(_segment, true); |
|
1187 |
}); |
|
1188 |
this.trigger("add"); |
|
| 898 | 1189 |
}; |
| 719 | 1190 |
|
| 898 | 1191 |
Mashup.prototype.addAnnotationsById = function(_segments) { |
| 719 | 1192 |
var _this = this; |
1193 |
ns._(_segments).forEach(function(_segment) { |
|
1194 |
_this.addAnnotationById(_segment, true); |
|
1195 |
}); |
|
1196 |
this.trigger("add"); |
|
| 898 | 1197 |
}; |
| 719 | 1198 |
|
| 898 | 1199 |
Mashup.prototype.removeAnnotation = function(_annotation, _defer) { |
| 719 | 1200 |
var _defer = _defer || false; |
1201 |
_annotation.off("change-begin", this._updateTimes); |
|
1202 |
_annotation.off("change-end", this._updateTimes); |
|
1203 |
this.segments.removeId(this.id + "_" + _annotation.id); |
|
1204 |
if (!_defer) { |
|
1205 |
this.trigger("remove"); |
|
1206 |
} |
|
| 898 | 1207 |
}; |
| 719 | 1208 |
|
| 898 | 1209 |
Mashup.prototype.removeAnnotationById = function(_annId, _defer) { |
| 719 | 1210 |
var _defer = _defer || false; |
1211 |
var _annotation = this.source.getElement(_annId); |
|
1212 |
||
1213 |
if (_annotation) { |
|
1214 |
this.removeAnnotation(_annotation, _defer); |
|
1215 |
} |
|
1216 |
if (!_defer) { |
|
1217 |
this.trigger("remove"); |
|
1218 |
} |
|
| 898 | 1219 |
}; |
| 719 | 1220 |
|
| 898 | 1221 |
Mashup.prototype.setAnnotations = function(_segments) { |
| 719 | 1222 |
while (this.segments.length) { |
1223 |
this.removeAnnotation(this.segments[0].annotation, true); |
|
1224 |
} |
|
1225 |
this.addAnnotations(_segments); |
|
| 898 | 1226 |
}; |
| 719 | 1227 |
|
| 898 | 1228 |
Mashup.prototype.setAnnotationsById = function(_segments) { |
| 719 | 1229 |
while (this.segments.length) { |
1230 |
this.removeAnnotation(this.segments[0].annotation, true); |
|
1231 |
} |
|
1232 |
this.addAnnotationsById(_segments); |
|
| 898 | 1233 |
}; |
| 719 | 1234 |
|
| 898 | 1235 |
Mashup.prototype.hasAnnotation = function(_annotation) { |
| 719 | 1236 |
return !!ns._(this.segments).find(function(_s) { |
| 955 | 1237 |
return _s.annotation === _annotation; |
| 694 | 1238 |
}); |
| 898 | 1239 |
}; |
| 623 | 1240 |
|
| 898 | 1241 |
Mashup.prototype.getAnnotation = function(_annotation) { |
| 719 | 1242 |
return ns._(this.segments).find(function(_s) { |
| 955 | 1243 |
return _s.annotation === _annotation; |
| 719 | 1244 |
}); |
| 898 | 1245 |
}; |
| 623 | 1246 |
|
| 898 | 1247 |
Mashup.prototype.getAnnotationById = function(_id) { |
| 719 | 1248 |
return ns._(this.segments).find(function(_s) { |
| 955 | 1249 |
return _s.annotation.id === _id; |
| 719 | 1250 |
}); |
| 898 | 1251 |
}; |
| 719 | 1252 |
|
| 898 | 1253 |
Mashup.prototype.getAnnotations = function() { |
| 719 | 1254 |
return this.segments; |
| 898 | 1255 |
}; |
| 623 | 1256 |
|
| 898 | 1257 |
Mashup.prototype.getOriginalAnnotations = function() { |
1258 |
var annotations = new List(this.source.directory); |
|
| 719 | 1259 |
this.segments.forEach(function(_s) { |
1260 |
annotations.push(_s.annotation); |
|
1261 |
}); |
|
1262 |
return annotations; |
|
| 898 | 1263 |
}; |
| 719 | 1264 |
|
| 898 | 1265 |
Mashup.prototype.getMedias = function() { |
1266 |
var medias = new List(this.source.directory); |
|
| 719 | 1267 |
this.segments.forEach(function(_annotation) { |
| 955 | 1268 |
medias.push(_annotation.getMedia()); |
1269 |
}); |
|
| 719 | 1270 |
return medias; |
| 898 | 1271 |
}; |
| 719 | 1272 |
|
| 898 | 1273 |
Mashup.prototype.getAnnotationsByTypeTitle = function(_title) { |
| 719 | 1274 |
var _annTypes = this.source.getAnnotationTypes().searchByTitle(_title).pluck("id"); |
1275 |
if (_annTypes.length) { |
|
1276 |
return this.getAnnotations().filter(function(_annotation) { |
|
1277 |
return ns._(_annTypes).indexOf(_annotation.getAnnotationType().id) !== -1; |
|
1278 |
}); |
|
1279 |
} else { |
|
| 955 | 1280 |
return new List(this.source.directory); |
| 623 | 1281 |
} |
| 898 | 1282 |
}; |
| 623 | 1283 |
|
| 898 | 1284 |
Mashup.prototype.getAnnotationAtTime = function(_time) { |
| 623 | 1285 |
var _list = this.segments.filter(function(_annotation) { |
1286 |
return _annotation.begin <= _time && _annotation.end > _time; |
|
1287 |
}); |
|
1288 |
if (_list.length) { |
|
1289 |
return _list[0]; |
|
1290 |
} else { |
|
1291 |
return undefined; |
|
1292 |
} |
|
| 898 | 1293 |
}; |
| 623 | 1294 |
|
| 898 | 1295 |
Mashup.prototype.getMediaAtTime = function(_time) { |
| 623 | 1296 |
var _annotation = this.getAnnotationAtTime(_time); |
1297 |
if (typeof _annotation !== "undefined") { |
|
1298 |
return _annotation.getMedia(); |
|
1299 |
} else { |
|
1300 |
return undefined; |
|
1301 |
} |
|
| 898 | 1302 |
}; |
| 623 | 1303 |
|
| 598 | 1304 |
/* */ |
1305 |
||
| 898 | 1306 |
var Source = Model.Source = function(_config) { |
1307 |
BaseElement.call(this, false, this); |
|
1308 |
this.status = _SOURCE_STATUS_EMPTY; |
|
| 719 | 1309 |
this.elementType = "source"; |
| 598 | 1310 |
if (typeof _config !== "undefined") { |
1311 |
var _this = this; |
|
| 719 | 1312 |
ns._(_config).forEach(function(_v, _k) { |
| 598 | 1313 |
_this[_k] = _v; |
| 955 | 1314 |
}); |
| 598 | 1315 |
this.callbackQueue = []; |
1316 |
this.contents = {}; |
|
1317 |
this.get(); |
|
1318 |
} |
|
| 898 | 1319 |
}; |
| 598 | 1320 |
|
| 898 | 1321 |
extendPrototype(Source, BaseElement); |
| 719 | 1322 |
|
| 898 | 1323 |
Source.prototype.addList = function(_listId, _contents) { |
| 598 | 1324 |
if (typeof this.contents[_listId] === "undefined") { |
| 898 | 1325 |
this.contents[_listId] = new List(this.directory); |
| 598 | 1326 |
} |
1327 |
this.contents[_listId].addElements(_contents); |
|
| 898 | 1328 |
}; |
| 598 | 1329 |
|
| 898 | 1330 |
Source.prototype.getList = function(_listId, _global) { |
| 598 | 1331 |
_global = (typeof _global !== "undefined" && _global); |
| 755 | 1332 |
if (_global) { |
| 598 | 1333 |
return this.directory.getGlobalList().filter(function(_e) { |
1334 |
return (_e.elementType === _listId); |
|
1335 |
}); |
|
1336 |
} else { |
|
| 940 | 1337 |
if (typeof this.contents[_listId] === "undefined") { |
| 955 | 1338 |
this.contents[_listId] = new List(this.directory); |
| 940 | 1339 |
} |
1340 |
return this.contents[_listId]; |
|
| 598 | 1341 |
} |
| 898 | 1342 |
}; |
| 598 | 1343 |
|
| 898 | 1344 |
Source.prototype.forEach = function(_callback) { |
| 598 | 1345 |
var _this = this; |
| 719 | 1346 |
ns._(this.contents).forEach(function(_value, _key) { |
| 598 | 1347 |
_callback.call(_this, _value, _key); |
| 955 | 1348 |
}); |
| 898 | 1349 |
}; |
| 598 | 1350 |
|
| 898 | 1351 |
Source.prototype.getElement = function(_elId) { |
| 638 | 1352 |
return this.directory.getElement(_elId); |
| 898 | 1353 |
}; |
| 598 | 1354 |
|
| 898 | 1355 |
Source.prototype.get = function() { |
1356 |
this.status = _SOURCE_STATUS_WAITING; |
|
| 598 | 1357 |
this.handleCallbacks(); |
| 898 | 1358 |
}; |
| 598 | 1359 |
|
1360 |
/* We defer the callbacks calls so they execute after the queue is cleared */ |
|
| 898 | 1361 |
Source.prototype.deferCallback = function(_callback) { |
| 598 | 1362 |
var _this = this; |
| 719 | 1363 |
ns._.defer(function() { |
| 598 | 1364 |
_callback.call(_this); |
1365 |
}); |
|
| 898 | 1366 |
}; |
| 598 | 1367 |
|
| 898 | 1368 |
Source.prototype.handleCallbacks = function() { |
1369 |
this.status = _SOURCE_STATUS_READY; |
|
| 598 | 1370 |
while (this.callbackQueue.length) { |
1371 |
this.deferCallback(this.callbackQueue.splice(0,1)[0]); |
|
1372 |
} |
|
| 898 | 1373 |
}; |
1374 |
Source.prototype.onLoad = function(_callback) { |
|
1375 |
if (this.status === _SOURCE_STATUS_READY) { |
|
| 598 | 1376 |
this.deferCallback(_callback); |
1377 |
} else { |
|
1378 |
this.callbackQueue.push(_callback); |
|
1379 |
} |
|
| 898 | 1380 |
}; |
| 598 | 1381 |
|
| 898 | 1382 |
Source.prototype.serialize = function() { |
| 598 | 1383 |
return this.serializer.serialize(this); |
| 898 | 1384 |
}; |
| 598 | 1385 |
|
| 898 | 1386 |
Source.prototype.deSerialize = function(_data) { |
| 598 | 1387 |
this.serializer.deSerialize(_data, this); |
| 898 | 1388 |
}; |
| 598 | 1389 |
|
| 898 | 1390 |
Source.prototype.getAnnotations = function(_global) { |
| 598 | 1391 |
_global = (typeof _global !== "undefined" && _global); |
1392 |
return this.getList("annotation", _global); |
|
| 898 | 1393 |
}; |
| 598 | 1394 |
|
| 898 | 1395 |
Source.prototype.getMedias = function(_global) { |
| 598 | 1396 |
_global = (typeof _global !== "undefined" && _global); |
1397 |
return this.getList("media", _global); |
|
| 898 | 1398 |
}; |
| 598 | 1399 |
|
| 898 | 1400 |
Source.prototype.getTags = function(_global) { |
| 623 | 1401 |
_global = (typeof _global !== "undefined" && _global); |
1402 |
return this.getList("tag", _global); |
|
| 898 | 1403 |
}; |
| 623 | 1404 |
|
| 898 | 1405 |
Source.prototype.getMashups = function(_global) { |
| 623 | 1406 |
_global = (typeof _global !== "undefined" && _global); |
1407 |
return this.getList("mashup", _global); |
|
| 898 | 1408 |
}; |
| 623 | 1409 |
|
| 898 | 1410 |
Source.prototype.getAnnotationTypes = function(_global) { |
| 598 | 1411 |
_global = (typeof _global !== "undefined" && _global); |
1412 |
return this.getList("annotationType", _global); |
|
| 898 | 1413 |
}; |
| 598 | 1414 |
|
| 898 | 1415 |
Source.prototype.getAnnotationsByTypeTitle = function(_title, _global) { |
| 598 | 1416 |
_global = (typeof _global !== "undefined" && _global); |
| 898 | 1417 |
var _res = new List(this.directory), |
| 598 | 1418 |
_annTypes = this.getAnnotationTypes(_global).searchByTitle(_title); |
1419 |
_annTypes.forEach(function(_annType) { |
|
1420 |
_res.addElements(_annType.getAnnotations(_global)); |
|
| 955 | 1421 |
}); |
| 598 | 1422 |
return _res; |
| 898 | 1423 |
}; |
| 598 | 1424 |
|
| 898 | 1425 |
Source.prototype.getDuration = function() { |
| 598 | 1426 |
var _m = this.currentMedia; |
1427 |
if (typeof _m !== "undefined") { |
|
1428 |
return this.currentMedia.duration; |
|
1429 |
} |
|
| 898 | 1430 |
}; |
| 598 | 1431 |
|
| 898 | 1432 |
Source.prototype.getCurrentMedia = function(_opts) { |
| 694 | 1433 |
if (typeof this.currentMedia === "undefined") { |
1434 |
if (_opts.is_mashup) { |
|
1435 |
var _mashups = this.getMashups(); |
|
1436 |
if (_mashups.length) { |
|
1437 |
this.currentMedia = _mashups[0]; |
|
1438 |
} |
|
1439 |
} else { |
|
1440 |
var _medias = this.getMedias(); |
|
1441 |
if (_medias.length) { |
|
| 719 | 1442 |
this.currentMedia = _medias[0]; |
| 694 | 1443 |
} |
1444 |
} |
|
1445 |
} |
|
1446 |
return this.currentMedia; |
|
| 898 | 1447 |
}; |
| 694 | 1448 |
|
| 898 | 1449 |
Source.prototype.merge = function(_source) { |
| 638 | 1450 |
var _this = this; |
1451 |
_source.forEach(function(_value, _key) { |
|
1452 |
_this.getList(_key).addElements(_value); |
|
1453 |
}); |
|
| 898 | 1454 |
}; |
| 638 | 1455 |
|
| 598 | 1456 |
/* */ |
1457 |
||
| 898 | 1458 |
var RemoteSource = Model.RemoteSource = function(_config) { |
1459 |
Source.call(this, _config); |
|
1460 |
}; |
|
| 598 | 1461 |
|
| 898 | 1462 |
extendPrototype(RemoteSource, Source); |
| 598 | 1463 |
|
| 898 | 1464 |
RemoteSource.prototype.get = function() { |
1465 |
this.status = _SOURCE_STATUS_WAITING; |
|
| 719 | 1466 |
var _this = this, |
1467 |
urlparams = this.url_params || {}, |
|
| 898 | 1468 |
dataType = (isLocalURL(this.url) ? "json" : "jsonp"); |
| 719 | 1469 |
urlparams.format = dataType; |
1470 |
ns.jQuery.ajax({ |
|
1471 |
url: this.url, |
|
1472 |
dataType: dataType, |
|
1473 |
data: urlparams, |
|
| 755 | 1474 |
traditional: true, |
| 719 | 1475 |
success: function(_result) { |
1476 |
_this.deSerialize(_result); |
|
1477 |
_this.handleCallbacks(); |
|
1478 |
} |
|
| 598 | 1479 |
}); |
| 898 | 1480 |
}; |
| 598 | 1481 |
|
1482 |
/* */ |
|
1483 |
||
| 898 | 1484 |
var Directory = Model.Directory = function() { |
| 598 | 1485 |
this.remoteSources = {}; |
1486 |
this.elements = {}; |
|
| 898 | 1487 |
}; |
| 598 | 1488 |
|
| 898 | 1489 |
Directory.prototype.remoteSource = function(_properties) { |
| 638 | 1490 |
if (typeof _properties !== "object" || typeof _properties.url === "undefined") { |
| 898 | 1491 |
throw "Error : Directory.remoteSource(configuration): configuration.url is undefined"; |
| 638 | 1492 |
} |
| 719 | 1493 |
var _config = ns._({ directory: this }).extend(_properties); |
1494 |
_config.url_params = _config.url_params || {}; |
|
1495 |
var _hash = _config.url + "?" + ns.jQuery.param(_config.url_params); |
|
1496 |
if (typeof this.remoteSources[_hash] === "undefined") { |
|
| 898 | 1497 |
this.remoteSources[_hash] = new RemoteSource(_config); |
| 598 | 1498 |
} |
| 719 | 1499 |
return this.remoteSources[_hash]; |
| 898 | 1500 |
}; |
| 598 | 1501 |
|
| 898 | 1502 |
Directory.prototype.newLocalSource = function(_properties) { |
| 719 | 1503 |
var _config = ns._({ directory: this }).extend(_properties), |
| 898 | 1504 |
_res = new Source(_config); |
| 598 | 1505 |
return _res; |
| 898 | 1506 |
}; |
| 598 | 1507 |
|
| 898 | 1508 |
Directory.prototype.getElement = function(_id) { |
| 623 | 1509 |
return this.elements[_id]; |
| 898 | 1510 |
}; |
| 598 | 1511 |
|
| 898 | 1512 |
Directory.prototype.addElement = function(_element) { |
| 598 | 1513 |
this.elements[_element.id] = _element; |
| 898 | 1514 |
}; |
| 598 | 1515 |
|
| 898 | 1516 |
Directory.prototype.getGlobalList = function() { |
1517 |
var _res = new List(this); |
|
| 719 | 1518 |
_res.addIds(ns._(this.elements).keys()); |
| 598 | 1519 |
return _res; |
| 898 | 1520 |
}; |
| 719 | 1521 |
return Model; |
1522 |
||
1523 |
})(IriSP); |
|
| 776 | 1524 |
|
| 898 | 1525 |
/* END js */ |
| 598 | 1526 |
|
| 898 | 1527 |
/* HTML player, to be reused in a widget, or elsewhere */ |
| 598 | 1528 |
|
| 898 | 1529 |
IriSP.htmlPlayer = function(media, jqselector, options) { |
1530 |
|
|
1531 |
var opts = options || {}, |
|
1532 |
videoURL = opts.video || media.video; |
|
1533 |
|
|
1534 |
if (typeof opts.url_transform === "function") { |
|
1535 |
videoURL = opts.url_transform(videoURL); |
|
| 598 | 1536 |
} |
| 898 | 1537 |
|
1538 |
var videoEl = IriSP.jQuery('<video>'); |
|
1539 |
|
|
1540 |
videoEl.attr({ |
|
1541 |
width : opts.width || undefined, |
|
| 940 | 1542 |
height : opts.height || undefined, |
1543 |
controls : opts.controls || undefined, |
|
1544 |
autoplay : opts.autostart || opts.autoplay || undefined |
|
| 898 | 1545 |
}); |
| 726 | 1546 |
|
| 898 | 1547 |
if(typeof videoURL === "string"){ |
1548 |
videoEl.attr("src",videoURL); |
|
1549 |
} else { |
|
1550 |
for (var i = 0; i < videoURL.length; i++) { |
|
1551 |
var _srcNode = IriSP.jQuery('<source>'); |
|
1552 |
_srcNode.attr({ |
|
1553 |
src: videoURL[i].src, |
|
1554 |
type: videoURL[i].type |
|
1555 |
}); |
|
1556 |
videoEl.append(_srcNode); |
|
1557 |
} |
|
1558 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1559 |
if (opts.subtitle) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1560 |
var _trackNode = IriSP.jQuery('<track>'); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1561 |
_trackNode.attr({ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1562 |
label: "Subtitles", |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1563 |
kind: "subtitles", |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1564 |
srclang: "fr", |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1565 |
src: opts.subtitle, |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1566 |
default: "" |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1567 |
}); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1568 |
videoEl.append(_trackNode); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1569 |
} |
| 898 | 1570 |
jqselector.html(videoEl); |
1571 |
|
|
1572 |
var mediaEl = videoEl[0]; |
|
| 726 | 1573 |
|
| 898 | 1574 |
// Binding HTML video functions to media events |
1575 |
media.on("setcurrenttime", function(_milliseconds) { |
|
1576 |
try { |
|
1577 |
mediaEl.currentTime = (_milliseconds / 1000); |
|
1578 |
} catch (err) { |
|
1579 |
|
|
1580 |
} |
|
1581 |
}); |
|
| 598 | 1582 |
|
| 898 | 1583 |
media.on("setvolume", function(_vol) { |
1584 |
media.volume = _vol; |
|
1585 |
try { |
|
1586 |
mediaEl.volume = _vol; |
|
1587 |
} catch (err) { |
|
1588 |
|
|
1589 |
} |
|
| 598 | 1590 |
}); |
1591 |
|
|
| 898 | 1592 |
media.on("setmuted", function(_muted) { |
1593 |
media.muted = _muted; |
|
1594 |
try { |
|
1595 |
mediaEl.muted = _muted; |
|
1596 |
} catch (err) { |
|
1597 |
|
|
1598 |
} |
|
1599 |
}); |
|
| 776 | 1600 |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1601 |
media.on("settimerange", function(_timeRange){ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1602 |
media.timeRange = _timeRange; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1603 |
try { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1604 |
if (media.getCurrentTime() > _timeRange[0] || media.getCurrentTime() < _timeRange){ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1605 |
mediaEl.currentTime = (_timeRange[0] / 1000); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1606 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1607 |
} catch (err) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1608 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1609 |
}) |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1610 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1611 |
media.on("resettimerange", function(){ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1612 |
media.timeRange = false; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1613 |
}) |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1614 |
|
| 898 | 1615 |
media.on("setplay", function() { |
1616 |
try { |
|
1617 |
mediaEl.play(); |
|
1618 |
} catch (err) { |
|
1619 |
|
|
1620 |
} |
|
1621 |
}); |
|
| 786 | 1622 |
|
| 898 | 1623 |
media.on("setpause", function() { |
1624 |
try { |
|
1625 |
mediaEl.pause(); |
|
1626 |
} catch (err) { |
|
1627 |
|
|
1628 |
} |
|
1629 |
}); |
|
1630 |
|
|
1631 |
// Binding DOM events to media |
|
1632 |
function getVolume() { |
|
1633 |
media.muted = mediaEl.muted; |
|
1634 |
media.volume = mediaEl.volume; |
|
| 598 | 1635 |
} |
1636 |
|
|
| 898 | 1637 |
videoEl.on("loadedmetadata", function() { |
1638 |
getVolume(); |
|
1639 |
media.trigger("loadedmetadata"); |
|
1640 |
media.trigger("volumechange"); |
|
| 955 | 1641 |
}); |
| 598 | 1642 |
|
| 898 | 1643 |
videoEl.on("timeupdate", function() { |
1644 |
media.trigger("timeupdate", new IriSP.Model.Time(1000*mediaEl.currentTime)); |
|
1645 |
}); |
|
| 598 | 1646 |
|
| 898 | 1647 |
videoEl.on("volumechange", function() { |
1648 |
getVolume(); |
|
1649 |
media.trigger("volumechange"); |
|
| 955 | 1650 |
}); |
| 755 | 1651 |
|
| 898 | 1652 |
videoEl.on("play", function() { |
1653 |
media.trigger("play"); |
|
1654 |
}); |
|
1655 |
|
|
1656 |
videoEl.on("pause", function() { |
|
1657 |
media.trigger("pause"); |
|
1658 |
}); |
|
1659 |
|
|
1660 |
videoEl.on("seeking", function() { |
|
1661 |
media.trigger("seeking"); |
|
1662 |
}); |
|
1663 |
|
|
1664 |
videoEl.on("seeked", function() { |
|
1665 |
media.trigger("seeked"); |
|
1666 |
}); |
|
| 755 | 1667 |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1668 |
videoEl.on("click", function() { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1669 |
if (mediaEl.paused) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1670 |
media.play(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1671 |
} else { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1672 |
media.pause(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1673 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1674 |
}); |
| 598 | 1675 |
}; |
| 956 | 1676 |
/* START contentapi-serializer.js */ |
1677 |
||
1678 |
if (typeof IriSP.serializers === "undefined") { |
|
1679 |
IriSP.serializers = {}; |
|
1680 |
} |
|
1681 |
||
| 955 | 1682 |
IriSP.serializers.content = { |
1683 |
deSerialize : function(_data, _source) { |
|
1684 |
var _medialist = new IriSP.Model.List(_source.directory); |
|
1685 |
|
|
1686 |
function deserializeObject(_m, i) { |
|
1687 |
var _media = new IriSP.Model.Media(_m.iri_id, _source); |
|
1688 |
_media.video = _m.media_url; |
|
1689 |
_media.title = _m.title; |
|
1690 |
_media.description = _m.description; |
|
1691 |
_media.setDuration(_m.duration); |
|
1692 |
_media.thumbnail = _m.image; |
|
1693 |
_media.color = IriSP.vizcolors[i % IriSP.vizcolors.length]; |
|
1694 |
_media.keywords = _m.tags; |
|
1695 |
_medialist.push(_media); |
|
1696 |
} |
|
1697 |
|
|
1698 |
if (typeof _data.objects !== "undefined") { |
|
1699 |
IriSP._(_data.objects).each(deserializeObject); |
|
1700 |
} else { |
|
1701 |
deserializeObject(_data, 0); |
|
1702 |
} |
|
1703 |
|
|
1704 |
_source.addList("media", _medialist); |
|
1705 |
} |
|
1706 |
}; |
|
1707 |
||
1708 |
/* END contentapi-serializer.js */ |
|
| 956 | 1709 |
/* Start ldt-serializer.js */ |
| 598 | 1710 |
|
1711 |
if (typeof IriSP.serializers === "undefined") { |
|
| 898 | 1712 |
IriSP.serializers = {}; |
| 598 | 1713 |
} |
1714 |
||
1715 |
IriSP.serializers.ldt = { |
|
1716 |
types : { |
|
1717 |
media : { |
|
1718 |
serialized_name : "medias", |
|
1719 |
deserializer : function(_data, _source) { |
|
1720 |
var _res = new IriSP.Model.Media(_data.id, _source); |
|
1721 |
_res.video = ( |
|
1722 |
typeof _data.url !== "undefined" |
|
1723 |
? _data.url |
|
1724 |
: ( |
|
1725 |
typeof _data.href !== "undefined" |
|
1726 |
? _data.href |
|
1727 |
: null |
|
1728 |
) |
|
1729 |
); |
|
1730 |
if (typeof _data.meta.item !== "undefined" && _data.meta.item.name === "streamer") { |
|
1731 |
_res.streamer = _data.meta.item.value; |
|
1732 |
} |
|
1733 |
_res.title = _data.meta["dc:title"]; |
|
1734 |
_res.description = _data.meta["dc:description"]; |
|
1735 |
_res.setDuration(_data.meta["dc:duration"]); |
|
| 638 | 1736 |
_res.url = _data.meta.url; |
1737 |
if (typeof _data.meta.img !== "undefined" && _data.meta.img.src !== "undefined") { |
|
1738 |
_res.thumbnail = _data.meta.img.src; |
|
1739 |
} |
|
| 598 | 1740 |
return _res; |
1741 |
}, |
|
| 719 | 1742 |
serializer : function(_data, _source, _dest) { |
1743 |
var _res = { |
|
| 638 | 1744 |
id : _data.id, |
| 598 | 1745 |
url : _data.video, |
1746 |
meta : { |
|
| 719 | 1747 |
"dc:title": _data.title || "", |
1748 |
"dc:description": _data.description || "", |
|
1749 |
"dc:created" : IriSP.Model.dateToIso(_data.created || _source.created), |
|
1750 |
"dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified), |
|
1751 |
"dc:creator" : _data.creator || _source.creator, |
|
1752 |
"dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator, |
|
| 598 | 1753 |
"dc:duration" : _data.duration.milliseconds |
1754 |
} |
|
| 955 | 1755 |
}; |
| 719 | 1756 |
_dest.medias.push(_res); |
1757 |
var _list = { |
|
1758 |
id: IriSP.Model.getUID(), |
|
1759 |
meta : { |
|
1760 |
"dc:title": _data.title || "", |
|
1761 |
"dc:description": _data.description || "", |
|
1762 |
"dc:created" : IriSP.Model.dateToIso(_data.created || _source.created), |
|
1763 |
"dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified), |
|
1764 |
"dc:creator" : _data.creator || _source.creator, |
|
1765 |
"dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator, |
|
1766 |
"id-ref": _data.id |
|
1767 |
}, |
|
1768 |
items: _source.getAnnotationTypes().filter(function(_at) { |
|
| 940 | 1769 |
switch (typeof _at.media) { |
1770 |
case "object": |
|
1771 |
return (_at.media === _data); |
|
1772 |
case "string": |
|
1773 |
return (_at.media === _data.id); |
|
1774 |
default: |
|
1775 |
var _ann = _at.getAnnotations(); |
|
1776 |
if (_ann) { |
|
1777 |
for (var i = 0; i < _ann.length; i++) { |
|
1778 |
if (_ann[i].getMedia() === _data) { |
|
1779 |
return true; |
|
1780 |
} |
|
1781 |
} |
|
1782 |
} |
|
1783 |
} |
|
1784 |
return false; |
|
| 719 | 1785 |
}).map(function(_at) { |
1786 |
return { |
|
1787 |
"id-ref": _at.id |
|
| 955 | 1788 |
}; |
| 719 | 1789 |
}) |
| 955 | 1790 |
}; |
| 719 | 1791 |
_dest.lists.push(_list); |
1792 |
_dest.views[0].contents.push(_data.id); |
|
| 598 | 1793 |
} |
1794 |
}, |
|
1795 |
tag : { |
|
1796 |
serialized_name : "tags", |
|
1797 |
deserializer : function(_data, _source) { |
|
1798 |
var _res = new IriSP.Model.Tag(_data.id, _source); |
|
1799 |
_res.title = _data.meta["dc:title"]; |
|
1800 |
return _res; |
|
1801 |
}, |
|
| 719 | 1802 |
serializer : function(_data, _source, _dest) { |
| 940 | 1803 |
if (_source.regenerateTags && !_data.regenerated) { |
1804 |
return; |
|
1805 |
} |
|
| 719 | 1806 |
var _res = { |
| 638 | 1807 |
id : _data.id, |
| 598 | 1808 |
meta : { |
| 719 | 1809 |
"dc:title": _data.title || "", |
1810 |
"dc:description": _data.description || "", |
|
1811 |
"dc:created" : IriSP.Model.dateToIso(_data.created || _source.created), |
|
1812 |
"dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified), |
|
1813 |
"dc:creator" : _data.creator || _source.creator, |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
1814 |
"dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator |
| 598 | 1815 |
} |
| 955 | 1816 |
}; |
| 719 | 1817 |
_dest.tags.push(_res); |
| 598 | 1818 |
} |
1819 |
}, |
|
1820 |
annotationType : { |
|
1821 |
serialized_name : "annotation-types", |
|
1822 |
deserializer : function(_data, _source) { |
|
1823 |
var _res = new IriSP.Model.AnnotationType(_data.id, _source); |
|
1824 |
_res.title = _data["dc:title"]; |
|
1825 |
_res.description = _data["dc:description"]; |
|
1826 |
return _res; |
|
1827 |
}, |
|
| 719 | 1828 |
serializer : function(_data, _source, _dest) { |
1829 |
var _res = { |
|
| 638 | 1830 |
id : _data.id, |
| 719 | 1831 |
"dc:title": _data.title || "", |
1832 |
"dc:description": _data.description || "", |
|
1833 |
"dc:created" : IriSP.Model.dateToIso(_data.created || _source.created), |
|
1834 |
"dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified), |
|
1835 |
"dc:creator" : _data.creator || _source.creator, |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
1836 |
"dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator |
| 955 | 1837 |
}; |
| 719 | 1838 |
_dest["annotation-types"].push(_res); |
1839 |
_dest.views[0].annotation_types.push(_data.id); |
|
| 598 | 1840 |
} |
1841 |
}, |
|
1842 |
annotation : { |
|
1843 |
serialized_name : "annotations", |
|
1844 |
deserializer : function(_data, _source) { |
|
1845 |
var _res = new IriSP.Model.Annotation(_data.id, _source); |
|
1846 |
_res.title = _data.content.title || ""; |
|
1847 |
_res.description = _data.content.description || ""; |
|
1848 |
if (typeof _data.content.img !== "undefined" && _data.content.img.src !== "undefined") { |
|
1849 |
_res.thumbnail = _data.content.img.src; |
|
1850 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
1851 |
_res.created = IriSP.Model.isoToDate(_data.created ? _data.created : _data.meta? _data.meta["dc:created"] : ""); |
| 598 | 1852 |
if (typeof _data.color !== "undefined") { |
1853 |
var _c = parseInt(_data.color).toString(16); |
|
1854 |
while (_c.length < 6) { |
|
1855 |
_c = '0' + _c; |
|
1856 |
} |
|
1857 |
_res.color = '#' + _c; |
|
1858 |
} |
|
| 940 | 1859 |
_res.content = _data.content; |
| 638 | 1860 |
_res.setMedia(_data.media); |
| 598 | 1861 |
_res.setAnnotationType(_data.meta["id-ref"]); |
1862 |
_res.setTags(IriSP._(_data.tags).pluck("id-ref")); |
|
| 719 | 1863 |
_res.keywords = _res.getTagTexts(); |
| 598 | 1864 |
_res.setBegin(_data.begin); |
1865 |
_res.setEnd(_data.end); |
|
1866 |
_res.creator = _data.meta["dc:creator"] || ""; |
|
1867 |
_res.project = _data.meta.project || ""; |
|
1868 |
if (typeof _data.meta["dc:source"] !== "undefined" && typeof _data.meta["dc:source"].content !== "undefined") { |
|
1869 |
_res.source = JSON.parse(_data.meta["dc:source"].content); |
|
1870 |
} |
|
| 638 | 1871 |
if (typeof _data.content.audio !== "undefined" && _data.content.audio.href) { |
1872 |
_res.audio = _data.content.audio; |
|
1873 |
} |
|
| 598 | 1874 |
return _res; |
1875 |
}, |
|
| 719 | 1876 |
serializer : function(_data, _source, _dest) { |
1877 |
var _color = parseInt(_data.color.replace(/^#/,''),16).toString(); |
|
1878 |
var _res = { |
|
| 638 | 1879 |
id : _data.id, |
| 623 | 1880 |
begin : _data.begin.milliseconds, |
1881 |
end : _data.end.milliseconds, |
|
| 940 | 1882 |
content : IriSP._.defaults( |
1883 |
{}, |
|
1884 |
{ |
|
1885 |
title : _data.title, |
|
1886 |
description : _data.description, |
|
| 719 | 1887 |
audio : _data.audio, |
1888 |
img: { |
|
1889 |
src: _data.thumbnail |
|
1890 |
} |
|
| 598 | 1891 |
}, |
| 940 | 1892 |
_data.content, |
1893 |
{ |
|
1894 |
title: "", |
|
1895 |
description: "" |
|
1896 |
} |
|
1897 |
), |
|
| 719 | 1898 |
color: _color, |
| 638 | 1899 |
media : _data.media.id, |
| 598 | 1900 |
meta : { |
| 719 | 1901 |
"id-ref" : _data.getAnnotationType().id, |
1902 |
"dc:created" : IriSP.Model.dateToIso(_data.created || _source.created), |
|
1903 |
"dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified), |
|
1904 |
"dc:creator" : _data.creator || _source.creator, |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
1905 |
"dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator |
| 719 | 1906 |
// project : _source.projectId |
| 940 | 1907 |
} |
| 955 | 1908 |
}; |
| 940 | 1909 |
if (_source.regenerateTags) { |
1910 |
_res.tags = IriSP._(_data.keywords).map(function(_kw) { |
|
1911 |
return { |
|
1912 |
"id-ref": _source.__keywords[_kw.toLowerCase()].id |
|
| 955 | 1913 |
}; |
| 940 | 1914 |
}); |
1915 |
} else { |
|
1916 |
_res.tags = IriSP._(_data.tag.id).map(function(_id) { |
|
| 598 | 1917 |
return { |
| 638 | 1918 |
"id-ref" : _id |
| 955 | 1919 |
}; |
| 940 | 1920 |
}); |
| 598 | 1921 |
} |
| 940 | 1922 |
_res.content.title = _data.title || _res.content.title || ""; |
| 719 | 1923 |
_dest.annotations.push(_res); |
| 598 | 1924 |
} |
| 623 | 1925 |
}, |
1926 |
mashup : { |
|
|
648
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
1927 |
serialized_name : "lists", |
| 623 | 1928 |
deserializer : function(_data, _source) { |
|
648
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
1929 |
if (typeof _data.meta !== "object" || typeof _data.meta.listtype !== "string" || _data.meta.listtype !== "mashup") { |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
1930 |
return undefined; |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
1931 |
} |
| 623 | 1932 |
var _res = new IriSP.Model.Mashup(_data.id, _source); |
1933 |
_res.title = _data.meta["dc:title"]; |
|
1934 |
_res.description = _data.meta["dc:description"]; |
|
| 719 | 1935 |
_res.creator = _data.meta["dc:creator"]; |
1936 |
_res.setAnnotationsById(_data.items); |
|
| 623 | 1937 |
return _res; |
1938 |
}, |
|
| 719 | 1939 |
serializer : function(_data, _source, _dest) { |
1940 |
var _res = { |
|
|
648
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
1941 |
meta : { |
| 719 | 1942 |
"dc:title": _data.title || "", |
1943 |
"dc:description": _data.description || "", |
|
1944 |
"dc:created" : IriSP.Model.dateToIso(_data.created || _source.created), |
|
1945 |
"dc:modified" : IriSP.Model.dateToIso(_data.modified || _source.modified), |
|
1946 |
"dc:creator" : _data.creator || _source.creator, |
|
1947 |
"dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator, |
|
|
648
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
1948 |
listtype: "mashup" |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
1949 |
}, |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
1950 |
items: _data.segments.map(function(_annotation) { |
| 719 | 1951 |
return _annotation.annotation.id; |
|
648
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
1952 |
}), |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
1953 |
id: _data.id |
| 955 | 1954 |
}; |
| 719 | 1955 |
_dest.lists.push(_res); |
| 623 | 1956 |
} |
| 598 | 1957 |
} |
1958 |
}, |
|
1959 |
serialize : function(_source) { |
|
| 719 | 1960 |
var _res = { |
1961 |
meta: { |
|
1962 |
"dc:creator": _source.creator, |
|
1963 |
"dc:contributor" : _source.contributor || _source.creator, |
|
1964 |
"dc:created": IriSP.Model.dateToIso(_source.created), |
|
1965 |
"dc:modified" : IriSP.Model.dateToIso(_source.modified), |
|
1966 |
"dc:title": _source.title || "", |
|
1967 |
"dc:description": _source.description || "", |
|
1968 |
id: _source.projectId || _source.id |
|
1969 |
}, |
|
1970 |
views: [ |
|
1971 |
{ |
|
1972 |
id: IriSP.Model.getUID(), |
|
1973 |
contents: [], |
|
1974 |
annotation_types: [] |
|
1975 |
} |
|
1976 |
], |
|
1977 |
lists: [], |
|
1978 |
"annotation-types": [], |
|
1979 |
medias: [], |
|
1980 |
tags: [], |
|
1981 |
annotations: [] |
|
1982 |
}, |
|
| 598 | 1983 |
_this = this; |
| 940 | 1984 |
if (_source.regenerateTags) { |
1985 |
_source.__keywords = {}; |
|
1986 |
_source.getAnnotations().forEach(function(a) { |
|
1987 |
IriSP._(a.keywords).each(function(kw) { |
|
1988 |
var lkw = kw.toLowerCase(); |
|
1989 |
if (typeof _source.__keywords[lkw] === "undefined") { |
|
1990 |
_source.__keywords[lkw] = { |
|
1991 |
id: IriSP.Model.getUID(), |
|
1992 |
title: kw, |
|
1993 |
regenerated: true |
|
| 955 | 1994 |
}; |
| 940 | 1995 |
} |
1996 |
}); |
|
1997 |
}); |
|
1998 |
IriSP._(_source.__keywords).each(function(kw) { |
|
1999 |
_this.types.tag.serializer(kw, _source, _res); |
|
| 955 | 2000 |
}); |
| 940 | 2001 |
} |
| 598 | 2002 |
_source.forEach(function(_list, _typename) { |
2003 |
if (typeof _this.types[_typename] !== "undefined") { |
|
| 719 | 2004 |
_list.forEach(function(_el) { |
2005 |
_this.types[_typename].serializer(_el, _source, _res); |
|
| 598 | 2006 |
}); |
2007 |
} |
|
2008 |
}); |
|
| 623 | 2009 |
return JSON.stringify(_res); |
| 598 | 2010 |
}, |
2011 |
deSerialize : function(_data, _source) { |
|
2012 |
if (typeof _data !== "object" || _data === null) { |
|
2013 |
return; |
|
2014 |
} |
|
2015 |
IriSP._(this.types).forEach(function(_type, _typename) { |
|
| 638 | 2016 |
var _listdata = _data[_type.serialized_name], |
2017 |
_list = new IriSP.Model.List(_source.directory); |
|
| 598 | 2018 |
if (typeof _listdata !== "undefined" && _listdata !== null) { |
2019 |
if (_listdata.hasOwnProperty("length")) { |
|
2020 |
var _l = _listdata.length; |
|
2021 |
for (var _i = 0; _i < _l; _i++) { |
|
|
648
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
2022 |
var _element = _type.deserializer(_listdata[_i], _source); |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
2023 |
if (typeof _element !== "undefined" && _element) { |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
2024 |
_list.push(_element); |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
2025 |
} |
| 598 | 2026 |
} |
2027 |
} else { |
|
|
648
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
2028 |
var _element = _type.deserializer(_listdata, _source); |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
2029 |
if (typeof _element !== "undefined" && _element) { |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
2030 |
_list.push(_element); |
|
b28afee5470b
Changed Segment widget parameters
Raphael Velt <raph.velt@gmail.com>
parents:
638
diff
changeset
|
2031 |
} |
| 598 | 2032 |
} |
2033 |
} |
|
| 638 | 2034 |
_source.addList(_typename, _list); |
| 598 | 2035 |
}); |
2036 |
|
|
2037 |
if (typeof _data.meta !== "undefined") { |
|
2038 |
_source.projectId = _data.meta.id; |
|
| 940 | 2039 |
_source.title = _data.meta["dc:title"] || _data.meta.title || ""; |
2040 |
_source.description = _data.meta["dc:description"] || _data.meta.description || ""; |
|
2041 |
_source.creator = _data.meta["dc:creator"] || _data.meta.creator || ""; |
|
2042 |
_source.contributor = _data.meta["dc:contributor"] || _data.meta.contributor || _source.creator; |
|
2043 |
_source.created = IriSP.Model.isoToDate(_data.meta["dc:created"] || _data.meta.created); |
|
| 598 | 2044 |
} |
2045 |
|
|
2046 |
if (typeof _data.meta !== "undefined" && typeof _data.meta.main_media !== "undefined" && typeof _data.meta.main_media["id-ref"] !== "undefined") { |
|
| 694 | 2047 |
_source.currentMedia = _source.getElement(_data.meta.main_media["id-ref"]); |
| 598 | 2048 |
} |
2049 |
} |
|
| 898 | 2050 |
}; |
| 598 | 2051 |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2052 |
/* End of LDT Platform Serializer */ |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2053 |
/* ldt_annotate serializer: Used when Putting annotations on the platform */ |
| 638 | 2054 |
|
2055 |
if (typeof IriSP.serializers === "undefined") { |
|
| 898 | 2056 |
IriSP.serializers = {}; |
| 638 | 2057 |
} |
2058 |
||
2059 |
IriSP.serializers.ldt_annotate = { |
|
| 719 | 2060 |
serializeAnnotation : function(_data, _source) { |
2061 |
var _annType = _data.getAnnotationType(); |
|
2062 |
return { |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2063 |
id: _data.id, |
| 719 | 2064 |
begin: _data.begin.milliseconds, |
2065 |
end: _data.end.milliseconds, |
|
2066 |
content: { |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2067 |
data: (_data.content ? _data.content.data || {} : {}), |
| 719 | 2068 |
description: _data.description, |
2069 |
title: _data.title, |
|
2070 |
audio: _data.audio |
|
2071 |
}, |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2072 |
id: _data.id ? _data.id : "", // If annotation is new, id will be undefined |
| 719 | 2073 |
tags: _data.getTagTexts(), |
2074 |
media: _data.getMedia().id, |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2075 |
project: _data.project_id, |
| 719 | 2076 |
type_title: _annType.title, |
2077 |
type: ( typeof _annType.dont_send_id !== "undefined" && _annType.dont_send_id ? "" : _annType.id ), |
|
2078 |
meta: { |
|
2079 |
created: _data.created, |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2080 |
creator: _data.creator, |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2081 |
modified: _data.modified, |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2082 |
contributor: _data.contributor |
| 638 | 2083 |
} |
| 955 | 2084 |
}; |
| 638 | 2085 |
}, |
| 719 | 2086 |
deserializeAnnotation : function(_anndata, _source) { |
2087 |
var _ann = new IriSP.Model.Annotation(_anndata.id, _source); |
|
2088 |
_ann.description = _anndata.content.description || ""; |
|
2089 |
_ann.title = _anndata.content.title || ""; |
|
2090 |
_ann.creator = _anndata.meta.creator || ""; |
|
2091 |
_ann.created = new Date(_anndata.meta.created); |
|
2092 |
_ann.setMedia(_anndata.media, _source); |
|
2093 |
var _anntype = _source.getElement(_anndata.type); |
|
2094 |
if (!_anntype) { |
|
2095 |
_anntype = new IriSP.Model.AnnotationType(_anndata.type, _source); |
|
2096 |
_anntype.title = _anndata.type_title; |
|
2097 |
_source.getAnnotationTypes().push(_anntype); |
|
2098 |
} |
|
2099 |
_ann.setAnnotationType(_anntype.id); |
|
2100 |
var _tagIds = IriSP._(_anndata.tags).map(function(_title) { |
|
2101 |
var _tags = _source.getTags(true).searchByTitle(_title, true); |
|
2102 |
if (_tags.length) { |
|
2103 |
var _tag = _tags[0]; |
|
2104 |
} |
|
2105 |
else { |
|
2106 |
_tag = new IriSP.Model.Tag(_title.replace(/\W/g,'_'),_source); |
|
2107 |
_tag.title = _title; |
|
2108 |
_source.getTags().push(_tag); |
|
2109 |
} |
|
2110 |
return _tag.id; |
|
2111 |
}); |
|
2112 |
_ann.setTags(_tagIds); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2113 |
_ann.setBeginEnd(_anndata.begin, _anndata.end); |
| 719 | 2114 |
if (typeof _anndata.content.audio !== "undefined" && _anndata.content.audio.href) { |
2115 |
_ann.audio = _anndata.content.audio; |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2116 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2117 |
if (_anndata.content.data) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2118 |
_ann.content = { data: _anndata.content.data }; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2119 |
}; |
| 719 | 2120 |
_source.getAnnotations().push(_ann); |
2121 |
}, |
|
| 638 | 2122 |
serialize : function(_source) { |
| 719 | 2123 |
return JSON.stringify(this.serializeAnnotation(_source.getAnnotations()[0], _source)); |
| 638 | 2124 |
}, |
2125 |
deSerialize : function(_data, _source) { |
|
2126 |
if (typeof _data == "string") { |
|
2127 |
_data = JSON.parse(_data); |
|
2128 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2129 |
|
| 638 | 2130 |
_source.addList('tag', new IriSP.Model.List(_source.directory)); |
2131 |
_source.addList('annotationType', new IriSP.Model.List(_source.directory)); |
|
2132 |
_source.addList('annotation', new IriSP.Model.List(_source.directory)); |
|
| 719 | 2133 |
this.deserializeAnnotation(_data, _source); |
| 638 | 2134 |
} |
| 898 | 2135 |
}; |
2136 |
||
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2137 |
/* End ldt_annotate serializer */ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2138 |
/* ldt_localstorage serializer: Used to store personal annotations in local storage */ |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2139 |
|
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2140 |
if (typeof IriSP.serializers === "undefined") { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2141 |
IriSP.serializers = {}; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2142 |
} |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2143 |
|
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2144 |
IriSP.serializers.ldt_localstorage = { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2145 |
serializeAnnotation : function(_data, _source) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2146 |
var _annType = _data.getAnnotationType(); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2147 |
return { |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2148 |
id: _data.id, |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2149 |
begin: _data.begin.milliseconds, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2150 |
end: _data.end.milliseconds, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2151 |
content: { |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2152 |
data: (_data.content ? _data.content.data || {} : {}), |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2153 |
description: _data.description, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2154 |
title: _data.title, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2155 |
audio: _data.audio |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2156 |
}, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2157 |
tags: _data.getTagTexts(), |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2158 |
media: _data.getMedia().id, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2159 |
type_title: _annType.title, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2160 |
type: ( typeof _annType.dont_send_id !== "undefined" && _annType.dont_send_id ? "" : _annType.id ), |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2161 |
meta: { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2162 |
created: _data.created, |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2163 |
creator: _data.creator, |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2164 |
modified: _data.modified, |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2165 |
contributor: _data.contributor |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2166 |
} |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2167 |
}; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2168 |
}, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2169 |
deserializeAnnotation : function(_anndata, _source) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2170 |
var _ann = new IriSP.Model.Annotation(_anndata.id, _source); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2171 |
_ann.description = _anndata.content.description || ""; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2172 |
_ann.title = _anndata.content.title || ""; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2173 |
_ann.creator = _anndata.meta.creator || ""; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2174 |
_ann.created = new Date(_anndata.meta.created); |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2175 |
_ann.contributor = _anndata.meta.contributor || ""; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2176 |
_ann.modified = new Date(_anndata.meta.modified); |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2177 |
_ann.setMedia(_anndata.media, _source); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2178 |
var _anntype = _source.getElement(_anndata.type); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2179 |
if (!_anntype) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2180 |
_anntype = new IriSP.Model.AnnotationType(_anndata.type, _source); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2181 |
_anntype.title = _anndata.type_title; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2182 |
_source.getAnnotationTypes().push(_anntype); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2183 |
} |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2184 |
_ann.setAnnotationType(_anntype.id); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2185 |
var _tagIds = IriSP._(_anndata.tags).map(function(_title) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2186 |
var _tags = _source.getTags(true).searchByTitle(_title, true); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2187 |
if (_tags.length) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2188 |
var _tag = _tags[0]; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2189 |
} |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2190 |
else { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2191 |
_tag = new IriSP.Model.Tag(_title.replace(/\W/g,'_'),_source); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2192 |
_tag.title = _title; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2193 |
_source.getTags().push(_tag); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2194 |
} |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2195 |
return _tag.id; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2196 |
}); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2197 |
_ann.setTags(_tagIds); |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2198 |
_ann.setBeginEnd(_anndata.begin, _anndata.end); |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2199 |
if (typeof _anndata.content.audio !== "undefined" && _anndata.content.audio.href) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2200 |
_ann.audio = _anndata.content.audio; |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2201 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2202 |
if (_anndata.content.data) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2203 |
_ann.content = { data: _anndata.content.data }; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2204 |
}; |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2205 |
_source.getAnnotations().push(_ann); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2206 |
}, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2207 |
serialize : function(_source) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2208 |
var _this = this; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2209 |
return JSON.stringify(_source.getAnnotations().map(function (a) { return _this.serializeAnnotation(a, _source); })); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2210 |
}, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2211 |
deSerialize : function(_data, _source) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2212 |
var _this = this; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2213 |
if (typeof _data == "string") { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2214 |
_data = JSON.parse(_data); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2215 |
} |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2216 |
|
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2217 |
_source.addList('tag', new IriSP.Model.List(_source.directory)); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2218 |
_source.addList('annotationType', new IriSP.Model.List(_source.directory)); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2219 |
_source.addList('annotation', new IriSP.Model.List(_source.directory)); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2220 |
_data.map( function (a) { _this.deserializeAnnotation(a, _source); }); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2221 |
} |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2222 |
}; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2223 |
|
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2224 |
/* End ldt_localstorage serializer */ |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2225 |
/* START segmentapi-serializer.js */ |
| 956 | 2226 |
|
2227 |
if (typeof IriSP.serializers === "undefined") { |
|
2228 |
IriSP.serializers = {}; |
|
2229 |
} |
|
2230 |
||
2231 |
IriSP.serializers.segmentapi = { |
|
| 955 | 2232 |
deSerialize : function(_data, _source) { |
2233 |
var _annotationlist = new IriSP.Model.List(_source.directory), |
|
2234 |
_medialist = new IriSP.Model.List(_source.directory); |
|
2235 |
_source.addList("media", _medialist); |
|
2236 |
|
|
2237 |
function deserializeObject(_s) { |
|
2238 |
var _ann = new IriSP.Model.Annotation(_s.element_id, _source), |
|
2239 |
_media = _source.getElement(_s.iri_id); |
|
2240 |
if (!_media) { |
|
2241 |
_media = new IriSP.Model.Media(_s.iri_id, _source); |
|
2242 |
_source.getMedias().push(_media); |
|
2243 |
} |
|
2244 |
_ann.setMedia(_s.iri_id); |
|
2245 |
_ann.title = _s.title; |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2246 |
_ann.description = _s['abstract']; |
| 955 | 2247 |
_ann.begin = new IriSP.Model.Time(_s.start_ts); |
2248 |
_ann.end = new IriSP.Model.Time(_s.start_ts + _s.duration); |
|
2249 |
_ann.keywords = (_s.tags ? _s.tags.split(",") : []); |
|
2250 |
_ann.project_id = _s.project_id; |
|
2251 |
_annotationlist.push(_ann); |
|
2252 |
} |
|
2253 |
|
|
2254 |
if (typeof _data.objects !== "undefined") { |
|
2255 |
IriSP._(_data.objects).each(deserializeObject); |
|
2256 |
} else { |
|
2257 |
deserializeObject(_data); |
|
2258 |
} |
|
2259 |
_source.addList("annotation", _annotationlist); |
|
2260 |
} |
|
2261 |
}; |
|
2262 |
||
2263 |
/* END segmentapi-serializer.js */ |
|
2264 |
/* Start of defaults.js */ |
|
| 898 | 2265 |
|
2266 |
IriSP.language = 'en'; |
|
2267 |
||
2268 |
IriSP.libFiles = { |
|
2269 |
defaultDir : "js/libs/", |
|
2270 |
inDefaultDir : { |
|
2271 |
underscore : "underscore-min.js", |
|
2272 |
Mustache : "mustache.js", |
|
2273 |
jQuery : "jquery.min.js", |
|
2274 |
jQueryUI : "jquery-ui.min.js", |
|
2275 |
swfObject : "swfobject.js", |
|
2276 |
cssjQueryUI : "jquery-ui.css", |
|
2277 |
popcorn : "popcorn-complete.min.js", |
|
2278 |
jwplayer : "jwplayer.js", |
|
2279 |
raphael : "raphael-min.js", |
|
2280 |
tracemanager : "tracemanager.js", |
|
2281 |
jwPlayerSWF : "player.swf", |
|
2282 |
json : "json2.js", |
|
2283 |
zeroClipboardJs: "ZeroClipboard.js", |
|
2284 |
zeroClipboardSwf: "ZeroClipboard.swf", |
|
2285 |
backbone: "backbone.js", |
|
2286 |
backboneRelational: "backbone-relational.js", |
|
2287 |
paper: "paper.js", |
|
2288 |
jqueryMousewheel: "jquery.mousewheel.min.js", |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2289 |
splitter: "jquery.touchsplitter.js", |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2290 |
cssSplitter: "jquery.touchsplitter.css", |
| 898 | 2291 |
renkanPublish: "renkan.js", |
2292 |
processing: "processing-1.3.6.min.js", |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2293 |
recordMicSwf: "record_mic.swf", |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2294 |
mousetrap: "mousetrap.min.js", |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2295 |
mousetrapGlobal: "mousetrap-global-bind.js" |
| 898 | 2296 |
}, |
2297 |
locations : { |
|
2298 |
// use to define locations outside default_dir |
|
2299 |
}, |
|
2300 |
cdn : { |
|
2301 |
jQuery : "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js", |
|
2302 |
jQueryUI : "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.min.js", |
|
2303 |
swfObject : "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js", |
|
2304 |
cssjQueryUI : "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/themes/ui-lightness/jquery-ui.css", |
|
2305 |
underscore : "http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js", |
|
2306 |
Mustache : "http://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.5.0-dev/mustache.min.js", |
|
2307 |
raphael : "http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js", |
|
2308 |
json : "http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js", |
|
2309 |
popcorn: "http://cdn.popcornjs.org/code/dist/popcorn-complete.min.js" |
|
2310 |
}, |
|
2311 |
useCdn : false |
|
2312 |
}; |
|
2313 |
||
2314 |
IriSP.widgetsDir = 'widgets'; |
|
2315 |
||
2316 |
IriSP.widgetsRequirements = { |
|
2317 |
PopcornPlayer: { |
|
2318 |
noCss: true, |
|
2319 |
requires: [ "popcorn" ] |
|
2320 |
}, |
|
2321 |
HtmlPlayer: { |
|
2322 |
noCss: true |
|
2323 |
}, |
|
2324 |
JwpPlayer: { |
|
2325 |
noCss: true, |
|
2326 |
requires: [ "jwplayer" ] |
|
2327 |
}, |
|
2328 |
DailymotionPlayer: { |
|
2329 |
noCss: true, |
|
2330 |
requires: [ "swfObject" ] |
|
2331 |
}, |
|
2332 |
AdaptivePlayer: { |
|
2333 |
noCss: true |
|
2334 |
}, |
|
2335 |
AutoPlayer: { |
|
2336 |
noCss: true |
|
2337 |
}, |
|
2338 |
AnnotationsList: { |
|
2339 |
requires: [ "jwplayer" ] |
|
2340 |
}, |
|
2341 |
Sparkline: { |
|
2342 |
noCss: true, |
|
2343 |
requires: [ "raphael" ] |
|
2344 |
}, |
|
2345 |
Arrow: { |
|
2346 |
noCss: true, |
|
2347 |
requires: [ "raphael" ] |
|
2348 |
}, |
|
2349 |
Mediafragment: { |
|
2350 |
noCss: true |
|
2351 |
}, |
|
2352 |
Trace : { |
|
2353 |
noCss: true, |
|
2354 |
requires: [ "tracemanager" ] |
|
2355 |
}, |
|
2356 |
Slideshare: { |
|
2357 |
requires: [ "swfObject" ] |
|
2358 |
}, |
|
2359 |
Social: { |
|
2360 |
requires: [ "zeroClipboardJs" ] |
|
2361 |
}, |
|
2362 |
Renkan: { |
|
2363 |
requires: [ "backbone", "backboneRelational", "paper", "jqueryMousewheel", "renkanPublish" ] |
|
2364 |
}, |
|
2365 |
KnowledgeConcierge: { |
|
2366 |
requires: [ "processing" ] |
|
2367 |
}, |
|
2368 |
MultiSegments: { |
|
2369 |
noCss: true |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2370 |
}, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2371 |
SlideVideoPlayer: { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2372 |
requires: [ "jQuery", "jQueryUI", "splitter" ] |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2373 |
}, |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2374 |
Shortcuts: { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2375 |
requires: [ "mousetrap", "mousetrapGlobal" ] |
| 898 | 2376 |
} |
2377 |
}; |
|
2378 |
||
2379 |
IriSP.guiDefaults = { |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2380 |
width : 640, |
| 898 | 2381 |
container : 'LdtPlayer', |
| 940 | 2382 |
spacer_div_height : 0, |
2383 |
widgets: [] |
|
| 898 | 2384 |
}; |
2385 |
||
2386 |
/* End of defaults.js */ |
|
2387 |
/* widgets-container/metadataplayer.js - initialization and configuration of the widgets |
|
2388 |
*/ |
|
2389 |
||
2390 |
/* The Metadataplayer Object, single point of entry, replaces IriSP.init_player */ |
|
2391 |
||
2392 |
(function(ns) { |
|
2393 |
||
2394 |
var formerJQuery, formerUnderscore, former$; |
|
2395 |
||
2396 |
var Metadataplayer = ns.Metadataplayer = function(config) { |
|
2397 |
ns.log("IriSP.Metadataplayer constructor"); |
|
2398 |
for (var key in ns.guiDefaults) { |
|
2399 |
if (ns.guiDefaults.hasOwnProperty(key) && !config.hasOwnProperty(key)) { |
|
2400 |
config[key] = ns.guiDefaults[key] |
|
2401 |
} |
|
2402 |
} |
|
2403 |
var _container = document.getElementById(config.container); |
|
2404 |
_container.innerHTML = '<h3 class="Ldt-Loader">Loading... Chargement...</h3>'; |
|
2405 |
this.sourceManager = new ns.Model.Directory(); |
|
2406 |
this.config = config; |
|
2407 |
this.__events = {}; |
|
2408 |
this.loadLibs(); |
|
2409 |
}; |
|
2410 |
||
2411 |
Metadataplayer.prototype.toString = function() { |
|
2412 |
return 'Metadataplayer in #' + this.config.container; |
|
2413 |
}; |
|
2414 |
||
2415 |
Metadataplayer.prototype.on = function(_event, _callback) { |
|
2416 |
if (typeof this.__events[_event] === "undefined") { |
|
2417 |
this.__events[_event] = []; |
|
2418 |
} |
|
2419 |
this.__events[_event].push(_callback); |
|
2420 |
}; |
|
2421 |
||
2422 |
Metadataplayer.prototype.trigger = function(_event, _data) { |
|
2423 |
var _element = this; |
|
2424 |
ns._(this.__events[_event]).each(function(_callback) { |
|
2425 |
_callback.call(_element, _data); |
|
2426 |
}); |
|
2427 |
}; |
|
2428 |
||
2429 |
Metadataplayer.prototype.loadLibs = function() { |
|
2430 |
ns.log("IriSP.Metadataplayer.prototype.loadLibs"); |
|
2431 |
var $L = $LAB |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2432 |
.queueScript(ns.getLib("Mustache")); |
| 898 | 2433 |
formerJQuery = !!window.jQuery; |
2434 |
former$ = !!window.$; |
|
2435 |
formerUnderscore = !!window._; |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2436 |
|
| 898 | 2437 |
if (typeof ns.jQuery === "undefined") { |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2438 |
$L.queueScript(ns.getLib("jQuery")); |
| 898 | 2439 |
} |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2440 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2441 |
if (typeof ns._ === "undefined") { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2442 |
$L.queueScript(ns.getLib("underscore")); |
| 898 | 2443 |
} |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2444 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2445 |
if (typeof window.JSON == "undefined") { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2446 |
$L.queueScript(ns.getLib("json")); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2447 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2448 |
$L.queueWait().queueScript(ns.getLib("jQueryUI")).queueWait(); |
| 898 | 2449 |
|
2450 |
/* widget specific requirements */ |
|
2451 |
for(var _i = 0; _i < this.config.widgets.length; _i++) { |
|
2452 |
var _t = this.config.widgets[_i].type; |
|
2453 |
if (typeof ns.widgetsRequirements[_t] !== "undefined" && typeof ns.widgetsRequirements[_t].requires !== "undefined" ) { |
|
2454 |
for (var _j = 0; _j < ns.widgetsRequirements[_t].requires.length; _j++) { |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2455 |
$L.queueScript(ns.getLib(ns.widgetsRequirements[_t].requires[_j])); |
| 898 | 2456 |
} |
2457 |
} |
|
2458 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2459 |
|
| 898 | 2460 |
var _this = this; |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2461 |
$L.queueWait(function() { |
| 898 | 2462 |
_this.onLibsLoaded(); |
2463 |
}); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2464 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2465 |
$L.runQueue(); |
| 898 | 2466 |
}; |
2467 |
||
2468 |
Metadataplayer.prototype.onLibsLoaded = function() { |
|
2469 |
ns.log("IriSP.Metadataplayer.prototype.onLibsLoaded"); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2470 |
|
| 898 | 2471 |
if (typeof ns.jQuery === "undefined" && typeof window.jQuery !== "undefined") { |
2472 |
ns.jQuery = window.jQuery; |
|
2473 |
if (former$ || formerJQuery) { |
|
2474 |
window.jQuery.noConflict(formerJQuery); |
|
2475 |
} |
|
2476 |
} |
|
2477 |
if (typeof ns._ === "undefined" && typeof window._ !== "undefined") { |
|
2478 |
ns._ = window._; |
|
2479 |
if (formerUnderscore) { |
|
2480 |
_.noConflict(); |
|
2481 |
} |
|
2482 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2483 |
|
| 898 | 2484 |
ns.loadCss(ns.getLib("cssjQueryUI")); |
2485 |
ns.loadCss(this.config.css); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2486 |
|
| 898 | 2487 |
this.$ = ns.jQuery('#' + this.config.container); |
2488 |
this.$.css({ |
|
2489 |
"width": this.config.width, |
|
2490 |
"clear": "both" |
|
2491 |
}); |
|
2492 |
if (typeof this.config.height !== "undefined") { |
|
2493 |
this.$.css("height", this.config.height); |
|
2494 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2495 |
|
| 898 | 2496 |
this.widgets = []; |
2497 |
var _this = this; |
|
2498 |
ns._(this.config.widgets).each(function(widgetconf, key) { |
|
2499 |
_this.widgets.push(null); |
|
2500 |
_this.loadWidget(widgetconf, function(widget) { |
|
2501 |
_this.widgets[key] = widget; |
|
2502 |
if (widget.isLoaded()) { |
|
2503 |
_this.trigger("widget-loaded"); |
|
2504 |
} |
|
2505 |
}); |
|
2506 |
}); |
|
2507 |
this.$.find('.Ldt-Loader').detach(); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2508 |
|
| 898 | 2509 |
this.widgetsLoaded = false; |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2510 |
|
| 898 | 2511 |
this.on("widget-loaded", function() { |
2512 |
if (_this.widgetsLoaded) { |
|
2513 |
return; |
|
2514 |
} |
|
2515 |
var isloaded = !ns._(_this.widgets).any(function(w) { |
|
| 955 | 2516 |
return !(w && w.isLoaded()); |
| 898 | 2517 |
}); |
2518 |
if (isloaded) { |
|
2519 |
_this.widgetsLoaded = true; |
|
2520 |
_this.trigger("widgets-loaded"); |
|
2521 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2522 |
}); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2523 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2524 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2525 |
Metadataplayer.prototype.loadLocalAnnotations = function(localsourceidentifier) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2526 |
if (this.localSource === undefined) |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2527 |
this.localSource = this.sourceManager.newLocalSource({serializer: IriSP.serializers['ldt_localstorage']}); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2528 |
// Load current local annotations |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2529 |
if (localsourceidentifier) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2530 |
// Allow to override localsourceidentifier when necessary (usually at init time) |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2531 |
this.localSource.identifier = localsourceidentifier; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2532 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2533 |
this.localSource.deSerialize(window.localStorage[this.localSource.identifier] || "[]"); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2534 |
return this.localSource; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2535 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2536 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2537 |
Metadataplayer.prototype.saveLocalAnnotations = function() { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2538 |
// Save annotations back to localstorage |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2539 |
window.localStorage[this.localSource.identifier] = this.localSource.serialize(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2540 |
// Merge modifications into widget source |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2541 |
// this.source.merge(this.localSource); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2542 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2543 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2544 |
Metadataplayer.prototype.addLocalAnnotation = function(a) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2545 |
this.loadLocalAnnotations(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2546 |
this.localSource.getAnnotations().push(a); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2547 |
this.saveLocalAnnotations(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2548 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2549 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2550 |
Metadataplayer.prototype.deleteLocalAnnotation = function(ident) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2551 |
this.localSource.getAnnotations().removeId(ident, true); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2552 |
this.saveLocalAnnotations(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2553 |
}; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2554 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2555 |
Metadataplayer.prototype.getLocalAnnotation = function (ident) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2556 |
this.loadLocalAnnotations(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2557 |
// We cannot use .getElement since it fetches |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2558 |
// elements from the global Directory |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2559 |
return IriSP._.first(IriSP._.filter(this.localSource.getAnnotations(), function (a) { return a.id == ident; })); |
| 898 | 2560 |
}; |
2561 |
||
2562 |
Metadataplayer.prototype.loadMetadata = function(_metadataInfo) { |
|
2563 |
if (_metadataInfo.elementType === "source") { |
|
2564 |
return _metadataInfo; |
|
2565 |
} |
|
2566 |
if (typeof _metadataInfo.serializer === "undefined" && typeof _metadataInfo.format !== "undefined") { |
|
2567 |
_metadataInfo.serializer = ns.serializers[_metadataInfo.format]; |
|
2568 |
} |
|
2569 |
if (typeof _metadataInfo.url !== "undefined" && typeof _metadataInfo.serializer !== "undefined") { |
|
2570 |
return this.sourceManager.remoteSource(_metadataInfo); |
|
2571 |
} else { |
|
2572 |
return this.sourceManager.newLocalSource(_metadataInfo); |
|
2573 |
} |
|
2574 |
}; |
|
2575 |
||
2576 |
Metadataplayer.prototype.loadWidget = function(_widgetConfig, _callback) { |
|
2577 |
/* Creating containers if needed */ |
|
2578 |
if (typeof _widgetConfig.container === "undefined") { |
|
2579 |
var _divs = this.layoutDivs(_widgetConfig.type); |
|
2580 |
_widgetConfig.container = _divs[0]; |
|
2581 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2582 |
|
| 898 | 2583 |
var _this = this; |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2584 |
|
| 898 | 2585 |
if (typeof ns.Widgets[_widgetConfig.type] !== "undefined") { |
2586 |
ns._.defer(function() { |
|
2587 |
_callback(new ns.Widgets[_widgetConfig.type](_this, _widgetConfig)); |
|
2588 |
}); |
|
2589 |
} else { |
|
2590 |
/* Loading Widget CSS */ |
|
2591 |
if (typeof ns.widgetsRequirements[_widgetConfig.type] === "undefined" || typeof ns.widgetsRequirements[_widgetConfig.type].noCss === "undefined" || !ns.widgetsRequirements[_widgetConfig.type].noCss) { |
|
2592 |
ns.loadCss(ns.widgetsDir + '/' + _widgetConfig.type + '.css'); |
|
2593 |
} |
|
2594 |
/* Loading Widget JS */ |
|
2595 |
$LAB.script(ns.widgetsDir + '/' + _widgetConfig.type + '.js').wait(function() { |
|
2596 |
_callback(new ns.Widgets[_widgetConfig.type](_this, _widgetConfig)); |
|
2597 |
}); |
|
2598 |
} |
|
2599 |
}; |
|
2600 |
||
2601 |
/** create a subdiv with an unique id, and a spacer div as well. |
|
2602 |
@param widgetName the name of the widget. |
|
2603 |
@return an array of the form [createdivId, spacerdivId]. |
|
2604 |
*/ |
|
2605 |
Metadataplayer.prototype.layoutDivs = function(_name, _height) { |
|
2606 |
if (typeof(_name) === "undefined") { |
|
2607 |
_name = ""; |
|
2608 |
} |
|
2609 |
var newDiv = ns._.uniqueId(this.config.container + "_widget_" + _name + "_"), |
|
2610 |
spacerDiv = ns._.uniqueId("LdtPlayer_spacer_"), |
|
2611 |
divHtml = ns.jQuery('<div>') |
|
2612 |
.attr("id",newDiv) |
|
2613 |
.css({ |
|
2614 |
width: this.config.width + "px", |
|
2615 |
position: "relative", |
|
2616 |
clear: "both" |
|
2617 |
}), |
|
2618 |
spacerHtml = ns.jQuery('<div>') |
|
2619 |
.attr("id",spacerDiv) |
|
2620 |
.css({ |
|
2621 |
width: this.config.width + "px", |
|
2622 |
height: this.config.spacer_div_height + "px", |
|
2623 |
position: "relative", |
|
2624 |
clear: "both" |
|
2625 |
}); |
|
2626 |
if (typeof _height !== "undefined") { |
|
2627 |
divHtml.css("height", _height); |
|
2628 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2629 |
|
| 898 | 2630 |
this.$.append(divHtml); |
2631 |
this.$.append(spacerHtml); |
|
2632 |
||
2633 |
return [newDiv, spacerDiv]; |
|
2634 |
}; |
|
2635 |
||
2636 |
})(IriSP); |
|
2637 |
||
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2638 |
/* End of widgets-container/metadataplayer.js */ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2639 |
/* widgetsDefinition of an ancestor for the Widget classes */ |
| 898 | 2640 |
|
2641 |
if (typeof IriSP.Widgets === "undefined") { |
|
2642 |
IriSP.Widgets = {}; |
|
2643 |
} |
|
2644 |
||
2645 |
/** |
|
2646 |
* @class IriSP.Widget is an "abstract" class. It's mostly used to define some properties common to every widget. |
|
2647 |
* |
|
2648 |
* Note that widget constructors are never called directly by the user. Instead, the widgets are instantiated by functions |
|
2649 |
* defined in init.js |
|
2650 |
* |
|
2651 |
* @constructor |
|
2652 |
* @param player - a reference to the player widget |
|
2653 |
* @param config - configuration options for the widget |
|
2654 |
*/ |
|
2655 |
||
2656 |
||
2657 |
IriSP.Widgets.Widget = function(player, config) { |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2658 |
|
| 898 | 2659 |
if( typeof player === "undefined") { |
2660 |
/* Probably an abstract call of the class when |
|
2661 |
* individual widgets set their prototype */ |
|
2662 |
return; |
|
2663 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2664 |
|
| 898 | 2665 |
this.__subwidgets = []; |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2666 |
|
| 898 | 2667 |
/* Setting all the configuration options */ |
| 940 | 2668 |
var _type = config.type || "(unknown)", |
2669 |
_config = IriSP._.defaults({}, config, (player && player.config ? player.config.default_options : {}), this.defaults), |
|
| 898 | 2670 |
_this = this; |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2671 |
|
| 898 | 2672 |
IriSP._(_config).forEach(function(_value, _key) { |
2673 |
_this[_key] = _value; |
|
2674 |
}); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2675 |
|
| 898 | 2676 |
this.$ = IriSP.jQuery('#' + this.container); |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2677 |
|
| 898 | 2678 |
if (typeof this.width === "undefined") { |
2679 |
this.width = this.$.width(); |
|
2680 |
} else { |
|
2681 |
this.$.css("width", this.width); |
|
2682 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2683 |
|
| 898 | 2684 |
if (typeof this.height !== "undefined") { |
2685 |
this.$.css("height", this.height); |
|
2686 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2687 |
|
| 898 | 2688 |
/* Setting this.player at the end in case it's been overriden |
2689 |
* by a configuration option of the same name :-( |
|
2690 |
*/ |
|
| 940 | 2691 |
this.player = player || new IriSP.FakeClass(["on","trigger","off","loadWidget","loadMetadata"]); |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2692 |
|
| 898 | 2693 |
/* Adding classes and html attributes */ |
2694 |
this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type", _type); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2695 |
|
| 898 | 2696 |
this.l10n = ( |
2697 |
typeof this.messages[IriSP.language] !== "undefined" |
|
2698 |
? this.messages[IriSP.language] |
|
2699 |
: ( |
|
2700 |
IriSP.language.length > 2 && typeof this.messages[IriSP.language.substr(0,2)] !== "undefined" |
|
2701 |
? this.messages[IriSP.language.substr(0,2)] |
|
2702 |
: this.messages["en"] |
|
2703 |
) |
|
2704 |
); |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2705 |
|
| 898 | 2706 |
/* Loading Metadata if required */ |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2707 |
|
| 940 | 2708 |
function onsourceloaded() { |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2709 |
if (_this.localannotations) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2710 |
_this.localsource = player.loadLocalAnnotations(_this.localannotations); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2711 |
_this.source.merge(_this.localsource); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2712 |
} |
| 940 | 2713 |
if (_this.media_id) { |
2714 |
_this.media = this.getElement(_this.media_id); |
|
2715 |
} else { |
|
2716 |
var _mediaopts = { |
|
2717 |
is_mashup: _this.is_mashup || false |
|
| 955 | 2718 |
}; |
| 940 | 2719 |
_this.media = _this.source.getCurrentMedia(_mediaopts); |
2720 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2721 |
if (_this.pre_draw_callback){ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2722 |
IriSP.jQuery.when(_this.pre_draw_callback()).done(_this.draw()); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2723 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2724 |
else { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2725 |
_this.draw(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2726 |
} |
| 940 | 2727 |
_this.player.trigger("widget-loaded"); |
2728 |
} |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2729 |
|
| 898 | 2730 |
if (this.metadata) { |
2731 |
/* Getting metadata */ |
|
2732 |
this.source = player.loadMetadata(this.metadata); |
|
2733 |
/* Call draw when loaded */ |
|
| 940 | 2734 |
this.source.onLoad(onsourceloaded); |
| 898 | 2735 |
} else { |
| 940 | 2736 |
if (this.source) { |
2737 |
onsourceloaded(); |
|
2738 |
} |
|
| 898 | 2739 |
} |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2740 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2741 |
|
| 898 | 2742 |
}; |
2743 |
||
2744 |
IriSP.Widgets.Widget.prototype.defaults = {}; |
|
2745 |
||
2746 |
IriSP.Widgets.Widget.prototype.template = ''; |
|
2747 |
||
2748 |
IriSP.Widgets.Widget.prototype.messages = {"en":{}}; |
|
2749 |
||
| 940 | 2750 |
IriSP.Widgets.Widget.prototype.toString = function() { |
2751 |
return "Widget " + this.type; |
|
2752 |
}; |
|
2753 |
||
| 898 | 2754 |
IriSP.Widgets.Widget.prototype.templateToHtml = function(_template) { |
2755 |
return Mustache.to_html(_template, this); |
|
2756 |
}; |
|
2757 |
||
2758 |
IriSP.Widgets.Widget.prototype.renderTemplate = function() { |
|
2759 |
this.$.append(this.templateToHtml(this.template)); |
|
2760 |
}; |
|
2761 |
||
2762 |
IriSP.Widgets.Widget.prototype.functionWrapper = function(_name) { |
|
2763 |
var _this = this, |
|
2764 |
_function = this[_name]; |
|
2765 |
if (typeof _function !== "undefined") { |
|
2766 |
return function() { |
|
2767 |
return _function.apply(_this, Array.prototype.slice.call(arguments, 0)); |
|
| 955 | 2768 |
}; |
| 898 | 2769 |
} else { |
| 955 | 2770 |
console.log("Error, Unknown function IriSP.Widgets." + this.type + "." + _name); |
| 898 | 2771 |
} |
2772 |
}; |
|
2773 |
||
2774 |
IriSP.Widgets.Widget.prototype.getFunctionOrName = function(_functionOrName) { |
|
2775 |
switch (typeof _functionOrName) { |
|
2776 |
case "function": |
|
2777 |
return _functionOrName; |
|
2778 |
case "string": |
|
2779 |
return this.functionWrapper(_functionOrName); |
|
2780 |
default: |
|
2781 |
return undefined; |
|
2782 |
} |
|
2783 |
}; |
|
2784 |
||
2785 |
IriSP.Widgets.Widget.prototype.onMdpEvent = function(_eventName, _functionOrName) { |
|
2786 |
this.player.on(_eventName, this.getFunctionOrName(_functionOrName)); |
|
2787 |
}; |
|
2788 |
||
2789 |
IriSP.Widgets.Widget.prototype.onMediaEvent = function(_eventName, _functionOrName) { |
|
2790 |
this.media.on(_eventName, this.getFunctionOrName(_functionOrName)); |
|
2791 |
}; |
|
2792 |
||
2793 |
IriSP.Widgets.Widget.prototype.getWidgetAnnotations = function() { |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2794 |
var result = null; |
| 898 | 2795 |
if (typeof this.annotation_type === "undefined") { |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2796 |
result = this.media.getAnnotations(); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2797 |
} else if (this.annotation_type.elementType === "annotationType") { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2798 |
result = this.annotation_type.getAnnotations(); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2799 |
} else { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2800 |
result = this.media.getAnnotationsByTypeTitle(this.annotation_type); |
| 898 | 2801 |
} |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2802 |
if (typeof this.annotation_filter !== "undefined") { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2803 |
return this.annotation_filter(result); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2804 |
} else { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2805 |
return result; |
| 898 | 2806 |
} |
2807 |
}; |
|
2808 |
||
2809 |
IriSP.Widgets.Widget.prototype.getWidgetAnnotationsAtTime = function() { |
|
2810 |
var _time = this.media.getCurrentTime(); |
|
2811 |
return this.getWidgetAnnotations().filter(function(_annotation) { |
|
2812 |
return _annotation.begin <= _time && _annotation.end > _time; |
|
2813 |
}); |
|
2814 |
}; |
|
2815 |
||
2816 |
IriSP.Widgets.Widget.prototype.isLoaded = function() { |
|
2817 |
var isloaded = !IriSP._(this.__subwidgets).any(function(w) { |
|
2818 |
return !(w && w.isLoaded()); |
|
2819 |
}); |
|
2820 |
return isloaded; |
|
2821 |
}; |
|
2822 |
||
2823 |
IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _widgetoptions, _propname) { |
|
2824 |
var _id = _selector.attr("id"), |
|
2825 |
_this = this, |
|
2826 |
_type = _widgetoptions.type, |
|
2827 |
$L = $LAB, |
|
2828 |
key = this.__subwidgets.length; |
|
2829 |
this.__subwidgets.push(null); |
|
2830 |
if (typeof _id == "undefined") { |
|
2831 |
_id = IriSP._.uniqueId(this.container + '_sub_widget_' + _widgetoptions.type); |
|
2832 |
_selector.attr("id", _id); |
|
2833 |
} |
|
2834 |
_widgetoptions.container = _id; |
|
2835 |
if (typeof IriSP.widgetsRequirements[_type] !== "undefined" && typeof IriSP.widgetsRequirements[_type].requires !== "undefined" ) { |
|
2836 |
for (var _j = 0; _j < IriSP.widgetsRequirements[_type].requires.length; _j++) { |
|
2837 |
$L.script(IriSP.getLib(IriSP.widgetsRequirements[_type].requires[_j])); |
|
2838 |
} |
|
2839 |
} |
|
2840 |
$L.wait(function() { |
|
2841 |
_this.player.loadWidget(_widgetoptions, function(_widget) { |
|
2842 |
if (_propname) { |
|
2843 |
_this[_propname] = _widget; |
|
2844 |
} |
|
2845 |
_this.__subwidgets[key] = _widget; |
|
2846 |
}); |
|
2847 |
}); |
|
2848 |
}; |
|
2849 |
||
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2850 |
/* |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2851 |
* Position the player to the next/previous annotations based on current player position |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2852 |
* |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2853 |
* Parameter: offset: -1 for previous annotation, +1 for next annotation |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2854 |
*/ |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2855 |
IriSP.Widgets.Widget.prototype.navigate = function(offset) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2856 |
// offset is normally either -1 (previous slide) or +1 (next slide) |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2857 |
var _this = this; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2858 |
var currentTime = _this.media.getCurrentTime(); |
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2859 |
var annotations = _this.getWidgetAnnotations().sortBy(function(_annotation) { |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2860 |
return _annotation.begin; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2861 |
}); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2862 |
for (var i = 0; i < annotations.length; i++) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2863 |
if (annotations[i].begin <= currentTime && currentTime < annotations[i].end) { |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2864 |
// Found a current annotation - clamp i+offset value to [0, length - 1] |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2865 |
i = Math.min(annotations.length - 1, Math.max(0, i + offset)); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2866 |
_this.media.setCurrentTime(annotations[i].begin); |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2867 |
break; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2868 |
} |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2869 |
}; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2870 |
}; |
|
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2871 |
|
|
1304
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2872 |
/* |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2873 |
* Propose an export of the widget's annotations |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2874 |
* |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2875 |
* Parameter: a list of annotations. If not specified, the widget's annotations will be exported. |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2876 |
*/ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2877 |
IriSP.Widgets.Widget.prototype.exportAnnotations = function(annotations) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2878 |
var widget = this; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2879 |
if (annotations === undefined) |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2880 |
annotations = this.getWidgetAnnotations(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2881 |
var $ = IriSP.jQuery; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2882 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2883 |
// FIXME: this should belong to a proper serialize/deserialize component? |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2884 |
var content = Mustache.to_html("[video:{{url}}]\n", {url: widget.media.url}) + annotations.map( function(a) { return Mustache.to_html("[{{ a.begin }}]{{ a.title }} {{ a.description }}[{{ a.end }}]", { a: a }); }).join("\n"); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2885 |
|
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2886 |
var el = $("<pre>") |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2887 |
.addClass("exportContainer") |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2888 |
.text(content) |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2889 |
.dialog({ |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2890 |
title: "Annotation export", |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2891 |
open: function( event, ui ) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2892 |
// Select text |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2893 |
var range; |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2894 |
if (document.selection) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2895 |
range = document.body.createTextRange(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2896 |
range.moveToElementText(this[0]); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2897 |
range.select(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2898 |
} else if (window.getSelection) { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2899 |
range = document.createRange(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2900 |
range.selectNode(this[0]); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2901 |
window.getSelection().addRange(range); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2902 |
} |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2903 |
}, |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2904 |
autoOpen: true, |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2905 |
width: '80%', |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2906 |
minHeight: '400', |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2907 |
height: 400, |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2908 |
buttons: [ { text: "Close", click: function() { $( this ).dialog( "close" ); } }, |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2909 |
{ text: "Download", click: function () { |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2910 |
a = document.createElement('a'); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2911 |
a.setAttribute('href', 'data:text/plain;base64,' + btoa(content)); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2912 |
a.setAttribute('download', 'Annotations - ' + widget.media.title.replace(/[^ \w]/g, '') + '.txt'); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2913 |
a.click(); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2914 |
} } ] |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2915 |
}); |
|
10974bff4dae
upgrade metadataplayer + publish enmi 14and 15
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
1198
diff
changeset
|
2916 |
}; |
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2917 |
|
| 898 | 2918 |
/** |
2919 |
* This method responsible of drawing a widget on screen. |
|
2920 |
*/ |
|
2921 |
IriSP.Widgets.Widget.prototype.draw = function() { |
|
2922 |
/* implemented by "sub-classes" */ |
|
|
1198
ff4b567d51f2
upgrade metadataplayer and add annotation creation
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
956
diff
changeset
|
2923 |
}; |