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

42 lines
1.0 KiB
JavaScript
Raw Normal View History

'use strict';
define(
[
'handlebars',
'Shared/FormatHelpers'
], function (Handlebars, FormatHelpers) {
2013-07-17 03:41:04 +03:00
Handlebars.registerHelper('EpisodeNumber', function () {
if (this.series.seriesType === 'daily') {
return FormatHelpers.DateHelper(this.airDate);
}
else {
2013-07-17 03:41:04 +03:00
return '{0}x{1}'.format(this.seasonNumber, this.episodeNumber.pad(2));
}
});
2013-07-17 03:41:04 +03:00
Handlebars.registerHelper('StatusLevel', function () {
var hasFile = this.hasFile;
var currentTime = Date.create();
var start = Date.create(this.airDate);
var end = Date.create(this.end);
if (currentTime.isBetween(start, end)) {
return 'warning';
}
if (start.isBefore(currentTime) && !hasFile) {
return 'danger';
}
if (hasFile) {
return 'success';
}
return 'primary';
});
});