2013-07-10 02:57:21 +00:00
|
|
|
'use strict';
|
|
|
|
define(
|
|
|
|
[
|
|
|
|
'handlebars',
|
2013-07-17 06:23:44 +00:00
|
|
|
'Shared/FormatHelpers',
|
|
|
|
'moment'
|
|
|
|
], function (Handlebars, FormatHelpers, Moment) {
|
2013-07-17 00:41:04 +00:00
|
|
|
Handlebars.registerHelper('EpisodeNumber', function () {
|
2013-07-10 02:57:21 +00:00
|
|
|
|
|
|
|
if (this.series.seriesType === 'daily') {
|
2013-07-24 05:28:06 +00:00
|
|
|
return Moment(this.airDateUtc).format('L');
|
2013-07-10 02:57:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
2013-07-17 06:41:40 +00:00
|
|
|
return '{0}x{1}'.format(this.seasonNumber, FormatHelpers.pad(this.episodeNumber, 2));
|
2013-07-10 02:57:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2013-07-17 00:41:04 +00:00
|
|
|
|
|
|
|
Handlebars.registerHelper('StatusLevel', function () {
|
|
|
|
|
|
|
|
var hasFile = this.hasFile;
|
2013-07-17 06:23:44 +00:00
|
|
|
var currentTime = Moment();
|
2013-07-24 05:28:06 +00:00
|
|
|
var start = Moment(this.airDateUtc);
|
2013-07-17 06:23:44 +00:00
|
|
|
var end = Moment(this.end);
|
2013-07-17 00:41:04 +00:00
|
|
|
|
2013-07-17 06:23:44 +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';
|
|
|
|
|
|
|
|
});
|
2013-07-10 02:57:21 +00:00
|
|
|
});
|