From af2b5c2f1ca2491ec8513d6d40782b0079b89d24 Mon Sep 17 00:00:00 2001 From: Bill Szeliga Date: Tue, 7 Mar 2017 22:04:25 -0500 Subject: [PATCH] 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. --- .../BulkImport/BulkImportCollection.js | 2 +- .../BulkImport/BulkImportMonitorCell.js | 1 + .../BulkImport/BulkImportProfileCellT.js | 1 + src/UI/AddMovies/List/AddFromListView.js | 6 ++-- src/UI/AddMovies/List/ListItemView.js | 2 +- src/UI/Calendar/CalendarView.js | 10 +++--- src/UI/Cells/MovieDownloadStatusCell.js | 1 - src/UI/Commands/CommandController.js | 2 +- src/UI/Handlebars/Helpers/Episode.js | 2 +- src/UI/Handlebars/Helpers/Series.js | 24 +++++++------ src/UI/Mixins/AsPersistedStateCollection.js | 9 ++--- src/UI/Movies/Details/MoviesDetailsLayout.js | 35 ++----------------- src/UI/Movies/Editor/MovieEditorLayout.js | 12 ++++--- src/UI/Movies/Files/Edit/EditFileView.js | 6 ++-- src/UI/Movies/MoviesCollection.js | 18 +++++----- src/UI/Series/Details/SeriesDetailsLayout.js | 2 +- src/UI/Series/SeriesController.js | 10 +++--- .../NetImport/Edit/NetImportEditView.js | 4 +-- .../Sorting/SortingButtonCollectionView.js | 3 +- 19 files changed, 61 insertions(+), 89 deletions(-) diff --git a/src/UI/AddMovies/BulkImport/BulkImportCollection.js b/src/UI/AddMovies/BulkImport/BulkImportCollection.js index 58ee9c86c..37a9f63af 100644 --- a/src/UI/AddMovies/BulkImport/BulkImportCollection.js +++ b/src/UI/AddMovies/BulkImport/BulkImportCollection.js @@ -79,7 +79,7 @@ var BulkImportCollection = PageableCollection.extend({ first : this.url, next: this.url, last : this.url - } + }; } }); diff --git a/src/UI/AddMovies/BulkImport/BulkImportMonitorCell.js b/src/UI/AddMovies/BulkImport/BulkImportMonitorCell.js index 88d599ad6..90276ef39 100644 --- a/src/UI/AddMovies/BulkImport/BulkImportMonitorCell.js +++ b/src/UI/AddMovies/BulkImport/BulkImportMonitorCell.js @@ -4,6 +4,7 @@ var _ = require('underscore'); var vent = require("vent"); var TemplatedCell = require('../../Cells/TemplatedCell'); var NzbDroneCell = require("../../Cells/NzbDroneCell"); +var Marionette = require('marionette'); module.exports = TemplatedCell.extend({ className : 'monitor-cell', diff --git a/src/UI/AddMovies/BulkImport/BulkImportProfileCellT.js b/src/UI/AddMovies/BulkImport/BulkImportProfileCellT.js index 249a475fd..89725c6c8 100644 --- a/src/UI/AddMovies/BulkImport/BulkImportProfileCellT.js +++ b/src/UI/AddMovies/BulkImport/BulkImportProfileCellT.js @@ -5,6 +5,7 @@ var _ = require('underscore'); var vent = require("vent"); var TemplatedCell = require('../../Cells/TemplatedCell'); var NzbDroneCell = require("../../Cells/NzbDroneCell"); +var Marionette = require('marionette'); module.exports = TemplatedCell.extend({ className : 'profile-cell', diff --git a/src/UI/AddMovies/List/AddFromListView.js b/src/UI/AddMovies/List/AddFromListView.js index 9696e4ee3..35790da65 100644 --- a/src/UI/AddMovies/List/AddFromListView.js +++ b/src/UI/AddMovies/List/AddFromListView.js @@ -75,7 +75,7 @@ module.exports = Marionette.Layout.extend({ this.isExisting = options.isExisting; //this.collection = new AddFromListCollection(); - this.templateHelpers = {} + this.templateHelpers = {}; this.listCollection = new ListCollection(); this.templateHelpers.lists = this.listCollection.toJSON(); @@ -155,7 +155,7 @@ module.exports = Marionette.Layout.extend({ if (rootFolderValue === 'addNew') { //var rootFolderLayout = new SchemaModal(this.listCollection); //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.currentFetchPromise = this.collection.fetch({ data: { listId: listId } }) + this.currentFetchPromise = this.collection.fetch({ data: { listId: listId } }); this.currentFetchPromise.fail(function() { self._showError(); }); diff --git a/src/UI/AddMovies/List/ListItemView.js b/src/UI/AddMovies/List/ListItemView.js index f93b2778e..f99dbb7e5 100644 --- a/src/UI/AddMovies/List/ListItemView.js +++ b/src/UI/AddMovies/List/ListItemView.js @@ -14,7 +14,7 @@ var view = Marionette.ItemView.extend({ template : 'AddMovies/SearchResultViewTemplate', -}) +}); AsValidatedView.apply(view); diff --git a/src/UI/Calendar/CalendarView.js b/src/UI/Calendar/CalendarView.js index 08001a132..d2f482aa7 100644 --- a/src/UI/Calendar/CalendarView.js +++ b/src/UI/Calendar/CalendarView.js @@ -175,7 +175,7 @@ module.exports = Marionette.ItemView.extend({ var downloading = QueueCollection.findMovie(element.get('id')) || element.get('grabbed'); var currentTime = moment(); var start = moment(element.get('inCinemas')); - var status = element.getStatus(); + var status = element.getStatus().toLowerCase(); var end = moment(endTime); var monitored = element.get('monitored'); @@ -193,15 +193,15 @@ module.exports = Marionette.ItemView.extend({ statusLevel = 'unmonitored'; } - else if (status == "inCinemas") { + else if (status === "incinemas") { statusLevel = 'premiere'; } - else if (status == "released") { + else if (status === "released") { statusLevel = 'danger'; } - else if (status == "announced") { + else if (status === "announced") { statusLevel = 'primary'; } @@ -258,7 +258,7 @@ module.exports = Marionette.ItemView.extend({ options.titleFormat = "L"; - options.columnFormat = "L"/*{ + options.columnFormat = "L"; /*{ month : 'ddd', week : UiSettings.get('calendarWeekColumnHeader'), day : 'dddd' diff --git a/src/UI/Cells/MovieDownloadStatusCell.js b/src/UI/Cells/MovieDownloadStatusCell.js index 7cb154374..3ab046c0c 100644 --- a/src/UI/Cells/MovieDownloadStatusCell.js +++ b/src/UI/Cells/MovieDownloadStatusCell.js @@ -4,7 +4,6 @@ module.exports = TemplatedCell.extend({ className : 'movie-title-cell', template : 'Cells/MovieDownloadStatusTemplate', sortKey : function(model) { - debugger; return 0; } }); diff --git a/src/UI/Commands/CommandController.js b/src/UI/Commands/CommandController.js index 929870107..8ca7157da 100644 --- a/src/UI/Commands/CommandController.js +++ b/src/UI/Commands/CommandController.js @@ -86,7 +86,7 @@ var singleton = function() { } } }); - console.warn(options) + console.warn(options); options.element.startSpin(); } }; diff --git a/src/UI/Handlebars/Helpers/Episode.js b/src/UI/Handlebars/Helpers/Episode.js index a39e72984..3db6cfcc4 100644 --- a/src/UI/Handlebars/Helpers/Episode.js +++ b/src/UI/Handlebars/Helpers/Episode.js @@ -21,7 +21,7 @@ Handlebars.registerHelper('StatusLevel', function() { var start = moment(this.airDateUtc); var end = moment(this.end); var monitored = this.series.monitored && this.monitored; - debugger; + if (hasFile) { return 'success'; } diff --git a/src/UI/Handlebars/Helpers/Series.js b/src/UI/Handlebars/Helpers/Series.js index 0df810e74..2fe7e61d3 100644 --- a/src/UI/Handlebars/Helpers/Series.js +++ b/src/UI/Handlebars/Helpers/Series.js @@ -61,10 +61,10 @@ Handlebars.registerHelper('homepage', function() { Handlebars.registerHelper('alternativeTitlesString', function() { var titles = this.alternativeTitles; - if (titles.length == 0) { + if (titles.length === 0) { return ""; } - if (titles.length == 1) { + if (titles.length === 1) { return titles[0]; } return titles.slice(0,titles.length-1).join(", ") + " and " + titles[titles.length-1]; @@ -82,12 +82,12 @@ Handlebars.registerHelper('GetStatus', function() { if (status === "announced") { return new Handlebars.SafeString(' Announced'); } - + if (status ==="inCinemas") { return new Handlebars.SafeString(' In Cinemas'); } - + if (status === 'released') { return new Handlebars.SafeString(' Released'); } @@ -95,7 +95,7 @@ Handlebars.registerHelper('GetStatus', function() { else if (!monitored) { return new Handlebars.SafeString(' Not Monitored'); } -}) +}); Handlebars.registerHelper('GetBannerStatus', function() { var monitored = this.monitored; @@ -138,7 +138,7 @@ Handlebars.registerHelper('DownloadedStatusColor', function() { } return "danger"; -}) +}); Handlebars.registerHelper('DownloadedStatus', function() { @@ -157,24 +157,26 @@ Handlebars.registerHelper("DownloadedQuality", function() { } return ""; -}) +}); Handlebars.registerHelper('inCinemas', function() { var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; + var year, month; + if (this.physicalRelease) { var d = new Date(this.physicalRelease); var day = d.getDate(); - var month = monthNames[d.getMonth()]; - var year = d.getFullYear(); + month = monthNames[d.getMonth()]; + year = d.getFullYear(); return "Available: " + day + ". " + month + " " + year; } if (this.inCinemas) { var cinemasDate = new Date(this.inCinemas); - var year = cinemasDate.getFullYear(); - var month = monthNames[cinemasDate.getMonth()]; + year = cinemasDate.getFullYear(); + month = monthNames[cinemasDate.getMonth()]; return "In Cinemas: " + month + " " + year; } return "To be announced"; diff --git a/src/UI/Mixins/AsPersistedStateCollection.js b/src/UI/Mixins/AsPersistedStateCollection.js index cecdeb2d8..11d67dee2 100644 --- a/src/UI/Mixins/AsPersistedStateCollection.js +++ b/src/UI/Mixins/AsPersistedStateCollection.js @@ -4,6 +4,7 @@ var Config = require('../Config'); module.exports = function() { var originalInit = this.prototype.initialize; + var _setInitialState, _storeStateFromBackgrid, _storeState, _convertDirectionToInt; this.prototype.initialize = function(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 direction = Config.getValue('{0}.sortDirection'.format(this.tableName), this.state.order); var order = parseInt(direction, 10); @@ -44,7 +45,7 @@ module.exports = function() { this.state.order = order; }; - var _storeStateFromBackgrid = function(column, sortDirection) { + _storeStateFromBackgrid = function(column, sortDirection) { var order = _convertDirectionToInt(sortDirection); var sortKey = this._getSortMapping(column.get('name')).sortKey; @@ -52,7 +53,7 @@ module.exports = function() { Config.setValue('{0}.sortDirection'.format(this.tableName), order); }; - var _storeState = function(sortModel, sortDirection) { + _storeState = function(sortModel, sortDirection) { var order = _convertDirectionToInt(sortDirection); var sortKey = this._getSortMapping(sortModel.get('name')).sortKey; @@ -60,7 +61,7 @@ module.exports = function() { Config.setValue('{0}.sortDirection'.format(this.tableName), order); }; - var _convertDirectionToInt = function(dir) { + _convertDirectionToInt = function(dir) { if (dir === 'ascending') { return '-1'; } diff --git a/src/UI/Movies/Details/MoviesDetailsLayout.js b/src/UI/Movies/Details/MoviesDetailsLayout.js index ea99e9046..be03da2e6 100644 --- a/src/UI/Movies/Details/MoviesDetailsLayout.js +++ b/src/UI/Movies/Details/MoviesDetailsLayout.js @@ -89,7 +89,7 @@ module.exports = Marionette.Layout.extend({ this._setMonitoredState(); this._showInfo(); if (this.model.get("movieFile")) { - this._showFiles() + this._showFiles(); } else { this._showHistory(); } @@ -223,37 +223,6 @@ module.exports = Marionette.Layout.extend({ var self = this; 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() { @@ -311,7 +280,7 @@ module.exports = Marionette.Layout.extend({ _manualSearchM : function() { console.warn("Manual Search started"); console.warn(this.model.id); - console.warn(this.model) + console.warn(this.model); console.warn(this.episodeCollection); vent.trigger(vent.Commands.ShowEpisodeDetails, { episode : this.model, diff --git a/src/UI/Movies/Editor/MovieEditorLayout.js b/src/UI/Movies/Editor/MovieEditorLayout.js index c9dee58ad..716fbf032 100644 --- a/src/UI/Movies/Editor/MovieEditorLayout.js +++ b/src/UI/Movies/Editor/MovieEditorLayout.js @@ -1,3 +1,4 @@ +var _ = require('underscore'); var vent = require('vent'); var Marionette = require('marionette'); var Backgrid = require('backgrid'); @@ -82,6 +83,7 @@ module.exports = Marionette.Layout.extend({ }, initialize : function() { + this.movieCollection = MoviesCollection.clone(); var pageSize = parseInt(Config.getValue("pageSize")) || 10; this.movieCollection.switchMode('client', {fetch: false}); @@ -164,10 +166,10 @@ module.exports = Marionette.Layout.extend({ //this._showToolbar(); //this._showTable(); //this._showPager(); - //if (window.shownOnce){ - // this.movieCollection.fetch(); - //} - //window.shownOnce = true; + //if (window.shownOnce){ + // this.movieCollection.fetch(); + //} + //window.shownOnce = true; }, onClose : function() { @@ -203,7 +205,7 @@ module.exports = Marionette.Layout.extend({ this.seriesRegion.show(this.editorGrid); this._showFooter(); - + }, _showToolbar : function() { diff --git a/src/UI/Movies/Files/Edit/EditFileView.js b/src/UI/Movies/Files/Edit/EditFileView.js index 8a0633fb8..8bc47090c 100644 --- a/src/UI/Movies/Files/Edit/EditFileView.js +++ b/src/UI/Movies/Files/Edit/EditFileView.js @@ -24,17 +24,17 @@ var view = Marionette.ItemView.extend({ this.qualities = new Qualities(); var self = this; this.listenTo(this.qualities, 'all', this._qualitiesUpdated); - this.qualities.fetch() + this.qualities.fetch(); }, onRender : function() { - this.ui.quality.val(this.model.get("quality").quality.id) + this.ui.quality.val(this.model.get("quality").quality.id); }, _onBeforeSave : function() { 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"); mQuality.quality = quality; this.model.set({ quality : mQuality }); diff --git a/src/UI/Movies/MoviesCollection.js b/src/UI/Movies/MoviesCollection.js index 6ddb9be93..a4ec0fa87 100644 --- a/src/UI/Movies/MoviesCollection.js +++ b/src/UI/Movies/MoviesCollection.js @@ -81,16 +81,12 @@ var Collection = PageableCollection.extend({ } }, - sortMappings : { - 'movie' : { sortKey : 'series.sortTitle' } - }, - parseState : function(resp) { if (this.mode === 'client') { return {}; } var direction = -1; - if (resp.sortDirection == "descending") { + if (resp.sortDirection.toLowerCase() === "descending") { direction = 1; } return { totalRecords : resp.totalRecords, order : direction, currentPage : resp.page }; @@ -167,20 +163,23 @@ var Collection = PageableCollection.extend({ }, filterModes : filterModes, - + sortMappings : { + movie : { + sortKey : 'series.sortTitle' + }, title : { sortKey : 'sortTitle' }, statusWeight : { sortValue : function(model, attr) { - if (model.getStatus() == "released") { + if (model.getStatus().toLowerCase() === "released") { return 3; } - if (model.getStatus() == "inCinemas") { + if (model.getStatus().toLowerCase() === "incinemas") { return 2; } - if (model.getStatus() == "announced") { + if (model.getStatus().toLowerCase() === "announced") { return 1; } return -1; @@ -212,7 +211,6 @@ var Collection = PageableCollection.extend({ }, status: { sortValue : function(model, attr) { - debugger; if (model.get("downloaded")) { return -1; } diff --git a/src/UI/Series/Details/SeriesDetailsLayout.js b/src/UI/Series/Details/SeriesDetailsLayout.js index d869b47c9..ca906970b 100644 --- a/src/UI/Series/Details/SeriesDetailsLayout.js +++ b/src/UI/Series/Details/SeriesDetailsLayout.js @@ -261,7 +261,7 @@ module.exports = Marionette.Layout.extend({ _manualSearchM : function() { console.warn("Manual Search started"); console.warn(this.model.get("seriesId")); - console.warn(this.model) + console.warn(this.model); console.warn(this.episodeCollection); vent.trigger(vent.Commands.ShowEpisodeDetails, { episode : this.episodeCollection.models[0], diff --git a/src/UI/Series/SeriesController.js b/src/UI/Series/SeriesController.js index 5638b5d85..183670626 100644 --- a/src/UI/Series/SeriesController.js +++ b/src/UI/Series/SeriesController.js @@ -11,7 +11,7 @@ module.exports = NzbDroneController.extend({ //this.route('', this.series); this.route('series', this.series); this.route('series/:query', this.seriesDetails); - + this._originalInit.apply(this, arguments); }, @@ -21,13 +21,13 @@ module.exports = NzbDroneController.extend({ }, seriesDetails : function(query) { - console.warn(AppLayout.mainRegion) - + console.warn(AppLayout.mainRegion); + var series = SeriesCollection.where({ titleSlug : query }); - + if (series.length !== 0) { var targetSeries = series[0]; - + this.setTitle(targetSeries.get('title')); this.showMainRegion(new SeriesDetailsLayout({ model : targetSeries })); } else { diff --git a/src/UI/Settings/NetImport/Edit/NetImportEditView.js b/src/UI/Settings/NetImport/Edit/NetImportEditView.js index f1144b91e..6e010a88e 100644 --- a/src/UI/Settings/NetImport/Edit/NetImportEditView.js +++ b/src/UI/Settings/NetImport/Edit/NetImportEditView.js @@ -1,6 +1,7 @@ var _ = require('underscore'); var $ = require('jquery'); var vent = require('vent'); +var AppLayout = require('../../../AppLayout'); var Marionette = require('marionette'); var DeleteView = require('../Delete/IndexerDeleteView'); var Profiles = require('../../../Profile/ProfileCollection'); @@ -55,7 +56,7 @@ var view = Marionette.ItemView.extend({ profileId : profile, rootFolderPath : rootFolderPath, minimumAvailability : minAvail, - }) + }); }, _onAfterSave : function() { @@ -95,7 +96,6 @@ var view = Marionette.ItemView.extend({ _rootFoldersUpdated : function() { this._configureTemplateHelpers(); - debugger; this.render(); }, diff --git a/src/UI/Shared/Toolbar/Sorting/SortingButtonCollectionView.js b/src/UI/Shared/Toolbar/Sorting/SortingButtonCollectionView.js index 8dc9d375d..25dc47556 100644 --- a/src/UI/Shared/Toolbar/Sorting/SortingButtonCollectionView.js +++ b/src/UI/Shared/Toolbar/Sorting/SortingButtonCollectionView.js @@ -31,13 +31,12 @@ module.exports = Marionette.CompositeView.extend({ } collection.setSorting(sortModel.get('name'), order); - if (collection.mode == "server"){ + if (collection.mode.toLowerCase() === "server"){ collection.fetch({reset: true}); } else { collection.fullCollection.sort(); } - return this; } });