From 9a0d764bbd159277723b5138fff9de70faee1268 Mon Sep 17 00:00:00 2001 From: HeeL Date: Thu, 13 Oct 2016 11:40:10 +0200 Subject: [PATCH 1/3] Fix wrap-iife linter rule --- .eslintrc.json | 1 - public/src/modules/helpers.js | 4 ++-- public/src/modules/settings/array.js | 2 +- public/src/modules/settings/object.js | 2 +- public/src/modules/translator.js | 10 +++++----- public/src/overrides.js | 4 ++-- public/src/utils.js | 4 ++-- src/password.js | 2 +- src/socket.io/index.js | 2 +- 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 996ebe85c2..f96c075add 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,7 +18,6 @@ "eqeqeq": "off", "camelcase": "off", "no-negated-condition": "off", - "wrap-iife": "off", "one-var-declaration-per-line": "off", "new-cap": "off", "no-lonely-if": "off", diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js index 7250fab3b6..db3f9c2728 100644 --- a/public/src/modules/helpers.js +++ b/public/src/modules/helpers.js @@ -286,8 +286,8 @@ define('helpers', exports); } -})( +}( typeof exports === 'object' ? exports : typeof define === 'function' && define.amd ? {} : helpers = {} -); +)); diff --git a/public/src/modules/settings/array.js b/public/src/modules/settings/array.js index 81071a65fa..fd94ed8226 100644 --- a/public/src/modules/settings/array.js +++ b/public/src/modules/settings/array.js @@ -107,7 +107,7 @@ define('settings/array', function () { } catch (_error) { return $(document.createTextNode(separator)); } - })(); + }()); if (typeof attributes !== 'object') { attributes = {}; } diff --git a/public/src/modules/settings/object.js b/public/src/modules/settings/object.js index 8c7a53f99a..05971d6d73 100644 --- a/public/src/modules/settings/object.js +++ b/public/src/modules/settings/object.js @@ -69,7 +69,7 @@ define('settings/object', function () { } catch (_error) { return $(document.createTextNode(separator)); } - })(); + }()); element.empty(); if (typeof value !== 'object') { value = {}; diff --git a/public/src/modules/translator.js b/public/src/modules/translator.js index 08525702d5..65a92772e5 100644 --- a/public/src/modules/translator.js +++ b/public/src/modules/translator.js @@ -29,16 +29,16 @@ } module.exports = factory(require('string'), loadServer); - })(); + }()); } else { window.translator = factory(window.string, loadClient); } -})(function (string, load) { +}(function (string, load) { 'use strict'; var assign = Object.assign || jQuery.extend; function classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var Translator = function () { + var Translator = (function () { /** * Construct a new Translator object * @param {string} language - Language code for this translator instance @@ -305,7 +305,7 @@ Translator.cache = {}; return Translator; - }(); + }()); var adaptor = { /** @@ -453,4 +453,4 @@ }; return adaptor; -}); +})); diff --git a/public/src/overrides.js b/public/src/overrides.js index 49dce7e754..ba4ab2745f 100644 --- a/public/src/overrides.js +++ b/public/src/overrides.js @@ -86,7 +86,7 @@ if ('undefined' !== typeof window) { }); } }); - })(jQuery || {fn:{}}); + }(jQuery || {fn:{}})); (function(){ // FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245 @@ -109,7 +109,7 @@ if ('undefined' !== typeof window) { _clearMenus(); } }); - })(); + }()); overrides.overrideBootbox = function () { require(['translator'], function(translator) { diff --git a/public/src/utils.js b/public/src/utils.js index 190d0ab3c6..989a9506a6 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -478,8 +478,8 @@ window.utils = module.exports; } -})('undefined' === typeof module ? { +}('undefined' === typeof module ? { module: { exports: {} } -} : module); +} : module)); diff --git a/src/password.js b/src/password.js index 20f4c79a95..8b9fbb33a6 100644 --- a/src/password.js +++ b/src/password.js @@ -30,4 +30,4 @@ } return module; -})(exports); \ No newline at end of file +}(exports)); \ No newline at end of file diff --git a/src/socket.io/index.js b/src/socket.io/index.js index d3393ea2d2..dedf6aab8e 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -224,4 +224,4 @@ var ratelimit = require('../middleware/ratelimit'); }; }; -})(exports); +}(exports)); From 3fa1c1f9273a13ea6e52f636946eac1483b7f421 Mon Sep 17 00:00:00 2001 From: HeeL Date: Thu, 13 Oct 2016 11:42:29 +0200 Subject: [PATCH 2/3] Fix space-infix-ops linter rule --- .eslintrc.json | 1 - app.js | 2 +- install/databases.js | 2 +- loader.js | 8 ++++---- public/src/admin/appearance/skins.js | 2 +- public/src/admin/extend/rewards.js | 2 +- public/src/admin/extend/widgets.js | 4 ++-- public/src/admin/general/dashboard.js | 12 ++++++------ public/src/admin/manage/categories.js | 2 +- public/src/admin/manage/category.js | 4 ++-- public/src/admin/manage/users.js | 2 +- public/src/client/account/header.js | 2 +- public/src/client/categoryTools.js | 4 ++-- public/src/client/chats.js | 2 +- public/src/client/chats/search.js | 2 +- public/src/client/recent.js | 4 ++-- public/src/client/topic/events.js | 2 +- public/src/client/topic/posts.js | 2 +- public/src/client/topic/threadTools.js | 2 +- public/src/client/unread.js | 2 +- public/src/client/users.js | 2 +- public/src/modules/notifications.js | 2 +- public/src/modules/search.js | 8 ++++---- public/src/modules/taskbar.js | 2 +- public/src/modules/topicSelect.js | 2 +- public/src/utils.js | 8 ++++---- public/src/widgets.js | 4 ++-- src/analytics.js | 6 +++--- src/categories.js | 2 +- src/categories/topics.js | 2 +- src/controllers/accounts/helpers.js | 2 +- src/controllers/topics.js | 4 ++-- src/database/mongo/hash.js | 12 ++++++------ src/database/mongo/helpers.js | 2 +- src/database/mongo/sets.js | 8 ++++---- src/database/mongo/sorted.js | 12 ++++++------ src/database/redis/hash.js | 2 +- src/database/redis/helpers.js | 8 ++++---- src/database/redis/main.js | 2 +- src/database/redis/sorted.js | 24 ++++++++++++------------ src/file.js | 2 +- src/groups/membership.js | 2 +- src/groups/search.js | 2 +- src/hotswap.js | 2 +- src/image.js | 10 +++++----- src/logger.js | 2 +- src/messaging.js | 8 ++++---- src/middleware/header.js | 2 +- src/middleware/maintenance.js | 2 +- src/notifications.js | 2 +- src/pagination.js | 4 ++-- src/plugins.js | 4 ++-- src/plugins/load.js | 2 +- src/posts.js | 4 ++-- src/posts/summary.js | 2 +- src/posts/votes.js | 2 +- src/privileges/categories.js | 4 ++-- src/privileges/helpers.js | 14 +++++++------- src/privileges/posts.js | 2 +- src/privileges/topics.js | 2 +- src/routes/feeds.js | 2 +- src/routes/index.js | 4 ++-- src/sitemap.js | 12 ++++++------ src/socket.io/admin/rooms.js | 2 +- src/socket.io/admin/user.js | 2 +- src/socket.io/user.js | 2 +- src/topics.js | 2 +- src/topics/create.js | 4 ++-- src/topics/data.js | 2 +- src/topics/follow.js | 4 ++-- src/topics/posts.js | 4 ++-- src/topics/tags.js | 2 +- src/user/data.js | 2 +- src/user/digest.js | 4 ++-- src/user/settings.js | 2 +- test/mocks/databasemock.js | 12 ++++++------ test/user.js | 6 +++--- 77 files changed, 159 insertions(+), 160 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index f96c075add..6d13f18de6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -76,7 +76,6 @@ "no-multi-spaces": "off", "quotes": "off", "keyword-spacing": "off", - "space-infix-ops": "off", "no-plusplus": "off", "no-mixed-operators": "off", "semi": "off", diff --git a/app.js b/app.js index c348cbfed5..8e19fb5184 100644 --- a/app.js +++ b/app.js @@ -251,7 +251,7 @@ function setup() { install.setup(function (err, data) { var separator = ' '; if (process.stdout.columns > 10) { - for(var x=0,cols=process.stdout.columns-10;x'; + html += ''; break; } html += '
'; diff --git a/public/src/admin/extend/widgets.js b/public/src/admin/extend/widgets.js index 91e05beb04..ad7479f247 100644 --- a/public/src/admin/extend/widgets.js +++ b/public/src/admin/extend/widgets.js @@ -197,13 +197,13 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) { $.get(RELATIVE_PATH + '/api/admin/extend/widgets', function(data) { var areas = data.areas; - for(var i=0; i'+ data.onlineRegisteredCount +'' + + '
' + data.onlineRegisteredCount + '
' + '
Users
' + '' + '
' + - '
'+ data.onlineGuestCount +'
' + + '
' + data.onlineGuestCount + '
' + '
Guests
' + '
' + '
' + - '
'+ (data.onlineRegisteredCount + data.onlineGuestCount) +'
' + + '
' + (data.onlineRegisteredCount + data.onlineGuestCount) + '
' + '
Total
' + '
' + '
' + - '
'+ data.socketCount +'
' + + '
' + data.socketCount + '
' + '
Connections
' + '
'; @@ -150,7 +150,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) { if (g > 255) g = 255; else if (g < 0) g = 0; - return (usePound?"#":"") + (g | (b << 8) | (r << 16)).toString(16); + return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16); } function setupGraphs() { @@ -277,7 +277,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) { switch($(this).attr('data-until')) { case 'last-month': var lastMonth = new Date(); - lastMonth.setDate(lastMonth.getDate()-30); + lastMonth.setDate(lastMonth.getDate() - 30); until = lastMonth.getTime(); } updateTrafficGraph($(this).attr('data-units'), until); diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.js index 398d24dd42..c406f0f879 100644 --- a/public/src/admin/manage/categories.js +++ b/public/src/admin/manage/categories.js @@ -179,7 +179,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri container.append(html); // Handle and children categories in this level have - for(var x=0,numCategories=categories.length;x' : + '' : '
' + userObj['icon:text'] + '
') + ' ' + userObj.username; } diff --git a/public/src/client/recent.js b/public/src/client/recent.js index 973819d44d..0a990560fc 100644 --- a/public/src/client/recent.js +++ b/public/src/client/recent.js @@ -108,7 +108,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite } else if (newPostCount === 1) { text = '[[recent:there-is-a-new-topic-and-a-new-post]]'; } else if (newPostCount > 1) { - text = '[[recent:there-is-a-new-topic-and-new-posts, ' + newPostCount +']]'; + text = '[[recent:there-is-a-new-topic-and-new-posts, ' + newPostCount + ']]'; } } else if (newTopicCount > 1) { if (newPostCount === 0) { @@ -116,7 +116,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite } else if (newPostCount === 1) { text = '[[recent:there-are-new-topics-and-a-new-post, ' + newTopicCount + ']]'; } else if (newPostCount > 1) { - text = '[[recent:there-are-new-topics-and-new-posts, ' + newTopicCount + ', ' + newPostCount +']]'; + text = '[[recent:there-are-new-topics-and-new-posts, ' + newTopicCount + ', ' + newPostCount + ']]'; } } diff --git a/public/src/client/topic/events.js b/public/src/client/topic/events.js index bba3cb0dcb..2c63abc4fb 100644 --- a/public/src/client/topic/events.js +++ b/public/src/client/topic/events.js @@ -158,7 +158,7 @@ define('forum/topic/events', [ return true; } - for (var i=0; i 0) { - topicSearchEl.find('.count').html((index+1) + ' / ' + Search.current.results.length); + topicSearchEl.find('.count').html((index + 1) + ' / ' + Search.current.results.length); topicSearchEl.find('.prev, .next').removeAttr('disabled'); var data = { pid: Search.current.results[index], diff --git a/public/src/modules/taskbar.js b/public/src/modules/taskbar.js index 7f5978250b..3b38787e65 100644 --- a/public/src/modules/taskbar.js +++ b/public/src/modules/taskbar.js @@ -114,7 +114,7 @@ define('taskbar', function() { .addClass(data.options.className) .html('' + (data.options.icon ? ' ' : '') + - (data.options.image ? ' ': '') + + (data.options.image ? ' ' : '') + '' + title + '' + '') .attr({ diff --git a/public/src/modules/topicSelect.js b/public/src/modules/topicSelect.js index d0dd85b601..8362980993 100644 --- a/public/src/modules/topicSelect.js +++ b/public/src/modules/topicSelect.js @@ -71,7 +71,7 @@ define('topicSelect', ['components'], function(components) { end = tmp; } - for(var i=start; i<=end; ++i) { + for(var i = start; i <= end; ++i) { var topic = $('[component="category/topic"]').eq(i); toggleSelect(topic.find('[component="topic/select"]'), isSelected); } diff --git a/public/src/utils.js b/public/src/utils.js index 989a9506a6..474df8151c 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -276,7 +276,7 @@ for (var i = envs.length - 1; i >= 0; i--) { var env = envs[i]; - $el.addClass('hidden-'+env); + $el.addClass('hidden-' + env); if ($el.is(':hidden')) { $el.remove(); return env; @@ -309,8 +309,8 @@ labels = [], tmpDate; - for(var x=29;x>=0;x--) { - tmpDate = new Date(currentDay - (1000*60*60*24*x)); + for(var x = 29;x >= 0;x--) { + tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x)); labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate()); } @@ -461,7 +461,7 @@ } var len = this.length; var suffixLen = suffix.length; - for (var i=1; (i <= suffixLen && this[len - i] === suffix[suffixLen - i]); ++i) { + for (var i = 1; (i <= suffixLen && this[len - i] === suffix[suffixLen - i]); ++i) { continue; } return i > suffixLen; diff --git a/public/src/widgets.js b/public/src/widgets.js index 8bae7cc465..c798ce0f93 100644 --- a/public/src/widgets.js +++ b/public/src/widgets.js @@ -42,12 +42,12 @@ url: url, isMobile: utils.isMobile() }, function(renderedAreas) { - for (var x=0; x 1) { url += '?page=' + currentPage; @@ -149,7 +149,7 @@ topicsController.get = function(req, res, callback) { }, function (topicData, next) { function findPost(index) { - for(var i=0; i origRatio) { - desiredRatio = 1/desiredRatio; + desiredRatio = 1 / desiredRatio; } if (origRatio >= 1) { y = 0; // height is the smaller dimension here - x = Math.floor((w/2) - (h * desiredRatio / 2)); + x = Math.floor((w / 2) - (h * desiredRatio / 2)); crop = async.apply(image.crop.bind(image), x, y, h * desiredRatio, h); } else { x = 0; // width is the smaller dimension here - y = Math.floor(h/2 - (w * desiredRatio / 2)); + y = Math.floor(h / 2 - (w * desiredRatio / 2)); crop = async.apply(image.crop.bind(image), x, y, w, w * desiredRatio); } } else { diff --git a/src/logger.js b/src/logger.js index e646046bd9..b99fbfbb91 100644 --- a/src/logger.js +++ b/src/logger.js @@ -148,7 +148,7 @@ var opts = { * The format is: io: */ try { - return 'io: '+_uid+' '+_type+' '+util.inspect(Array.prototype.slice.call(_args))+'\n'; + return 'io: ' + _uid + ' ' + _type + ' ' + util.inspect(Array.prototype.slice.call(_args)) + '\n'; } catch(err) { winston.info("Logger.prepare_io_string: Failed", err); return "error"; diff --git a/src/messaging.js b/src/messaging.js index ae554f7359..cdf5f77ce4 100644 --- a/src/messaging.js +++ b/src/messaging.js @@ -156,10 +156,10 @@ var userNotifications = require('./user/notifications'); // Add a spacer in between messages with time gaps between them messages = messages.map(function(message, index) { // Compare timestamps with the previous message, and check if a spacer needs to be added - if (index > 0 && parseInt(message.timestamp, 10) > parseInt(messages[index-1].timestamp, 10) + (1000*60*5)) { + if (index > 0 && parseInt(message.timestamp, 10) > parseInt(messages[index - 1].timestamp, 10) + (1000 * 60 * 5)) { // If it's been 5 minutes, this is a new set of messages message.newSet = true; - } else if (index > 0 && message.fromuid !== messages[index-1].fromuid) { + } else if (index > 0 && message.fromuid !== messages[index - 1].fromuid) { // If the previous message was from the other person, this is also a new set message.newSet = true; } @@ -176,7 +176,7 @@ var userNotifications = require('./user/notifications'); function(index, next) { // Continue only if this isn't the first message in sorted set if (index > 0) { - db.getSortedSetRange(key, index-1, index-1, next); + db.getSortedSetRange(key, index - 1, index - 1, next); } else { messages[0].newSet = true; return next(undefined, messages); @@ -191,7 +191,7 @@ var userNotifications = require('./user/notifications'); } if ( - (parseInt(messages[0].timestamp, 10) > parseInt(fields.timestamp, 10) + (1000*60*5)) || + (parseInt(messages[0].timestamp, 10) > parseInt(fields.timestamp, 10) + (1000 * 60 * 5)) || (parseInt(messages[0].fromuid, 10) !== parseInt(fields.fromuid, 10)) ) { // If it's been 5 minutes, this is a new set of messages diff --git a/src/middleware/header.js b/src/middleware/header.js index be56abc44b..3386e35856 100644 --- a/src/middleware/header.js +++ b/src/middleware/header.js @@ -50,7 +50,7 @@ module.exports = function(middleware) { 'brand:logo': meta.config['brand:logo'] || '', 'brand:logo:url': meta.config['brand:logo:url'] || '', 'brand:logo:alt': meta.config['brand:logo:alt'] || '', - 'brand:logo:display': meta.config['brand:logo']?'':'hide', + 'brand:logo:display': meta.config['brand:logo'] ? '' : 'hide', allowRegistration: registrationType === 'normal' || registrationType === 'admin-approval' || registrationType === 'admin-approval-ip', searchEnabled: plugins.hasListeners('filter:search.query'), config: res.locals.config, diff --git a/src/middleware/maintenance.js b/src/middleware/maintenance.js index 33079b88ef..2c8d30305b 100644 --- a/src/middleware/maintenance.js +++ b/src/middleware/maintenance.js @@ -43,7 +43,7 @@ module.exports = function(middleware) { }; var isAllowed = function(url) { - for(var x=0,numAllowed=allowedRoutes.length,route;x0; --i) { + for (i = pages.length - 1; i > 0; --i) { if (pages[i - 1].page !== pages[i].page - 1) { pages.splice(i, 0, {separator: true}); } diff --git a/src/plugins.js b/src/plugins.js index af3bc887c9..74cb39d034 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -126,7 +126,7 @@ var middleware; if (Plugins.versionWarning.length && nconf.get('isPrimary') === 'true') { process.stdout.write('\n'); winston.warn('[plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it.'); - for(var x=0,numPlugins=Plugins.versionWarning.length;x= preventTopicDeleteAfterReplies) { var langKey = preventTopicDeleteAfterReplies > 1 ? - '[[error:cant-delete-topic-has-replies, ' + meta.config.preventTopicDeleteAfterReplies + ']]': + '[[error:cant-delete-topic-has-replies, ' + meta.config.preventTopicDeleteAfterReplies + ']]' : '[[error:cant-delete-topic-has-reply]]'; return callback(new Error(langKey)); } diff --git a/src/routes/feeds.js b/src/routes/feeds.js index 3ceefbb4d6..721a34cffc 100644 --- a/src/routes/feeds.js +++ b/src/routes/feeds.js @@ -350,7 +350,7 @@ function generateForPostsFeed(feedOptions, posts) { feed.item({ title: postData.topic ? postData.topic.title : '', description: postData.content, - url: nconf.get('url') + '/topic/' + (postData.topic ? postData.topic.slug : '#') + '/'+postData.index, + url: nconf.get('url') + '/topic/' + (postData.topic ? postData.topic.slug : '#') + '/' + postData.index, author: postData.user ? postData.user.username : '', date: new Date(parseInt(postData.timestamp, 10)).toUTCString() }); diff --git a/src/routes/index.js b/src/routes/index.js index 659f4132ae..3ef899d4df 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -94,7 +94,7 @@ module.exports = function(app, middleware, hotswapIds) { var ensureLoggedIn = require('connect-ensure-login'); if (Array.isArray(hotswapIds) && hotswapIds.length) { - for(var idx,x=0;x parseInt(max, 10)) { - return callback(new Error('[[error:'+ maxError + ', ' + max + ']]')); + return callback(new Error('[[error:' + maxError + ', ' + max + ']]')); } callback(); } diff --git a/src/topics/data.js b/src/topics/data.js index 6e7172bb5f..9a7553f2b0 100644 --- a/src/topics/data.js +++ b/src/topics/data.js @@ -40,7 +40,7 @@ module.exports = function(Topics) { Topics.getTopicsData = function(tids, callback) { var keys = []; - for (var i=0; i 19) { diff --git a/src/user/data.js b/src/user/data.js index c8af4698a9..19c54895dc 100644 --- a/src/user/data.js +++ b/src/user/data.js @@ -126,7 +126,7 @@ module.exports = function(User) { user.status = User.getStatus(user); } - for(var i=0; i 10 seconds', function(done) { - User.setUserField(testUid, 'lastposttime', +new Date()-(11*1000), function() { + User.setUserField(testUid, 'lastposttime', +new Date() - (11 * 1000), function() { Topics.post({ uid: testUid, title: 'Topic 3', @@ -141,7 +141,7 @@ describe('User', function() { Meta.config.newbiePostDelay = 30; Meta.config.newbiePostDelayThreshold = 3; - User.setUserField(testUid, 'lastposttime', +new Date()-(20*1000), function() { + User.setUserField(testUid, 'lastposttime', +new Date() - (20 * 1000), function() { Topics.post({ uid: testUid, title: 'Topic 4', @@ -156,7 +156,7 @@ describe('User', function() { it('should not error if a non-newbie user posts if the last post time is 10 < 30 seconds', function(done) { User.setUserFields(testUid, { - lastposttime: +new Date()-(20*1000), + lastposttime: +new Date() - (20 * 1000), reputation: 10 }, function() { Topics.post({ From 4a3c31b2dcc81baea88739452f512aafc940034b Mon Sep 17 00:00:00 2001 From: HeeL Date: Thu, 13 Oct 2016 11:43:39 +0200 Subject: [PATCH 3/3] Fix space-before-function-paren linter rule --- .eslintrc.json | 1 - Gruntfile.js | 6 +- app.js | 24 +- bcrypt.js | 6 +- install/databases.js | 2 +- install/web.js | 18 +- loader.js | 34 +- minifier.js | 14 +- public/src/admin/admin.js | 58 +-- public/src/admin/advanced/errors.js | 12 +- public/src/admin/advanced/events.js | 8 +- public/src/admin/advanced/logs.js | 10 +- public/src/admin/appearance/customise.js | 10 +- public/src/admin/appearance/skins.js | 18 +- public/src/admin/appearance/themes.js | 24 +- public/src/admin/extend/plugins.js | 66 ++-- public/src/admin/extend/rewards.js | 30 +- public/src/admin/extend/widgets.js | 36 +- public/src/admin/general/dashboard.js | 24 +- public/src/admin/general/homepage.js | 4 +- public/src/admin/general/languages.js | 4 +- public/src/admin/general/navigation.js | 24 +- public/src/admin/general/social.js | 10 +- public/src/admin/general/sounds.js | 10 +- public/src/admin/manage/categories.js | 34 +- public/src/admin/manage/category-analytics.js | 8 +- public/src/admin/manage/category.js | 108 +++--- public/src/admin/manage/flags.js | 28 +- public/src/admin/manage/group.js | 38 +- public/src/admin/manage/groups.js | 30 +- public/src/admin/manage/ip-blacklist.js | 16 +- public/src/admin/manage/registration.js | 14 +- public/src/admin/manage/tags.js | 40 +- public/src/admin/manage/users.js | 88 ++--- public/src/admin/modules/colorpicker.js | 10 +- public/src/admin/modules/instance.js | 10 +- public/src/admin/modules/search.js | 14 +- public/src/admin/modules/selectable.js | 4 +- public/src/admin/settings.js | 34 +- public/src/admin/settings/email.js | 22 +- public/src/admin/settings/general.js | 12 +- public/src/ajaxify.js | 54 +-- public/src/app.js | 120 +++--- public/src/client/account/best.js | 4 +- public/src/client/account/bookmarks.js | 4 +- public/src/client/account/downvoted.js | 4 +- public/src/client/account/edit.js | 60 +-- public/src/client/account/edit/email.js | 6 +- public/src/client/account/edit/password.js | 10 +- public/src/client/account/edit/username.js | 6 +- public/src/client/account/followers.js | 4 +- public/src/client/account/following.js | 4 +- public/src/client/account/groups.js | 6 +- public/src/client/account/header.js | 40 +- public/src/client/account/info.js | 8 +- public/src/client/account/posts.js | 10 +- public/src/client/account/profile.js | 10 +- public/src/client/account/settings.js | 26 +- public/src/client/account/topics.js | 10 +- public/src/client/account/upvoted.js | 4 +- public/src/client/account/watched.js | 4 +- public/src/client/categories.js | 14 +- public/src/client/category.js | 54 +-- public/src/client/categoryTools.js | 36 +- public/src/client/chats.js | 98 ++--- public/src/client/chats/messages.js | 40 +- public/src/client/chats/recent.js | 12 +- public/src/client/chats/search.js | 16 +- public/src/client/compose.js | 4 +- public/src/client/footer.js | 6 +- public/src/client/groups/details.js | 60 +-- public/src/client/groups/list.js | 26 +- public/src/client/groups/memberlist.js | 22 +- public/src/client/infinitescroll.js | 12 +- public/src/client/login.js | 12 +- public/src/client/notifications.js | 16 +- public/src/client/pagination.js | 12 +- public/src/client/popular.js | 4 +- public/src/client/recent.js | 24 +- public/src/client/register.js | 42 +-- public/src/client/reset.js | 8 +- public/src/client/reset_code.js | 8 +- public/src/client/search.js | 18 +- public/src/client/tag.js | 8 +- public/src/client/tags.js | 22 +- public/src/client/topic.js | 40 +- public/src/client/topic/delete-posts.js | 16 +- public/src/client/topic/events.js | 24 +- public/src/client/topic/flag.js | 18 +- public/src/client/topic/fork.js | 18 +- public/src/client/topic/move.js | 22 +- public/src/client/topic/postTools.js | 108 +++--- public/src/client/topic/posts.js | 62 ++-- public/src/client/topic/threadTools.js | 54 +-- public/src/client/unread.js | 26 +- public/src/client/users.js | 24 +- public/src/installer/install.js | 14 +- public/src/modules/alerts.js | 12 +- public/src/modules/autocomplete.js | 22 +- public/src/modules/chat.js | 84 ++--- public/src/modules/components.js | 32 +- public/src/modules/coverPhoto.js | 16 +- public/src/modules/helpers.js | 44 +-- public/src/modules/iconSelect.js | 22 +- public/src/modules/navigator.js | 44 +-- public/src/modules/notifications.js | 38 +- public/src/modules/postSelect.js | 10 +- public/src/modules/search.js | 34 +- public/src/modules/settings.js | 8 +- public/src/modules/share.js | 10 +- public/src/modules/sort.js | 6 +- public/src/modules/sounds.js | 14 +- public/src/modules/taskbar.js | 26 +- public/src/modules/topicSelect.js | 14 +- public/src/modules/uploader.js | 26 +- public/src/overrides.js | 48 +-- public/src/sockets.js | 8 +- public/src/utils.js | 88 ++--- public/src/widgets.js | 16 +- src/analytics.js | 46 +-- src/batch.js | 28 +- src/categories.js | 96 ++--- src/categories/activeusers.js | 8 +- src/categories/create.js | 28 +- src/categories/data.js | 32 +- src/categories/delete.js | 40 +- src/categories/recentreplies.js | 92 ++--- src/categories/topics.js | 26 +- src/categories/unread.js | 20 +- src/categories/update.js | 30 +- src/controllers/accounts/chats.js | 18 +- src/controllers/accounts/edit.js | 38 +- src/controllers/accounts/follow.js | 10 +- src/controllers/accounts/groups.js | 8 +- src/controllers/accounts/helpers.js | 26 +- src/controllers/accounts/info.js | 8 +- src/controllers/accounts/notifications.js | 4 +- src/controllers/accounts/posts.js | 26 +- src/controllers/accounts/profile.js | 14 +- src/controllers/accounts/session.js | 8 +- src/controllers/accounts/settings.js | 34 +- src/controllers/admin/appearance.js | 2 +- src/controllers/admin/blacklist.js | 4 +- src/controllers/admin/cache.js | 2 +- src/controllers/admin/categories.js | 12 +- src/controllers/admin/dashboard.js | 28 +- src/controllers/admin/database.js | 8 +- src/controllers/admin/errors.js | 8 +- src/controllers/admin/events.js | 8 +- src/controllers/admin/flags.js | 18 +- src/controllers/admin/groups.js | 20 +- src/controllers/admin/homepage.js | 16 +- src/controllers/admin/info.js | 28 +- src/controllers/admin/languages.js | 6 +- src/controllers/admin/logger.js | 2 +- src/controllers/admin/logs.js | 4 +- src/controllers/admin/navigation.js | 6 +- src/controllers/admin/plugins.js | 22 +- src/controllers/admin/rewards.js | 4 +- src/controllers/admin/settings.js | 12 +- src/controllers/admin/social.js | 4 +- src/controllers/admin/sounds.js | 6 +- src/controllers/admin/tags.js | 4 +- src/controllers/admin/themes.js | 4 +- src/controllers/admin/uploads.js | 36 +- src/controllers/admin/users.js | 60 +-- src/controllers/admin/widgets.js | 4 +- src/controllers/api.js | 64 ++-- src/controllers/authentication.js | 78 ++-- src/controllers/categories.js | 6 +- src/controllers/category.js | 18 +- src/controllers/globalmods.js | 8 +- src/controllers/groups.js | 38 +- src/controllers/helpers.js | 26 +- src/controllers/index.js | 54 +-- src/controllers/popular.js | 4 +- src/controllers/posts.js | 4 +- src/controllers/recent.js | 6 +- src/controllers/search.js | 4 +- src/controllers/sitemap.js | 18 +- src/controllers/tags.js | 12 +- src/controllers/topics.js | 28 +- src/controllers/unread.js | 24 +- src/controllers/uploads.js | 40 +- src/controllers/users.js | 58 +-- src/coverPhoto.js | 4 +- src/database/mongo.js | 32 +- src/database/mongo/hash.js | 62 ++-- src/database/mongo/helpers.js | 8 +- src/database/mongo/list.js | 32 +- src/database/mongo/main.js | 36 +- src/database/mongo/sets.js | 70 ++-- src/database/mongo/sorted.js | 164 ++++----- src/database/redis.js | 18 +- src/database/redis/hash.js | 60 +-- src/database/redis/helpers.js | 14 +- src/database/redis/list.js | 34 +- src/database/redis/main.js | 64 ++-- src/database/redis/sets.js | 50 +-- src/database/redis/sorted.js | 110 +++--- src/emailer.js | 28 +- src/emitter.js | 8 +- src/events.js | 64 ++-- src/file.js | 24 +- src/groups.js | 138 +++---- src/groups/cover.js | 14 +- src/groups/create.js | 4 +- src/groups/delete.js | 14 +- src/groups/membership.js | 172 ++++----- src/groups/ownership.js | 14 +- src/groups/search.js | 44 +-- src/groups/update.js | 44 +-- src/hotswap.js | 6 +- src/image.js | 30 +- src/install.js | 42 +-- src/languages.js | 20 +- src/logger.js | 32 +- src/messaging.js | 122 +++---- src/messaging/create.js | 16 +- src/messaging/delete.js | 8 +- src/messaging/edit.js | 14 +- src/messaging/notifications.js | 30 +- src/messaging/rooms.js | 54 +-- src/messaging/unread.js | 16 +- src/meta.js | 12 +- src/meta/blacklist.js | 20 +- src/meta/configs.js | 18 +- src/meta/css.js | 46 +-- src/meta/dependencies.js | 10 +- src/meta/errors.js | 14 +- src/meta/js.js | 44 +-- src/meta/logs.js | 8 +- src/meta/settings.js | 18 +- src/meta/sounds.js | 48 +-- src/meta/tags.js | 14 +- src/meta/templates.js | 36 +- src/meta/themes.js | 24 +- src/middleware/admin.js | 30 +- src/middleware/header.js | 38 +- src/middleware/headers.js | 4 +- src/middleware/index.js | 38 +- src/middleware/maintenance.js | 12 +- src/middleware/ratelimit.js | 2 +- src/middleware/render.js | 26 +- src/middleware/user.js | 24 +- src/navigation/admin.js | 18 +- src/navigation/index.js | 8 +- src/notifications.js | 150 ++++---- src/pagination.js | 8 +- src/password.js | 8 +- src/plugins.js | 114 +++--- src/plugins/hooks.js | 26 +- src/plugins/install.js | 52 +-- src/plugins/load.js | 54 +-- src/posts.js | 76 ++-- src/posts/bookmarks.js | 28 +- src/posts/category.js | 28 +- src/posts/create.js | 30 +- src/posts/delete.js | 62 ++-- src/posts/edit.js | 26 +- src/posts/flags.js | 100 ++--- src/posts/parse.js | 10 +- src/posts/recent.js | 22 +- src/posts/summary.js | 38 +- src/posts/tools.js | 10 +- src/posts/topics.js | 32 +- src/posts/user.js | 42 +-- src/posts/votes.js | 54 +-- src/privileges/categories.js | 154 ++++---- src/privileges/helpers.js | 30 +- src/privileges/posts.js | 66 ++-- src/privileges/topics.js | 78 ++-- src/privileges/users.js | 36 +- src/pubsub.js | 6 +- src/reset.js | 22 +- src/rewards/admin.js | 44 +-- src/rewards/index.js | 40 +- src/routes/admin.js | 2 +- src/routes/api.js | 2 +- src/routes/authentication.js | 18 +- src/routes/debug.js | 4 +- src/routes/feeds.js | 44 +-- src/routes/helpers.js | 2 +- src/routes/index.js | 4 +- src/routes/meta.js | 2 +- src/routes/plugins.js | 8 +- src/search.js | 102 +++--- src/sitemap.js | 28 +- src/social.js | 18 +- src/socket.io/admin.js | 66 ++-- src/socket.io/admin/categories.js | 36 +- src/socket.io/admin/groups.js | 8 +- src/socket.io/admin/navigation.js | 2 +- src/socket.io/admin/rewards.js | 4 +- src/socket.io/admin/rooms.js | 34 +- src/socket.io/admin/social.js | 2 +- src/socket.io/admin/tags.js | 6 +- src/socket.io/admin/user.js | 68 ++-- src/socket.io/blacklist.js | 6 +- src/socket.io/categories.js | 64 ++-- src/socket.io/groups.js | 82 ++--- src/socket.io/helpers.js | 40 +- src/socket.io/index.js | 2 +- src/socket.io/meta.js | 10 +- src/socket.io/modules.js | 56 +-- src/socket.io/notifications.js | 16 +- src/socket.io/posts.js | 28 +- src/socket.io/posts/bookmarks.js | 6 +- src/socket.io/posts/edit.js | 12 +- src/socket.io/posts/flag.js | 24 +- src/socket.io/posts/helpers.js | 12 +- src/socket.io/posts/move.js | 4 +- src/socket.io/posts/tools.js | 58 +-- src/socket.io/posts/votes.js | 30 +- src/socket.io/topics.js | 24 +- src/socket.io/topics/infinitescroll.js | 20 +- src/socket.io/topics/move.js | 20 +- src/socket.io/topics/tags.js | 12 +- src/socket.io/topics/tools.js | 32 +- src/socket.io/topics/unread.js | 38 +- src/socket.io/user.js | 66 ++-- src/socket.io/user/ban.js | 16 +- src/socket.io/user/picture.js | 22 +- src/socket.io/user/profile.js | 24 +- src/socket.io/user/search.js | 6 +- src/socket.io/user/status.js | 10 +- src/topics.js | 128 +++---- src/topics/create.js | 94 ++--- src/topics/data.js | 30 +- src/topics/delete.js | 90 ++--- src/topics/follow.js | 44 +-- src/topics/fork.js | 60 +-- src/topics/popular.js | 22 +- src/topics/posts.js | 130 +++---- src/topics/recent.js | 24 +- src/topics/suggested.js | 28 +- src/topics/tags.js | 146 ++++---- src/topics/teaser.js | 40 +- src/topics/thumb.js | 20 +- src/topics/tools.js | 36 +- src/topics/unread.js | 110 +++--- src/topics/user.js | 8 +- src/upgrade.js | 260 ++++++------- src/user.js | 104 +++--- src/user/admin.js | 28 +- src/user/approval.js | 68 ++-- src/user/auth.js | 38 +- src/user/categories.js | 18 +- src/user/create.js | 68 ++-- src/user/data.js | 56 +-- src/user/delete.js | 66 ++-- src/user/digest.js | 24 +- src/user/email.js | 40 +- src/user/follow.js | 16 +- src/user/info.js | 38 +- src/user/invite.js | 58 +-- src/user/jobs.js | 10 +- src/user/notifications.js | 82 ++--- src/user/password.js | 12 +- src/user/picture.js | 46 +-- src/user/posts.js | 34 +- src/user/profile.js | 52 +-- src/user/reset.js | 56 +-- src/user/search.js | 38 +- src/user/settings.js | 32 +- src/user/topics.js | 6 +- src/webserver.js | 32 +- src/widgets/admin.js | 20 +- src/widgets/index.js | 44 +-- test/categories.js | 62 ++-- test/database.js | 6 +- test/database/hash.js | 174 ++++----- test/database/keys.js | 70 ++-- test/database/list.js | 80 ++-- test/database/sets.js | 116 +++--- test/database/sorted.js | 344 +++++++++--------- test/groups.js | 160 ++++---- test/messaging.js | 34 +- test/mocks/databasemock.js | 8 +- test/notifications.js | 44 +-- test/posts.js | 50 +-- test/topics.js | 212 +++++------ test/translator.js | 78 ++-- test/user.js | 120 +++--- test/utils.js | 18 +- 385 files changed, 6621 insertions(+), 6622 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 6d13f18de6..9e8e4dd35b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -56,7 +56,6 @@ "indent": "off", "func-names": "off", "prefer-arrow-callback": "off", - "space-before-function-paren": "off", "object-curly-spacing": "off", "no-var": "off", "no-shadow": "off", diff --git a/Gruntfile.js b/Gruntfile.js index eb3cdc7417..9f1585f301 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,7 +6,7 @@ var fork = require('child_process').fork, incomplete = []; -module.exports = function(grunt) { +module.exports = function (grunt) { var args = []; if (!grunt.option('verbose')) { args.push('--log-level=info'); @@ -34,7 +34,7 @@ module.exports = function(grunt) { fromFile = ['clientLess', 'acpLess', 'js', 'tpl']; } - fromFile = fromFile.filter(function(ext) { + fromFile = fromFile.filter(function (ext) { return incomplete.indexOf(ext) === -1; }); @@ -44,7 +44,7 @@ module.exports = function(grunt) { worker.kill(); worker = fork('app.js', updateArgs, { env: env }); - worker.on('message', function() { + worker.on('message', function () { if (incomplete.length) { incomplete = []; diff --git a/app.js b/app.js index 8e19fb5184..82ffd2f7b1 100644 --- a/app.js +++ b/app.js @@ -36,7 +36,7 @@ global.env = process.env.NODE_ENV || 'production'; winston.remove(winston.transports.Console); winston.add(winston.transports.Console, { colorize: true, - timestamp: function() { + timestamp: function () { var date = new Date(); return date.getDate() + '/' + (date.getMonth() + 1) + ' ' + date.toTimeString().substr(0,5) + ' [' + global.process.pid + ']'; }, @@ -146,7 +146,7 @@ function start() { process.on('SIGTERM', shutdown); process.on('SIGINT', shutdown); process.on('SIGHUP', restart); - process.on('message', function(message) { + process.on('message', function (message) { if (typeof message !== 'object') { return; } @@ -173,7 +173,7 @@ function start() { } }); - process.on('uncaughtException', function(err) { + process.on('uncaughtException', function (err) { winston.error(err.stack); console.log(err.stack); @@ -184,10 +184,10 @@ function start() { async.waterfall([ async.apply(db.init), async.apply(db.checkCompatibility), - function(next) { + function (next) { require('./src/meta').configs.init(next); }, - function(next) { + function (next) { if (nconf.get('dep-check') === undefined || nconf.get('dep-check') !== false) { require('./src/meta').dependencies.check(next); } else { @@ -195,10 +195,10 @@ function start() { setImmediate(next); } }, - function(next) { + function (next) { require('./src/upgrade').check(next); }, - function(next) { + function (next) { var webserver = require('./src/webserver'); require('./src/socket.io').init(webserver.server); @@ -209,7 +209,7 @@ function start() { webserver.listen(); } - ], function(err) { + ], function (err) { if (err) { switch(err.message) { case 'schema-out-of-date': @@ -280,7 +280,7 @@ function setup() { } function upgrade() { - require('./src/database').init(function(err) { + require('./src/database').init(function (err) { if (err) { winston.error(err.stack); process.exit(); @@ -292,7 +292,7 @@ function upgrade() { } function activate() { - require('./src/database').init(function(err) { + require('./src/database').init(function (err) { if (err) { winston.error(err.stack); process.exit(1); @@ -308,7 +308,7 @@ function activate() { } function listPlugins() { - require('./src/database').init(function(err) { + require('./src/database').init(function (err) { if (err) { winston.error(err.stack); process.exit(1); @@ -316,7 +316,7 @@ function listPlugins() { var db = require('./src/database'); - db.getSortedSetRange('plugins:active', 0, -1, function(err, plugins) { + db.getSortedSetRange('plugins:active', 0, -1, function (err, plugins) { if (err) { winston.error(err.stack); process.exit(1); diff --git a/bcrypt.js b/bcrypt.js index ae81d09eb7..4040aa2a8f 100644 --- a/bcrypt.js +++ b/bcrypt.js @@ -5,7 +5,7 @@ var bcrypt = require('bcryptjs'), async = require('async'); -process.on('message', function(msg) { +process.on('message', function (msg) { if (msg.type === 'hash') { hashPassword(msg.password, msg.rounds); } else if (msg.type === 'compare') { @@ -15,10 +15,10 @@ process.on('message', function(msg) { function hashPassword(password, rounds) { async.waterfall([ - function(next) { + function (next) { bcrypt.genSalt(parseInt(rounds, 10), next); }, - function(salt, next) { + function (salt, next) { bcrypt.hash(password, salt, next); } ], done); diff --git a/install/databases.js b/install/databases.js index f270dbe21e..c314ad75ef 100644 --- a/install/databases.js +++ b/install/databases.js @@ -9,7 +9,7 @@ var questions = { mongo: require('../src/database/mongo').questions }; -module.exports = function(config, callback) { +module.exports = function (config, callback) { async.waterfall([ function (next) { process.stdout.write('\n'); diff --git a/install/web.js b/install/web.js index b60614de07..72284fea5f 100644 --- a/install/web.js +++ b/install/web.js @@ -15,7 +15,7 @@ var server; winston.add(winston.transports.File, { filename: 'logs/webinstall.log', colorize: true, - timestamp: function() { + timestamp: function () { var date = new Date(); return date.getDate() + '/' + (date.getMonth() + 1) + ' ' + date.toTimeString().substr(0,5) + ' [' + global.process.pid + ']'; }, @@ -30,7 +30,7 @@ var scripts = [ 'public/src/installer/install.js' ]; -web.install = function(port) { +web.install = function (port) { port = port || 4567; winston.info('Launching web installer on port', port); @@ -42,7 +42,7 @@ web.install = function(port) { extended: true })); - async.parallel([compileLess, compileJS], function() { + async.parallel([compileLess, compileJS], function () { setupRoutes(); launchExpress(port); }); @@ -50,7 +50,7 @@ web.install = function(port) { function launchExpress(port) { - server = app.listen(port, function() { + server = app.listen(port, function () { winston.info('Web installer listening on http://%s:%s', '0.0.0.0', port); }); } @@ -63,7 +63,7 @@ function setupRoutes() { function welcome(req, res) { var dbs = ['redis', 'mongo']; - var databases = dbs.map(function(el) { + var databases = dbs.map(function (el) { return { name: el, questions: require('../src/database/' + el).questions @@ -93,7 +93,7 @@ function install(req, res) { env: process.env }); - child.on('close', function(data) { + child.on('close', function (data) { if (data === 0) { res.locals.success = true; } else { @@ -129,12 +129,12 @@ function compileLess(callback) { return callback(false); } - fs.readFile(path.join(__dirname, '../public/less/install.less'), function(err, style) { + fs.readFile(path.join(__dirname, '../public/less/install.less'), function (err, style) { if (err) { return winston.error('Unable to read LESS install file: ', err); } - less.render(style.toString(), function(err, css) { + less.render(style.toString(), function (err, css) { if(err) { return winston.error('Unable to compile LESS: ', err); } @@ -151,7 +151,7 @@ function compileJS(callback) { } var scriptPath = path.join(__dirname, '..'); - var result = uglify.minify(scripts.map(function(script) { + var result = uglify.minify(scripts.map(function (script) { return path.join(scriptPath, script); })); diff --git a/loader.js b/loader.js index 8eee556852..02a668c174 100644 --- a/loader.js +++ b/loader.js @@ -33,9 +33,9 @@ var pidFilePath = __dirname + '/pidfile', templatesCompiled: false }; -Loader.init = function(callback) { +Loader.init = function (callback) { if (silent) { - console.log = function() { + console.log = function () { var args = Array.prototype.slice.call(arguments); output.write(args.join(' ') + '\n'); }; @@ -47,7 +47,7 @@ Loader.init = function(callback) { callback(); }; -Loader.displayStartupMessages = function(callback) { +Loader.displayStartupMessages = function (callback) { console.log(''); console.log('NodeBB v' + pkg.version + ' Copyright (C) 2013-2014 NodeBB Inc.'); console.log('This program comes with ABSOLUTELY NO WARRANTY.'); @@ -57,16 +57,16 @@ Loader.displayStartupMessages = function(callback) { callback(); }; -Loader.addWorkerEvents = function(worker) { +Loader.addWorkerEvents = function (worker) { - worker.on('exit', function(code, signal) { + worker.on('exit', function (code, signal) { if (code !== 0) { if (Loader.timesStarted < numProcs * 3) { Loader.timesStarted++; if (Loader.crashTimer) { clearTimeout(Loader.crashTimer); } - Loader.crashTimer = setTimeout(function() { + Loader.crashTimer = setTimeout(function () { Loader.timesStarted = 0; }, 10000); } else { @@ -83,7 +83,7 @@ Loader.addWorkerEvents = function(worker) { } }); - worker.on('message', function(message) { + worker.on('message', function (message) { if (message && typeof message === 'object' && message.action) { switch (message.action) { case 'ready': @@ -148,7 +148,7 @@ Loader.addWorkerEvents = function(worker) { }); }; -Loader.start = function(callback) { +Loader.start = function (callback) { numProcs = getPorts().length; console.log('Clustering enabled: Spinning up ' + numProcs + ' process(es).\n'); @@ -205,22 +205,22 @@ function getPorts() { return port; } -Loader.restart = function() { +Loader.restart = function () { killWorkers(); nconf.remove('file'); nconf.use('file', { file: path.join(__dirname, '/config.json') }); Loader.start(); }; -Loader.reload = function() { - workers.forEach(function(worker) { +Loader.reload = function () { + workers.forEach(function (worker) { worker.send({ action: 'reload' }); }); }; -Loader.stop = function() { +Loader.stop = function () { killWorkers(); // Clean up the pidfile @@ -228,15 +228,15 @@ Loader.stop = function() { }; function killWorkers() { - workers.forEach(function(worker) { + workers.forEach(function (worker) { worker.suicide = true; worker.kill(); }); } -Loader.notifyWorkers = function(msg, worker_pid) { +Loader.notifyWorkers = function (msg, worker_pid) { worker_pid = parseInt(worker_pid, 10); - workers.forEach(function(worker) { + workers.forEach(function (worker) { if (parseInt(worker.pid, 10) !== worker_pid) { try { worker.send(msg); @@ -247,7 +247,7 @@ Loader.notifyWorkers = function(msg, worker_pid) { }); }; -fs.open(path.join(__dirname, 'config.json'), 'r', function(err) { +fs.open(path.join(__dirname, 'config.json'), 'r', function (err) { if (!err) { if (nconf.get('daemon') !== 'false' && nconf.get('daemon') !== false) { if (file.existsSync(pidFilePath)) { @@ -272,7 +272,7 @@ fs.open(path.join(__dirname, 'config.json'), 'r', function(err) { Loader.init, Loader.displayStartupMessages, Loader.start - ], function(err) { + ], function (err) { if (err) { console.log('[loader] Error during startup: ' + err.message); } diff --git a/minifier.js b/minifier.js index 50106e2957..25c0177175 100644 --- a/minifier.js +++ b/minifier.js @@ -12,18 +12,18 @@ var Minifier = { /* Javascript */ Minifier.js.minify = function (scripts, minify, callback) { - scripts = scripts.filter(function(file) { + scripts = scripts.filter(function (file) { return file && file.endsWith('.js'); }); - async.filter(scripts, function(script, next) { - file.exists(script, function(exists) { + async.filter(scripts, function (script, next) { + file.exists(script, function (exists) { if (!exists) { console.warn('[minifier] file not found, ' + script); } next(exists); }); - }, function(scripts) { + }, function (scripts) { if (minify) { minifyScripts(scripts, callback); } else { @@ -32,10 +32,10 @@ Minifier.js.minify = function (scripts, minify, callback) { }); }; -process.on('message', function(payload) { +process.on('message', function (payload) { switch(payload.action) { case 'js': - Minifier.js.minify(payload.scripts, payload.minify, function(minified/*, sourceMap*/) { + Minifier.js.minify(payload.scripts, payload.minify, function (minified/*, sourceMap*/) { process.send({ type: 'end', // sourceMap: sourceMap, @@ -65,7 +65,7 @@ function minifyScripts(scripts, callback) { } function concatenateScripts(scripts, callback) { - async.map(scripts, fs.readFile, function(err, scripts) { + async.map(scripts, fs.readFile, function (err, scripts) { if (err) { process.send({ type: 'error', diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js index 4351f4eae3..9d56403854 100644 --- a/public/src/admin/admin.js +++ b/public/src/admin/admin.js @@ -1,20 +1,20 @@ "use strict"; /*global config, componentHandler, socket, app, bootbox, Slideout, NProgress*/ -(function() { +(function () { var logoutTimer = 0; function startLogoutTimer() { if (logoutTimer) { clearTimeout(logoutTimer); } - logoutTimer = setTimeout(function() { - require(['translator'], function(translator) { - translator.translate('[[login:logged-out-due-to-inactivity]]', function(translated) { + logoutTimer = setTimeout(function () { + require(['translator'], function (translator) { + translator.translate('[[login:logged-out-due-to-inactivity]]', function (translated) { bootbox.alert({ closeButton: false, message: translated, - callback: function(){ + callback: function (){ window.location.reload(); } }); @@ -23,7 +23,7 @@ }, 3600000); } - $(window).on('action:ajaxify.end', function() { + $(window).on('action:ajaxify.end', function () { showCorrectNavTab(); startLogoutTimer(); }); @@ -35,11 +35,11 @@ } } - $(document).ready(function() { + $(document).ready(function () { setupKeybindings(); if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { - require(['admin/modules/search'], function(search) { + require(['admin/modules/search'], function (search) { search.init(); }); } @@ -51,7 +51,7 @@ setupNProgress(); }); - $(window).on('action:ajaxify.contentLoaded', function(ev, data) { + $(window).on('action:ajaxify.contentLoaded', function (ev, data) { selectMenuItem(data.url); setupRestartLinks(); @@ -59,28 +59,28 @@ }); function setupNProgress() { - $(window).on('action:ajaxify.start', function() { + $(window).on('action:ajaxify.start', function () { NProgress.set(0.7); }); - $(window).on('action:ajaxify.end', function() { + $(window).on('action:ajaxify.end', function () { NProgress.done(); }); } function setupKeybindings() { - require(['mousetrap'], function(mousetrap) { - mousetrap.bind('ctrl+shift+a r', function() { - require(['admin/modules/instance'], function(instance) { + require(['mousetrap'], function (mousetrap) { + mousetrap.bind('ctrl+shift+a r', function () { + require(['admin/modules/instance'], function (instance) { instance.reload(); }); }); - mousetrap.bind('ctrl+shift+a R', function() { + mousetrap.bind('ctrl+shift+a R', function () { socket.emit('admin.restart'); }); - mousetrap.bind('/', function() { + mousetrap.bind('/', function () { $('#acp-search input').focus(); return false; @@ -100,7 +100,7 @@ } $('#main-menu li').removeClass('active'); - $('#main-menu a').removeClass('active').each(function() { + $('#main-menu a').removeClass('active').each(function () { var menu = $(this), href = menu.attr('href'), isLink = menu.parent().attr('data-link') === '1'; @@ -115,7 +115,7 @@ }); var acpPath = url.replace('admin/', '').split('/'); - acpPath.forEach(function(path, i) { + acpPath.forEach(function (path, i) { acpPath[i] = path.charAt(0).toUpperCase() + path.slice(1); }); acpPath = acpPath.join(' > '); @@ -124,18 +124,18 @@ } function setupRestartLinks() { - $('.restart').off('click').on('click', function() { - bootbox.confirm('Are you sure you wish to restart NodeBB?', function(confirm) { + $('.restart').off('click').on('click', function () { + bootbox.confirm('Are you sure you wish to restart NodeBB?', function (confirm) { if (confirm) { - require(['admin/modules/instance'], function(instance) { + require(['admin/modules/instance'], function (instance) { instance.restart(); }); } }); }); - $('.reload').off('click').on('click', function() { - require(['admin/modules/instance'], function(instance) { + $('.reload').off('click').on('click', function () { + require(['admin/modules/instance'], function (instance) { instance.reload(); }); }); @@ -144,8 +144,8 @@ function launchSnackbar(params) { var message = (params.title ? "" + params.title + "" : '') + (params.message ? params.message : ''); - require(['translator'], function(translator) { - translator.translate(message, function(html) { + require(['translator'], function (translator) { + translator.translate(message, function (html) { var bar = $.snackbar({ content: html, timeout: 3000, @@ -167,15 +167,15 @@ 'tolerance': 70 }); - $('#mobile-menu').on('click', function() { + $('#mobile-menu').on('click', function () { slideout.toggle(); }); - $('#menu a').on('click', function() { + $('#menu a').on('click', function () { slideout.close(); }); - $(window).on('resize', function() { + $(window).on('resize', function () { slideout.close(); }); @@ -190,7 +190,7 @@ slideout.on('open', onOpeningMenu); slideout.on('translate', onOpeningMenu); - slideout.on('close', function() { + slideout.on('close', function () { $('#header').css({ 'top': '0px', 'position': 'fixed' diff --git a/public/src/admin/advanced/errors.js b/public/src/admin/advanced/errors.js index 3977778b5a..29ee7e362c 100644 --- a/public/src/admin/advanced/errors.js +++ b/public/src/admin/advanced/errors.js @@ -1,19 +1,19 @@ "use strict"; /*global config, define, app, socket, ajaxify, bootbox, templates, Chart, utils */ -define('admin/advanced/errors', ['Chart'], function(Chart) { +define('admin/advanced/errors', ['Chart'], function (Chart) { var Errors = {}; - Errors.init = function() { + Errors.init = function () { Errors.setupCharts(); $('[data-action="clear"]').on('click', Errors.clear404); }; - Errors.clear404 = function() { - bootbox.confirm('Are you sure you wish to clear the 404 error logs?', function(ok) { + Errors.clear404 = function () { + bootbox.confirm('Are you sure you wish to clear the 404 error logs?', function (ok) { if (ok) { - socket.emit('admin.errors.clear', {}, function(err) { + socket.emit('admin.errors.clear', {}, function (err) { if (err) { return app.alertError(err.message); } @@ -25,7 +25,7 @@ define('admin/advanced/errors', ['Chart'], function(Chart) { }); }; - Errors.setupCharts = function() { + Errors.setupCharts = function () { var notFoundCanvas = document.getElementById('not-found'), tooBusyCanvas = document.getElementById('toobusy'), dailyLabels = utils.getDaysArray(); diff --git a/public/src/admin/advanced/events.js b/public/src/admin/advanced/events.js index a952666786..b4f18414ea 100644 --- a/public/src/admin/advanced/events.js +++ b/public/src/admin/advanced/events.js @@ -3,13 +3,13 @@ /* global define, socket, app */ -define('admin/advanced/events', function() { +define('admin/advanced/events', function () { var Events = {}; - Events.init = function() { + Events.init = function () { - $('[data-action="clear"]').on('click', function() { - socket.emit('admin.deleteAllEvents', function(err) { + $('[data-action="clear"]').on('click', function () { + socket.emit('admin.deleteAllEvents', function (err) { if (err) { return app.alertError(err.message); } diff --git a/public/src/admin/advanced/logs.js b/public/src/admin/advanced/logs.js index 8411effabc..2ea10f1b36 100644 --- a/public/src/admin/advanced/logs.js +++ b/public/src/admin/advanced/logs.js @@ -1,22 +1,22 @@ "use strict"; /* global define, socket, app */ -define('admin/advanced/logs', function() { +define('admin/advanced/logs', function () { var Logs = {}; - Logs.init = function() { + Logs.init = function () { var logsEl = $('.logs pre'); logsEl.scrollTop(logsEl.prop('scrollHeight')); // Affix menu $('.affix').affix(); - $('.logs').find('button[data-action]').on('click', function(event) { + $('.logs').find('button[data-action]').on('click', function (event) { var btnEl = $(this), action = btnEl.attr('data-action'); switch(action) { case 'reload': - socket.emit('admin.logs.get', function(err, logs) { + socket.emit('admin.logs.get', function (err, logs) { if (!err) { logsEl.text(logs); logsEl.scrollTop(logsEl.prop('scrollHeight')); @@ -27,7 +27,7 @@ define('admin/advanced/logs', function() { break; case 'clear': - socket.emit('admin.logs.clear', function(err) { + socket.emit('admin.logs.clear', function (err) { if (!err) { app.alertSuccess('Logs Cleared!'); btnEl.prev().click(); diff --git a/public/src/admin/appearance/customise.js b/public/src/admin/appearance/customise.js index e76bb9d3e4..d8ad5e3ecb 100644 --- a/public/src/admin/appearance/customise.js +++ b/public/src/admin/appearance/customise.js @@ -1,11 +1,11 @@ "use strict"; /* global ace, define, app, socket */ -define('admin/appearance/customise', ['admin/settings'], function(Settings) { +define('admin/appearance/customise', ['admin/settings'], function (Settings) { var Customise = {}; - Customise.init = function() { - Settings.prepare(function() { + Customise.init = function () { + Settings.prepare(function () { $('#customCSS').text($('#customCSS-holder').val()); $('#customHTML').text($('#customHTML-holder').val()); @@ -15,7 +15,7 @@ define('admin/appearance/customise', ['admin/settings'], function(Settings) { customCSS.setTheme("ace/theme/twilight"); customCSS.getSession().setMode("ace/mode/css"); - customCSS.on('change', function(event) { + customCSS.on('change', function (event) { app.flags = app.flags || {}; app.flags._unsaved = true; $('#customCSS-holder').val(customCSS.getValue()); @@ -24,7 +24,7 @@ define('admin/appearance/customise', ['admin/settings'], function(Settings) { customHTML.setTheme("ace/theme/twilight"); customHTML.getSession().setMode("ace/mode/html"); - customHTML.on('change', function(event) { + customHTML.on('change', function (event) { app.flags = app.flags || {}; app.flags._unsaved = true; $('#customHTML-holder').val(customHTML.getValue()); diff --git a/public/src/admin/appearance/skins.js b/public/src/admin/appearance/skins.js index e489a453c5..9dc02a1efc 100644 --- a/public/src/admin/appearance/skins.js +++ b/public/src/admin/appearance/skins.js @@ -1,17 +1,17 @@ "use strict"; /* global define, app, socket, templates */ -define('admin/appearance/skins', function() { +define('admin/appearance/skins', function () { var Skins = {}; - Skins.init = function() { + Skins.init = function () { // Populate skins from Bootswatch API $.ajax({ method: 'get', url: 'https://bootswatch.com/api/3.json' }).done(Skins.render); - $('#skins').on('click', function(e){ + $('#skins').on('click', function (e){ var target = $(e.target); if (!target.attr('data-action')) { @@ -31,7 +31,7 @@ define('admin/appearance/skins', function() { type: themeType, id: themeId, src: cssSrc - }, function(err) { + }, function (err) { if (err) { return app.alertError(err.message); } @@ -49,11 +49,11 @@ define('admin/appearance/skins', function() { }); }; - Skins.render = function(bootswatch) { + Skins.render = function (bootswatch) { var themeContainer = $('#bootstrap_themes'); templates.parse('admin/partials/theme_list', { - themes: bootswatch.themes.map(function(theme) { + themes: bootswatch.themes.map(function (theme) { return { type: 'bootswatch', id: theme.name, @@ -66,13 +66,13 @@ define('admin/appearance/skins', function() { }; }), showRevert: true - }, function(html) { + }, function (html) { themeContainer.html(html); if (config['theme:src']) { var skin = config['theme:src'] .match(/latest\/(\S+)\/bootstrap.min.css/)[1] - .replace(/(^|\s)([a-z])/g , function(m,p1,p2){return p1 + p2.toUpperCase();}); + .replace(/(^|\s)([a-z])/g , function (m,p1,p2){return p1 + p2.toUpperCase();}); highlightSelectedTheme(skin); } @@ -82,7 +82,7 @@ define('admin/appearance/skins', function() { function highlightSelectedTheme(themeId) { $('[data-theme]') .removeClass('selected') - .find('[data-action="use"]').each(function() { + .find('[data-action="use"]').each(function () { if ($(this).parents('[data-theme]').attr('data-theme')) { $(this) .html('Select Skin') diff --git a/public/src/admin/appearance/themes.js b/public/src/admin/appearance/themes.js index 0d4e403fbd..41adcc1589 100644 --- a/public/src/admin/appearance/themes.js +++ b/public/src/admin/appearance/themes.js @@ -1,11 +1,11 @@ "use strict"; /* global define, app, socket, bootbox, templates, config */ -define('admin/appearance/themes', function() { +define('admin/appearance/themes', function () { var Themes = {}; - Themes.init = function() { - $('#installed_themes').on('click', function(e){ + Themes.init = function () { + $('#installed_themes').on('click', function (e){ var target = $(e.target), action = target.attr('data-action'); @@ -19,7 +19,7 @@ define('admin/appearance/themes', function() { type: themeType, id: themeId, src: cssSrc - }, function(err) { + }, function (err) { if (err) { return app.alertError(err.message); } @@ -31,7 +31,7 @@ define('admin/appearance/themes', function() { title: 'Theme Changed', message: 'Please restart your NodeBB to fully activate this theme', timeout: 5000, - clickfn: function() { + clickfn: function () { socket.emit('admin.restart'); } }); @@ -39,13 +39,13 @@ define('admin/appearance/themes', function() { } }); - $('#revert_theme').on('click', function() { - bootbox.confirm('Are you sure you wish to restore the default NodeBB theme?', function(confirm) { + $('#revert_theme').on('click', function () { + bootbox.confirm('Are you sure you wish to restore the default NodeBB theme?', function (confirm) { if (confirm) { socket.emit('admin.themes.set', { type: 'local', id: 'nodebb-theme-persona' - }, function(err) { + }, function (err) { if (err) { return app.alertError(err.message); } @@ -62,7 +62,7 @@ define('admin/appearance/themes', function() { }); }); - socket.emit('admin.themes.getInstalled', function(err, themes) { + socket.emit('admin.themes.getInstalled', function (err, themes) { if(err) { return app.alertError(err.message); } @@ -75,9 +75,9 @@ define('admin/appearance/themes', function() { } else { templates.parse('admin/partials/theme_list', { themes: themes - }, function(html) { - require(['translator'], function(translator) { - translator.translate(html, function(html) { + }, function (html) { + require(['translator'], function (translator) { + translator.translate(html, function (html) { instListEl.html(html); highlightSelectedTheme(config['theme:id']); }); diff --git a/public/src/admin/extend/plugins.js b/public/src/admin/extend/plugins.js index 3e12074e3a..bb89256959 100644 --- a/public/src/admin/extend/plugins.js +++ b/public/src/admin/extend/plugins.js @@ -1,9 +1,9 @@ "use strict"; /* global define, app, socket, bootbox */ -define('admin/extend/plugins', function() { +define('admin/extend/plugins', function () { var Plugins = {}; - Plugins.init = function() { + Plugins.init = function () { var pluginsList = $('.plugins'), numPlugins = pluginsList[0].querySelectorAll('li').length, pluginID; @@ -15,11 +15,11 @@ define('admin/extend/plugins', function() { $('#plugin-search').val(''); - pluginsList.on('click', 'button[data-action="toggleActive"]', function() { + pluginsList.on('click', 'button[data-action="toggleActive"]', function () { var pluginEl = $(this).parents('li'); pluginID = pluginEl.attr('data-plugin-id'); var btn = $('#' + pluginID + ' [data-action="toggleActive"]'); - socket.emit('admin.plugins.toggleActive', pluginID, function(err, status) { + socket.emit('admin.plugins.toggleActive', pluginID, function (err, status) { if (err) { return app.alertError(err); } @@ -37,8 +37,8 @@ define('admin/extend/plugins', function() { message: status.active ? 'Please restart your NodeBB to fully activate this plugin' : 'Plugin successfully deactivated', type: status.active ? 'warning' : 'success', timeout: 5000, - clickfn: function() { - require(['admin/modules/instance'], function(instance) { + clickfn: function () { + require(['admin/modules/instance'], function (instance) { instance.restart(); }); } @@ -46,7 +46,7 @@ define('admin/extend/plugins', function() { }); }); - pluginsList.on('click', 'button[data-action="toggleInstall"]', function() { + pluginsList.on('click', 'button[data-action="toggleInstall"]', function () { var btn = $(this); btn.attr('disabled', true); pluginID = $(this).parents('li').attr('data-plugin-id'); @@ -55,9 +55,9 @@ define('admin/extend/plugins', function() { return Plugins.toggleInstall(pluginID, $(this).parents('li').attr('data-version')); } - Plugins.suggest(pluginID, function(err, payload) { + Plugins.suggest(pluginID, function (err, payload) { if (err) { - bootbox.confirm('

NodeBB could not reach the package manager, proceed with installation of latest version?

Server returned (' + err.status + '): ' + err.responseText + '
', function(confirm) { + bootbox.confirm('

NodeBB could not reach the package manager, proceed with installation of latest version?

Server returned (' + err.status + '): ' + err.responseText + '
', function (confirm) { if (confirm) { Plugins.toggleInstall(pluginID, 'latest'); } else { @@ -67,11 +67,11 @@ define('admin/extend/plugins', function() { return; } - require(['semver'], function(semver) { + require(['semver'], function (semver) { if (payload.version !== 'latest') { Plugins.toggleInstall(pluginID, payload.version); } else if (payload.version === 'latest') { - confirmInstall(pluginID, function(confirm) { + confirmInstall(pluginID, function (confirm) { if (confirm) { Plugins.toggleInstall(pluginID, 'latest'); } else { @@ -85,21 +85,21 @@ define('admin/extend/plugins', function() { }); }); - pluginsList.on('click', 'button[data-action="upgrade"]', function() { + pluginsList.on('click', 'button[data-action="upgrade"]', function () { var btn = $(this); var parent = btn.parents('li'); pluginID = parent.attr('data-plugin-id'); - Plugins.suggest(pluginID, function(err, payload) { + Plugins.suggest(pluginID, function (err, payload) { if (err) { return bootbox.alert('

NodeBB could not reach the package manager, an upgrade is not suggested at this time.

'); } - require(['semver'], function(semver) { + require(['semver'], function (semver) { if (payload.version !== 'latest' && semver.gt(payload.version, parent.find('.currentVersion').text())) { upgrade(pluginID, btn, payload.version); } else if (payload.version === 'latest') { - confirmInstall(pluginID, function() { + confirmInstall(pluginID, function () { upgrade(pluginID, btn, payload.version); }); } else { @@ -109,22 +109,22 @@ define('admin/extend/plugins', function() { }); }); - $('#plugin-search').on('input propertychange', function() { + $('#plugin-search').on('input propertychange', function () { var term = $(this).val(); - $('.plugins li').each(function() { + $('.plugins li').each(function () { var pluginId = $(this).attr('data-plugin-id'); $(this).toggleClass('hide', pluginId && pluginId.indexOf(term) === -1); }); }); - $('#plugin-order').on('click', function() { + $('#plugin-order').on('click', function () { $('#order-active-plugins-modal').modal('show'); - socket.emit('admin.plugins.getActive', function(err, activePlugins) { + socket.emit('admin.plugins.getActive', function (err, activePlugins) { if (err) { return app.alertError(err); } var html = ''; - activePlugins.forEach(function(plugin) { + activePlugins.forEach(function (plugin) { html += '
  • ' + plugin + '
  • '; }); if (!activePlugins.length) { @@ -134,14 +134,14 @@ define('admin/extend/plugins', function() { }); }); - $('#save-plugin-order').on('click', function() { + $('#save-plugin-order').on('click', function () { var plugins = $('#order-active-plugins-modal .plugin-list').children(); var data = []; - plugins.each(function(index, el) { + plugins.each(function (index, el) { data.push({name: $(el).text(), order: index}); }); - socket.emit('admin.plugins.orderActivePlugins', data, function(err) { + socket.emit('admin.plugins.orderActivePlugins', data, function (err) { if (err) { return app.alertError(err.message); } @@ -158,7 +158,7 @@ define('admin/extend/plugins', function() { '

    No Compatibility Infomation Found

    This plugin did not specify a specific version for installation given your NodeBB version. Full compatibility cannot be guaranteed, and may cause your NodeBB to no longer start properly.

    ' + '

    In the event that NodeBB cannot boot properly:

    ' + '
    $ ./nodebb reset plugin="' + pluginID + '"
    ' + - '

    Continue installation of latest version of this plugin?

    ', function(confirm) { + '

    Continue installation of latest version of this plugin?

    ', function (confirm) { callback(confirm); }); } @@ -168,7 +168,7 @@ define('admin/extend/plugins', function() { socket.emit('admin.plugins.upgrade', { id: pluginID, version: version - }, function(err, isActive) { + }, function (err, isActive) { if (err) { return app.alertError(err.message); } @@ -183,8 +183,8 @@ define('admin/extend/plugins', function() { message: 'Please reload your NodeBB to fully upgrade this plugin', type: 'warning', timeout: 5000, - clickfn: function() { - require(['admin/modules/instance'], function(instance) { + clickfn: function () { + require(['admin/modules/instance'], function (instance) { instance.reload(); }); } @@ -193,7 +193,7 @@ define('admin/extend/plugins', function() { }); } - Plugins.toggleInstall = function(pluginID, version, callback) { + Plugins.toggleInstall = function (pluginID, version, callback) { var btn = $('li[data-plugin-id="' + pluginID + '"] button[data-action="toggleInstall"]'); var activateBtn = btn.siblings('[data-action="toggleActive"]'); btn.find('i').attr('class', 'fa fa-refresh fa-spin'); @@ -201,7 +201,7 @@ define('admin/extend/plugins', function() { socket.emit('admin.plugins.toggleInstall', { id: pluginID, version: version - }, function(err, pluginData) { + }, function (err, pluginData) { if (err) { btn.removeAttr('disabled'); return app.alertError(err.message); @@ -223,7 +223,7 @@ define('admin/extend/plugins', function() { }); }; - Plugins.suggest = function(pluginId, callback) { + Plugins.suggest = function (pluginId, callback) { var nbbVersion = app.config.version.match(/^\d\.\d\.\d/); $.ajax((app.config.registry || 'https://packages.nodebb.org') + '/api/v1/suggest', { type: 'GET', @@ -232,13 +232,13 @@ define('admin/extend/plugins', function() { version: nbbVersion[0] }, dataType: 'json' - }).done(function(payload) { + }).done(function (payload) { callback(undefined, payload); }).fail(callback); }; function populateUpgradeablePlugins() { - $('#installed ul li').each(function() { + $('#installed ul li').each(function () { if ($(this).children('[data-action="upgrade"]').length) { $('#upgrade ul').append($(this).clone(true)); } @@ -246,7 +246,7 @@ define('admin/extend/plugins', function() { } function populateActivePlugins() { - $('#installed ul li').each(function() { + $('#installed ul li').each(function () { if ($(this).hasClass('active')) { $('#active ul').append($(this).clone(true)); } else { diff --git a/public/src/admin/extend/rewards.js b/public/src/admin/extend/rewards.js index dd30a5cf00..939bdbb20d 100644 --- a/public/src/admin/extend/rewards.js +++ b/public/src/admin/extend/rewards.js @@ -1,7 +1,7 @@ "use strict"; /* global define, app, ajaxify, socket, templates, bootbox */ -define('admin/extend/rewards', function() { +define('admin/extend/rewards', function () { var rewards = {}; @@ -10,25 +10,25 @@ define('admin/extend/rewards', function() { conditions, conditionals; - rewards.init = function() { + rewards.init = function () { available = ajaxify.data.rewards; active = ajaxify.data.active; conditions = ajaxify.data.conditions; conditionals = ajaxify.data.conditionals; - $('[data-selected]').each(function() { + $('[data-selected]').each(function () { select($(this)); }); $('#active') - .on('change', '[data-selected]', function() { + .on('change', '[data-selected]', function () { update($(this)); }) - .on('click', '.delete', function() { + .on('click', '.delete', function () { var parent = $(this).parents('[data-id]'), id = parent.attr('data-id'); - socket.emit('admin.rewards.delete', {id: id}, function(err) { + socket.emit('admin.rewards.delete', {id: id}, function (err) { if (err) { app.alertError(err.message); } else { @@ -39,7 +39,7 @@ define('admin/extend/rewards', function() { parent.remove(); return false; }) - .on('click', '.toggle', function() { + .on('click', '.toggle', function () { var btn = $(this), disabled = btn.hasClass('btn-success'), id = $(this).parents('[data-id]').attr('data-id'); @@ -93,12 +93,12 @@ define('admin/extend/rewards', function() { return app.alertError('Illegal reward - no inputs found! ' + el.attr('data-selected')); } - inputs.forEach(function(input) { + inputs.forEach(function (input) { html += '