');
$el.appendTo($('body'));
@@ -292,8 +296,8 @@
},
getHoursArray: function () {
- var currentHour = new Date().getHours(),
- labels = [];
+ var currentHour = new Date().getHours();
+ var labels = [];
for (var i = currentHour, ii = currentHour - 24; i > ii; i--) {
var hour = i < 0 ? 24 + i : i;
@@ -304,10 +308,10 @@
},
getDaysArray: function (from) {
- var currentDay = new Date(from || Date.now()).getTime(),
- months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
- labels = [],
- tmpDate;
+ var currentDay = new Date(from || Date.now()).getTime();
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+ var labels = [];
+ var tmpDate;
for(var x = 29; x >= 0; x--) {
tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x));
@@ -336,7 +340,9 @@
// get all the url params in a single key/value hash
params: function (options) {
- var a, hash = {}, params;
+ var a;
+ var hash = {};
+ var params;
options = options || {};
options.skipToType = options.skipToType || {};
@@ -347,9 +353,9 @@
params = (a ? a.search : window.location.search).substring(1).split("&");
params.forEach(function (param) {
- var val = param.split('='),
- key = decodeURI(val[0]),
- value = options.skipToType[key] ? decodeURI(val[1]) : utils.toType(decodeURI(val[1]));
+ var val = param.split('=');
+ var key = decodeURI(val[0]);
+ var value = options.skipToType[key] ? decodeURI(val[1]) : utils.toType(decodeURI(val[1]));
if (key) {
if (key.substr(-2, 2) === '[]') {
@@ -423,8 +429,8 @@
}
return obj[props];
}
- var prop = props.slice(0, i),
- newProps = props.slice(i + 1);
+ var prop = props.slice(0, i);
+ var newProps = props.slice(i + 1);
if(props !== undefined && !(obj[prop] instanceof Object) ) {
obj[prop] = {};
diff --git a/src/analytics.js b/src/analytics.js
index 4da4c819bb..6aa5bf0505 100644
--- a/src/analytics.js
+++ b/src/analytics.js
@@ -50,8 +50,8 @@ Analytics.pageView = function (payload) {
}
if (payload.path) {
- var categoryMatch = payload.path.match(isCategory),
- cid = categoryMatch ? parseInt(categoryMatch[1], 10) : null;
+ var categoryMatch = payload.path.match(isCategory);
+ var cid = categoryMatch ? parseInt(categoryMatch[1], 10) : null;
if (cid) {
Analytics.increment(['pageviews:byCid:' + cid]);
@@ -103,8 +103,8 @@ Analytics.writeData = function (callback) {
};
Analytics.getHourlyStatsForSet = function (set, hour, numHours, callback) {
- var terms = {},
- hoursArr = [];
+ var terms = {};
+ var hoursArr = [];
hour = new Date(hour);
hour.setHours(hour.getHours(), 0, 0, 0);
diff --git a/src/batch.js b/src/batch.js
index 53f88bfc05..19595df07e 100644
--- a/src/batch.js
+++ b/src/batch.js
@@ -57,7 +57,7 @@ exports.processSortedSet = function (setKey, process, options, callback) {
});
});
},
- callback,
+ callback
);
};
@@ -105,6 +105,6 @@ exports.processArray = function (array, process, options, callback) {
},
function (err) {
callback(err);
- },
+ }
);
};
diff --git a/src/categories.js b/src/categories.js
index 4021f05749..32aa5bf88b 100644
--- a/src/categories.js
+++ b/src/categories.js
@@ -293,7 +293,10 @@ var privileges = require('./privileges');
* @param parentCid {number} start from 0 to build full tree
*/
Categories.getTree = function (categories, parentCid) {
- var tree = [], i = 0, len = categories.length, category;
+ var tree = [];
+ var i = 0;
+ var len = categories.length;
+ var category;
for (i; i < len; ++i) {
category = categories[i];
diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.js
index 29d7ca57a7..f6279aa8eb 100644
--- a/src/controllers/accounts/profile.js
+++ b/src/controllers/accounts/profile.js
@@ -120,7 +120,7 @@ profileController.get = function (req, res, callback) {
property: "og:image:url",
content: userData.picture,
noEscape: true,
- },
+ }
);
}
userData.selectedGroup = userData.groups.find(function (group) {
diff --git a/src/controllers/admin/themes.js b/src/controllers/admin/themes.js
index 4f6f3e1f3b..1cf51ae7e6 100644
--- a/src/controllers/admin/themes.js
+++ b/src/controllers/admin/themes.js
@@ -12,8 +12,8 @@ themesController.get = function (req, res, next) {
return next();
}
- var themeConfig = require(path.join(themeDir, 'theme.json')),
- screenshotPath = path.join(themeDir, themeConfig.screenshot);
+ var themeConfig = require(path.join(themeDir, 'theme.json'));
+ var screenshotPath = path.join(themeDir, themeConfig.screenshot);
if (themeConfig.screenshot && file.existsSync(screenshotPath)) {
res.sendFile(screenshotPath);
} else {
diff --git a/src/controllers/admin/uploads.js b/src/controllers/admin/uploads.js
index 701294153b..3ed6f9b6f4 100644
--- a/src/controllers/admin/uploads.js
+++ b/src/controllers/admin/uploads.js
@@ -55,9 +55,9 @@ uploadsController.uploadFavicon = function (req, res, next) {
};
uploadsController.uploadTouchIcon = function (req, res, next) {
- var uploadedFile = req.files.files[0],
- allowedTypes = ['image/png'],
- sizes = [36, 48, 72, 96, 144, 192];
+ var uploadedFile = req.files.files[0];
+ var allowedTypes = ['image/png'];
+ var sizes = [36, 48, 72, 96, 144, 192];
if (validateUpload(req, res, next, uploadedFile, allowedTypes)) {
file.saveFileToLocal('touchicon-orig.png', 'system', uploadedFile.path, function (err, imageObj) {
@@ -105,8 +105,8 @@ uploadsController.uploadSound = function (req, res, next) {
return next(err);
}
- var soundsPath = path.join(__dirname, '../../../build/public/sounds'),
- filePath = path.join(nconf.get('upload_path'), 'sounds', uploadedFile.name);
+ var soundsPath = path.join(__dirname, '../../../build/public/sounds');
+ var filePath = path.join(nconf.get('upload_path'), 'sounds', uploadedFile.name);
file.link(filePath, path.join(soundsPath, path.basename(filePath)));
diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js
index 289b43055e..6561bc5385 100644
--- a/src/controllers/authentication.js
+++ b/src/controllers/authentication.js
@@ -343,7 +343,8 @@ authenticationController.localLogin = function (req, username, password, next) {
}
var userslug = utils.slugify(username);
- var uid, userData = {};
+ var uid;
+ var userData = {};
async.waterfall([
function (next) {
diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js
index 214d796ddd..ef76db33d9 100644
--- a/src/database/mongo/sorted.js
+++ b/src/database/mongo/sorted.js
@@ -259,9 +259,9 @@ module.exports = function (db, module) {
return callback(err);
}
- var map = helpers.toMap(result),
- returnData = [],
- item;
+ var map = helpers.toMap(result);
+ var returnData = [];
+ var item;
for(var i = 0; i < keys.length; ++i) {
item = map[keys[i]];
@@ -500,7 +500,7 @@ module.exports = function (db, module) {
});
});
},
- callback,
+ callback
);
};
diff --git a/src/database/redis/sorted.js b/src/database/redis/sorted.js
index 1e8c629fa9..90e2cfdf08 100644
--- a/src/database/redis/sorted.js
+++ b/src/database/redis/sorted.js
@@ -198,7 +198,8 @@ module.exports = function (redisClient, module) {
function sortedSetLex(method, reverse, key, min, max, start, count, callback) {
callback = callback || start;
- var minmin, maxmax;
+ var minmin;
+ var maxmax;
if (reverse) {
minmin = '+';
maxmax = '-';
diff --git a/src/groups.js b/src/groups.js
index 5f8102a807..5db8c32c83 100644
--- a/src/groups.js
+++ b/src/groups.js
@@ -20,30 +20,30 @@ var utils = require('../public/src/utils');
require('./groups/search')(Groups);
require('./groups/cover')(Groups);
- var ephemeralGroups = ['guests'],
-
- internals = {
- getEphemeralGroup: function (groupName) {
- return {
- name: groupName,
- slug: utils.slugify(groupName),
- description: '',
- deleted: '0',
- hidden: '0',
- system: '1',
- };
- },
- removeEphemeralGroups: function (groups) {
- var x = groups.length;
- while(x--) {
- if (ephemeralGroups.indexOf(groups[x]) !== -1) {
- groups.splice(x, 1);
- }
+ var ephemeralGroups = ['guests'];
+
+ var internals = {
+ getEphemeralGroup: function (groupName) {
+ return {
+ name: groupName,
+ slug: utils.slugify(groupName),
+ description: '',
+ deleted: '0',
+ hidden: '0',
+ system: '1',
+ };
+ },
+ removeEphemeralGroups: function (groups) {
+ var x = groups.length;
+ while(x--) {
+ if (ephemeralGroups.indexOf(groups[x]) !== -1) {
+ groups.splice(x, 1);
}
+ }
- return groups;
- },
- };
+ return groups;
+ },
+ };
Groups.internals = internals;
diff --git a/src/groups/ownership.js b/src/groups/ownership.js
index 7edaf19659..9bb007a7da 100644
--- a/src/groups/ownership.js
+++ b/src/groups/ownership.js
@@ -1,8 +1,8 @@
'use strict';
-var async = require('async'),
- db = require('../database'),
- plugins = require('../plugins');
+var async = require('async');
+var db = require('../database');
+var plugins = require('../plugins');
module.exports = function (Groups) {
diff --git a/src/hotswap.js b/src/hotswap.js
index ece8f205d7..9fa776a16a 100644
--- a/src/hotswap.js
+++ b/src/hotswap.js
@@ -1,8 +1,8 @@
"use strict";
-var HotSwap = {},
- winston = require('winston'),
- stack;
+var HotSwap = {};
+var winston = require('winston');
+var stack;
HotSwap.prepare = function (app) {
stack = app._router.stack;
diff --git a/src/image.js b/src/image.js
index 4ecb49387a..54777d6c79 100644
--- a/src/image.js
+++ b/src/image.js
@@ -24,13 +24,13 @@ image.resizeImage = function (data, callback) {
return callback(err);
}
- var w = image.bitmap.width,
- h = image.bitmap.height,
- origRatio = w / h,
- desiredRatio = data.width && data.height ? data.width / data.height : origRatio,
- x = 0,
- y = 0,
- crop;
+ var w = image.bitmap.width;
+ var h = image.bitmap.height;
+ var origRatio = w / h;
+ var desiredRatio = data.width && data.height ? data.width / data.height : origRatio;
+ var x = 0;
+ var y = 0;
+ var crop;
if (origRatio !== desiredRatio) {
if (desiredRatio > origRatio) {
diff --git a/src/install.js b/src/install.js
index 8e9b32fee7..4c3e4df0ec 100644
--- a/src/install.js
+++ b/src/install.js
@@ -228,84 +228,84 @@ function createAdmin(callback) {
winston.warn('No administrators have been detected, running initial user setup\n');
var questions = [{
- name: 'username',
- description: 'Administrator username',
- required: true,
- type: 'string',
- }, {
- name: 'email',
- description: 'Administrator email address',
- pattern: /.+@.+/,
- required: true,
- }],
- passwordQuestions = [{
- name: 'password',
- description: 'Password',
- required: true,
- hidden: true,
- type: 'string',
- }, {
- name: 'password:confirm',
- description: 'Confirm Password',
- required: true,
- hidden: true,
- type: 'string',
- }],
- success = function (err, results) {
+ name: 'username',
+ description: 'Administrator username',
+ required: true,
+ type: 'string',
+ }, {
+ name: 'email',
+ description: 'Administrator email address',
+ pattern: /.+@.+/,
+ required: true,
+ }];
+ var passwordQuestions = [{
+ name: 'password',
+ description: 'Password',
+ required: true,
+ hidden: true,
+ type: 'string',
+ }, {
+ name: 'password:confirm',
+ description: 'Confirm Password',
+ required: true,
+ hidden: true,
+ type: 'string',
+ }];
+ function success(err, results) {
+ if (err) {
+ return callback(err);
+ }
+ if (!results) {
+ return callback(new Error('aborted'));
+ }
+
+ if (results['password:confirm'] !== results.password) {
+ winston.warn("Passwords did not match, please try again");
+ return retryPassword(results);
+ }
+
+ if (results.password.length < meta.config.minimumPasswordLength) {
+ winston.warn("Password too short, please try again");
+ return retryPassword(results);
+ }
+
+ var adminUid;
+ async.waterfall([
+ function (next) {
+ User.create({username: results.username, password: results.password, email: results.email}, next);
+ },
+ function (uid, next) {
+ adminUid = uid;
+ Groups.join('administrators', uid, next);
+ },
+ function (next) {
+ Groups.show('administrators', next);
+ },
+ function (next) {
+ Groups.ownership.grant(adminUid, 'administrators', next);
+ },
+ ], function (err) {
if (err) {
return callback(err);
}
+ callback(null, password ? results : undefined);
+ });
+ }
+ function retryPassword(originalResults) {
+ // Ask only the password questions
+ prompt.get(passwordQuestions, function (err, results) {
if (!results) {
return callback(new Error('aborted'));
}
- if (results['password:confirm'] !== results.password) {
- winston.warn("Passwords did not match, please try again");
- return retryPassword(results);
- }
-
- if (results.password.length < meta.config.minimumPasswordLength) {
- winston.warn("Password too short, please try again");
- return retryPassword(results);
- }
-
- var adminUid;
- async.waterfall([
- function (next) {
- User.create({username: results.username, password: results.password, email: results.email}, next);
- },
- function (uid, next) {
- adminUid = uid;
- Groups.join('administrators', uid, next);
- },
- function (next) {
- Groups.show('administrators', next);
- },
- function (next) {
- Groups.ownership.grant(adminUid, 'administrators', next);
- },
- ], function (err) {
- if (err) {
- return callback(err);
- }
- callback(null, password ? results : undefined);
- });
- },
- retryPassword = function (originalResults) {
- // Ask only the password questions
- prompt.get(passwordQuestions, function (err, results) {
- if (!results) {
- return callback(new Error('aborted'));
- }
-
- // Update the original data with newly collected password
- originalResults.password = results.password;
- originalResults['password:confirm'] = results['password:confirm'];
+ // Update the original data with newly collected password
+ originalResults.password = results.password;
+ originalResults['password:confirm'] = results['password:confirm'];
- // Send back to success to handle
- success(err, originalResults);
- });
- };
+ // Send back to success to handle
+ success(err, originalResults);
+ });
+ }
// Add the password questions
questions = questions.concat(passwordQuestions);
@@ -389,16 +389,16 @@ function createMenuItems(next) {
if (err || exists) {
return next(err);
}
- var navigation = require('./navigation/admin'),
- data = require('../install/data/navigation.json');
+ var navigation = require('./navigation/admin');
+ var data = require('../install/data/navigation.json');
navigation.save(data, next);
});
}
function createWelcomePost(next) {
- var db = require('./database'),
- Topics = require('./topics');
+ var db = require('./database');
+ var Topics = require('./topics');
async.parallel([
function (next) {
@@ -412,8 +412,8 @@ function createWelcomePost(next) {
return next(err);
}
- var content = results[0],
- numTopics = results[1];
+ var content = results[0];
+ var numTopics = results[1];
if (!parseInt(numTopics, 10)) {
process.stdout.write('Creating welcome post!\n');
@@ -434,16 +434,16 @@ function enableDefaultPlugins(next) {
process.stdout.write('Enabling default plugins\n');
var defaultEnabled = [
- 'nodebb-plugin-composer-default',
- 'nodebb-plugin-markdown',
- 'nodebb-plugin-mentions',
- 'nodebb-widget-essentials',
- 'nodebb-rewards-essentials',
- 'nodebb-plugin-soundpack-default',
- 'nodebb-plugin-emoji-extended',
- 'nodebb-plugin-emoji-one',
- ],
- customDefaults = nconf.get('defaultPlugins');
+ 'nodebb-plugin-composer-default',
+ 'nodebb-plugin-markdown',
+ 'nodebb-plugin-mentions',
+ 'nodebb-widget-essentials',
+ 'nodebb-rewards-essentials',
+ 'nodebb-plugin-soundpack-default',
+ 'nodebb-plugin-emoji-extended',
+ 'nodebb-plugin-emoji-one',
+ ];
+ var customDefaults = nconf.get('defaultPlugins');
winston.info('[install/defaultPlugins] customDefaults', customDefaults);
diff --git a/src/logger.js b/src/logger.js
index f098ef7289..87e14d2f65 100644
--- a/src/logger.js
+++ b/src/logger.js
@@ -4,14 +4,14 @@
* Logger module: ability to dynamically turn on/off logging for http requests & socket.io events
*/
-var fs = require('fs'),
- path = require('path'),
- winston = require('winston'),
- util = require('util'),
-
- file = require('./file'),
- meta = require('./meta'),
- morgan = require('morgan');
+var fs = require('fs');
+var path = require('path');
+var winston = require('winston');
+var util = require('util');
+
+var file = require('./file');
+var meta = require('./meta');
+var morgan = require('morgan');
var opts = {
/*
diff --git a/src/meta/blacklist.js b/src/meta/blacklist.js
index 97f6b5b974..3487d31f41 100644
--- a/src/meta/blacklist.js
+++ b/src/meta/blacklist.js
@@ -78,9 +78,9 @@ Blacklist.validate = function (rules, callback) {
var cidr = [];
var invalid = [];
- var isCidrSubnet = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/,
- inlineCommentMatch = /#.*$/,
- whitelist = ['127.0.0.1', '::1', '::ffff:0:127.0.0.1'];
+ var isCidrSubnet = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/;
+ var inlineCommentMatch = /#.*$/;
+ var whitelist = ['127.0.0.1', '::1', '::ffff:0:127.0.0.1'];
// Filter out blank lines and lines starting with the hash character (comments)
// Also trim inputs and remove inline comments
diff --git a/src/meta/css.js b/src/meta/css.js
index fd3c526e48..99c4abd96b 100644
--- a/src/meta/css.js
+++ b/src/meta/css.js
@@ -90,8 +90,8 @@ module.exports = function (Meta) {
};
function getStyleSource(files, prefix, extension, callback) {
- var pluginDirectories = [],
- source = '';
+ var pluginDirectories = [];
+ var source = '';
files.forEach(function (styleFile) {
if (styleFile.endsWith(extension)) {
diff --git a/src/meta/languages.js b/src/meta/languages.js
index b7c79db5ba..c386141ccb 100644
--- a/src/meta/languages.js
+++ b/src/meta/languages.js
@@ -38,7 +38,8 @@ function getTranslationTree(callback) {
// generate list of languages and namespaces
function (plugins, next) {
- var languages = [], namespaces = [];
+ var languages = [];
+ namespaces = [];
// pull languages and namespaces from paths
function extrude(languageDir, paths) {
diff --git a/src/meta/templates.js b/src/meta/templates.js
index f15efd0fa9..c30db7f3b7 100644
--- a/src/meta/templates.js
+++ b/src/meta/templates.js
@@ -21,8 +21,9 @@ Templates.compile = function (callback) {
function getBaseTemplates(theme) {
- var baseTemplatesPaths = [],
- baseThemePath, baseThemeConfig;
+ var baseTemplatesPaths = [];
+ var baseThemePath;
+ var baseThemeConfig;
while (theme) {
baseThemePath = path.join(nconf.get('themes_path'), theme);
@@ -78,9 +79,9 @@ function preparePaths(baseTemplatesPaths, callback) {
}, next);
},
}, function (err, data) {
- var baseThemes = data.baseThemes,
- coreTpls = data.coreTpls,
- paths = {};
+ var baseThemes = data.baseThemes;
+ var coreTpls = data.coreTpls;
+ var paths = {};
coreTpls.forEach(function (el, i) {
paths[coreTpls[i].replace(coreTemplatesPath, '')] = coreTpls[i];
@@ -104,9 +105,9 @@ function preparePaths(baseTemplatesPaths, callback) {
}
function compile(callback) {
- var themeConfig = require(nconf.get('theme_config')),
- baseTemplatesPaths = themeConfig.baseTheme ? getBaseTemplates(themeConfig.baseTheme) : [nconf.get('base_templates_path')],
- viewsPath = nconf.get('views_dir');
+ var themeConfig = require(nconf.get('theme_config'));
+ var baseTemplatesPaths = themeConfig.baseTheme ? getBaseTemplates(themeConfig.baseTheme) : [nconf.get('base_templates_path')];
+ var viewsPath = nconf.get('views_dir');
preparePaths(baseTemplatesPaths, function (err, paths) {
@@ -115,9 +116,9 @@ function compile(callback) {
}
async.each(Object.keys(paths), function (relativePath, next) {
- var file = fs.readFileSync(paths[relativePath]).toString(),
- matches = null,
- regex = /[ \t]*[ \t]*/;
+ var file = fs.readFileSync(paths[relativePath]).toString();
+ var matches = null;
+ var regex = /[ \t]*[ \t]*/;
while((matches = file.match(regex)) !== null) {
var partial = "/" + matches[1];
diff --git a/src/meta/themes.js b/src/meta/themes.js
index 0a21dc32b1..9dfc9f376b 100644
--- a/src/meta/themes.js
+++ b/src/meta/themes.js
@@ -153,8 +153,8 @@ module.exports = function (Meta) {
Meta.themes.setPath = function (themeObj) {
// Theme's templates path
- var themePath = nconf.get('base_templates_path'),
- fallback = path.join(nconf.get('themes_path'), themeObj.id, 'templates');
+ var themePath = nconf.get('base_templates_path');
+ var fallback = path.join(nconf.get('themes_path'), themeObj.id, 'templates');
if (themeObj.templates) {
themePath = path.join(nconf.get('themes_path'), themeObj.id, themeObj.templates);
diff --git a/src/middleware/index.js b/src/middleware/index.js
index 7f01ea06a2..fd1c816a80 100644
--- a/src/middleware/index.js
+++ b/src/middleware/index.js
@@ -184,9 +184,9 @@ middleware.applyBlacklist = function (req, res, next) {
};
middleware.processTimeagoLocales = function (req, res, next) {
- var fallback = req.path.indexOf('-short') === -1 ? 'jquery.timeago.en.js' : 'jquery.timeago.en-short.js',
- localPath = path.join(__dirname, '../../public/vendor/jquery/timeago/locales', req.path),
- exists;
+ var fallback = req.path.indexOf('-short') === -1 ? 'jquery.timeago.en.js' : 'jquery.timeago.en-short.js';
+ var localPath = path.join(__dirname, '../../public/vendor/jquery/timeago/locales', req.path);
+ var exists;
try {
exists = fs.accessSync(localPath, fs.F_OK | fs.R_OK);
diff --git a/src/notifications.js b/src/notifications.js
index 9faf5a3bfa..74453e5046 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -373,8 +373,8 @@ var utils = require('../public/src/utils');
};
Notifications.prune = function () {
- var week = 604800000,
- numPruned = 0;
+ var week = 604800000;
+ var numPruned = 0;
var cutoffTime = Date.now() - week;
@@ -411,13 +411,17 @@ var utils = require('../public/src/utils');
Notifications.merge = function (notifications, callback) {
// When passed a set of notification objects, merge any that can be merged
var mergeIds = [
- 'notifications:upvoted_your_post_in',
- 'notifications:user_started_following_you',
- 'notifications:user_posted_to',
- 'notifications:user_flagged_post_in',
- 'new_register',
- ],
- isolated, differentiators, differentiator, modifyIndex, set;
+ 'notifications:upvoted_your_post_in',
+ 'notifications:user_started_following_you',
+ 'notifications:user_posted_to',
+ 'notifications:user_flagged_post_in',
+ 'new_register',
+ ];
+ var isolated;
+ var differentiators;
+ var differentiator;
+ var modifyIndex;
+ var set;
notifications = mergeIds.reduce(function (notifications, mergeId) {
isolated = notifications.filter(function (notifObj) {
diff --git a/src/plugins.js b/src/plugins.js
index 84a9e148f7..5dfead6383 100644
--- a/src/plugins.js
+++ b/src/plugins.js
@@ -147,8 +147,8 @@ var middleware;
};
Plugins.getTemplates = function (callback) {
- var templates = {},
- tplName;
+ var templates = {};
+ var tplName;
async.waterfall([
async.apply(db.getSortedSetRange, 'plugins:active', 0, -1),
diff --git a/src/plugins/hooks.js b/src/plugins/hooks.js
index be0fb4cf8f..979cf90994 100644
--- a/src/plugins/hooks.js
+++ b/src/plugins/hooks.js
@@ -1,7 +1,7 @@
'use strict';
-var winston = require('winston'),
- async = require('async');
+var winston = require('winston');
+var async = require('async');
module.exports = function (Plugins) {
Plugins.deprecatedHooks = {
@@ -36,7 +36,7 @@ module.exports = function (Plugins) {
(Plugins.deprecatedHooks[data.hook] ?
'please use `' + Plugins.deprecatedHooks[data.hook] + '` instead.' :
'there is no alternative.'
- ),
+ )
);
} else {
// handle hook's startsWith, i.e. action:homepage.get
diff --git a/src/posts/parse.js b/src/posts/parse.js
index e4b4cc7d3c..7497dc6781 100644
--- a/src/posts/parse.js
+++ b/src/posts/parse.js
@@ -49,7 +49,9 @@ module.exports = function (Posts) {
Posts.relativeToAbsolute = function (content) {
// Turns relative links in post body to absolute urls
- var parsed, current, absolute;
+ var parsed;
+ var current;
+ var absolute;
while ((current = urlRegex.exec(content)) !== null) {
if (current[1]) {
@@ -76,8 +78,8 @@ module.exports = function (Posts) {
};
function sanitizeSignature(signature) {
- var string = S(signature),
- tagsToStrip = [];
+ var string = S(signature);
+ var tagsToStrip = [];
if (parseInt(meta.config['signatures:disableLinks'], 10) === 1) {
tagsToStrip.push('a');
diff --git a/src/posts/votes.js b/src/posts/votes.js
index d13acf3736..3ecf71a018 100644
--- a/src/posts/votes.js
+++ b/src/posts/votes.js
@@ -158,9 +158,9 @@ module.exports = function (Posts) {
return callback(new Error('[[error:not-enough-reputation-to-downvote]]'));
}
- var voteStatus = results.voteStatus,
- hook,
- current = voteStatus.upvoted ? 'upvote' : 'downvote';
+ var voteStatus = results.voteStatus;
+ var hook;
+ var current = voteStatus.upvoted ? 'upvote' : 'downvote';
if (voteStatus.upvoted && command === 'downvote' || voteStatus.downvoted && command === 'upvote') { // e.g. User *has* upvoted, and clicks downvote
hook = command;
diff --git a/src/privileges/helpers.js b/src/privileges/helpers.js
index 22d8795c7c..90c9c38ba4 100644
--- a/src/privileges/helpers.js
+++ b/src/privileges/helpers.js
@@ -31,7 +31,8 @@ function isUserAllowedToCids(privilege, uid, cids, callback) {
return isGuestAllowedToCids(privilege, cids, callback);
}
- var userKeys = [], groupKeys = [];
+ var userKeys = [];
+ var groupKeys = [];
for (var i = 0; i < cids.length; ++i) {
userKeys.push('cid:' + cids[i] + ':privileges:' + privilege);
groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege);
@@ -63,7 +64,8 @@ function isUserAllowedToPrivileges(privileges, uid, cid, callback) {
return isGuestAllowedToPrivileges(privileges, cid, callback);
}
- var userKeys = [], groupKeys = [];
+ var userKeys = [];
+ var groupKeys = [];
for (var i = 0; i < privileges.length; ++i) {
userKeys.push('cid:' + cid + ':privileges:' + privileges[i]);
groupKeys.push('cid:' + cid + ':privileges:groups:' + privileges[i]);
diff --git a/src/privileges/users.js b/src/privileges/users.js
index 7bdac2df14..a91175ecb1 100644
--- a/src/privileges/users.js
+++ b/src/privileges/users.js
@@ -73,9 +73,9 @@ module.exports = function (privileges) {
}
var isMembers = checks.user.map(function (isMember, idx) {
- return isMember || checks.group[idx];
- }),
- map = {};
+ return isMember || checks.group[idx];
+ });
+ var map = {};
uniqueCids.forEach(function (cid, index) {
map[cid] = isMembers[index];
diff --git a/src/pubsub.js b/src/pubsub.js
index a2e11746e1..f5c6c2f0ed 100644
--- a/src/pubsub.js
+++ b/src/pubsub.js
@@ -1,10 +1,10 @@
'use strict';
-var nconf = require('nconf'),
- util = require('util'),
- winston = require('winston'),
- EventEmitter = require('events').EventEmitter;
+var nconf = require('nconf');
+var util = require('util');
+var winston = require('winston');
+var EventEmitter = require('events').EventEmitter;
var channelName;
diff --git a/src/routes/authentication.js b/src/routes/authentication.js
index b0de9b9024..bc8833f034 100644
--- a/src/routes/authentication.js
+++ b/src/routes/authentication.js
@@ -1,17 +1,17 @@
(function (Auth) {
"use strict";
- var passport = require('passport'),
- passportLocal = require('passport-local').Strategy,
- nconf = require('nconf'),
- winston = require('winston'),
- express = require('express'),
+ var passport = require('passport');
+ var passportLocal = require('passport-local').Strategy;
+ var nconf = require('nconf');
+ var winston = require('winston');
+ var express = require('express');
- controllers = require('../controllers'),
- plugins = require('../plugins'),
- hotswap = require('../hotswap'),
+ var controllers = require('../controllers');
+ var plugins = require('../plugins');
+ var hotswap = require('../hotswap');
- loginStrategies = [];
+ var loginStrategies = [];
Auth.initialize = function (app, middleware) {
app.use(passport.initialize());
diff --git a/src/settings.js b/src/settings.js
index a50c1ff51f..9472f3e4e5 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -3,7 +3,11 @@
var meta = require('./meta');
function expandObjBy(obj1, obj2) {
- var key, val1, val2, xorValIsArray, changed = false;
+ var key;
+ var val1;
+ var val2;
+ var xorValIsArray;
+ var changed = false;
for (key in obj2) {
if (obj2.hasOwnProperty(key)) {
val2 = obj2[key];
@@ -23,7 +27,8 @@ function expandObjBy(obj1, obj2) {
}
function trim(obj1, obj2) {
- var key, val1;
+ var key;
+ var val1;
for (key in obj1) {
if (obj1.hasOwnProperty(key)) {
val1 = obj1[key];
@@ -106,8 +111,8 @@ Settings.prototype.sync = function (callback) {
@param callback Gets called when done.
*/
Settings.prototype.persist = function (callback) {
- var conf = this.cfg._,
- _this = this;
+ var conf = this.cfg._;
+ var _this = this;
if (typeof conf === 'object') {
conf = JSON.stringify(conf);
}
@@ -126,9 +131,9 @@ Settings.prototype.persist = function (callback) {
@returns Object The setting to be used.
*/
Settings.prototype.get = function (key, def) {
- var obj = this.cfg._,
- parts = (key || '').split('.'),
- part;
+ var obj = this.cfg._;
+ var parts = (key || '').split('.');
+ var part;
for (var i = 0; i < parts.length; i++) {
part = parts[i];
if (part && obj != null) {
@@ -183,7 +188,9 @@ Settings.prototype.createDefaultWrapper = function () {
@param val The value to set.
*/
Settings.prototype.set = function (key, val) {
- var part, obj, parts;
+ var part;
+ var obj;
+ var parts;
this.cfg.v = this.version;
if (val == null || !key) {
this.cfg._ = val || key;
diff --git a/src/socket.io/admin/navigation.js b/src/socket.io/admin/navigation.js
index 2f4d9817b4..07af8baa04 100644
--- a/src/socket.io/admin/navigation.js
+++ b/src/socket.io/admin/navigation.js
@@ -1,7 +1,7 @@
"use strict";
-var navigationAdmin = require('../../navigation/admin'),
- SocketNavigation = {};
+var navigationAdmin = require('../../navigation/admin');
+var SocketNavigation = {};
SocketNavigation.save = function (socket, data, callback) {
navigationAdmin.save(data, callback);
diff --git a/src/socket.io/admin/social.js b/src/socket.io/admin/social.js
index 77227ea760..5cb797edf1 100644
--- a/src/socket.io/admin/social.js
+++ b/src/socket.io/admin/social.js
@@ -1,7 +1,7 @@
"use strict";
-var social = require('../../social'),
- SocketSocial = {};
+var social = require('../../social');
+var SocketSocial = {};
SocketSocial.savePostSharingNetworks = function (socket, data, callback) {
social.setActivePostSharingNetworks(data, callback);
diff --git a/src/topics.js b/src/topics.js
index ec03c04b47..1da7994a7b 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -89,7 +89,9 @@ var social = require('./social');
return callback(null, []);
}
- var uids, cids, topics;
+ var uids;
+ var cids;
+ var topics;
async.waterfall([
function (next) {
diff --git a/src/topics/delete.js b/src/topics/delete.js
index 9d114629ae..4dc1e866d2 100644
--- a/src/topics/delete.js
+++ b/src/topics/delete.js
@@ -70,7 +70,8 @@ module.exports = function (Topics) {
postData = postData.filter(function (post) {
return post && parseInt(post.deleted, 10) !== 1;
});
- var pidsToAdd = [], scores = [];
+ var pidsToAdd = [];
+ var scores = [];
postData.forEach(function (post) {
pidsToAdd.push(post.pid);
scores.push(post.timestamp);
diff --git a/src/topics/posts.js b/src/topics/posts.js
index 69905b454e..5ab032cedc 100644
--- a/src/topics/posts.js
+++ b/src/topics/posts.js
@@ -263,7 +263,7 @@ module.exports = function (Topics) {
},
function (err) {
callback(err, latestPid);
- },
+ }
);
};
diff --git a/src/user/auth.js b/src/user/auth.js
index 92b206b4c0..ddbcc57520 100644
--- a/src/user/auth.js
+++ b/src/user/auth.js
@@ -78,8 +78,8 @@ module.exports = function (User) {
});
// Revoke any sessions that have expired, return filtered list
- var expiredSids = [],
- expired;
+ var expiredSids = [];
+ var expired;
sessions = sessions.filter(function (sessionObj, idx) {
expired = !sessionObj || !sessionObj.hasOwnProperty('passport') ||
diff --git a/src/user/info.js b/src/user/info.js
index 16b383340c..6df33f4757 100644
--- a/src/user/info.js
+++ b/src/user/info.js
@@ -11,7 +11,9 @@ var topics = require('../topics');
module.exports = function (User) {
User.getLatestBanInfo = function (uid, callback) {
// Simply retrieves the last record of the user's ban, even if they've been unbanned since then.
- var timestamp, expiry, reason;
+ var timestamp;
+ var expiry;
+ var reason;
async.waterfall([
async.apply(db.getSortedSetRevRangeWithScores, 'uid:' + uid + ':bans', 0, 0),
diff --git a/src/user/picture.js b/src/user/picture.js
index 1d5653c371..379834f914 100644
--- a/src/user/picture.js
+++ b/src/user/picture.js
@@ -126,7 +126,8 @@ module.exports = function (User) {
User.updateCoverPicture = function (data, callback) {
var keepAllVersions = parseInt(meta.config['profile:keepAllUserImages'], 10) === 1;
- var url, md5sum;
+ var url;
+ var md5sum;
if (!data.imageData && data.position) {
return User.updateCoverPosition(data.uid, data.position, callback);
@@ -224,7 +225,8 @@ module.exports = function (User) {
User.uploadCroppedPicture = function (data, callback) {
var keepAllVersions = parseInt(meta.config['profile:keepAllUserImages'], 10) === 1;
- var url, md5sum;
+ var url;
+ var md5sum;
if (!data.imageData) {
return callback(new Error('[[error:invalid-data]]'));
diff --git a/src/user/reset.js b/src/user/reset.js
index dc484d1825..9b3732c13e 100644
--- a/src/user/reset.js
+++ b/src/user/reset.js
@@ -1,16 +1,16 @@
'use strict';
-var async = require('async'),
- nconf = require('nconf'),
- winston = require('winston'),
+var async = require('async');
+var nconf = require('nconf');
+var winston = require('winston');
- user = require('../user'),
- utils = require('../../public/src/utils'),
- translator = require('../../public/src/modules/translator'),
+var user = require('../user');
+var utils = require('../../public/src/utils');
+var translator = require('../../public/src/modules/translator');
- db = require('../database'),
- meta = require('../meta'),
- emailer = require('../emailer');
+var db = require('../database');
+var meta = require('../meta');
+var emailer = require('../emailer');
(function (UserReset) {
var twoHours = 7200000;
diff --git a/src/widgets/admin.js b/src/widgets/admin.js
index e92df2e154..c4730f7de9 100644
--- a/src/widgets/admin.js
+++ b/src/widgets/admin.js
@@ -48,8 +48,9 @@ admin.get = function (callback) {
w.content += widgetData.adminTemplate;
});
- var templates = [],
- list = {}, index = 0;
+ var templates = [];
+ var list = {};
+ var index = 0;
widgetData.areas.forEach(function (area) {
if (typeof list[area.template] === 'undefined') {
diff --git a/test/database/hash.js b/test/database/hash.js
index 266e8cbdae..39df28e6fc 100644
--- a/test/database/hash.js
+++ b/test/database/hash.js
@@ -1,9 +1,9 @@
'use strict';
/*global require, after, before*/
-var async = require('async'),
- assert = require('assert'),
- db = require('../mocks/databasemock');
+var async = require('async');
+var assert = require('assert');
+var db = require('../mocks/databasemock');
describe('Hash methods', function () {
var testData = {
diff --git a/test/database/keys.js b/test/database/keys.js
index 602731241f..7f44fea060 100644
--- a/test/database/keys.js
+++ b/test/database/keys.js
@@ -1,9 +1,9 @@
'use strict';
/*global require, after*/
-var async = require('async'),
- assert = require('assert'),
- db = require('../mocks/databasemock');
+var async = require('async');
+var assert = require('assert');
+var db = require('../mocks/databasemock');
describe('Key methods', function () {
diff --git a/test/database/list.js b/test/database/list.js
index 09528a00fe..4d51b3dbd9 100644
--- a/test/database/list.js
+++ b/test/database/list.js
@@ -1,9 +1,9 @@
'use strict';
/*global require, after, before*/
-var async = require('async'),
- assert = require('assert'),
- db = require('../mocks/databasemock');
+var async = require('async');
+var assert = require('assert');
+var db = require('../mocks/databasemock');
describe('List methods', function () {
diff --git a/test/database/sets.js b/test/database/sets.js
index a753de9eae..7b36d5fc60 100644
--- a/test/database/sets.js
+++ b/test/database/sets.js
@@ -1,9 +1,9 @@
'use strict';
/*global require, after, before*/
-var async = require('async'),
- assert = require('assert'),
- db = require('../mocks/databasemock');
+var async = require('async');
+var assert = require('assert');
+var db = require('../mocks/databasemock');
describe('Set methods', function () {
diff --git a/test/database/sorted.js b/test/database/sorted.js
index f3c7c297f9..f1ed54ca00 100644
--- a/test/database/sorted.js
+++ b/test/database/sorted.js
@@ -1,9 +1,9 @@
'use strict';
/*global require, after, before*/
-var async = require('async'),
- assert = require('assert'),
- db = require('../mocks/databasemock');
+var async = require('async');
+var assert = require('assert');
+var db = require('../mocks/databasemock');
describe('Sorted Set methods', function () {
diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js
index 00f076ae2a..1ef42e3298 100644
--- a/test/mocks/databasemock.js
+++ b/test/mocks/databasemock.js
@@ -60,7 +60,7 @@
' "password": "",' + '\n' +
' "database": "nodebb_test"' + '\n' +
'}\n' +
- '===========================================================',
+ '==========================================================='
);
winston.error(errorText);
throw new Error(errorText);
diff --git a/test/search-admin.js b/test/search-admin.js
index 8a8a810f63..216d26d35f 100644
--- a/test/search-admin.js
+++ b/test/search-admin.js
@@ -40,7 +40,7 @@ describe('admin search', function () {
search.sanitize('Pellentesque tristique senectus' +
' habitant morbi'),
'Pellentesque tristique senectus' +
- ' habitant morbi',
+ ' habitant morbi'
);
done();
});
@@ -49,7 +49,7 @@ describe('admin search', function () {
search.sanitize('
Pellentesque habitant morbi tristique senectus' +
'Aenean vitae est.Mauris eleifend leo.
'),
'Pellentesque habitant morbi tristique senectus' +
- 'Aenean vitae est.Mauris eleifend leo.',
+ 'Aenean vitae est.Mauris eleifend leo.'
);
done();
});
@@ -60,10 +60,10 @@ describe('admin search', function () {
assert.equal(
search.simplify(
'Pellentesque tristique {{senectus}}habitant morbi' +
- 'liquam tincidunt {mauris.eu}risus',
+ 'liquam tincidunt {mauris.eu}risus'
),
'Pellentesque tristique habitant morbi' +
- 'liquam tincidunt risus',
+ 'liquam tincidunt risus'
);
done();
});
@@ -71,10 +71,10 @@ describe('admin search', function () {
assert.equal(
search.simplify(
'Pellentesque tristique habitant morbi' +
- ' \n\n liquam tincidunt mauris eu risus.',
+ ' \n\n liquam tincidunt mauris eu risus.'
),
'Pellentesque tristique habitant morbi' +
- '\nliquam tincidunt mauris eu risus.',
+ '\nliquam tincidunt mauris eu risus.'
);
done();
});
diff --git a/test/topics.js b/test/topics.js
index 741f095192..88d264f4fd 100644
--- a/test/topics.js
+++ b/test/topics.js
@@ -569,7 +569,7 @@ describe('Topic\'s', function () {
assert.ok(result);
replies.push(result);
next();
- },
+ }
);
}
diff --git a/test/translator.js b/test/translator.js
index ad8c9c34ee..8198814164 100644
--- a/test/translator.js
+++ b/test/translator.js
@@ -218,7 +218,7 @@ describe('Translator static methods', function () {
it('should remove translator patterns from text', function (done) {
assert.strictEqual(
Translator.removePatterns('Lorem ipsum dolor [[sit:amet]], consectetur adipiscing elit. [[sed:vitae, [[semper:dolor]]]] lorem'),
- 'Lorem ipsum dolor , consectetur adipiscing elit. lorem',
+ 'Lorem ipsum dolor , consectetur adipiscing elit. lorem'
);
done();
});
@@ -227,7 +227,7 @@ describe('Translator static methods', function () {
it('should escape translation patterns within text', function (done) {
assert.strictEqual(
Translator.escape('some nice text [[global:home]] here'),
- 'some nice text \\[\\[global:home\\]\\] here',
+ 'some nice text \\[\\[global:home\\]\\] here'
);
done();
});
@@ -237,7 +237,7 @@ describe('Translator static methods', function () {
it('should unescape escaped translation patterns within text', function (done) {
assert.strictEqual(
Translator.unescape('some nice text \\[\\[global:home\\]\\] here'),
- 'some nice text [[global:home]] here',
+ 'some nice text [[global:home]] here'
);
done();
});
@@ -247,7 +247,7 @@ describe('Translator static methods', function () {
it('should create a translator pattern from a key and list of arguments', function (done) {
assert.strictEqual(
Translator.compile('amazing:cool', 'awesome', 'great'),
- '[[amazing:cool, awesome, great]]',
+ '[[amazing:cool, awesome, great]]'
);
done();
});
@@ -255,7 +255,7 @@ describe('Translator static methods', function () {
it('should escape `%` and `,` in arguments', function (done) {
assert.strictEqual(
Translator.compile('amazing:cool', '100% awesome!', 'one, two, and three'),
- '[[amazing:cool, 100% awesome!, one, two, and three]]',
+ '[[amazing:cool, 100% awesome!, one, two, and three]]'
);
done();
});
diff --git a/test/user.js b/test/user.js
index a9003d6b9c..96d6cfbbfc 100644
--- a/test/user.js
+++ b/test/user.js
@@ -230,8 +230,8 @@ describe('User', function () {
});
describe('passwordReset', function () {
- var uid,
- code;
+ var uid;
+ var code;
before(function (done) {
User.create({username: 'resetuser', password: '123456', email: 'reset@me.com'}, function (err, newUid) {
assert.ifError(err);
diff --git a/test/utils.js b/test/utils.js
index 95f3040df4..bb71b0c9ec 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -30,8 +30,8 @@ describe('Utility Methods', function () {
describe('UUID generation', function () {
it('return unique random value every time', function () {
- var uuid1 = utils.generateUUID(),
- uuid2 = utils.generateUUID();
+ var uuid1 = utils.generateUUID();
+ var uuid2 = utils.generateUUID();
assert.notEqual(uuid1, uuid2, 'matches');
});
});