| author | veltr |
| Fri, 06 Jul 2012 18:13:32 +0200 | |
| branch | new-model |
| changeset 925 | 28efc97b5d78 |
| parent 919 | 972099304059 |
| child 930 | 165f236e42f2 |
| permissions | -rw-r--r-- |
| 917 | 1 |
/* TODO: Separate Project-specific data from Source */ |
2 |
||
| 854 | 3 |
/* model.js is where data is stored in a standard form, whatever the serializer */ |
4 |
||
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
5 |
IriSP.Model = { |
| 868 | 6 |
_SOURCE_STATUS_EMPTY : 0, |
7 |
_SOURCE_STATUS_WAITING : 1, |
|
8 |
_SOURCE_STATUS_READY : 2, |
|
9 |
_ID_AUTO_INCREMENT : 0, |
|
| 915 | 10 |
_ID_BASE : (function(_d) { |
11 |
function pad(n){return n<10 ? '0'+n : n} |
|
12 |
function fillrand(n) { |
|
13 |
var _res = '' |
|
14 |
for (var i=0; i<n; i++) { |
|
15 |
_res += Math.floor(16*Math.random()).toString(16); |
|
16 |
} |
|
17 |
return _res; |
|
18 |
} |
|
19 |
return _d.getUTCFullYear() + '-' |
|
20 |
+ pad(_d.getUTCMonth()+1) + '-' |
|
21 |
+ pad(_d.getUTCDate()) + '-' |
|
22 |
+ fillrand(16); |
|
23 |
})(new Date()), |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
24 |
getUID : function() { |
| 915 | 25 |
var _n = (++this._ID_AUTO_INCREMENT).toString(); |
26 |
while (_n.length < 4) { |
|
27 |
_n = '0' + _n |
|
28 |
} |
|
29 |
return "autoid-" + this._ID_BASE + '-' + _n; |
|
| 860 | 30 |
}, |
| 925 | 31 |
regexpFromTextOrArray : function(_textOrArray, _testOnly) { |
32 |
var _testOnly = _testOnly || false; |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
33 |
function escapeText(_text) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
34 |
return _text.replace(/([\\\*\+\?\|\{\[\}\]\(\)\^\$\.\#\/])/gm, '\\$1'); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
35 |
} |
| 925 | 36 |
var _source = |
37 |
typeof _textOrArray === "string" |
|
38 |
? escapeText(_textOrArray) |
|
39 |
: IriSP._(_textOrArray).map(escapeText).join("|"); |
|
40 |
if (_testOnly) { |
|
41 |
return new RegExp( _source, 'im'); |
|
42 |
} else { |
|
43 |
return new RegExp( '(' + _source + ')', 'gim'); |
|
44 |
} |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
45 |
}, |
| 860 | 46 |
isoToDate : function(_str) { |
47 |
// http://delete.me.uk/2005/03/iso8601.html |
|
48 |
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})))?)?)?)?"; |
|
49 |
var d = _str.match(new RegExp(regexp)); |
|
50 |
|
|
51 |
var offset = 0; |
|
52 |
var date = new Date(d[1], 0, 1); |
|
53 |
|
|
54 |
if (d[3]) { date.setMonth(d[3] - 1); } |
|
55 |
if (d[5]) { date.setDate(d[5]); } |
|
56 |
if (d[7]) { date.setHours(d[7]); } |
|
57 |
if (d[8]) { date.setMinutes(d[8]); } |
|
58 |
if (d[10]) { date.setSeconds(d[10]); } |
|
59 |
if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); } |
|
60 |
if (d[14]) { |
|
61 |
offset = (Number(d[16]) * 60) + Number(d[17]); |
|
62 |
offset *= ((d[15] == '-') ? 1 : -1); |
|
63 |
} |
|
64 |
|
|
65 |
offset -= date.getTimezoneOffset(); |
|
66 |
time = (Number(date) + (offset * 60 * 1000)); |
|
67 |
var _res = new Date(); |
|
68 |
_res.setTime(Number(time)); |
|
69 |
return _res; |
|
70 |
}, |
|
| 915 | 71 |
dateToIso : function(d) { |
| 860 | 72 |
function pad(n){return n<10 ? '0'+n : n} |
73 |
return d.getUTCFullYear()+'-' |
|
74 |
+ pad(d.getUTCMonth()+1)+'-' |
|
75 |
+ pad(d.getUTCDate())+'T' |
|
76 |
+ pad(d.getUTCHours())+':' |
|
77 |
+ pad(d.getUTCMinutes())+':' |
|
78 |
+ pad(d.getUTCSeconds())+'Z' |
|
79 |
} |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
80 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
81 |
|
| 868 | 82 |
/* |
83 |
* IriSP.Model.List is a class for a list of elements (e.g. annotations, medias, etc. that each have a distinct ID) |
|
84 |
*/ |
|
| 858 | 85 |
IriSP.Model.List = function(_directory) { |
| 866 | 86 |
Array.call(this); |
| 858 | 87 |
this.directory = _directory; |
| 866 | 88 |
this.idIndex = []; |
| 860 | 89 |
if (typeof _directory == "undefined") { |
| 900 | 90 |
console.trace(); |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
91 |
throw "Error : new IriSP.Model.List(directory): directory is undefined"; |
| 860 | 92 |
} |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
93 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
94 |
|
| 866 | 95 |
IriSP.Model.List.prototype = new Array(); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
96 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
97 |
IriSP.Model.List.prototype.getElement = function(_id) { |
| 900 | 98 |
return this[_id]; |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
99 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
100 |
|
| 864 | 101 |
IriSP.Model.List.prototype.hasId = function(_id) { |
| 866 | 102 |
return (IriSP._(this.idIndex).indexOf(_id) !== -1); |
| 864 | 103 |
} |
104 |
||
| 868 | 105 |
/* On recent browsers, forEach and map are defined and do what we want. |
106 |
* Otherwise, we'll use the Underscore.js functions |
|
107 |
*/ |
|
| 866 | 108 |
if (typeof Array.prototype.forEach === "undefined") { |
109 |
IriSP.Model.List.prototype.forEach = function(_callback) { |
|
110 |
var _this = this; |
|
111 |
IriSP._(this).forEach(function(_value, _key) { |
|
112 |
_callback(_value, _key, _this); |
|
113 |
}); |
|
114 |
} |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
115 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
116 |
|
| 866 | 117 |
if (typeof Array.prototype.map === "undefined") { |
118 |
IriSP.Model.List.prototype.map = function(_callback) { |
|
119 |
var _this = this; |
|
120 |
return IriSP._(this).map(function(_value, _key) { |
|
121 |
return _callback(_value, _key, _this); |
|
122 |
}); |
|
123 |
} |
|
| 858 | 124 |
} |
125 |
||
| 900 | 126 |
IriSP.Model.List.prototype.pluck = function(_key) { |
127 |
return this.map(function(_value) { |
|
128 |
return _value[_key]; |
|
129 |
}); |
|
130 |
} |
|
131 |
||
| 868 | 132 |
/* We override Array's filter function because it doesn't return an IriSP.Model.List |
133 |
*/ |
|
| 858 | 134 |
IriSP.Model.List.prototype.filter = function(_callback) { |
135 |
var _this = this, |
|
136 |
_res = new IriSP.Model.List(this.directory); |
|
| 866 | 137 |
_res.addElements(IriSP._(this).filter(function(_value, _key) { |
138 |
return _callback(_value, _key, _this); |
|
139 |
})); |
|
| 858 | 140 |
return _res; |
141 |
} |
|
142 |
||
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
143 |
IriSP.Model.List.prototype.slice = function(_start, _end) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
144 |
var _res = new IriSP.Model.List(this.directory); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
145 |
_res.addElements(Array.prototype.slice.call(this, _start, _end)); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
146 |
return _res; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
147 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
148 |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
149 |
IriSP.Model.List.prototype.splice = function(_start, _end) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
150 |
var _res = new IriSP.Model.List(this.directory); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
151 |
_res.addElements(Array.prototype.splice.call(this, _start, _end)); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
152 |
this.idIndex.splice(_start, _end); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
153 |
return _res; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
154 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
155 |
|
| 868 | 156 |
/* Array has a sort function, but it's not as interesting as Underscore.js's sortBy |
157 |
* and won't return a new IriSP.Model.List |
|
158 |
*/ |
|
| 864 | 159 |
IriSP.Model.List.prototype.sortBy = function(_callback) { |
160 |
var _this = this, |
|
161 |
_res = new IriSP.Model.List(this.directory); |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
162 |
_res.addElements(IriSP._(this).sortBy(function(_value, _key) { |
| 866 | 163 |
return _callback(_value, _key, _this); |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
164 |
})); |
| 864 | 165 |
return _res; |
166 |
} |
|
167 |
||
| 868 | 168 |
/* Title and Description are basic information for (almost) all element types, |
169 |
* here we can search by these criteria |
|
170 |
*/ |
|
| 858 | 171 |
IriSP.Model.List.prototype.searchByTitle = function(_text) { |
| 925 | 172 |
var _rgxp = IriSP.Model.regexpFromTextOrArray(_text, true); |
| 858 | 173 |
return this.filter(function(_element) { |
| 864 | 174 |
return _rgxp.test(_element.title); |
| 858 | 175 |
}); |
176 |
} |
|
177 |
||
178 |
IriSP.Model.List.prototype.searchByDescription = function(_text) { |
|
| 925 | 179 |
var _rgxp = IriSP.Model.regexpFromTextOrArray(_text, true); |
| 858 | 180 |
return this.filter(function(_element) { |
181 |
return _rgxp.test(_element.description); |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
182 |
}); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
183 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
184 |
|
| 858 | 185 |
IriSP.Model.List.prototype.searchByTextFields = function(_text) { |
| 925 | 186 |
var _rgxp = IriSP.Model.regexpFromTextOrArray(_text, true); |
| 858 | 187 |
return this.filter(function(_element) { |
| 864 | 188 |
return _rgxp.test(_element.description) || _rgxp.test(_element.title); |
| 858 | 189 |
}); |
190 |
} |
|
191 |
||
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
192 |
IriSP.Model.List.prototype.getTitles = function() { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
193 |
return this.map(function(_el) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
194 |
return _el.title; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
195 |
}); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
196 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
197 |
|
| 858 | 198 |
IriSP.Model.List.prototype.addId = function(_id) { |
| 866 | 199 |
var _el = this.directory.getElement(_id) |
200 |
if (!this.hasId(_id) && typeof _el !== "undefined") { |
|
201 |
this.idIndex.push(_id); |
|
202 |
Array.prototype.push.call(this, _el); |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
203 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
204 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
205 |
|
| 866 | 206 |
IriSP.Model.List.prototype.push = function(_el) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
207 |
if (typeof _el === "undefined") { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
208 |
return; |
| 866 | 209 |
} |
| 868 | 210 |
var _index = (IriSP._(this.idIndex).indexOf(_el.id)); |
211 |
if (_index === -1) { |
|
212 |
this.idIndex.push(_el.id); |
|
213 |
Array.prototype.push.call(this, _el); |
|
214 |
} else { |
|
215 |
this[_index] = _el; |
|
216 |
} |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
217 |
} |
| 858 | 218 |
|
| 866 | 219 |
IriSP.Model.List.prototype.addIds = function(_array) { |
220 |
var _l = _array.length, |
|
221 |
_this = this; |
|
222 |
IriSP._(_array).forEach(function(_id) { |
|
223 |
_this.addId(_id); |
|
224 |
}); |
|
| 858 | 225 |
} |
226 |
||
| 866 | 227 |
IriSP.Model.List.prototype.addElements = function(_array) { |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
228 |
var _this = this; |
| 866 | 229 |
IriSP._(_array).forEach(function(_el) { |
230 |
_this.push(_el); |
|
231 |
}); |
|
| 858 | 232 |
} |
233 |
||
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
234 |
IriSP.Model.List.prototype.removeId = function(_id, _deleteFromDirectory) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
235 |
var _deleteFromDirectory = _deleteFromDirectory || false, |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
236 |
_index = (IriSP._(this.idIndex).indexOf(_id)); |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
237 |
if (_index !== -1) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
238 |
this.splice(_index,1); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
239 |
} |
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
240 |
if (_deleteFromDirectory) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
241 |
delete this.directory.elements[_id]; |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
242 |
} |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
243 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
244 |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
245 |
IriSP.Model.List.prototype.removeElement = function(_el, _deleteFromDirectory) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
246 |
var _deleteFromDirectory = _deleteFromDirectory || false; |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
247 |
this.removeId(_el.id); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
248 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
249 |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
250 |
IriSP.Model.List.prototype.removeIds = function(_list, _deleteFromDirectory) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
251 |
var _deleteFromDirectory = _deleteFromDirectory || false, |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
252 |
_this = this; |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
253 |
IriSP._(_list).forEach(function(_id) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
254 |
_this.removeId(_id); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
255 |
}); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
256 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
257 |
|
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
258 |
IriSP.Model.List.prototype.removeElements = function(_list, _deleteFromDirectory) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
259 |
var _deleteFromDirectory = _deleteFromDirectory || false, |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
260 |
_this = this; |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
261 |
IriSP._(_list).forEach(function(_el) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
262 |
_this.removeElement(_el); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
263 |
}); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
264 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
265 |
|
| 868 | 266 |
/* A simple time management object, that helps converting millisecs to seconds and strings, |
267 |
* without the clumsiness of the original Date object. |
|
268 |
*/ |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
269 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
270 |
IriSP.Model.Time = function(_milliseconds) { |
| 900 | 271 |
this.milliseconds = 0; |
272 |
this.setMilliseconds(_milliseconds); |
|
273 |
} |
|
274 |
||
275 |
IriSP.Model.Time.prototype.setMilliseconds = function(_milliseconds) { |
|
276 |
var _ante = _milliseconds; |
|
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
277 |
switch(typeof _milliseconds) { |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
278 |
case "string": |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
279 |
this.milliseconds = parseFloat(_milliseconds); |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
280 |
break; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
281 |
case "number": |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
282 |
this.milliseconds = _milliseconds; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
283 |
break; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
284 |
case "object": |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
285 |
this.milliseconds = parseFloat(_milliseconds.valueOf()); |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
286 |
break; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
287 |
default: |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
288 |
this.milliseconds = 0; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
289 |
} |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
290 |
if (this.milliseconds === NaN) { |
| 900 | 291 |
this.milliseconds = _ante; |
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
292 |
} |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
293 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
294 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
295 |
IriSP.Model.Time.prototype.setSeconds = function(_seconds) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
296 |
this.milliseconds = 1000 * _seconds; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
297 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
298 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
299 |
IriSP.Model.Time.prototype.getSeconds = function() { |
| 917 | 300 |
return this.milliseconds / 1000; |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
301 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
302 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
303 |
IriSP.Model.Time.prototype.getHMS = function() { |
| 917 | 304 |
var _totalSeconds = Math.abs(Math.floor(this.getSeconds())); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
305 |
return { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
306 |
hours : Math.floor(_totalSeconds / 3600), |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
307 |
minutes : (Math.floor(_totalSeconds / 60) % 60), |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
308 |
seconds : _totalSeconds % 60 |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
309 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
310 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
311 |
|
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
312 |
IriSP.Model.Time.prototype.add = function(_milliseconds) { |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
313 |
this.milliseconds += new IriSP.Model.Time(_milliseconds).milliseconds; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
314 |
} |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
315 |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
316 |
IriSP.Model.Time.prototype.valueOf = function() { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
317 |
return this.milliseconds; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
318 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
319 |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
320 |
IriSP.Model.Time.prototype.toString = function() { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
321 |
function pad(_n) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
322 |
var _res = _n.toString(); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
323 |
while (_res.length < 2) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
324 |
_res = '0' + _res; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
325 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
326 |
return _res; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
327 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
328 |
var _hms = this.getHMS(), |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
329 |
_res = ''; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
330 |
if (_hms.hours) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
331 |
_res += pad(_hms.hours) + ':' |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
332 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
333 |
_res += pad(_hms.minutes) + ':' + pad(_hms.seconds); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
334 |
return _res; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
335 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
336 |
|
| 868 | 337 |
/* IriSP.Model.Reference handles references between elements |
338 |
*/ |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
339 |
|
| 860 | 340 |
IriSP.Model.Reference = function(_source, _idRef) { |
341 |
this.source = _source; |
|
| 916 | 342 |
this.id = _idRef; |
| 858 | 343 |
if (typeof _idRef === "object") { |
344 |
this.isList = true; |
|
345 |
} else { |
|
346 |
this.isList = false; |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
347 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
348 |
this.refresh(); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
349 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
350 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
351 |
IriSP.Model.Reference.prototype.refresh = function() { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
352 |
if (this.isList) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
353 |
this.contents = new IriSP.Model.List(this.source.directory); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
354 |
this.contents.addIds(this.id); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
355 |
} else { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
356 |
this.contents = this.source.directory.getElement(this.id); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
357 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
358 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
359 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
360 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
361 |
IriSP.Model.Reference.prototype.getContents = function() { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
362 |
if (typeof this.contents === "undefined" || (this.isList && this.contents.length != this.id.length)) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
363 |
this.refresh(); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
364 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
365 |
return this.contents; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
366 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
367 |
|
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
368 |
IriSP.Model.Reference.prototype.isOrHasId = function(_idRef) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
369 |
if (this.isList) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
370 |
return (IriSP._(this.id).indexOf(_idRef) !== -1) |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
371 |
} else { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
372 |
return (this.id == _idRef); |
| 858 | 373 |
} |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
374 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
375 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
376 |
/* */ |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
377 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
378 |
IriSP.Model.Element = function(_id, _source) { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
379 |
this.elementType = 'element'; |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
380 |
if (typeof _source === "undefined") { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
381 |
return; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
382 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
383 |
if (typeof _id === "undefined" || !_id) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
384 |
_id = IriSP.Model.getUID(); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
385 |
} |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
386 |
this.source = _source; |
| 916 | 387 |
this.id = _id; |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
388 |
this.title = ""; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
389 |
this.description = ""; |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
390 |
this.source.directory.addElement(this); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
391 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
392 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
393 |
IriSP.Model.Element.prototype.toString = function() { |
| 858 | 394 |
return this.elementType + (this.elementType !== 'element' ? ', id=' + this.id + ', title="' + this.title + '"' : ''); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
395 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
396 |
|
| 858 | 397 |
IriSP.Model.Element.prototype.setReference = function(_elementType, _idRef) { |
| 860 | 398 |
this[_elementType] = new IriSP.Model.Reference(this.source, _idRef); |
| 854 | 399 |
} |
400 |
||
| 858 | 401 |
IriSP.Model.Element.prototype.getReference = function(_elementType) { |
402 |
if (typeof this[_elementType] !== "undefined") { |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
403 |
return this[_elementType].getContents(); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
404 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
405 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
406 |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
407 |
IriSP.Model.Element.prototype.getRelated = function(_elementType, _global) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
408 |
_global = (typeof _global !== "undefined" && _global); |
| 864 | 409 |
var _this = this; |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
410 |
return this.source.getList(_elementType, _global).filter(function(_el) { |
| 864 | 411 |
var _ref = _el[_this.elementType]; |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
412 |
return _ref.isOrHasId(_this.id); |
| 864 | 413 |
}); |
414 |
} |
|
415 |
||
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
416 |
/* */ |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
417 |
|
| 864 | 418 |
IriSP.Model.Media = function(_id, _source) { |
419 |
IriSP.Model.Element.call(this, _id, _source); |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
420 |
this.elementType = 'media'; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
421 |
this.duration = new IriSP.Model.Time(); |
| 866 | 422 |
this.video = ''; |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
423 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
424 |
|
| 858 | 425 |
IriSP.Model.Media.prototype = new IriSP.Model.Element(); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
426 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
427 |
IriSP.Model.Media.prototype.setDuration = function(_durationMs) { |
| 900 | 428 |
this.duration.setMilliseconds(_durationMs); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
429 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
430 |
|
| 864 | 431 |
IriSP.Model.Media.prototype.getAnnotations = function() { |
432 |
return this.getRelated("annotation"); |
|
433 |
} |
|
434 |
||
| 900 | 435 |
IriSP.Model.Media.prototype.getAnnotationsByTypeTitle = function(_title) { |
436 |
var _annTypes = this.source.getAnnotationTypes().searchByTitle(_title).pluck("id"); |
|
437 |
if (_annTypes.length) { |
|
438 |
return this.getAnnotations().filter(function(_annotation) { |
|
439 |
return IriSP._(_annTypes).indexOf(_annotation.getAnnotationType().id) !== -1; |
|
440 |
}); |
|
441 |
} else { |
|
442 |
return new IriSP.Model.List(this.source.directory) |
|
443 |
} |
|
444 |
} |
|
445 |
||
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
446 |
/* */ |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
447 |
|
| 864 | 448 |
IriSP.Model.Tag = function(_id, _source) { |
449 |
IriSP.Model.Element.call(this, _id, _source); |
|
| 858 | 450 |
this.elementType = 'tag'; |
451 |
} |
|
452 |
||
453 |
IriSP.Model.Tag.prototype = new IriSP.Model.Element(); |
|
454 |
||
| 864 | 455 |
IriSP.Model.Tag.prototype.getAnnotations = function() { |
456 |
return this.getRelated("annotation"); |
|
457 |
} |
|
458 |
||
| 858 | 459 |
/* */ |
460 |
||
| 864 | 461 |
IriSP.Model.AnnotationType = function(_id, _source) { |
462 |
IriSP.Model.Element.call(this, _id, _source); |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
463 |
this.elementType = 'annotationType'; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
464 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
465 |
|
| 858 | 466 |
IriSP.Model.AnnotationType.prototype = new IriSP.Model.Element(); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
467 |
|
| 864 | 468 |
IriSP.Model.AnnotationType.prototype.getAnnotations = function() { |
469 |
return this.getRelated("annotation"); |
|
470 |
} |
|
471 |
||
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
472 |
/* Annotation |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
473 |
* */ |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
474 |
|
| 864 | 475 |
IriSP.Model.Annotation = function(_id, _source) { |
476 |
IriSP.Model.Element.call(this, _id, _source); |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
477 |
this.elementType = 'annotation'; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
478 |
this.begin = new IriSP.Model.Time(); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
479 |
this.end = new IriSP.Model.Time(); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
480 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
481 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
482 |
IriSP.Model.Annotation.prototype = new IriSP.Model.Element(null); |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
483 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
484 |
IriSP.Model.Annotation.prototype.setBegin = function(_beginMs) { |
| 900 | 485 |
this.begin.setMilliseconds(_beginMs); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
486 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
487 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
488 |
IriSP.Model.Annotation.prototype.setEnd = function(_beginMs) { |
| 900 | 489 |
this.end.setMilliseconds(_beginMs); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
490 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
491 |
|
| 858 | 492 |
IriSP.Model.Annotation.prototype.setMedia = function(_idRef) { |
493 |
this.setReference("media", _idRef); |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
494 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
495 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
496 |
IriSP.Model.Annotation.prototype.getMedia = function() { |
| 858 | 497 |
return this.getReference("media"); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
498 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
499 |
|
| 858 | 500 |
IriSP.Model.Annotation.prototype.setAnnotationType = function(_idRef) { |
501 |
this.setReference("annotationType", _idRef); |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
502 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
503 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
504 |
IriSP.Model.Annotation.prototype.getAnnotationType = function() { |
| 858 | 505 |
return this.getReference("annotationType"); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
506 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
507 |
|
| 858 | 508 |
IriSP.Model.Annotation.prototype.setTags = function(_idRefs) { |
509 |
this.setReference("tag", _idRefs); |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
510 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
511 |
|
| 858 | 512 |
IriSP.Model.Annotation.prototype.getTags = function() { |
513 |
return this.getReference("tag"); |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
514 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
515 |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
516 |
IriSP.Model.Annotation.prototype.getTagTexts = function() { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
517 |
return this.getTags().getTitles(); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
518 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
519 |
|
| 900 | 520 |
IriSP.Model.Annotation.prototype.getDuration = function() { |
521 |
return new IriSP.Model.Time(this.end.milliseconds - this.begin.milliseconds) |
|
522 |
} |
|
523 |
||
| 858 | 524 |
/* */ |
525 |
||
| 902 | 526 |
IriSP.Model.MashedAnnotation = function(_mashup, _annotation) { |
| 916 | 527 |
IriSP.Model.Element.call(this, _mashup.id + "_" + _annotation.id, _annotation.source); |
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
528 |
this.elementType = 'mashedAnnotation'; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
529 |
this.annotation = _annotation; |
| 902 | 530 |
this.begin = new IriSP.Model.Time(_mashup.duration); |
531 |
this.end = new IriSP.Model.Time(_mashup.duration + _annotation.getDuration()); |
|
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
532 |
this.title = this.annotation.title; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
533 |
this.description = this.annotation.description; |
| 900 | 534 |
this.color = this.annotation.color; |
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
535 |
} |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
536 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
537 |
IriSP.Model.MashedAnnotation.prototype = new IriSP.Model.Element(null); |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
538 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
539 |
IriSP.Model.MashedAnnotation.prototype.getMedia = function() { |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
540 |
return this.annotation.getReference("media"); |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
541 |
} |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
542 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
543 |
IriSP.Model.MashedAnnotation.prototype.getAnnotationType = function() { |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
544 |
return this.annotation.getReference("annotationType"); |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
545 |
} |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
546 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
547 |
IriSP.Model.MashedAnnotation.prototype.getTags = function() { |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
548 |
return this.annotation.getReference("tag"); |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
549 |
} |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
550 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
551 |
IriSP.Model.MashedAnnotation.prototype.getTagTexts = function() { |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
552 |
return this.annotation.getTags().getTitles(); |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
553 |
} |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
554 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
555 |
/* */ |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
556 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
557 |
IriSP.Model.Mashup = function(_id, _source) { |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
558 |
IriSP.Model.Element.call(this, _id, _source); |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
559 |
this.elementType = 'mashup'; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
560 |
this.duration = new IriSP.Model.Time(); |
| 900 | 561 |
this.segments = new IriSP.Model.List(_source.directory); |
562 |
this.medias = new IriSP.Model.List(_source.directory); |
|
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
563 |
} |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
564 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
565 |
IriSP.Model.Mashup.prototype = new IriSP.Model.Element(); |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
566 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
567 |
IriSP.Model.Mashup.prototype.addSegment = function(_annotation) { |
| 902 | 568 |
var _mashedAnnotation = new IriSP.Model.MashedAnnotation(this, _annotation); |
| 900 | 569 |
this.duration.setMilliseconds(_mashedAnnotation.end); |
570 |
this.segments.push(_mashedAnnotation); |
|
571 |
this.medias.push(_annotation.getMedia()); |
|
572 |
} |
|
573 |
||
574 |
IriSP.Model.Mashup.prototype.addSegmentById = function(_elId) { |
|
575 |
var _annotation = this.source.getElement(_elId); |
|
576 |
if (typeof _annotation !== "undefined") { |
|
577 |
this.addSegment(_annotation); |
|
578 |
} |
|
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
579 |
} |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
580 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
581 |
IriSP.Model.Mashup.prototype.getAnnotations = function() { |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
582 |
return this.segments; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
583 |
} |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
584 |
|
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
585 |
IriSP.Model.Mashup.prototype.getMedias = function() { |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
586 |
return this.medias; |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
587 |
} |
| 900 | 588 |
|
589 |
IriSP.Model.Mashup.prototype.getAnnotationsByTypeTitle = function(_title) { |
|
590 |
var _annTypes = this.source.getAnnotationTypes().searchByTitle(_title).pluck("id"); |
|
591 |
if (_annTypes.length) { |
|
592 |
return this.getAnnotations().filter(function(_annotation) { |
|
593 |
return IriSP._(_annTypes).indexOf(_annotation.getAnnotationType().id) !== -1; |
|
594 |
}); |
|
595 |
} else { |
|
596 |
return new IriSP.Model.List(this.source.directory) |
|
597 |
} |
|
598 |
} |
|
599 |
||
| 903 | 600 |
IriSP.Model.Mashup.prototype.getAnnotationAtTime = function(_time) { |
601 |
var _list = this.segments.filter(function(_annotation) { |
|
602 |
return _annotation.begin <= _time && _annotation.end > _time; |
|
603 |
}); |
|
604 |
if (_list.length) { |
|
605 |
return _list[0]; |
|
606 |
} else { |
|
607 |
return undefined; |
|
608 |
} |
|
609 |
} |
|
610 |
||
611 |
IriSP.Model.Mashup.prototype.getMediaAtTime = function(_time) { |
|
612 |
var _annotation = this.getAnnotationAtTime(_time); |
|
613 |
if (typeof _annotation !== "undefined") { |
|
614 |
return _annotation.getMedia(); |
|
615 |
} else { |
|
616 |
return undefined; |
|
617 |
} |
|
618 |
} |
|
619 |
||
|
887
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
620 |
/* */ |
|
6a04bd37da0a
Corrected lib loading function so several instances of the Metadataplayer can be called
veltr
parents:
881
diff
changeset
|
621 |
|
| 860 | 622 |
IriSP.Model.Source = function(_config) { |
| 868 | 623 |
this.status = IriSP.Model._SOURCE_STATUS_EMPTY; |
| 860 | 624 |
if (typeof _config !== "undefined") { |
625 |
var _this = this; |
|
| 866 | 626 |
IriSP._(_config).forEach(function(_v, _k) { |
| 860 | 627 |
_this[_k] = _v; |
628 |
}) |
|
629 |
this.callbackQueue = []; |
|
630 |
this.contents = {}; |
|
631 |
this.get(); |
|
632 |
} |
|
633 |
} |
|
634 |
||
| 858 | 635 |
IriSP.Model.Source.prototype.addList = function(_listId, _contents) { |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
636 |
if (typeof this.contents[_listId] === "undefined") { |
| 860 | 637 |
this.contents[_listId] = new IriSP.Model.List(this.directory); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
638 |
} |
| 866 | 639 |
this.contents[_listId].addElements(_contents); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
640 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
641 |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
642 |
IriSP.Model.Source.prototype.getList = function(_listId, _global) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
643 |
_global = (typeof _global !== "undefined" && _global); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
644 |
if (_global || typeof this.contents[_listId] === "undefined") { |
| 860 | 645 |
return this.directory.getGlobalList().filter(function(_e) { |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
646 |
return (_e.elementType === _listId); |
| 858 | 647 |
}); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
648 |
} else { |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
649 |
return this.contents[_listId]; |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
650 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
651 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
652 |
|
| 866 | 653 |
IriSP.Model.Source.prototype.forEach = function(_callback) { |
| 860 | 654 |
var _this = this; |
| 866 | 655 |
IriSP._(this.contents).forEach(function(_value, _key) { |
| 860 | 656 |
_callback.call(_this, _value, _key); |
657 |
}) |
|
658 |
} |
|
659 |
||
| 866 | 660 |
IriSP.Model.Source.prototype.getElement = function(_elId) { |
| 916 | 661 |
return this.directory.getElement(_elId); |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
662 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
663 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
664 |
IriSP.Model.Source.prototype.get = function() { |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
665 |
this.status = IriSP.Model._SOURCE_STATUS_WAITING; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
666 |
this.handleCallbacks(); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
667 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
668 |
|
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
669 |
/* We defer the callbacks calls so they execute after the queue is cleared */ |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
670 |
IriSP.Model.Source.prototype.deferCallback = function(_callback) { |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
671 |
var _this = this; |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
672 |
IriSP._.defer(function() { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
673 |
_callback.call(_this); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
674 |
}); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
675 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
676 |
|
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
677 |
IriSP.Model.Source.prototype.handleCallbacks = function() { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
678 |
this.status = IriSP.Model._SOURCE_STATUS_READY; |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
679 |
while (this.callbackQueue.length) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
680 |
this.deferCallback(this.callbackQueue.splice(0,1)[0]); |
| 858 | 681 |
} |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
682 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
683 |
IriSP.Model.Source.prototype.onLoad = function(_callback) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
684 |
if (this.status === IriSP.Model._SOURCE_STATUS_READY) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
685 |
this.deferCallback(_callback); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
686 |
} else { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
687 |
this.callbackQueue.push(_callback); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
688 |
} |
| 854 | 689 |
} |
690 |
||
| 860 | 691 |
IriSP.Model.Source.prototype.serialize = function() { |
692 |
return this.serializer.serialize(this); |
|
693 |
} |
|
694 |
||
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
695 |
IriSP.Model.Source.prototype.deSerialize = function(_data) { |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
696 |
this.serializer.deSerialize(_data, this); |
| 854 | 697 |
} |
698 |
||
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
699 |
IriSP.Model.Source.prototype.getAnnotations = function(_global) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
700 |
_global = (typeof _global !== "undefined" && _global); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
701 |
return this.getList("annotation", _global); |
| 854 | 702 |
} |
703 |
||
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
704 |
IriSP.Model.Source.prototype.getMedias = function(_global) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
705 |
_global = (typeof _global !== "undefined" && _global); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
706 |
return this.getList("media", _global); |
| 864 | 707 |
} |
708 |
||
| 904 | 709 |
IriSP.Model.Source.prototype.getTags = function(_global) { |
710 |
_global = (typeof _global !== "undefined" && _global); |
|
711 |
return this.getList("tag", _global); |
|
712 |
} |
|
713 |
||
| 900 | 714 |
IriSP.Model.Source.prototype.getMashups = function(_global) { |
715 |
_global = (typeof _global !== "undefined" && _global); |
|
716 |
return this.getList("mashup", _global); |
|
717 |
} |
|
718 |
||
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
719 |
IriSP.Model.Source.prototype.getAnnotationTypes = function(_global) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
720 |
_global = (typeof _global !== "undefined" && _global); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
721 |
return this.getList("annotationType", _global); |
| 864 | 722 |
} |
723 |
||
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
724 |
IriSP.Model.Source.prototype.getAnnotationsByTypeTitle = function(_title, _global) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
725 |
_global = (typeof _global !== "undefined" && _global); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
726 |
var _res = new IriSP.Model.List(this.directory), |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
727 |
_annTypes = this.getAnnotationTypes(_global).searchByTitle(_title); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
728 |
_annTypes.forEach(function(_annType) { |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
729 |
_res.addElements(_annType.getAnnotations(_global)); |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
730 |
}) |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
731 |
return _res; |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
732 |
} |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
733 |
|
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
734 |
IriSP.Model.Source.prototype.getDuration = function() { |
| 866 | 735 |
var _m = this.currentMedia; |
736 |
if (typeof _m !== "undefined") { |
|
737 |
return this.currentMedia.duration; |
|
738 |
} |
|
| 858 | 739 |
} |
740 |
||
|
908
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
741 |
IriSP.Model.Source.prototype.merge = function(_source) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
742 |
var _this = this; |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
743 |
_source.forEach(function(_value, _key) { |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
744 |
_this.getList(_key).addElements(_value); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
745 |
}); |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
746 |
} |
|
f56199193fad
CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents:
904
diff
changeset
|
747 |
|
| 858 | 748 |
/* */ |
749 |
||
| 860 | 750 |
IriSP.Model.RemoteSource = function(_config) { |
751 |
IriSP.Model.Source.call(this, _config); |
|
| 858 | 752 |
} |
753 |
||
754 |
IriSP.Model.RemoteSource.prototype = new IriSP.Model.Source(); |
|
755 |
||
756 |
IriSP.Model.RemoteSource.prototype.get = function() { |
|
| 868 | 757 |
this.status = IriSP.Model._SOURCE_STATUS_WAITING; |
| 858 | 758 |
var _this = this; |
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
759 |
this.serializer.loadData(this.url, function(_result) { |
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
760 |
_this.deSerialize(_result); |
|
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
868
diff
changeset
|
761 |
_this.handleCallbacks(); |
| 858 | 762 |
}); |
| 854 | 763 |
} |
764 |
||
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
765 |
/* */ |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
766 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
767 |
IriSP.Model.Directory = function() { |
| 858 | 768 |
this.remoteSources = {}; |
769 |
this.elements = {}; |
|
|
872
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
770 |
} |
|
d777d05a16e4
finished AnnotationsList and started New PolemicWidget
veltr
parents:
870
diff
changeset
|
771 |
|
| 858 | 772 |
IriSP.Model.Directory.prototype.remoteSource = function(_properties) { |
| 917 | 773 |
if (typeof _properties !== "object" || typeof _properties.url === "undefined") { |
774 |
throw "Error : IriSP.Model.Directory.remoteSource(configuration): configuration.url is undefined"; |
|
775 |
} |
|
| 860 | 776 |
var _config = IriSP._({ directory: this }).extend(_properties); |
| 858 | 777 |
if (typeof this.remoteSources[_properties.url] === "undefined") { |
| 860 | 778 |
this.remoteSources[_properties.url] = new IriSP.Model.RemoteSource(_config); |
| 858 | 779 |
} |
780 |
return this.remoteSources[_properties.url]; |
|
| 854 | 781 |
} |
782 |
||
| 860 | 783 |
IriSP.Model.Directory.prototype.newLocalSource = function(_properties) { |
784 |
var _config = IriSP._({ directory: this }).extend(_properties), |
|
785 |
_res = new IriSP.Model.Source(_config); |
|
786 |
return _res; |
|
787 |
} |
|
788 |
||
| 858 | 789 |
IriSP.Model.Directory.prototype.getElement = function(_id) { |
| 900 | 790 |
return this.elements[_id]; |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
791 |
} |
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
792 |
|
| 858 | 793 |
IriSP.Model.Directory.prototype.addElement = function(_element) { |
794 |
this.elements[_element.id] = _element; |
|
795 |
} |
|
796 |
||
797 |
IriSP.Model.Directory.prototype.getGlobalList = function() { |
|
798 |
var _res = new IriSP.Model.List(this); |
|
| 866 | 799 |
_res.addIds(IriSP._(this.elements).keys()); |
| 858 | 800 |
return _res; |
| 854 | 801 |
} |
|
856
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
802 |
|
|
41c574c807d1
basic implementation of model: media, annotation type, annotation
veltr
parents:
854
diff
changeset
|
803 |
/* */ |