parent
fb7988edb8
commit
a5fd28326e
@ -1,9 +1,7 @@
|
|||||||
var Handlebars = require('handlebars');
|
var Handlebars = require('handlebars');
|
||||||
|
|
||||||
module.exports = (function(){
|
Handlebars.registerHelper('debug', function() {
|
||||||
Handlebars.registerHelper('debug', function(){
|
console.group('Handlebar context');
|
||||||
console.group('Handlebar context');
|
console.log(this);
|
||||||
console.log(this);
|
console.groupEnd();
|
||||||
console.groupEnd();
|
});
|
||||||
});
|
|
||||||
}).call(this);
|
|
@ -1,17 +1,16 @@
|
|||||||
var Handlebars = require('handlebars');
|
var Handlebars = require('handlebars');
|
||||||
|
|
||||||
module.exports = (function(){
|
Handlebars.registerHelper('eachReverse', function(context) {
|
||||||
Handlebars.registerHelper('eachReverse', function(context){
|
var options = arguments[arguments.length - 1];
|
||||||
var options = arguments[arguments.length - 1];
|
var ret = '';
|
||||||
var ret = '';
|
|
||||||
if(context && context.length > 0) {
|
if (context && context.length > 0) {
|
||||||
for (var i = context.length - 1; i >= 0; i--) {
|
for (var i = context.length - 1; i >= 0; i--) {
|
||||||
ret += options.fn(context[i]);
|
ret += options.fn(context[i]);
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ret = options.inverse(this);
|
|
||||||
}
|
}
|
||||||
return ret;
|
} else {
|
||||||
});
|
ret = options.inverse(this);
|
||||||
}).call(this);
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
});
|
@ -1,18 +1,21 @@
|
|||||||
var Handlebars = require('handlebars');
|
var Handlebars = require('handlebars');
|
||||||
|
|
||||||
module.exports = (function(){
|
Handlebars.registerHelper('times', function(n, block) {
|
||||||
Handlebars.registerHelper('times', function(n, block){
|
var accum = '';
|
||||||
var accum = '';
|
|
||||||
for (var i = 0; i < n; ++i) {
|
for (var i = 0; i < n; ++i) {
|
||||||
accum += block.fn(i);
|
accum += block.fn(i);
|
||||||
}
|
}
|
||||||
return accum;
|
|
||||||
});
|
return accum;
|
||||||
Handlebars.registerHelper('for', function(from, to, incr, block){
|
});
|
||||||
var accum = '';
|
|
||||||
for (var i = from; i < to; i += incr) {
|
Handlebars.registerHelper('for', function(from, to, incr, block) {
|
||||||
accum += block.fn(i);
|
var accum = '';
|
||||||
}
|
|
||||||
return accum;
|
for (var i = from; i < to; i += incr) {
|
||||||
});
|
accum += block.fn(i);
|
||||||
}).call(this);
|
}
|
||||||
|
|
||||||
|
return accum;
|
||||||
|
});
|
@ -1,14 +1,14 @@
|
|||||||
var Handlebars = require('handlebars');
|
var Handlebars = require('handlebars');
|
||||||
var FormatHelpers = require('../../Shared/FormatHelpers');
|
var FormatHelpers = require('../../Shared/FormatHelpers');
|
||||||
|
|
||||||
module.exports = (function(){
|
Handlebars.registerHelper('Bytes', function(size) {
|
||||||
Handlebars.registerHelper('Bytes', function(size){
|
return new Handlebars.SafeString(FormatHelpers.bytes(size));
|
||||||
return new Handlebars.SafeString(FormatHelpers.bytes(size));
|
});
|
||||||
});
|
|
||||||
Handlebars.registerHelper('Pad2', function(input){
|
Handlebars.registerHelper('Pad2', function(input) {
|
||||||
return FormatHelpers.pad(input, 2);
|
return FormatHelpers.pad(input, 2);
|
||||||
});
|
});
|
||||||
Handlebars.registerHelper('Number', function(input){
|
|
||||||
return FormatHelpers.number(input);
|
Handlebars.registerHelper('Number', function(input) {
|
||||||
});
|
return FormatHelpers.number(input);
|
||||||
}).call(this);
|
});
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
var Handlebars = require('handlebars');
|
var Handlebars = require('handlebars');
|
||||||
var ProfileCollection = require('../../Profile/ProfileCollection');
|
var ProfileCollection = require('../../Profile/ProfileCollection');
|
||||||
|
|
||||||
module.exports = (function(){
|
Handlebars.registerHelper('profile', function(profileId) {
|
||||||
Handlebars.registerHelper('profile', function(profileId){
|
var profile = ProfileCollection.get(profileId);
|
||||||
var profile = ProfileCollection.get(profileId);
|
|
||||||
if(profile) {
|
if (profile) {
|
||||||
return new Handlebars.SafeString('<span class="label label-default profile-label">' + profile.get('name') + '</span>');
|
return new Handlebars.SafeString('<span class="label label-default profile-label">' + profile.get('name') + '</span>');
|
||||||
}
|
}
|
||||||
return undefined;
|
|
||||||
});
|
return undefined;
|
||||||
}).call(this);
|
});
|
@ -1,83 +1,79 @@
|
|||||||
'use strict';
|
var Handlebars = require('handlebars');
|
||||||
define(
|
var StatusModel = require('../../System/StatusModel');
|
||||||
[
|
var _ = require('underscore');
|
||||||
'handlebars',
|
|
||||||
'System/StatusModel',
|
Handlebars.registerHelper('poster', function() {
|
||||||
'underscore'
|
|
||||||
], function (Handlebars, StatusModel, _) {
|
var placeholder = StatusModel.get('urlBase') + '/Content/Images/poster-dark.png';
|
||||||
Handlebars.registerHelper('poster', function () {
|
var poster = _.where(this.images, { coverType : 'poster' });
|
||||||
|
|
||||||
var placeholder = StatusModel.get('urlBase') + '/Content/Images/poster-dark.png';
|
if (poster[0]) {
|
||||||
var poster = _.where(this.images, {coverType: 'poster'});
|
if (!poster[0].url.match(/^https?:\/\//)) {
|
||||||
|
return new Handlebars.SafeString('<img class="series-poster" {0}>'.format(Handlebars.helpers.defaultImg.call(null, poster[0].url, 250)));
|
||||||
if (poster[0]) {
|
} else {
|
||||||
if (!poster[0].url.match(/^https?:\/\//)) {
|
return new Handlebars.SafeString('<img class="series-poster" {0}>'.format(Handlebars.helpers.defaultImg.call(null, poster[0].url)));
|
||||||
return new Handlebars.SafeString('<img class="series-poster" {0}>'.format(Handlebars.helpers.defaultImg.call(null, poster[0].url, 250)));
|
}
|
||||||
} else {
|
}
|
||||||
return new Handlebars.SafeString('<img class="series-poster" {0}>'.format(Handlebars.helpers.defaultImg.call(null, poster[0].url)));
|
|
||||||
}
|
return new Handlebars.SafeString('<img class="series-poster placeholder-image" src="{0}">'.format(placeholder));
|
||||||
}
|
});
|
||||||
|
|
||||||
return new Handlebars.SafeString('<img class="series-poster placeholder-image" src="{0}">'.format(placeholder));
|
Handlebars.registerHelper('traktUrl', function() {
|
||||||
});
|
return 'http://trakt.tv/show/' + this.titleSlug;
|
||||||
|
});
|
||||||
Handlebars.registerHelper('traktUrl', function () {
|
|
||||||
return 'http://trakt.tv/show/' + this.titleSlug;
|
Handlebars.registerHelper('imdbUrl', function() {
|
||||||
});
|
return 'http://imdb.com/title/' + this.imdbId;
|
||||||
|
});
|
||||||
Handlebars.registerHelper('imdbUrl', function () {
|
|
||||||
return 'http://imdb.com/title/' + this.imdbId;
|
Handlebars.registerHelper('tvdbUrl', function() {
|
||||||
});
|
return 'http://www.thetvdb.com/?tab=series&id=' + this.tvdbId;
|
||||||
|
});
|
||||||
Handlebars.registerHelper('tvdbUrl', function () {
|
|
||||||
return 'http://www.thetvdb.com/?tab=series&id=' + this.tvdbId;
|
Handlebars.registerHelper('tvRageUrl', function() {
|
||||||
});
|
return 'http://www.tvrage.com/shows/id-' + this.tvRageId;
|
||||||
|
});
|
||||||
Handlebars.registerHelper('tvRageUrl', function () {
|
|
||||||
return 'http://www.tvrage.com/shows/id-' + this.tvRageId;
|
Handlebars.registerHelper('route', function() {
|
||||||
});
|
return StatusModel.get('urlBase') + '/series/' + this.titleSlug;
|
||||||
|
});
|
||||||
Handlebars.registerHelper('route', function () {
|
|
||||||
return StatusModel.get('urlBase') + '/series/' + this.titleSlug;
|
Handlebars.registerHelper('percentOfEpisodes', function() {
|
||||||
});
|
var episodeCount = this.episodeCount;
|
||||||
|
var episodeFileCount = this.episodeFileCount;
|
||||||
Handlebars.registerHelper('percentOfEpisodes', function () {
|
|
||||||
var episodeCount = this.episodeCount;
|
var percent = 100;
|
||||||
var episodeFileCount = this.episodeFileCount;
|
|
||||||
|
if (episodeCount > 0) {
|
||||||
var percent = 100;
|
percent = episodeFileCount / episodeCount * 100;
|
||||||
|
}
|
||||||
if (episodeCount > 0) {
|
|
||||||
percent = episodeFileCount / episodeCount * 100;
|
return percent;
|
||||||
}
|
});
|
||||||
|
|
||||||
return percent;
|
Handlebars.registerHelper('seasonCountHelper', function() {
|
||||||
});
|
var seasonCount = this.seasonCount;
|
||||||
|
var continuing = this.status === 'continuing';
|
||||||
Handlebars.registerHelper('seasonCountHelper', function () {
|
|
||||||
var seasonCount = this.seasonCount;
|
if (continuing) {
|
||||||
var continuing = this.status === 'continuing';
|
return new Handlebars.SafeString('<span class="label label-info">Season {0}</span>'.format(seasonCount));
|
||||||
|
}
|
||||||
if (continuing) {
|
|
||||||
return new Handlebars.SafeString('<span class="label label-info">Season {0}</span>'.format(seasonCount));
|
if (seasonCount === 1) {
|
||||||
}
|
return new Handlebars.SafeString('<span class="label label-info">{0} Season</span>'.format(seasonCount));
|
||||||
|
}
|
||||||
if (seasonCount === 1) {
|
|
||||||
return new Handlebars.SafeString('<span class="label label-info">{0} Season</span>'.format(seasonCount));
|
return new Handlebars.SafeString('<span class="label label-info">{0} Seasons</span>'.format(seasonCount));
|
||||||
}
|
});
|
||||||
|
|
||||||
return new Handlebars.SafeString('<span class="label label-info">{0} Seasons</span>'.format(seasonCount));
|
Handlebars.registerHelper('titleWithYear', function() {
|
||||||
});
|
if (this.title.endsWith(' ({0})'.format(this.year))) {
|
||||||
|
return this.title;
|
||||||
Handlebars.registerHelper('titleWithYear', function () {
|
}
|
||||||
if (this.title.endsWith(' ({0})'.format(this.year))) {
|
|
||||||
return this.title;
|
if (!this.year) {
|
||||||
}
|
return this.title;
|
||||||
|
}
|
||||||
if (!this.year) {
|
|
||||||
return this.title;
|
return new Handlebars.SafeString('{0} <span class="year">({1})</span>'.format(this.title, this.year));
|
||||||
}
|
});
|
||||||
|
|
||||||
return new Handlebars.SafeString('{0} <span class="year">({1})</span>'.format(this.title, this.year));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
var Handlebars = require('handlebars');
|
var Handlebars = require('handlebars');
|
||||||
|
|
||||||
module.exports = (function(){
|
Handlebars.registerHelper('TitleCase', function(input) {
|
||||||
Handlebars.registerHelper('TitleCase', function(input){
|
return new Handlebars.SafeString(input.replace(/\w\S*/g, function(txt) {
|
||||||
return new Handlebars.SafeString(input.replace(/\w\S*/g, function(txt){
|
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
}));
|
||||||
}));
|
});
|
||||||
});
|
|
||||||
}).call(this);
|
|
@ -1,17 +1,18 @@
|
|||||||
var Handlebars = require('handlebars');
|
var Handlebars = require('handlebars');
|
||||||
var StatusModel = require('../../System/StatusModel');
|
var StatusModel = require('../../System/StatusModel');
|
||||||
|
|
||||||
module.exports = (function(){
|
Handlebars.registerHelper('if_windows', function(options) {
|
||||||
Handlebars.registerHelper('if_windows', function(options){
|
if (StatusModel.get('isWindows')) {
|
||||||
if(StatusModel.get('isWindows')) {
|
return options.fn(this);
|
||||||
return options.fn(this);
|
}
|
||||||
}
|
|
||||||
return options.inverse(this);
|
return options.inverse(this);
|
||||||
});
|
});
|
||||||
Handlebars.registerHelper('if_mono', function(options){
|
|
||||||
if(StatusModel.get('isMono')) {
|
Handlebars.registerHelper('if_mono', function(options) {
|
||||||
return options.fn(this);
|
if (StatusModel.get('isMono')) {
|
||||||
}
|
return options.fn(this);
|
||||||
return options.inverse(this);
|
}
|
||||||
});
|
|
||||||
}).call(this);
|
return options.inverse(this);
|
||||||
|
});
|
Loading…
Reference in new issue