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-19 04:32:52 +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();
|
|
|
|
var start = Moment(this.airDate);
|
|
|
|
var end = Moment(this.end);
|
2013-07-17 02:41:04 +02:00
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasFile) {
|
|
|
|
return 'success';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'primary';
|
|
|
|
|
|
|
|
});
|
2013-07-10 04:57:21 +02:00
|
|
|
});
|