1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-01 00:12:30 +01:00
Sonarr/UI/Handlebars/Helpers/Series.js
2013-07-16 16:55:20 -07:00

45 lines
1.1 KiB
JavaScript

'use strict';
define(
[
'handlebars',
'underscore'
], function (Handlebars, _) {
Handlebars.registerHelper('poster', function () {
var poster = _.where(this.images, {coverType: 'poster'});
if (poster[0]) {
return poster[0].url;
}
return undefined;
});
Handlebars.registerHelper('traktUrl', function () {
return 'http://trakt.tv/show/' + this.titleSlug;
});
Handlebars.registerHelper('imdbUrl', function () {
return 'http://imdb.com/title/' + this.imdbId;
});
Handlebars.registerHelper('route', function () {
return '/series/' + this.titleSlug;
});
Handlebars.registerHelper('percentOfEpisodes', function () {
var episodeCount = this.episodeCount;
var episodeFileCount = this.episodeFileCount;
var percent = 100;
if (episodeCount > 0) {
percent = episodeFileCount / episodeCount * 100;
}
return percent;
});
});