Sonarr/UI/Calendar/CalendarModel.js

58 lines
1.8 KiB
JavaScript
Raw Normal View History

2013-03-30 19:30:00 +00:00
"use strict";
define(['app'], function () {
NzbDrone.Calendar.CalendarModel = Backbone.Model.extend({
mutators: {
title : function () {
2013-02-28 16:34:18 +00:00
return this.get('seriesTitle');
2013-02-25 00:00:17 +00:00
},
allDay : function () {
2013-02-25 00:00:17 +00:00
return false;
2013-02-28 16:34:18 +00:00
},
day : function () {
2013-02-28 16:34:18 +00:00
return Date.create(this.get('start')).format('{dd}');
},
month : function () {
2013-02-28 16:34:18 +00:00
return Date.create(this.get('start')).format('{MON}');
},
startTime : function () {
2013-02-28 16:34:18 +00:00
var start = Date.create(this.get('start'));
if (start.format('{mm}') === '00') {
2013-02-28 16:34:18 +00:00
return start.format('{h}{tt}');
}
2013-02-28 16:34:18 +00:00
return start.format('{h}.{mm}{tt}');
},
paddedEpisodeNumber: function () {
2013-02-28 16:34:18 +00:00
return this.get('episodeNumber');
},
statusLevel : function () {
2013-02-28 16:34:18 +00:00
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)) {
2013-02-28 16:34:18 +00:00
return 'warning';
}
2013-02-28 16:34:18 +00:00
if (start.isBefore(currentTime) || status === 'Missing') {
return 'danger';
}
if (status === 'Ready') {
return 'success';
}
2013-02-28 16:34:18 +00:00
return 'primary';
},
bestDateString : function () {
return bestDateString(this.get('start'));
2013-03-30 19:30:00 +00:00
}
},
defaults: {
status: 0
}
});
});