Addressing jshint warnings (#1050)

* Cleaning up some jsLiniting problems

* fix jshint issue with variablle declaration

This shouldn't be an issue because of hoisting but, jshint is finicky.
Bill Szeliga 8 years ago committed by Devin Buhl
parent 961a6d89a4
commit af2b5c2f1c

@ -79,7 +79,7 @@ var BulkImportCollection = PageableCollection.extend({
first : this.url, first : this.url,
next: this.url, next: this.url,
last : this.url last : this.url
} };
} }
}); });

@ -4,6 +4,7 @@ var _ = require('underscore');
var vent = require("vent"); var vent = require("vent");
var TemplatedCell = require('../../Cells/TemplatedCell'); var TemplatedCell = require('../../Cells/TemplatedCell');
var NzbDroneCell = require("../../Cells/NzbDroneCell"); var NzbDroneCell = require("../../Cells/NzbDroneCell");
var Marionette = require('marionette');
module.exports = TemplatedCell.extend({ module.exports = TemplatedCell.extend({
className : 'monitor-cell', className : 'monitor-cell',

@ -5,6 +5,7 @@ var _ = require('underscore');
var vent = require("vent"); var vent = require("vent");
var TemplatedCell = require('../../Cells/TemplatedCell'); var TemplatedCell = require('../../Cells/TemplatedCell');
var NzbDroneCell = require("../../Cells/NzbDroneCell"); var NzbDroneCell = require("../../Cells/NzbDroneCell");
var Marionette = require('marionette');
module.exports = TemplatedCell.extend({ module.exports = TemplatedCell.extend({
className : 'profile-cell', className : 'profile-cell',

@ -75,7 +75,7 @@ module.exports = Marionette.Layout.extend({
this.isExisting = options.isExisting; this.isExisting = options.isExisting;
//this.collection = new AddFromListCollection(); //this.collection = new AddFromListCollection();
this.templateHelpers = {} this.templateHelpers = {};
this.listCollection = new ListCollection(); this.listCollection = new ListCollection();
this.templateHelpers.lists = this.listCollection.toJSON(); this.templateHelpers.lists = this.listCollection.toJSON();
@ -155,7 +155,7 @@ module.exports = Marionette.Layout.extend({
if (rootFolderValue === 'addNew') { if (rootFolderValue === 'addNew') {
//var rootFolderLayout = new SchemaModal(this.listCollection); //var rootFolderLayout = new SchemaModal(this.listCollection);
//AppLayout.modalRegion.show(rootFolderLayout); //AppLayout.modalRegion.show(rootFolderLayout);
SchemaModal.open(this.listCollection) SchemaModal.open(this.listCollection);
} }
}, },
@ -165,7 +165,7 @@ module.exports = Marionette.Layout.extend({
this.fetchResult.show(new LoadingView()); this.fetchResult.show(new LoadingView());
this.currentFetchPromise = this.collection.fetch({ data: { listId: listId } }) this.currentFetchPromise = this.collection.fetch({ data: { listId: listId } });
this.currentFetchPromise.fail(function() { this.currentFetchPromise.fail(function() {
self._showError(); self._showError();
}); });

@ -14,7 +14,7 @@ var view = Marionette.ItemView.extend({
template : 'AddMovies/SearchResultViewTemplate', template : 'AddMovies/SearchResultViewTemplate',
}) });
AsValidatedView.apply(view); AsValidatedView.apply(view);

@ -175,7 +175,7 @@ module.exports = Marionette.ItemView.extend({
var downloading = QueueCollection.findMovie(element.get('id')) || element.get('grabbed'); var downloading = QueueCollection.findMovie(element.get('id')) || element.get('grabbed');
var currentTime = moment(); var currentTime = moment();
var start = moment(element.get('inCinemas')); var start = moment(element.get('inCinemas'));
var status = element.getStatus(); var status = element.getStatus().toLowerCase();
var end = moment(endTime); var end = moment(endTime);
var monitored = element.get('monitored'); var monitored = element.get('monitored');
@ -193,15 +193,15 @@ module.exports = Marionette.ItemView.extend({
statusLevel = 'unmonitored'; statusLevel = 'unmonitored';
} }
else if (status == "inCinemas") { else if (status === "incinemas") {
statusLevel = 'premiere'; statusLevel = 'premiere';
} }
else if (status == "released") { else if (status === "released") {
statusLevel = 'danger'; statusLevel = 'danger';
} }
else if (status == "announced") { else if (status === "announced") {
statusLevel = 'primary'; statusLevel = 'primary';
} }
@ -258,7 +258,7 @@ module.exports = Marionette.ItemView.extend({
options.titleFormat = "L"; options.titleFormat = "L";
options.columnFormat = "L"/*{ options.columnFormat = "L"; /*{
month : 'ddd', month : 'ddd',
week : UiSettings.get('calendarWeekColumnHeader'), week : UiSettings.get('calendarWeekColumnHeader'),
day : 'dddd' day : 'dddd'

@ -4,7 +4,6 @@ module.exports = TemplatedCell.extend({
className : 'movie-title-cell', className : 'movie-title-cell',
template : 'Cells/MovieDownloadStatusTemplate', template : 'Cells/MovieDownloadStatusTemplate',
sortKey : function(model) { sortKey : function(model) {
debugger;
return 0; return 0;
} }
}); });

@ -86,7 +86,7 @@ var singleton = function() {
} }
} }
}); });
console.warn(options) console.warn(options);
options.element.startSpin(); options.element.startSpin();
} }
}; };

@ -21,7 +21,7 @@ Handlebars.registerHelper('StatusLevel', function() {
var start = moment(this.airDateUtc); var start = moment(this.airDateUtc);
var end = moment(this.end); var end = moment(this.end);
var monitored = this.series.monitored && this.monitored; var monitored = this.series.monitored && this.monitored;
debugger;
if (hasFile) { if (hasFile) {
return 'success'; return 'success';
} }

@ -61,10 +61,10 @@ Handlebars.registerHelper('homepage', function() {
Handlebars.registerHelper('alternativeTitlesString', function() { Handlebars.registerHelper('alternativeTitlesString', function() {
var titles = this.alternativeTitles; var titles = this.alternativeTitles;
if (titles.length == 0) { if (titles.length === 0) {
return ""; return "";
} }
if (titles.length == 1) { if (titles.length === 1) {
return titles[0]; return titles[0];
} }
return titles.slice(0,titles.length-1).join(", ") + " and " + titles[titles.length-1]; return titles.slice(0,titles.length-1).join(", ") + " and " + titles[titles.length-1];
@ -95,7 +95,7 @@ Handlebars.registerHelper('GetStatus', function() {
else if (!monitored) { else if (!monitored) {
return new Handlebars.SafeString('<i class="icon-sonarr-series-unmonitored grid-icon" title=""></i>&nbsp;Not Monitored'); return new Handlebars.SafeString('<i class="icon-sonarr-series-unmonitored grid-icon" title=""></i>&nbsp;Not Monitored');
} }
}) });
Handlebars.registerHelper('GetBannerStatus', function() { Handlebars.registerHelper('GetBannerStatus', function() {
var monitored = this.monitored; var monitored = this.monitored;
@ -138,7 +138,7 @@ Handlebars.registerHelper('DownloadedStatusColor', function() {
} }
return "danger"; return "danger";
}) });
Handlebars.registerHelper('DownloadedStatus', function() { Handlebars.registerHelper('DownloadedStatus', function() {
@ -157,24 +157,26 @@ Handlebars.registerHelper("DownloadedQuality", function() {
} }
return ""; return "";
}) });
Handlebars.registerHelper('inCinemas', function() { Handlebars.registerHelper('inCinemas', function() {
var monthNames = ["January", "February", "March", "April", "May", "June", var monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" "July", "August", "September", "October", "November", "December"
]; ];
var year, month;
if (this.physicalRelease) { if (this.physicalRelease) {
var d = new Date(this.physicalRelease); var d = new Date(this.physicalRelease);
var day = d.getDate(); var day = d.getDate();
var month = monthNames[d.getMonth()]; month = monthNames[d.getMonth()];
var year = d.getFullYear(); year = d.getFullYear();
return "Available: " + day + ". " + month + " " + year; return "Available: " + day + ". " + month + " " + year;
} }
if (this.inCinemas) { if (this.inCinemas) {
var cinemasDate = new Date(this.inCinemas); var cinemasDate = new Date(this.inCinemas);
var year = cinemasDate.getFullYear(); year = cinemasDate.getFullYear();
var month = monthNames[cinemasDate.getMonth()]; month = monthNames[cinemasDate.getMonth()];
return "In Cinemas: " + month + " " + year; return "In Cinemas: " + month + " " + year;
} }
return "To be announced"; return "To be announced";

@ -4,6 +4,7 @@ var Config = require('../Config');
module.exports = function() { module.exports = function() {
var originalInit = this.prototype.initialize; var originalInit = this.prototype.initialize;
var _setInitialState, _storeStateFromBackgrid, _storeState, _convertDirectionToInt;
this.prototype.initialize = function(options) { this.prototype.initialize = function(options) {
options = options || {}; options = options || {};
@ -35,7 +36,7 @@ module.exports = function() {
}; };
} }
var _setInitialState = function() { _setInitialState = function() {
var key = Config.getValue('{0}.sortKey'.format(this.tableName), this.state.sortKey); var key = Config.getValue('{0}.sortKey'.format(this.tableName), this.state.sortKey);
var direction = Config.getValue('{0}.sortDirection'.format(this.tableName), this.state.order); var direction = Config.getValue('{0}.sortDirection'.format(this.tableName), this.state.order);
var order = parseInt(direction, 10); var order = parseInt(direction, 10);
@ -44,7 +45,7 @@ module.exports = function() {
this.state.order = order; this.state.order = order;
}; };
var _storeStateFromBackgrid = function(column, sortDirection) { _storeStateFromBackgrid = function(column, sortDirection) {
var order = _convertDirectionToInt(sortDirection); var order = _convertDirectionToInt(sortDirection);
var sortKey = this._getSortMapping(column.get('name')).sortKey; var sortKey = this._getSortMapping(column.get('name')).sortKey;
@ -52,7 +53,7 @@ module.exports = function() {
Config.setValue('{0}.sortDirection'.format(this.tableName), order); Config.setValue('{0}.sortDirection'.format(this.tableName), order);
}; };
var _storeState = function(sortModel, sortDirection) { _storeState = function(sortModel, sortDirection) {
var order = _convertDirectionToInt(sortDirection); var order = _convertDirectionToInt(sortDirection);
var sortKey = this._getSortMapping(sortModel.get('name')).sortKey; var sortKey = this._getSortMapping(sortModel.get('name')).sortKey;
@ -60,7 +61,7 @@ module.exports = function() {
Config.setValue('{0}.sortDirection'.format(this.tableName), order); Config.setValue('{0}.sortDirection'.format(this.tableName), order);
}; };
var _convertDirectionToInt = function(dir) { _convertDirectionToInt = function(dir) {
if (dir === 'ascending') { if (dir === 'ascending') {
return '-1'; return '-1';
} }

@ -89,7 +89,7 @@ module.exports = Marionette.Layout.extend({
this._setMonitoredState(); this._setMonitoredState();
this._showInfo(); this._showInfo();
if (this.model.get("movieFile")) { if (this.model.get("movieFile")) {
this._showFiles() this._showFiles();
} else { } else {
this._showHistory(); this._showHistory();
} }
@ -223,37 +223,6 @@ module.exports = Marionette.Layout.extend({
var self = this; var self = this;
return; return;
reqres.setHandler(reqres.Requests.GetEpisodeFileById, function(episodeFileId) {
return self.episodeFileCollection.get(episodeFileId);
});
reqres.setHandler(reqres.Requests.GetAlternateNameBySeasonNumber, function(moviesId, seasonNumber, sceneSeasonNumber) {
if (self.model.get('id') !== moviesId) {
return [];
}
if (sceneSeasonNumber === undefined) {
sceneSeasonNumber = seasonNumber;
}
return _.where(self.model.get('alternateTitles'),
function(alt) {
return alt.sceneSeasonNumber === sceneSeasonNumber || alt.seasonNumber === seasonNumber;
});
});
$.when(this.episodeCollection.fetch(), this.episodeFileCollection.fetch()).done(function() {
var seasonCollectionView = new SeasonCollectionView({
collection : self.seasonCollection,
episodeCollection : self.episodeCollection,
movies : self.model
});
if (!self.isClosed) {
self.seasons.show(seasonCollectionView);
}
});
}, },
_showInfo : function() { _showInfo : function() {
@ -311,7 +280,7 @@ module.exports = Marionette.Layout.extend({
_manualSearchM : function() { _manualSearchM : function() {
console.warn("Manual Search started"); console.warn("Manual Search started");
console.warn(this.model.id); console.warn(this.model.id);
console.warn(this.model) console.warn(this.model);
console.warn(this.episodeCollection); console.warn(this.episodeCollection);
vent.trigger(vent.Commands.ShowEpisodeDetails, { vent.trigger(vent.Commands.ShowEpisodeDetails, {
episode : this.model, episode : this.model,

@ -1,3 +1,4 @@
var _ = require('underscore');
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var Backgrid = require('backgrid'); var Backgrid = require('backgrid');
@ -82,6 +83,7 @@ module.exports = Marionette.Layout.extend({
}, },
initialize : function() { initialize : function() {
this.movieCollection = MoviesCollection.clone(); this.movieCollection = MoviesCollection.clone();
var pageSize = parseInt(Config.getValue("pageSize")) || 10; var pageSize = parseInt(Config.getValue("pageSize")) || 10;
this.movieCollection.switchMode('client', {fetch: false}); this.movieCollection.switchMode('client', {fetch: false});

@ -24,17 +24,17 @@ var view = Marionette.ItemView.extend({
this.qualities = new Qualities(); this.qualities = new Qualities();
var self = this; var self = this;
this.listenTo(this.qualities, 'all', this._qualitiesUpdated); this.listenTo(this.qualities, 'all', this._qualitiesUpdated);
this.qualities.fetch() this.qualities.fetch();
}, },
onRender : function() { onRender : function() {
this.ui.quality.val(this.model.get("quality").quality.id) this.ui.quality.val(this.model.get("quality").quality.id);
}, },
_onBeforeSave : function() { _onBeforeSave : function() {
var qualityId = this.ui.quality.val(); var qualityId = this.ui.quality.val();
var quality = this.qualities.find(function(m){return m.get("quality").id == qualityId}).get("quality"); var quality = this.qualities.find(function(m){return m.get("quality").id === qualityId;}).get("quality");
var mQuality = this.model.get("quality"); var mQuality = this.model.get("quality");
mQuality.quality = quality; mQuality.quality = quality;
this.model.set({ quality : mQuality }); this.model.set({ quality : mQuality });

@ -81,16 +81,12 @@ var Collection = PageableCollection.extend({
} }
}, },
sortMappings : {
'movie' : { sortKey : 'series.sortTitle' }
},
parseState : function(resp) { parseState : function(resp) {
if (this.mode === 'client') { if (this.mode === 'client') {
return {}; return {};
} }
var direction = -1; var direction = -1;
if (resp.sortDirection == "descending") { if (resp.sortDirection.toLowerCase() === "descending") {
direction = 1; direction = 1;
} }
return { totalRecords : resp.totalRecords, order : direction, currentPage : resp.page }; return { totalRecords : resp.totalRecords, order : direction, currentPage : resp.page };
@ -169,18 +165,21 @@ var Collection = PageableCollection.extend({
filterModes : filterModes, filterModes : filterModes,
sortMappings : { sortMappings : {
movie : {
sortKey : 'series.sortTitle'
},
title : { title : {
sortKey : 'sortTitle' sortKey : 'sortTitle'
}, },
statusWeight : { statusWeight : {
sortValue : function(model, attr) { sortValue : function(model, attr) {
if (model.getStatus() == "released") { if (model.getStatus().toLowerCase() === "released") {
return 3; return 3;
} }
if (model.getStatus() == "inCinemas") { if (model.getStatus().toLowerCase() === "incinemas") {
return 2; return 2;
} }
if (model.getStatus() == "announced") { if (model.getStatus().toLowerCase() === "announced") {
return 1; return 1;
} }
return -1; return -1;
@ -212,7 +211,6 @@ var Collection = PageableCollection.extend({
}, },
status: { status: {
sortValue : function(model, attr) { sortValue : function(model, attr) {
debugger;
if (model.get("downloaded")) { if (model.get("downloaded")) {
return -1; return -1;
} }

@ -261,7 +261,7 @@ module.exports = Marionette.Layout.extend({
_manualSearchM : function() { _manualSearchM : function() {
console.warn("Manual Search started"); console.warn("Manual Search started");
console.warn(this.model.get("seriesId")); console.warn(this.model.get("seriesId"));
console.warn(this.model) console.warn(this.model);
console.warn(this.episodeCollection); console.warn(this.episodeCollection);
vent.trigger(vent.Commands.ShowEpisodeDetails, { vent.trigger(vent.Commands.ShowEpisodeDetails, {
episode : this.episodeCollection.models[0], episode : this.episodeCollection.models[0],

@ -21,7 +21,7 @@ module.exports = NzbDroneController.extend({
}, },
seriesDetails : function(query) { seriesDetails : function(query) {
console.warn(AppLayout.mainRegion) console.warn(AppLayout.mainRegion);
var series = SeriesCollection.where({ titleSlug : query }); var series = SeriesCollection.where({ titleSlug : query });

@ -1,6 +1,7 @@
var _ = require('underscore'); var _ = require('underscore');
var $ = require('jquery'); var $ = require('jquery');
var vent = require('vent'); var vent = require('vent');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette'); var Marionette = require('marionette');
var DeleteView = require('../Delete/IndexerDeleteView'); var DeleteView = require('../Delete/IndexerDeleteView');
var Profiles = require('../../../Profile/ProfileCollection'); var Profiles = require('../../../Profile/ProfileCollection');
@ -55,7 +56,7 @@ var view = Marionette.ItemView.extend({
profileId : profile, profileId : profile,
rootFolderPath : rootFolderPath, rootFolderPath : rootFolderPath,
minimumAvailability : minAvail, minimumAvailability : minAvail,
}) });
}, },
_onAfterSave : function() { _onAfterSave : function() {
@ -95,7 +96,6 @@ var view = Marionette.ItemView.extend({
_rootFoldersUpdated : function() { _rootFoldersUpdated : function() {
this._configureTemplateHelpers(); this._configureTemplateHelpers();
debugger;
this.render(); this.render();
}, },

@ -31,13 +31,12 @@ module.exports = Marionette.CompositeView.extend({
} }
collection.setSorting(sortModel.get('name'), order); collection.setSorting(sortModel.get('name'), order);
if (collection.mode == "server"){ if (collection.mode.toLowerCase() === "server"){
collection.fetch({reset: true}); collection.fetch({reset: true});
} else { } else {
collection.fullCollection.sort(); collection.fullCollection.sort();
} }
return this; return this;
} }
}); });

Loading…
Cancel
Save