2013-07-10 04:57:21 +02:00
|
|
|
'use strict';
|
|
|
|
define(
|
|
|
|
[
|
|
|
|
'handlebars',
|
2013-07-17 08:23:44 +02:00
|
|
|
'Shared/FormatHelpers',
|
|
|
|
'moment'
|
|
|
|
], function (Handlebars, FormatHelpers, Moment) {
|
2013-07-17 02:41:04 +02:00
|
|
|
Handlebars.registerHelper('EpisodeNumber', function () {
|
2013-07-10 04:57:21 +02:00
|
|
|
|
|
|
|
if (this.series.seriesType === 'daily') {
|
2013-07-29 21:24:41 +02:00
|
|
|
return Moment(this.airDate).format('L');
|
2013-07-10 04:57:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
2013-07-17 08:41:40 +02:00
|
|
|
return '{0}x{1}'.format(this.seasonNumber, FormatHelpers.pad(this.episodeNumber, 2));
|
2013-07-10 04:57:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2013-07-17 02:41:04 +02:00
|
|
|
|
|
|
|
Handlebars.registerHelper('StatusLevel', function () {
|
|
|
|
|
|
|
|
var hasFile = this.hasFile;
|
2013-07-17 08:23:44 +02:00
|
|
|
var currentTime = Moment();
|
2013-07-24 07:28:06 +02:00
|
|
|
var start = Moment(this.airDateUtc);
|
2013-07-17 08:23:44 +02:00
|
|
|
var end = Moment(this.end);
|
2013-07-17 02:41:04 +02:00
|
|
|
|
2013-07-29 04:30:01 +02:00
|
|
|
if (hasFile) {
|
|
|
|
return 'success';
|
|
|
|
}
|
|
|
|
|
2013-07-17 08:23:44 +02:00
|
|
|
if (currentTime.isAfter(start) && currentTime.isBefore(end)) {
|
2013-07-17 02:41:04 +02:00
|
|
|
return 'warning';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start.isBefore(currentTime) && !hasFile) {
|
|
|
|
return 'danger';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'primary';
|
|
|
|
|
|
|
|
});
|
2013-07-10 04:57:21 +02:00
|
|
|
});
|