2013-03-30 22:30:00 +03:00
|
|
|
"use strict";
|
|
|
|
define(['app'], function () {
|
2013-02-23 20:42:15 +03:00
|
|
|
NzbDrone.Calendar.CalendarModel = Backbone.Model.extend({
|
|
|
|
mutators: {
|
2013-03-30 02:28:58 +03:00
|
|
|
title : function () {
|
2013-02-28 19:34:18 +03:00
|
|
|
return this.get('seriesTitle');
|
2013-02-25 03:00:17 +03:00
|
|
|
},
|
2013-03-30 02:28:58 +03:00
|
|
|
allDay : function () {
|
2013-02-25 03:00:17 +03:00
|
|
|
return false;
|
2013-02-28 19:34:18 +03:00
|
|
|
},
|
2013-03-30 02:28:58 +03:00
|
|
|
day : function () {
|
2013-02-28 19:34:18 +03:00
|
|
|
return Date.create(this.get('start')).format('{dd}');
|
|
|
|
},
|
2013-03-30 02:28:58 +03:00
|
|
|
month : function () {
|
2013-02-28 19:34:18 +03:00
|
|
|
return Date.create(this.get('start')).format('{MON}');
|
|
|
|
},
|
2013-03-30 02:28:58 +03:00
|
|
|
startTime : function () {
|
2013-02-28 19:34:18 +03:00
|
|
|
var start = Date.create(this.get('start'));
|
|
|
|
|
2013-03-30 02:28:58 +03:00
|
|
|
if (start.format('{mm}') === '00') {
|
2013-02-28 19:34:18 +03:00
|
|
|
return start.format('{h}{tt}');
|
2013-03-30 02:28:58 +03:00
|
|
|
}
|
2013-02-28 19:34:18 +03:00
|
|
|
|
|
|
|
return start.format('{h}.{mm}{tt}');
|
|
|
|
},
|
2013-03-30 02:28:58 +03:00
|
|
|
paddedEpisodeNumber: function () {
|
2013-02-28 19:34:18 +03:00
|
|
|
return this.get('episodeNumber');
|
|
|
|
},
|
2013-03-30 02:28:58 +03:00
|
|
|
statusLevel : function () {
|
2013-02-28 19:34:18 +03:00
|
|
|
var status = this.get('status');
|
|
|
|
var currentTime = Date.create();
|
|
|
|
var start = Date.create(this.get('start'));
|
|
|
|
var end = Date.create(this.get('end'));
|
|
|
|
|
2013-03-30 02:28:58 +03:00
|
|
|
if (currentTime.isBetween(start, end)) {
|
2013-02-28 19:34:18 +03:00
|
|
|
return 'warning';
|
2013-03-30 02:28:58 +03:00
|
|
|
}
|
2013-02-28 19:34:18 +03:00
|
|
|
|
2013-03-30 02:28:58 +03:00
|
|
|
if (start.isBefore(currentTime) || status === 'Missing') {
|
2013-03-01 07:59:06 +03:00
|
|
|
return 'danger';
|
2013-03-30 02:28:58 +03:00
|
|
|
}
|
2013-03-01 07:59:06 +03:00
|
|
|
|
2013-03-30 02:28:58 +03:00
|
|
|
if (status === 'Ready') {
|
|
|
|
return 'success';
|
|
|
|
}
|
2013-02-28 19:34:18 +03:00
|
|
|
|
2013-03-01 07:59:06 +03:00
|
|
|
return 'primary';
|
|
|
|
},
|
2013-03-30 02:28:58 +03:00
|
|
|
bestDateString : function () {
|
2013-03-01 07:59:06 +03:00
|
|
|
return bestDateString(this.get('start'));
|
2013-03-30 22:30:00 +03:00
|
|
|
}
|
2013-02-23 20:42:15 +03:00
|
|
|
},
|
|
|
|
defaults: {
|
|
|
|
status: 0
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|