1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-29 11:05:44 +00:00
Lidarr/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 00:41:04 +00:00
Handlebars.registerHelper('EpisodeNumber', function () {
if (this.series.seriesType === 'daily') {
return FormatHelpers.DateHelper(this.airDate);
}
else {
return '{0}x{1}'.format(this.seasonNumber, FormatHelpers.pad(this.episodeNumber, 2));
}
});
2013-07-17 00:41:04 +00:00
Handlebars.registerHelper('StatusLevel', function () {
var hasFile = this.hasFile;
var currentTime = Moment();
var start = Moment(this.airDate);
var end = Moment(this.end);
2013-07-17 00:41:04 +00:00
if (currentTime.isAfter(start) && currentTime.isBefore(end)) {
2013-07-17 00:41:04 +00:00
return 'warning';
}
if (start.isBefore(currentTime) && !hasFile) {
return 'danger';
}
if (hasFile) {
return 'success';
}
return 'primary';
});
});