1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/Handlebars/Helpers/Episode.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict';
define(
[
'handlebars',
'Shared/FormatHelpers',
'moment'
], function (Handlebars, FormatHelpers, Moment) {
2013-07-17 03:41:04 +03:00
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));
}
});
2013-07-17 03:41:04 +03:00
Handlebars.registerHelper('StatusLevel', function () {
var hasFile = this.hasFile;
var currentTime = Moment();
2013-07-24 08:28:06 +03:00
var start = Moment(this.airDateUtc);
var end = Moment(this.end);
2013-07-17 03:41:04 +03:00
2013-07-29 05:30:01 +03:00
if (hasFile) {
return 'success';
}
if (currentTime.isAfter(start) && currentTime.isBefore(end)) {
2013-07-17 03:41:04 +03:00
return 'warning';
}
if (start.isBefore(currentTime) && !hasFile) {
return 'danger';
}
return 'primary';
});
});