2013-06-22 06:24:24 +00:00
|
|
|
'use strict';
|
2013-06-09 20:51:32 +00:00
|
|
|
|
|
|
|
define(['app', 'Cells/NzbDroneCell'], function () {
|
|
|
|
NzbDrone.Cells.EpisodeNumberCell = NzbDrone.Cells.NzbDroneCell.extend({
|
|
|
|
|
2013-06-22 06:24:24 +00:00
|
|
|
className: 'episode-number-cell',
|
2013-06-09 20:51:32 +00:00
|
|
|
|
|
|
|
render: function () {
|
|
|
|
|
2013-06-10 02:10:15 +00:00
|
|
|
this.$el.empty();
|
2013-06-09 20:51:32 +00:00
|
|
|
|
2013-06-10 02:10:15 +00:00
|
|
|
var airDateField = this.column.get('airDate') || 'airDate';
|
2013-06-10 05:27:20 +00:00
|
|
|
var seasonField = this.column.get('seasonNumber') || 'seasonNumber';
|
|
|
|
var episodeField = this.column.get('episodes') || 'episodeNumber';
|
2013-06-09 20:51:32 +00:00
|
|
|
|
2013-06-10 02:10:15 +00:00
|
|
|
if (this.cellValue) {
|
2013-06-09 20:51:32 +00:00
|
|
|
|
2013-06-10 02:10:15 +00:00
|
|
|
var airDate = this.cellValue.get(airDateField);
|
2013-06-10 05:27:20 +00:00
|
|
|
var seasonNumber = this.cellValue.get(seasonField);
|
|
|
|
var episodes = this.cellValue.get(episodeField);
|
2013-06-09 20:51:32 +00:00
|
|
|
|
2013-06-10 02:10:15 +00:00
|
|
|
var result = 'Unknown';
|
2013-06-09 20:51:32 +00:00
|
|
|
|
2013-06-10 02:10:15 +00:00
|
|
|
if (episodes) {
|
|
|
|
|
|
|
|
var paddedEpisodes;
|
2013-06-09 20:51:32 +00:00
|
|
|
|
2013-06-10 02:10:15 +00:00
|
|
|
if (episodes.constructor === Array) {
|
|
|
|
paddedEpisodes = _.map(episodes,function (episodeNumber) {
|
|
|
|
return episodeNumber.pad(2);
|
|
|
|
}).join();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
paddedEpisodes = episodes.pad(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = 'S{0}-E{1}'.format(seasonNumber.pad(2), paddedEpisodes);
|
|
|
|
}
|
|
|
|
else if (airDate) {
|
|
|
|
result = new Date(airDate).toLocaleDateString();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$el.html(result);
|
|
|
|
}
|
2013-06-09 20:51:32 +00:00
|
|
|
this.delegateEvents();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|