# HG changeset patch # User veltr # Date 1346836178 -7200 # Node ID b58eda0ce5df295b63729ff47acde26d64963c9c # Parent 693c282aa4e9ceb749987d216be1f3533e0e5e10 Removed obsolete files diff -r 693c282aa4e9 -r b58eda0ce5df src/obsolete-files/CinecastSerializer.js --- a/src/obsolete-files/CinecastSerializer.js Wed Sep 05 11:03:20 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,186 +0,0 @@ -/* Cinecast Cinelab Serializer */ - -if (typeof IriSP.serializers === "undefined") { - IriSP.serializers = {} -} - -IriSP.serializers.cinecast = { - types : { - media : { - serialized_name : "medias", - model_name : "media", - deserializer : function(_data, _source) { - var _res = new IriSP.Model.Media(_data.id, _source); - _res.video = _data.url; - _res.title = _data.meta.title; - _res.description = _data.meta.synopsis; - _res.setDuration(_data.meta.duration); - return _res; - }, - serializer : function(_data, _source) { - return { - id : _source.unNamespace(_data.id), - url : _data.video, - meta : { - title : _data.title, - synopsis : _data.description, - duration : _data.duration.milliseconds - } - } - } - }, - tag : { - serialized_name : "tags", - model_name : "tag", - deserializer : function(_data, _source) { - var _res = new IriSP.Model.Tag(_data.id, _source); - _res.title = _data.meta.description; - return _res; - }, - serializer : function(_data, _source) { - return { - id : _source.unNamespace(_data.id), - meta : { - description : _data.title - } - } - } - }, - annotationType : { - serialized_name : "annotation_types", - deserializer : function(_data, _source) { - var _res = new IriSP.Model.AnnotationType(_data.id, _source); - _res.title = _source.getNamespaced(_data.id).name; - _res.description = _data.meta.description; - return _res; - }, - serializer : function(_data, _source) { - return { - id : _source.unNamespace(_data.id), - meta : { - description : _data.description - } - } - } - }, - annotation : { - serialized_name : "annotations", - deserializer : function(_data, _source) { - var _res = new IriSP.Model.Annotation(_data.id, _source); - _res.title = _data.meta.creator_name; - _res.description = _data.content.data; - _res.created = IriSP.Model.isoToDate(_data.meta.created); - _res.setMedia(_data.media, _source); - _res.setAnnotationType(_data.type); - _res.setTags(IriSP._(_data.tags).map(function(_t) { - if (typeof _source.contents.tag === "undefined") { - _source.contents.tag = new IriSP.Model.List(_source.directory); - } - if (_source.contents.tag.hasId(_t)) { - return _t; - } else { - var _id = _t.toLowerCase() - .replace(/#/g,'') - .replace(/^(\d)/,'_$1') - .replace(/[áâäàã]/g,'a') - .replace(/ç/g,'c') - .replace(/[éèêë]/g,'e') - .replace(/[íìîï]/g,'i') - .replace(/ñ/g,'n') - .replace(/[óòôöõ]/g,'o') - .replace(/œ/g,'oe') - .replace(/[úùûü]/g,'u') - .replace(/ÿ/g,'y') - .replace(/[^A-Za-z0-9_]/g,''), - _tag = new IriSP.Model.Tag(_id, _source); - _tag.title = _t; - _source.contents.tag.push(_tag); - return _id; - } - })); - _res.setBegin(_data.begin); - _res.setEnd(_data.end); - _res.creator = _data.meta.creator; - return _res; - }, - serializer : function(_data, _source) { - return { - id : _source.unNamespace(_data.id), - content : { - data : _data.description - }, - begin : _data.begin.milliseconds, - end : _data.begin.milliseconds, - media : _source.unNamespace(_data.media.id), - type : _source.unNamespace(_data.annotationType.id), - meta : { - created : IriSP.Model.dateToIso(_data.created), - creator : _data.creator, - creator_name : _data.title - }, - tags : _data.tag.id.map(function(_id) { - return _source.unNamespace(_id) - }) - } - } - } - }, - serialize : function(_source) { - var _res = { - format : "http://advene.org/ns/cinelab/" - }, - _this = this, - _nsls = _source.listNamespaces(true); - _res.imports = []; - for (var _i = 0; _i < _nsls.length; _i++) { - if (typeof _source.directory.namespaces[_nsls[_i]] !== "undefined") { - _res.imports.push({ - id : _nsls[_i], - url : _source.directory.namespaces[_nsls[_i]] - }) - } - } - _source.forEach(function(_list, _typename) { - if (typeof _this.types[_typename] !== "undefined") { - _res[_this.types[_typename].serialized_name] = _list.map(function(_el) { - return _this.types[_typename].serializer(_el, _source); - }); - } - }); - return _res; - }, - loadData : function(_url, _callback) { - IriSP.jQuery.getJSON(_url, _callback) - }, - deSerialize : function(_data, _source) { - if (typeof _data !== "object" || _data === null) { - return; - } - if (typeof _data.imports !== "undefined") { - IriSP._(_data.imports).forEach(function(_import) { - _source.directory.namespaces[_import.id] = _import.url; - }) - } - IriSP._(this.types).forEach(function(_type, _typename) { - var _listdata = _data[_type.serialized_name]; - if (typeof _listdata !== "undefined" && _listdata !== null) { - var _list = new IriSP.Model.List(_source.directory); - if (_listdata.hasOwnProperty("length")) { - var _l = _listdata.length; - for (var _i = 0; _i < _l; _i++) { - _list.push(_type.deserializer(_listdata[_i], _source)); - } - } else { - _list.push(_type.deserializer(_listdata, _source)); - } - _source.addList(_typename, _list); - } - }); - - if (typeof _data.meta !== "undefined" && typeof _data.meta.main_media !== "undefined" && typeof _data.meta.main_media["id-ref"] !== "undefined") { - _source.setCurrentMediaId(_data.meta.id); - } - _source.setDefaultCurrentMedia(); - } -} - diff -r 693c282aa4e9 -r b58eda0ce5df src/obsolete-files/model-namespaced.js --- a/src/obsolete-files/model-namespaced.js Wed Sep 05 11:03:20 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,877 +0,0 @@ -/* model.js is where data is stored in a standard form, whatever the serializer */ - -IriSP.Model = { - _SOURCE_STATUS_EMPTY : 0, - _SOURCE_STATUS_WAITING : 1, - _SOURCE_STATUS_READY : 2, - _ID_AUTO_INCREMENT : 0, - _ID_BASE : (function(_d) { - function pad(n){return n<10 ? '0'+n : n} - function fillrand(n) { - var _res = '' - for (var i=0; i _time; - }); - if (_list.length) { - return _list[0]; - } else { - return undefined; - } -} - -IriSP.Model.Mashup.prototype.getMediaAtTime = function(_time) { - var _annotation = this.getAnnotationAtTime(_time); - if (typeof _annotation !== "undefined") { - return _annotation.getMedia(); - } else { - return undefined; - } -} - -/* */ - -IriSP.Model.Source = function(_config) { - this.status = IriSP.Model._SOURCE_STATUS_EMPTY; - if (typeof _config !== "undefined") { - var _this = this; - IriSP._(_config).forEach(function(_v, _k) { - _this[_k] = _v; - }) - this.callbackQueue = []; - this.contents = {}; - if (typeof this.namespace === "undefined") { - this.namespace = "metadataplayer"; - } else { - if (typeof this.namespaceUrl === "undefined" && typeof this.url !== "undefined") { - var _matches = this.url.match(/(^[^?&]+|[^?&][a-zA-Z0-9_%=?]+)/g), - _url = _matches[0]; - if (_matches.length > 1) { - _matches = IriSP._(_matches.slice(1)).reject(function(_txt) { - return /\?$/.test(_txt); - }); - } - if (_matches.length > 0) { - _url += '?' + _matches.join('&'); - } - this.namespaceUrl = _url; - } - } - if (typeof this.namespaceUrl === "undefined") { - this.namespaceUrl = "http://ldt.iri.centrepompidou.fr/"; - } - this.directory.addNamespace(this.namespace, this.namespaceUrl); - this.get(); - } -} - -IriSP.Model.Source.prototype.getNamespaced = function(_id) { - var _tab = _id.split(':'); - if (_tab.length > 1) { - return { - namespace : _tab[0], - name : _tab[1], - fullname : _id - } - } else { - return { - namespace : this.namespace, - name : _id, - fullname : this.namespace + ':' + _id - } - } -} - -IriSP.Model.Source.prototype.unNamespace = function(_id) { - if (typeof _id !== "undefined") { - return _id.replace(this.namespace + ':', ''); - } -} - -IriSP.Model.Source.prototype.addList = function(_listId, _contents) { - if (typeof this.contents[_listId] === "undefined") { - this.contents[_listId] = new IriSP.Model.List(this.directory); - } - this.contents[_listId].addElements(_contents); -} - -IriSP.Model.Source.prototype.getList = function(_listId, _global) { - _global = (typeof _global !== "undefined" && _global); - if (_global || typeof this.contents[_listId] === "undefined") { - return this.directory.getGlobalList().filter(function(_e) { - return (_e.elementType === _listId); - }); - } else { - return this.contents[_listId]; - } -} - -IriSP.Model.Source.prototype.forEach = function(_callback) { - var _this = this; - IriSP._(this.contents).forEach(function(_value, _key) { - _callback.call(_this, _value, _key); - }) -} - -IriSP.Model.Source.prototype.getElement = function(_elId) { - return this.directory.getElement(this.getNamespaced(_elId).fullname); -} - -IriSP.Model.Source.prototype.setCurrentMediaId = function(_idRef) { - if (typeof _idRef !== "undefined") { - this.currentMedia = this.getElement(_idRef); - } -} - -IriSP.Model.Source.prototype.setDefaultCurrentMedia = function() { - if (typeof this.currentMedia === "undefined" && this.getMedias().length) { - this.currentMedia = this.getMedias()[0]; - } -} - -IriSP.Model.Source.prototype.listNamespaces = function(_excludeSelf) { - var _this = this, - _nsls = [], - _excludeSelf = (typeof _excludeSelf !== "undefined" && _excludeSelf); - this.forEach(function(_list) { - IriSP._(_list).forEach(function(_el) { - var _ns = _el.id.replace(/:.*$/,''); - if (IriSP._(_nsls).indexOf(_ns) === -1 && (!_excludeSelf || _ns !== _this.namespace)) { - _nsls.push(_ns); - } - }) - }); - return _nsls; -} - -IriSP.Model.Source.prototype.get = function() { - this.status = IriSP.Model._SOURCE_STATUS_WAITING; - this.handleCallbacks(); -} - -/* We defer the callbacks calls so they execute after the queue is cleared */ -IriSP.Model.Source.prototype.deferCallback = function(_callback) { - var _this = this; - IriSP._.defer(function() { - _callback.call(_this); - }); -} - -IriSP.Model.Source.prototype.handleCallbacks = function() { - this.status = IriSP.Model._SOURCE_STATUS_READY; - while (this.callbackQueue.length) { - this.deferCallback(this.callbackQueue.splice(0,1)[0]); - } -} -IriSP.Model.Source.prototype.onLoad = function(_callback) { - if (this.status === IriSP.Model._SOURCE_STATUS_READY) { - this.deferCallback(_callback); - } else { - this.callbackQueue.push(_callback); - } -} - -IriSP.Model.Source.prototype.serialize = function() { - return this.serializer.serialize(this); -} - -IriSP.Model.Source.prototype.deSerialize = function(_data) { - this.serializer.deSerialize(_data, this); -} - -IriSP.Model.Source.prototype.getAnnotations = function(_global) { - _global = (typeof _global !== "undefined" && _global); - return this.getList("annotation", _global); -} - -IriSP.Model.Source.prototype.getMedias = function(_global) { - _global = (typeof _global !== "undefined" && _global); - return this.getList("media", _global); -} - -IriSP.Model.Source.prototype.getTags = function(_global) { - _global = (typeof _global !== "undefined" && _global); - return this.getList("tag", _global); -} - -IriSP.Model.Source.prototype.getMashups = function(_global) { - _global = (typeof _global !== "undefined" && _global); - return this.getList("mashup", _global); -} - -IriSP.Model.Source.prototype.getAnnotationTypes = function(_global) { - _global = (typeof _global !== "undefined" && _global); - return this.getList("annotationType", _global); -} - -IriSP.Model.Source.prototype.getAnnotationsByTypeTitle = function(_title, _global) { - _global = (typeof _global !== "undefined" && _global); - var _res = new IriSP.Model.List(this.directory), - _annTypes = this.getAnnotationTypes(_global).searchByTitle(_title); - _annTypes.forEach(function(_annType) { - _res.addElements(_annType.getAnnotations(_global)); - }) - return _res; -} - -IriSP.Model.Source.prototype.getDuration = function() { - var _m = this.currentMedia; - if (typeof _m !== "undefined") { - return this.currentMedia.duration; - } -} - -IriSP.Model.Source.prototype.merge = function(_source) { - var _this = this; - _source.forEach(function(_value, _key) { - _this.getList(_key).addElements(_value); - }); -} - -/* */ - -IriSP.Model.RemoteSource = function(_config) { - IriSP.Model.Source.call(this, _config); -} - -IriSP.Model.RemoteSource.prototype = new IriSP.Model.Source(); - -IriSP.Model.RemoteSource.prototype.get = function() { - this.status = IriSP.Model._SOURCE_STATUS_WAITING; - var _this = this; - this.serializer.loadData(this.url, function(_result) { - _this.deSerialize(_result); - _this.handleCallbacks(); - }); -} - -/* */ - -IriSP.Model.Directory = function() { - this.remoteSources = {}; - this.elements = {}; - this.namespaces = {}; -} - -IriSP.Model.Directory.prototype.addNamespace = function(_namespace, _url) { - this.namespaces[_namespace] = _url; -} - -IriSP.Model.Directory.prototype.remoteSource = function(_properties) { - var _config = IriSP._({ directory: this }).extend(_properties); - if (typeof this.remoteSources[_properties.url] === "undefined") { - this.remoteSources[_properties.url] = new IriSP.Model.RemoteSource(_config); - } - return this.remoteSources[_properties.url]; -} - -IriSP.Model.Directory.prototype.newLocalSource = function(_properties) { - var _config = IriSP._({ directory: this }).extend(_properties), - _res = new IriSP.Model.Source(_config); - return _res; -} - -IriSP.Model.Directory.prototype.getElement = function(_id) { - return this.elements[_id]; -} - -IriSP.Model.Directory.prototype.addElement = function(_element) { - this.elements[_element.id] = _element; -} - -IriSP.Model.Directory.prototype.getGlobalList = function() { - var _res = new IriSP.Model.List(this); - _res.addIds(IriSP._(this.elements).keys()); - return _res; -} - -/* */