Sonarr/UI/Series/EpisodeModel.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-06-22 06:24:24 +00:00
'use strict';
define(
[
'backbone',
'moment',
2013-08-21 06:46:23 +00:00
'Series/SeriesModel',
'Series/EpisodeFileModel'
], function (Backbone, Moment, SeriesModel, EpisodeFileModel) {
return Backbone.Model.extend({
2013-07-17 00:41:04 +00:00
initialize: function () {
if (this.has('series')) {
2013-07-24 05:28:06 +00:00
var start = Moment(this.get('airDateUtc'));
2013-07-17 00:41:04 +00:00
var runtime = this.get('series').get('runtime');
2013-05-01 01:54:15 +00:00
this.set('end', start.add('minutes', runtime));
}
2013-05-20 21:06:01 +00:00
},
2013-03-02 19:13:23 +00:00
parse: function (model) {
model.series = new SeriesModel(model.series);
2013-08-21 06:46:23 +00:00
if (model.episodeFile) {
model.episodeFile = new EpisodeFileModel(model.episodeFile);
}
return model;
},
toJSON: function () {
var json = _.clone(this.attributes);
if (this.has('series')) {
json.series = this.get('series').toJSON();
}
return json;
},
2013-06-10 02:10:15 +00:00
defaults: {
seasonNumber: 0,
status : 0
}
});
2013-03-02 19:13:23 +00:00
});