src/js/model.js
branchnew-model
changeset 908 f56199193fad
parent 904 510ebab76fa3
child 915 ba7aab923d08
equal deleted inserted replaced
906:4b6e154ae8de 908:f56199193fad
   208     IriSP._(_array).forEach(function(_el) {
   208     IriSP._(_array).forEach(function(_el) {
   209         _this.push(_el);
   209         _this.push(_el);
   210     });
   210     });
   211 }
   211 }
   212 
   212 
   213 IriSP.Model.List.prototype.removeId = function(_id) {
   213 IriSP.Model.List.prototype.removeId = function(_id, _deleteFromDirectory) {
   214     var _index = (IriSP._(this.idIndex).indexOf(_id));
   214     var _deleteFromDirectory = _deleteFromDirectory || false,
       
   215         _index = (IriSP._(this.idIndex).indexOf(_id));
   215     if (_index !== -1) {
   216     if (_index !== -1) {
   216         this.splice(_index,1);
   217         this.splice(_index,1);
   217     }
   218     }
   218 }
   219     if (_deleteFromDirectory) {
   219 
   220         delete this.directory.elements[_id];
   220 IriSP.Model.List.prototype.removeElement = function(_el) {
   221     }
       
   222 }
       
   223 
       
   224 IriSP.Model.List.prototype.removeElement = function(_el, _deleteFromDirectory) {
       
   225     var _deleteFromDirectory = _deleteFromDirectory || false;
   221     this.removeId(_el.id);
   226     this.removeId(_el.id);
   222 }
   227 }
   223 
   228 
   224 IriSP.Model.List.prototype.removeIds = function(_list) {
   229 IriSP.Model.List.prototype.removeIds = function(_list, _deleteFromDirectory) {
   225     var _this = this;
   230     var _deleteFromDirectory = _deleteFromDirectory || false,
       
   231         _this = this;
   226     IriSP._(_list).forEach(function(_id) {
   232     IriSP._(_list).forEach(function(_id) {
   227         _this.removeId(_id);
   233         _this.removeId(_id);
   228     });
   234     });
   229 }
   235 }
   230 
   236 
   231 IriSP.Model.List.prototype.removeElements = function(_list) {
   237 IriSP.Model.List.prototype.removeElements = function(_list, _deleteFromDirectory) {
   232     var _this = this;
   238     var _deleteFromDirectory = _deleteFromDirectory || false,
       
   239         _this = this;
   233     IriSP._(_list).forEach(function(_el) {
   240     IriSP._(_list).forEach(function(_el) {
   234         _this.removeElement(_el);
   241         _this.removeElement(_el);
   235     });
   242     });
   236 }
   243 }
   237 
   244 
   783     if (typeof _m !== "undefined") {
   790     if (typeof _m !== "undefined") {
   784         return this.currentMedia.duration;
   791         return this.currentMedia.duration;
   785     }
   792     }
   786 }
   793 }
   787 
   794 
       
   795 IriSP.Model.Source.prototype.merge = function(_source) {
       
   796     var _this = this;
       
   797     _source.forEach(function(_value, _key) {
       
   798         _this.getList(_key).addElements(_value);
       
   799     });
       
   800 }
       
   801 
   788 /* */
   802 /* */
   789 
   803 
   790 IriSP.Model.RemoteSource = function(_config) {
   804 IriSP.Model.RemoteSource = function(_config) {
   791     IriSP.Model.Source.call(this, _config);
   805     IriSP.Model.Source.call(this, _config);
   792 }
   806 }