2013-04-24 08:56:51 +03:00
|
|
|
"use strict";
|
2013-03-04 01:42:26 +03:00
|
|
|
define(['app'], function () {
|
|
|
|
NzbDrone.Series.EpisodeModel = Backbone.Model.extend({
|
2013-03-02 22:13:23 +03:00
|
|
|
|
|
|
|
mutators: {
|
2013-05-01 03:25:33 +03:00
|
|
|
bestDateString : function () {
|
|
|
|
return bestDateString(this.get('airDate'));
|
|
|
|
},
|
|
|
|
paddedEpisodeNumber: function () {
|
|
|
|
return this.get('episodeNumber');
|
2013-05-01 04:54:15 +03: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}');
|
|
|
|
},
|
|
|
|
statusLevel : function () {
|
|
|
|
var status = this.get('status');
|
|
|
|
var currentTime = Date.create();
|
|
|
|
var start = Date.create(this.get('start'));
|
|
|
|
var end = Date.create(this.get('end'));
|
|
|
|
|
|
|
|
if (currentTime.isBetween(start, end)) {
|
|
|
|
return 'warning';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start.isBefore(currentTime) || status === 'Missing') {
|
|
|
|
return 'danger';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status === 'Ready') {
|
|
|
|
return 'success';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'primary';
|
2013-05-01 03:25:33 +03:00
|
|
|
}
|
2013-03-02 22:13:23 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
defaults: {
|
2013-05-01 04:54:15 +03:00
|
|
|
seasonNumber: 0,
|
|
|
|
status: 0
|
2013-03-02 22:13:23 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|