1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-29 03:05:49 +00:00
Sonarr/UI/Cells/EpisodeNumberCell.js

54 lines
1.7 KiB
JavaScript
Raw Normal View History

2013-06-22 06:24:24 +00:00
'use strict';
define(
[
'Cells/NzbDroneCell',
'Shared/FormatHelpers'
], function (NzbDroneCell, FormatHelpers) {
return NzbDroneCell.extend({
className: 'episode-number-cell',
render: function () {
this.$el.empty();
2013-07-24 05:28:06 +00:00
var airDateField = this.column.get('airDateUtc') || 'airDateUtc';
var seasonField = this.column.get('seasonNumber') || 'seasonNumber';
var episodeField = this.column.get('episodes') || 'episodeNumber';
2013-09-13 23:17:58 +00:00
if (this.model) {
2013-09-13 23:17:58 +00:00
var airDate = this.model.get(airDateField);
var seasonNumber = this.model.get(seasonField);
var episodes = this.model.get(episodeField);
var result = 'Unknown';
if (episodes) {
2013-06-10 02:10:15 +00:00
var paddedEpisodes;
if (episodes.constructor === Array) {
paddedEpisodes = _.map(episodes,function (episodeNumber) {
return FormatHelpers.pad(episodeNumber, 2);
}).join();
}
else {
paddedEpisodes = FormatHelpers.pad(episodes, 2);
}
result = '{0}x{1}'.format(seasonNumber, paddedEpisodes);
2013-06-10 02:10:15 +00:00
}
else if (airDate) {
result = new Date(airDate).toLocaleDateString();
2013-06-10 02:10:15 +00:00
}
this.$el.html(result);
2013-06-10 02:10:15 +00:00
}
this.delegateEvents();
return this;
2013-06-10 02:10:15 +00:00
}
});
});