1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-28 02:27:13 +00:00
Lidarr/UI/Cells/EpisodeNumberCell.js

50 lines
1.5 KiB
JavaScript
Raw Normal View History

"use strict";
define(['app', 'Cells/NzbDroneCell'], function () {
NzbDrone.Cells.EpisodeNumberCell = NzbDrone.Cells.NzbDroneCell.extend({
className: "episode-number-cell",
render: function () {
2013-06-10 02:10:15 +00:00
this.$el.empty();
2013-06-10 02:10:15 +00:00
var airDateField = this.column.get('airDate') || 'airDate';
var seasonFiled = this.column.get('seasonNumber') || 'seasonNumber';
var episodeFiled = this.column.get('episodes') || 'episodeNumber';
2013-06-10 02:10:15 +00:00
if (this.cellValue) {
2013-06-10 02:10:15 +00:00
var airDate = this.cellValue.get(airDateField);
var seasonNumber = this.cellValue.get(seasonFiled);
var episodes = this.cellValue.get(episodeFiled);
2013-06-10 02:10:15 +00:00
var result = 'Unknown';
2013-06-10 02:10:15 +00:00
if (episodes) {
var paddedEpisodes;
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);
}
this.delegateEvents();
return this;
}
});
});