Readarr/src/UI/Handlebars/Helpers/Episode.js
Mark McDowall 00717a638a Updated full calendar to 1.6.4
Calendar/Upcoming now update on grab/download events
Better use of backbone collection on calendar
New: Calendar will auto refresh when episodes are grabbed and downloaded
2013-11-30 02:54:11 -08:00

47 lines
1.2 KiB
JavaScript

'use strict';
define(
[
'handlebars',
'Shared/FormatHelpers',
'moment'
], function (Handlebars, FormatHelpers, Moment) {
Handlebars.registerHelper('EpisodeNumber', function () {
if (this.series.seriesType === 'daily') {
return Moment(this.airDate).format('L');
}
else {
return '{0}x{1}'.format(this.seasonNumber, FormatHelpers.pad(this.episodeNumber, 2));
}
});
Handlebars.registerHelper('StatusLevel', function () {
var hasFile = this.hasFile;
var downloading = require('History/Queue/QueueCollection').findEpisode(this.id) || this.downloading;
var currentTime = Moment();
var start = Moment(this.airDateUtc);
var end = Moment(this.end);
if (hasFile) {
return 'success';
}
if (downloading) {
return 'purple';
}
if (currentTime.isAfter(start) && currentTime.isBefore(end)) {
return 'warning';
}
if (start.isBefore(currentTime) && !hasFile) {
return 'danger';
}
return 'primary';
});
});