1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/Series/SeriesModel.js

88 lines
2.5 KiB
JavaScript
Raw Normal View History

2013-06-22 09:24:24 +03:00
'use strict';
2013-06-09 01:23:17 +03:00
define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfiles) {
NzbDrone.Series.SeriesModel = Backbone.Model.extend({
2013-02-13 09:32:17 +03:00
urlRoot: NzbDrone.Constants.ApiRoot + '/series',
mutators: {
percentOfEpisodes: function () {
var episodeCount = this.get('episodeCount');
var episodeFileCount = this.get('episodeFileCount');
2013-02-13 09:32:17 +03:00
var percent = 100;
2013-02-13 09:32:17 +03:00
if (episodeCount > 0) {
percent = episodeFileCount / episodeCount * 100;
}
return percent;
2013-04-01 00:45:16 +03:00
},
2013-04-04 07:38:51 +03:00
poster : function () {
var poster = _.find(this.get('images'), function (image) {
return image.coverType === 'poster';
});
if (poster) {
return poster.url;
}
return undefined;
2013-04-04 07:38:51 +03:00
},
2013-04-23 05:07:21 +03:00
fanArt : function () {
var poster = _.find(this.get('images'), function (image) {
2013-06-14 03:39:53 +03:00
return image.coverType === 'fanart';
});
if (poster) {
return poster.url;
}
return undefined;
2013-04-23 05:07:21 +03:00
},
2013-04-01 00:45:16 +03:00
traktUrl : function () {
2013-06-22 09:24:24 +03:00
return 'http://trakt.tv/show/' + this.get('titleSlug');
},
2013-06-09 01:23:17 +03:00
imdbUrl : function () {
2013-06-22 09:24:24 +03:00
return 'http://imdb.com/title/' + this.get('imdbId');
},
isContinuing : function () {
return this.get('status') === 'continuing';
},
shortDate : function () {
var date = this.get('nextAiring');
if (!date) {
return '';
}
return Date.create(date).short();
},
2013-06-09 01:23:17 +03:00
route : function () {
return '/series/details/' + this.get('titleSlug');
2013-06-09 01:23:17 +03:00
//return '/series/details/' + this.get('id');
},
qualityProfile: function () {
var profile = qualityProfiles.get(this.get('qualityProfileId'));
if (profile) {
return profile.toJSON();
}
return undefined;
}
},
2013-02-13 09:32:17 +03:00
defaults: {
episodeFileCount: 0,
episodeCount : 0,
2013-04-22 04:21:24 +03:00
isExisting : false,
2013-04-23 05:07:21 +03:00
status : 0
2013-02-13 09:32:17 +03:00
}
});
2013-02-13 09:32:17 +03:00
return NzbDrone.Series.SeriesModel;
});