1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-17 15:02:34 +02:00

added jshint

This commit is contained in:
kayone 2013-11-10 20:09:11 -08:00
parent 9536c6c1bb
commit 47d924cff3
30 changed files with 177 additions and 127 deletions

View File

@ -129,6 +129,27 @@ module.exports = function (grunt) {
} }
}, },
jshint: {
options: {
'-W030': false,
'-W064': false,
'-W097': false,
'-W100': false,
'undef': true,
'globals': {
'require': true,
'define': true,
'window': true,
'document': true,
'console': true
}
},
all: [
srcRoot + '**/*.js',
'!**/JsLibraries/*.js'
]
},
requirejs: { requirejs: {
compile:{ compile:{
options: { options: {
@ -184,6 +205,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-notify'); grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-curl'); grunt.loadNpmTasks('grunt-curl');
grunt.loadNpmTasks('grunt-contrib-requirejs'); grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('package', ['clean:output','handlebars', 'copy', 'less']); grunt.registerTask('package', ['clean:output','handlebars', 'copy', 'less']);
grunt.registerTask('packagerjs', ['clean:output','handlebars', 'requirejs', 'copy:content', 'less']); grunt.registerTask('packagerjs', ['clean:output','handlebars', 'requirejs', 'copy:content', 'less']);

View File

@ -80,7 +80,7 @@ define(
this.collection.reset(); this.collection.reset();
if (!options.term || options.term === this.collection.term) { if (!options.term || options.term === this.collection.term) {
return $.Deferred().resolve(); return Marionette.$.Deferred().resolve();
} }
this.searchResult.show(new LoadingView()); this.searchResult.show(new LoadingView());

View File

@ -2,8 +2,9 @@
define( define(
[ [
'backbone', 'backbone',
'AddSeries/Existing/UnmappedFolderModel' 'AddSeries/Existing/UnmappedFolderModel',
], function (Backbone, UnmappedFolderModel) { 'underscore'
], function (Backbone, UnmappedFolderModel,_) {
return Backbone.Collection.extend({ return Backbone.Collection.extend({
model: UnmappedFolderModel, model: UnmappedFolderModel,

View File

@ -7,7 +7,7 @@ define(
'moment', 'moment',
'Calendar/Collection', 'Calendar/Collection',
'fullcalendar' 'fullcalendar'
], function (vent, Marionette, Moment, CalendarCollection) { ], function (vent, Marionette, moment, CalendarCollection) {
var _instance; var _instance;
@ -16,7 +16,10 @@ define(
this.collection = new CalendarCollection(); this.collection = new CalendarCollection();
}, },
render : function () { render : function () {
$(this.$el).empty().fullCalendar({
var self = this;
this.$el.empty().fullCalendar({
defaultView : 'basicWeek', defaultView : 'basicWeek',
allDayDefault : false, allDayDefault : false,
ignoreTimezone: false, ignoreTimezone: false,
@ -34,8 +37,8 @@ define(
}, },
events : this.getEvents, events : this.getEvents,
eventRender : function (event, element) { eventRender : function (event, element) {
$(element).addClass(event.statusLevel); self.$(element).addClass(event.statusLevel);
$(element).children('.fc-event-inner').addClass(event.statusLevel); self.$(element).children('.fc-event-inner').addClass(event.statusLevel);
}, },
eventClick : function (event) { eventClick : function (event) {
vent.trigger(vent.Commands.ShowEpisodeDetails, {episode: event.model}); vent.trigger(vent.Commands.ShowEpisodeDetails, {episode: event.model});
@ -50,8 +53,8 @@ define(
}, },
getEvents: function (start, end, callback) { getEvents: function (start, end, callback) {
var startDate = Moment(start).toISOString(); var startDate = moment(start).toISOString();
var endDate = Moment(end).toISOString(); var endDate = moment(end).toISOString();
_instance.collection.fetch({ _instance.collection.fetch({
data : { start: startDate, end: endDate }, data : { start: startDate, end: endDate },
@ -61,7 +64,7 @@ define(
var seriesTitle = element.get('series').title; var seriesTitle = element.get('series').title;
var start = element.get('airDateUtc'); var start = element.get('airDateUtc');
var runtime = element.get('series').runtime; var runtime = element.get('series').runtime;
var end = Moment(start).add('minutes', runtime).toISOString(); var end = moment(start).add('minutes', runtime).toISOString();
element.set({ element.set({
@ -83,9 +86,9 @@ define(
getStatusLevel: function (element) { getStatusLevel: function (element) {
var hasFile = element.get('hasFile'); var hasFile = element.get('hasFile');
var currentTime = Moment(); var currentTime = moment();
var start = Moment(element.get('airDateUtc')); var start = moment(element.get('airDateUtc'));
var end = Moment(element.get('end')); var end = moment(element.get('end'));
var statusLevel = 'primary'; var statusLevel = 'primary';
@ -94,10 +97,6 @@ define(
} }
else if (currentTime.isAfter(start) && currentTime.isBefore(end)) { else if (currentTime.isAfter(start) && currentTime.isBefore(end)) {
var s = start.toISOString();
var e = end.toISOString();
var c = currentTime.toISOString();
statusLevel = 'warning'; statusLevel = 'warning';
} }

View File

@ -3,8 +3,9 @@
define( define(
[ [
'Cells/NzbDroneCell', 'Cells/NzbDroneCell',
'Shared/FormatHelpers' 'Shared/FormatHelpers',
], function (NzbDroneCell, FormatHelpers) { 'underscore'
], function (NzbDroneCell, FormatHelpers, _) {
return NzbDroneCell.extend({ return NzbDroneCell.extend({
className: 'episode-number-cell', className: 'episode-number-cell',

View File

@ -2,8 +2,9 @@
define( define(
[ [
'backgrid' 'backgrid',
], function (Backgrid) { 'backbone'
], function (Backgrid, Backbone) {
return Backgrid.Cell.extend({ return Backgrid.Cell.extend({
_originalInit: Backgrid.Cell.prototype.initialize, _originalInit: Backgrid.Cell.prototype.initialize,
@ -15,8 +16,8 @@ define(
this.listenTo(this.model, 'change', this._refresh); this.listenTo(this.model, 'change', this._refresh);
if (this._onEdit) { if (this._onEdit) {
this.listenTo(this.model, "backgrid:edit", function (model, column, cell, editor) { this.listenTo(this.model, 'backgrid:edit', function (model, column, cell, editor) {
if (column.get("name") == this.column.get("name")) { if (column.get('name') === this.column.get('name')) {
this._onEdit(model, column, cell, editor); this._onEdit(model, column, cell, editor);
} }
}); });

View File

@ -2,8 +2,9 @@
define( define(
[ [
'backgrid', 'backgrid',
'Quality/QualityProfileCollection' 'Quality/QualityProfileCollection',
], function (Backgrid, QualityProfileCollection) { 'underscore'
], function (Backgrid, QualityProfileCollection,_) {
return Backgrid.Cell.extend({ return Backgrid.Cell.extend({
className: 'quality-profile-cell', className: 'quality-profile-cell',

View File

@ -18,7 +18,7 @@ define(
getValue: function (key, defaultValue) { getValue: function (key, defaultValue) {
var storeValue = localStorage.getItem(key); var storeValue = window.localStorage.getItem(key);
if (!storeValue) { if (!storeValue) {
return defaultValue; return defaultValue;
@ -35,7 +35,7 @@ define(
return; return;
} }
localStorage.setItem(key, value); window.localStorage.setItem(key, value);
vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value}); vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
} }

View File

@ -1,8 +1,10 @@
'use strict'; 'use strict';
define( define(
[ [
'handlebars' 'marionette',
], function (Handlebars) { 'handlebars',
'underscore'
], function (Marionette, Handlebars, _) {
var _fieldBuilder = function (field) { var _fieldBuilder = function (field) {
if (!field.type) { if (!field.type) {

View File

@ -38,7 +38,7 @@
return false; //don't suppress default alerts and logs. return false; //don't suppress default alerts and logs.
}; };
$(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) { window.$(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) {
//don't report 200 error codes //don't report 200 error codes
if (xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) { if (xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
define(function () { define(['jquery'],function ($) {
$.fn.autoComplete = function (resource) { $.fn.autoComplete = function (resource) {
$(this).typeahead({ $(this).typeahead({

View File

@ -2,10 +2,11 @@
define( define(
[ [
'marionette', 'marionette',
'Navbar/Search' 'Navbar/Search',
], function (Marionette) { 'jquery'
], function (Marionette, $) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template : 'Navbar/NavbarTemplate', template: 'Navbar/NavbarTemplate',
ui: { ui: {
search: '.x-series-search' search: '.x-series-search'
@ -15,7 +16,7 @@ define(
'click a': 'onClick' 'click a': 'onClick'
}, },
onRender: function (){ onRender: function () {
this.ui.search.bindSearch(); this.ui.search.bindSearch();
}, },

View File

@ -1,8 +1,9 @@
'use strict'; 'use strict';
define( define(
[ [
'backbone',
'Quality/QualitySizeModel' 'Quality/QualitySizeModel'
], function (QualitySizeModel) { ], function (Backbone, QualitySizeModel) {
return Backbone.Collection.extend({ return Backbone.Collection.extend({
model: QualitySizeModel, model: QualitySizeModel,
url : window.NzbDrone.ApiRoot + '/qualitysize' url : window.NzbDrone.ApiRoot + '/qualitysize'

View File

@ -1,9 +1,12 @@
define(function () { define(
[
'jquery'
], function ($) {
'use strict'; 'use strict';
return { return {
load: function (name, parentRequire, onload, config) { load: function (name, parentRequire, onload, config) {
if(config.isBuild){ if (config.isBuild) {
return onload(); return onload();
} }
@ -19,7 +22,7 @@ define(function () {
xhr : xhr, xhr : xhr,
status: status, status: status,
error : error}); error : error});
}); });
} }
}; };
}); });

View File

@ -112,13 +112,13 @@ define(
var element; var element;
if (e.target.localName === 'i') { if (e.target.localName === 'i') {
seasonNumber = parseInt($(e.target).parent('td').attr('data-season-number'), 10); seasonNumber = parseInt(this.$(e.target).parent('td').attr('data-season-number'), 10);
element = $(e.target); element = this.$(e.target);
} }
else { else {
seasonNumber = parseInt($(e.target).attr('data-season-number'), 10); seasonNumber = parseInt(this.$(e.target).attr('data-season-number'), 10);
element = $(e.target).children('i'); element = this.$(e.target).children('i');
} }
this.model.setSeasonMonitored(seasonNumber); this.model.setSeasonMonitored(seasonNumber);
@ -146,7 +146,7 @@ define(
} }
}, },
_toggleSeriesMonitored: function (e) { _toggleSeriesMonitored: function () {
var savePromise = this.model.save('monitored', !this.model.get('monitored'), { var savePromise = this.model.save('monitored', !this.model.get('monitored'), {
wait: true wait: true
}); });

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
define( define(
[ [
'jquery',
'vent', 'vent',
'reqres', 'reqres',
'marionette', 'marionette',
@ -15,7 +16,7 @@ define(
'underscore', 'underscore',
'backstrech', 'backstrech',
'Mixins/backbone.signalr.mixin' 'Mixins/backbone.signalr.mixin'
], function (vent,reqres, Marionette, Backbone, EpisodeCollection, EpisodeFileCollection, SeasonCollection, SeasonCollectionView, InfoView, CommandController, LoadingView, _) { ], function ($,vent,reqres, Marionette, Backbone, EpisodeCollection, EpisodeFileCollection, SeasonCollection, SeasonCollectionView, InfoView, CommandController, LoadingView, _) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
itemViewContainer: '.x-series-seasons', itemViewContainer: '.x-series-seasons',

View File

@ -54,7 +54,7 @@ define(
options = {}; options = {};
} }
options['data'] = { seriesId: this.seriesId }; options.data = { seriesId: this.seriesId };
return this.originalFetch.call(this, options); return this.originalFetch.call(this, options);
} }

View File

@ -23,7 +23,7 @@ define(
options = {}; options = {};
} }
options['data'] = { seriesId: this.seriesId }; options.data = { seriesId: this.seriesId };
return this.originalFetch.call(this, options); return this.originalFetch.call(this, options);
} }

View File

@ -2,6 +2,7 @@
define( define(
[ [
'marionette', 'marionette',
'backgrid',
'Series/Index/Posters/CollectionView', 'Series/Index/Posters/CollectionView',
'Series/Index/List/CollectionView', 'Series/Index/List/CollectionView',
'Series/Index/EmptyView', 'Series/Index/EmptyView',
@ -16,8 +17,10 @@ define(
'Cells/SeriesStatusCell', 'Cells/SeriesStatusCell',
'Series/Index/FooterView', 'Series/Index/FooterView',
'Series/Index/FooterModel', 'Series/Index/FooterModel',
'Shared/Toolbar/ToolbarLayout' 'Shared/Toolbar/ToolbarLayout',
'underscore'
], function (Marionette, ], function (Marionette,
Backgrid,
PosterCollectionView, PosterCollectionView,
ListCollectionView, ListCollectionView,
EmptyView, EmptyView,
@ -32,7 +35,8 @@ define(
SeriesStatusCell, SeriesStatusCell,
FooterView, FooterView,
FooterModel, FooterModel,
ToolbarLayout) { ToolbarLayout,
_) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Series/Index/SeriesIndexLayoutTemplate', template: 'Series/Index/SeriesIndexLayoutTemplate',

View File

@ -1,6 +1,6 @@
window.NzbDrone.ApiRoot = '/api'; window.NzbDrone.ApiRoot = '/api';
var statusText = $.ajax({ var statusText = window.$.ajax({
type : 'GET', type : 'GET',
url : window.NzbDrone.ApiRoot + '/system/status', url : window.NzbDrone.ApiRoot + '/system/status',
async: false, async: false,
@ -13,10 +13,13 @@ window.NzbDrone.ServerStatus = JSON.parse(statusText);
var footerText = window.NzbDrone.ServerStatus.version; var footerText = window.NzbDrone.ServerStatus.version;
$(document).ready(function () { window.$(document).ready(function () {
if (window.NzbDrone.ServerStatus.branch != 'master') { if (window.NzbDrone.ServerStatus.branch !== 'master') {
footerText += '</br>' + window.NzbDrone.ServerStatus.branch; footerText += '</br>' + window.NzbDrone.ServerStatus.branch;
} }
$('#footer-region .version').html(footerText); window.$('#footer-region .version').html(footerText);
}); });

View File

@ -83,7 +83,7 @@ define(
this.indexerSettings = new IndexerCollection(); this.indexerSettings = new IndexerCollection();
this.notificationSettings = new NotificationCollection(); this.notificationSettings = new NotificationCollection();
$.when(this.settings.fetch(), Backbone.$.when(this.settings.fetch(),
this.generalSettings.fetch(), this.generalSettings.fetch(),
this.namingSettings.fetch(), this.namingSettings.fetch(),
this.indexerSettings.fetch(), this.indexerSettings.fetch(),

View File

@ -51,7 +51,7 @@ define(
return ''; return '';
} }
return input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); return input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
} }
} };
}); });

View File

@ -1,8 +1,9 @@
'use strict'; 'use strict';
define( define(
[ [
'marionette',
'backgrid.paginator' 'backgrid.paginator'
], function (Paginator) { ], function (Marionette, Paginator) {
return Paginator.extend({ return Paginator.extend({
@ -24,7 +25,7 @@ define(
changePage: function (e) { changePage: function (e) {
e.preventDefault(); e.preventDefault();
var target = $(e.target); var target =this.$(e.target);
if (target.closest('li').hasClass('disabled')) { if (target.closest('li').hasClass('disabled')) {
return; return;
@ -59,7 +60,7 @@ define(
} }
var state = collection.state; var state = collection.state;
var pageIndex = $(e.target).text() * 1; var pageIndex = target.text();
collection.getPage(state.firstPage === 0 ? pageIndex - 1 :pageIndex); collection.getPage(state.firstPage === 0 ? pageIndex - 1 :pageIndex);
}, },

View File

@ -14,10 +14,10 @@ define(
setTitle: function (title) { setTitle: function (title) {
if (title.toLocaleLowerCase() === 'nzbdrone') { if (title.toLocaleLowerCase() === 'nzbdrone') {
window.document.title = 'NzbDrone'; document.title = 'NzbDrone';
} }
else { else {
window.document.title = title + ' - NzbDrone'; document.title = title + ' - NzbDrone';
} }
} }
}); });

View File

@ -2,8 +2,9 @@
define( define(
[ [
'vent', 'vent',
'jquery',
'signalR' 'signalR'
], function (vent) { ], function (vent, $) {
return { return {
appInitializer: function () { appInitializer: function () {

View File

@ -5,8 +5,9 @@ define(
'Shared/Toolbar/ButtonCollection', 'Shared/Toolbar/ButtonCollection',
'Shared/Toolbar/ButtonModel', 'Shared/Toolbar/ButtonModel',
'Shared/Toolbar/Radio/RadioButtonCollectionView', 'Shared/Toolbar/Radio/RadioButtonCollectionView',
'Shared/Toolbar/Button/ButtonCollectionView' 'Shared/Toolbar/Button/ButtonCollectionView',
], function (Marionette, ButtonCollection, ButtonModel, RadioButtonCollectionView, ButtonCollectionView) { 'underscore'
], function (Marionette, ButtonCollection, ButtonModel, RadioButtonCollectionView, ButtonCollectionView,_) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Shared/Toolbar/ToolbarLayoutTemplate', template: 'Shared/Toolbar/ToolbarLayoutTemplate',

View File

@ -1,14 +1,17 @@
'use strict'; 'use strict';
define(['System/Logs/Files/LogFileModel' ], define(
function (LogFileModel) { [
return Backbone.Collection.extend({ 'backbone',
url : window.NzbDrone.ApiRoot + '/log/files', 'System/Logs/Files/LogFileModel'
model: LogFileModel, ], function (Backbone, LogFileModel) {
return Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/log/files',
model: LogFileModel,
state: { state: {
sortKey : 'lastWriteTime', sortKey: 'lastWriteTime',
order : 1 order : 1
} }
});
}); });
});

View File

@ -99,8 +99,8 @@ require.config({
exports: 'Marionette', exports: 'Marionette',
init : function (Backbone, TemplateMixin, AsNamedView) { init : function (Backbone, TemplateMixin, AsNamedView) {
TemplateMixin.call(Marionette.TemplateCache); TemplateMixin.call(window.Marionette.TemplateCache);
AsNamedView.call(Marionette.ItemView.prototype); AsNamedView.call(window.Marionette.ItemView.prototype);
} }
}, },
@ -140,7 +140,7 @@ require.config({
'Shared/Grid/HeaderCell' 'Shared/Grid/HeaderCell'
], function () { ], function () {
Backgrid.Column.prototype.defaults = { window.Backgrid.Column.prototype.defaults = {
name : undefined, name : undefined,
label : undefined, label : undefined,
sortable : true, sortable : true,

View File

@ -1,55 +1,59 @@
'use strict'; 'use strict';
define(['backbone'],function (Backbone) { define(
//This module will automatically route all relative links through backbone router rather than [
//causing links to reload pages. 'backbone',
'jquery'
], function (Backbone,$) {
//This module will automatically route all relative links through backbone router rather than
//causing links to reload pages.
var routeBinder = { var routeBinder = {
bind: function () { bind: function () {
var self = this; var self = this;
$(document).on('click', 'a[href]', function (event) { $(document).on('click', 'a[href]', function (event) {
self._handleClick(event); self._handleClick(event);
}); });
}, },
_handleClick: function (event) { _handleClick: function (event) {
var $target = $(event.target); var $target = $(event.target);
//check if tab nav //check if tab nav
if ($target.parents('.nav-tabs').length) { if ($target.parents('.nav-tabs').length) {
return; return;
}
if ($target.hasClass('no-router')) {
return;
}
event.preventDefault();
var href = event.target.getAttribute('href');
if (!href && $target.parent('a') && $target.parent('a')[0]) {
var linkElement = $target.parent('a')[0];
href = linkElement.getAttribute('href');
}
if (!href) {
throw 'couldn\'t find route target';
}
if (!href.startsWith('http')) {
Backbone.history.navigate(href, { trigger: true });
}
else {
//Open in new tab
window.open(href, '_blank');
}
} }
};
if ($target.hasClass('no-router')) { return routeBinder;
return; });
}
event.preventDefault();
var href = event.target.getAttribute('href');
if (!href && $target.parent('a') && $target.parent('a')[0]) {
var linkElement = $target.parent('a')[0];
href = linkElement.getAttribute('href');
}
if (!href) {
throw 'couldn\'t find route target';
}
if (!href.startsWith('http')) {
Backbone.history.navigate(href, { trigger: true });
}
else {
//Open in new tab
window.open(href, '_blank');
}
}
};
return routeBinder;
});

View File

@ -50,7 +50,7 @@ define(
}; };
$.fn.addFormError = function (error) { $.fn.addFormError = function (error) {
this.find('.control-group').parent().prepend('<div class="alert alert-error validation-error">' + error.errorMessage + '</div>') this.find('.control-group').parent().prepend('<div class="alert alert-error validation-error">' + error.errorMessage + '</div>');
}; };
$.fn.removeAllErrors = function () { $.fn.removeAllErrors = function () {