diff --git a/UI/Calendar/CalendarView.js b/UI/Calendar/CalendarView.js
index 91976be28..6ba4f40cc 100644
--- a/UI/Calendar/CalendarView.js
+++ b/UI/Calendar/CalendarView.js
@@ -60,12 +60,14 @@ define(
var episodeTitle = element.get('title');
var seriesTitle = element.get('series').get('title');
var start = element.get('airDate');
+ var statusLevel = _instance.getStatusLevel(element);
element.set({
- 'title': seriesTitle,
+ title : seriesTitle,
episodeTitle: episodeTitle,
- start: start,
- allDay: false
+ start : start,
+ allDay : false,
+ statusLevel : statusLevel
});
element.set('model', element);
@@ -74,6 +76,27 @@ define(
callback(calendarCollection.toJSON());
}
});
+ },
+
+ getStatusLevel: function (element) {
+ var hasFile = element.get('hasFile');
+ var currentTime = Date.create();
+ var start = Date.create(element.get('airDate'));
+ var end = Date.create(element.get('end'));
+
+ if (currentTime.isBetween(start, end)) {
+ return 'warning';
+ }
+
+ if (start.isBefore(currentTime) && !hasFile) {
+ return 'danger';
+ }
+
+ if (hasFile) {
+ return 'success';
+ }
+
+ return 'primary';
}
});
});
diff --git a/UI/Calendar/UpcomingItemTemplate.html b/UI/Calendar/UpcomingItemTemplate.html
index af9fd5854..f8b4a8ee9 100644
--- a/UI/Calendar/UpcomingItemTemplate.html
+++ b/UI/Calendar/UpcomingItemTemplate.html
@@ -1,11 +1,11 @@
-
-
{{day}}
-
{{month}}
+
+
{{Day airDate}}
+ {{Month airDate}}
{{series.title}}
-
{{startTime}} {{ShortDate airDate}}{{seasonNumber}}x{{paddedEpisodeNumber}}
{{episodeTitle}}
+
{{StartTime airDate}} {{ShortDate airDate}}{{seasonNumber}}x{{Pad2 episodeNumber}}
{{episodeTitle}}
{{title}}
diff --git a/UI/Episode/LayoutTemplate.html b/UI/Episode/LayoutTemplate.html
index 35048ed7a..7cbe5ba2b 100644
--- a/UI/Episode/LayoutTemplate.html
+++ b/UI/Episode/LayoutTemplate.html
@@ -3,9 +3,9 @@
{{#if episodeTitle}}
-
{{episodeTitle}} - {{episodeNumberHelper}}
+
{{episodeTitle}} - {{EpisodeNumber}}
{{else}}
-
{{title}} - {{episodeNumberHelper}}
+
{{title}} - {{EpisodeNumber}}
{{/if}}
diff --git a/UI/Handlebars/Helpers/DateTime.js b/UI/Handlebars/Helpers/DateTime.js
index fb1e972e0..6a4513329 100644
--- a/UI/Handlebars/Helpers/DateTime.js
+++ b/UI/Handlebars/Helpers/DateTime.js
@@ -14,4 +14,33 @@ define(
return new Handlebars.SafeString(result);
});
+
+ Handlebars.registerHelper('Day', function (input) {
+ if (!input) {
+ return '';
+ }
+
+ return Date.create(input).format('{dd}');
+ });
+
+ Handlebars.registerHelper('Month', function (input) {
+ if (!input) {
+ return '';
+ }
+
+ return Date.create(input).format('{Mon}');
+ });
+
+ Handlebars.registerHelper('StartTime', function (input) {
+ if (!input) {
+ return '';
+ }
+
+ var date = Date.create(input);
+ if (date.format('{mm}') === '00') {
+ return date.format('{h}{tt}');
+ }
+
+ return date.format('{h}.{mm}{tt}');
+ });
});
diff --git a/UI/Handlebars/Helpers/Episode.js b/UI/Handlebars/Helpers/Episode.js
index 97b0469de..662368c41 100644
--- a/UI/Handlebars/Helpers/Episode.js
+++ b/UI/Handlebars/Helpers/Episode.js
@@ -4,15 +4,38 @@ define(
'handlebars',
'Shared/FormatHelpers'
], function (Handlebars, FormatHelpers) {
- Handlebars.registerHelper('episodeNumberHelper', function () {
+ Handlebars.registerHelper('EpisodeNumber', function () {
if (this.series.seriesType === 'daily') {
return FormatHelpers.DateHelper(this.airDate);
}
else {
- return '{0}x{1}'.format(this.seasonNumber, this.paddedEpisodeNumber);
+ return '{0}x{1}'.format(this.seasonNumber, this.episodeNumber.pad(2));
}
});
+
+ 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';
+
+ });
});
diff --git a/UI/Handlebars/Helpers/Numbers.js b/UI/Handlebars/Helpers/Numbers.js
index 60cd2382e..45ea021bf 100644
--- a/UI/Handlebars/Helpers/Numbers.js
+++ b/UI/Handlebars/Helpers/Numbers.js
@@ -7,4 +7,8 @@ define(
Handlebars.registerHelper('Bytes', function (size) {
return new Handlebars.SafeString(FormatHelpers.Bytes(size));
});
+
+ Handlebars.registerHelper('Pad2', function (input) {
+ return input.pad(2);
+ });
});
diff --git a/UI/Handlebars/Helpers/Quality.js b/UI/Handlebars/Helpers/Quality.js
index 6c13398a3..c4a1399d5 100644
--- a/UI/Handlebars/Helpers/Quality.js
+++ b/UI/Handlebars/Helpers/Quality.js
@@ -11,7 +11,7 @@ define(
var profile = QualityProfileCollection.get(profileId);
if (profile) {
- return new Handlebars.SafeString('' + profile.get("name") + '');
+ return new Handlebars.SafeString('' + profile.get("name") + '');
}
return undefined;
diff --git a/UI/Series/EpisodeModel.js b/UI/Series/EpisodeModel.js
index eb486af9a..8be349b4d 100644
--- a/UI/Series/EpisodeModel.js
+++ b/UI/Series/EpisodeModel.js
@@ -6,59 +6,15 @@ define(
], function (Backbone, SeriesModel) {
return Backbone.Model.extend({
- mutators: {
- paddedEpisodeNumber: function () {
- return this.get('episodeNumber').pad(2);
- },
- day : function () {
- return Date.create(this.get('airDate')).format('{dd}');
- },
- month : function () {
- return Date.create(this.get('airDate')).format('{Mon}');
- },
- startTime : function () {
- var start = Date.create(this.get('airDate'));
-
- if (start.format('{mm}') === '00') {
- return start.format('{h}{tt}');
- }
-
- return start.format('{h}.{mm}{tt}');
- },
- end : function () {
-
- if (this.has('series')) {
- var start = Date.create(this.get('airDate'));
- var runtime = this.get('series').get('runtime');
-
- return start.addMinutes(runtime);
- }
-
- return undefined;
- },
- statusLevel : function () {
- var hasFile = this.get('hasFile');
- var currentTime = Date.create();
+ initialize: function () {
+ if (this.has('series')) {
var start = Date.create(this.get('airDate'));
- var end = Date.create(this.get('end'));
-
- if (currentTime.isBetween(start, end)) {
- return 'warning';
- }
-
- if (start.isBefore(currentTime) && !hasFile) {
- return 'danger';
- }
+ var runtime = this.get('series').get('runtime');
- if (hasFile) {
- return 'success';
- }
-
- return 'primary';
+ this.set('end', start.addMinutes(runtime));
}
},
-
parse: function (model) {
model.series = new SeriesModel(model.series);
@@ -68,16 +24,6 @@ define(
toJSON: function () {
var json = _.clone(this.attributes);
- _.each(this.mutators, _.bind(function (mutator, name) {
- // check if we have some getter mutations
- if (_.isObject(this.mutators[name]) === true && _.isFunction(this.mutators[name].get)) {
- json[name] = _.bind(this.mutators[name].get, this)();
- }
- else {
- json[name] = _.bind(this.mutators[name], this)();
- }
- }, this));
-
if (this.has('series')) {
json.series = this.get('series').toJSON();
}