2013-04-24 05:56:51 +00:00
|
|
|
"use strict";
|
2013-03-03 22:42:26 +00:00
|
|
|
define(['app'], function () {
|
|
|
|
NzbDrone.Series.EpisodeModel = Backbone.Model.extend({
|
2013-03-02 19:13:23 +00:00
|
|
|
|
|
|
|
mutators: {
|
2013-05-01 00:25:33 +00:00
|
|
|
bestDateString : function () {
|
|
|
|
return bestDateString(this.get('airDate'));
|
|
|
|
},
|
|
|
|
paddedEpisodeNumber: function () {
|
2013-05-10 22:33:04 +00:00
|
|
|
return this.get('episodeNumber').pad(2);
|
2013-05-01 01:54:15 +00:00
|
|
|
},
|
|
|
|
day : function () {
|
|
|
|
return Date.create(this.get('airDate')).format('{dd}');
|
|
|
|
},
|
|
|
|
month : function () {
|
|
|
|
return Date.create(this.get('airDate')).format('{MON}');
|
|
|
|
},
|
|
|
|
startTime : function () {
|
|
|
|
var start = Date.create(this.get('airDate'));
|
|
|
|
|
|
|
|
if (start.format('{mm}') === '00') {
|
|
|
|
return start.format('{h}{tt}');
|
|
|
|
}
|
|
|
|
|
|
|
|
return start.format('{h}.{mm}{tt}');
|
|
|
|
},
|
2013-06-05 01:04:34 +00:00
|
|
|
end : function () {
|
|
|
|
|
|
|
|
if (this.has('series')) {
|
|
|
|
var start = Date.create(this.get('airDate'));
|
|
|
|
var runtime = this.get('series').runtime;
|
2013-06-04 06:10:41 +00:00
|
|
|
|
2013-06-05 01:04:34 +00:00
|
|
|
return start.addMinutes(runtime);
|
|
|
|
}
|
2013-06-04 06:10:41 +00:00
|
|
|
},
|
2013-05-01 01:54:15 +00:00
|
|
|
statusLevel : function () {
|
2013-06-04 06:10:41 +00:00
|
|
|
var episodeFileId = this.get('episodeFileId');
|
2013-05-01 01:54:15 +00:00
|
|
|
var currentTime = Date.create();
|
2013-06-04 06:10:41 +00:00
|
|
|
var start = Date.create(this.get('airDate'));
|
2013-05-01 01:54:15 +00:00
|
|
|
var end = Date.create(this.get('end'));
|
|
|
|
|
|
|
|
if (currentTime.isBetween(start, end)) {
|
|
|
|
return 'warning';
|
|
|
|
}
|
|
|
|
|
2013-06-04 06:10:41 +00:00
|
|
|
if (start.isBefore(currentTime) && episodeFileId === 0) {
|
2013-05-01 01:54:15 +00:00
|
|
|
return 'danger';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status === 'Ready') {
|
|
|
|
return 'success';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'primary';
|
2013-05-20 21:06:01 +00:00
|
|
|
},
|
|
|
|
hasAired : function () {
|
|
|
|
return Date.create(this.get('airDate')).isBefore(Date.create());
|
2013-05-01 00:25:33 +00:00
|
|
|
}
|
2013-03-02 19:13:23 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
defaults: {
|
2013-05-01 01:54:15 +00:00
|
|
|
seasonNumber: 0,
|
2013-05-20 21:06:01 +00:00
|
|
|
status : 0
|
2013-03-02 19:13:23 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|