1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-23 02:05:27 +02:00
Sonarr/UI/Series/SeriesModel.js

78 lines
2.5 KiB
JavaScript
Raw Normal View History

2013-06-25 07:51:17 +03:00
'use strict';
define(
[
'backbone',
2013-07-04 03:57:55 +03:00
'Quality/QualityProfileCollection',
'underscore'
], function (Backbone, QualityProfileCollection,_) {
return Backbone.Model.extend({
2013-06-25 08:12:42 +03:00
urlRoot: ApiRoot + '/series',
mutators: {
percentOfEpisodes: function () {
var episodeCount = this.get('episodeCount');
var episodeFileCount = this.get('episodeFileCount');
var percent = 100;
if (episodeCount > 0) {
percent = episodeFileCount / episodeCount * 100;
}
return percent;
},
poster : function () {
var poster = _.find(this.get('images'), function (image) {
return image.coverType === 'poster';
});
if (poster) {
return poster.url;
}
return undefined;
},
fanArt : function () {
var poster = _.find(this.get('images'), function (image) {
return image.coverType === 'fanart';
});
if (poster) {
return poster.url;
}
return undefined;
},
traktUrl : function () {
return 'http://trakt.tv/show/' + this.get('titleSlug');
},
imdbUrl : function () {
return 'http://imdb.com/title/' + this.get('imdbId');
},
isContinuing : function () {
return this.get('status') === 'continuing';
},
route : function () {
2013-06-26 04:00:56 +03:00
return '/series/' + this.get('titleSlug');
},
qualityProfile: function () {
var profile = QualityProfileCollection.get(this.get('qualityProfileId'));
if (profile) {
return profile.toJSON();
}
return undefined;
}
2013-04-04 07:38:51 +03:00
},
defaults: {
episodeFileCount: 0,
episodeCount : 0,
isExisting : false,
status : 0
}
});
});