src/js/model.js
branchnew-model
changeset 917 eb8677d3a663
parent 916 ec6849bbbdcc
child 919 972099304059
equal deleted inserted replaced
916:ec6849bbbdcc 917:eb8677d3a663
       
     1 /* TODO: Separate Project-specific data from Source */
       
     2 
     1 /* model.js is where data is stored in a standard form, whatever the serializer */
     3 /* model.js is where data is stored in a standard form, whatever the serializer */
     2 
     4 
     3 IriSP.Model = {
     5 IriSP.Model = {
     4     _SOURCE_STATUS_EMPTY : 0,
     6     _SOURCE_STATUS_EMPTY : 0,
     5     _SOURCE_STATUS_WAITING : 1,
     7     _SOURCE_STATUS_WAITING : 1,
   292 IriSP.Model.Time.prototype.setSeconds = function(_seconds) {
   294 IriSP.Model.Time.prototype.setSeconds = function(_seconds) {
   293     this.milliseconds = 1000 * _seconds;
   295     this.milliseconds = 1000 * _seconds;
   294 }
   296 }
   295 
   297 
   296 IriSP.Model.Time.prototype.getSeconds = function() {
   298 IriSP.Model.Time.prototype.getSeconds = function() {
   297     return Math.floor(this.milliseconds / 1000);
   299     return this.milliseconds / 1000;
   298 }
   300 }
   299 
   301 
   300 IriSP.Model.Time.prototype.getHMS = function() {
   302 IriSP.Model.Time.prototype.getHMS = function() {
   301     var _totalSeconds = Math.abs(this.getSeconds());
   303     var _totalSeconds = Math.abs(Math.floor(this.getSeconds()));
   302     return {
   304     return {
   303         hours : Math.floor(_totalSeconds / 3600),
   305         hours : Math.floor(_totalSeconds / 3600),
   304         minutes : (Math.floor(_totalSeconds / 60) % 60),
   306         minutes : (Math.floor(_totalSeconds / 60) % 60),
   305         seconds : _totalSeconds % 60
   307         seconds : _totalSeconds % 60
   306     } 
   308     } 
   777     this.remoteSources = {};
   779     this.remoteSources = {};
   778     this.elements = {};
   780     this.elements = {};
   779 }
   781 }
   780 
   782 
   781 IriSP.Model.Directory.prototype.remoteSource = function(_properties) {
   783 IriSP.Model.Directory.prototype.remoteSource = function(_properties) {
       
   784     if (typeof _properties !== "object" || typeof _properties.url === "undefined") {
       
   785         throw "Error : IriSP.Model.Directory.remoteSource(configuration): configuration.url is undefined";
       
   786     }
   782     var _config = IriSP._({ directory: this }).extend(_properties);
   787     var _config = IriSP._({ directory: this }).extend(_properties);
   783     if (typeof this.remoteSources[_properties.url] === "undefined") {
   788     if (typeof this.remoteSources[_properties.url] === "undefined") {
   784         this.remoteSources[_properties.url] = new IriSP.Model.RemoteSource(_config);
   789         this.remoteSources[_properties.url] = new IriSP.Model.RemoteSource(_config);
   785     }
   790     }
   786     return this.remoteSources[_properties.url];
   791     return this.remoteSources[_properties.url];