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 += '