Fix space-infix-ops linter rule

v1.18.x
HeeL 8 years ago
parent 9a0d764bbd
commit 3fa1c1f927

@ -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",

@ -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<cols;x++) {
for(var x = 0,cols = process.stdout.columns - 10;x < cols;x++) {
separator += '=';
}
}

@ -74,7 +74,7 @@ function saveDatabaseConfig(config, databaseConfig, callback) {
}
var allQuestions = questions.redis.concat(questions.mongo);
for (var x=0; x<allQuestions.length; x++) {
for (var x = 0; x < allQuestions.length; x++) {
delete config[allQuestions[x].name];
}

@ -61,7 +61,7 @@ Loader.addWorkerEvents = function(worker) {
worker.on('exit', function(code, signal) {
if (code !== 0) {
if (Loader.timesStarted < numProcs*3) {
if (Loader.timesStarted < numProcs * 3) {
Loader.timesStarted++;
if (Loader.crashTimer) {
clearTimeout(Loader.crashTimer);
@ -70,12 +70,12 @@ Loader.addWorkerEvents = function(worker) {
Loader.timesStarted = 0;
}, 10000);
} else {
console.log(numProcs*3 + ' restarts in 10 seconds, most likely an error on startup. Halting.');
console.log(numProcs * 3 + ' restarts in 10 seconds, most likely an error on startup. Halting.');
process.exit();
}
}
console.log('[cluster] Child Process (' + worker.pid + ') has exited (code: ' + code + ', signal: ' + signal +')');
console.log('[cluster] Child Process (' + worker.pid + ') has exited (code: ' + code + ', signal: ' + signal + ')');
if (!(worker.suicide || code === 0)) {
console.log('[cluster] Spinning up another process...');
@ -152,7 +152,7 @@ Loader.start = function(callback) {
numProcs = getPorts().length;
console.log('Clustering enabled: Spinning up ' + numProcs + ' process(es).\n');
for (var x=0; x<numProcs; ++x) {
for (var x = 0; x < numProcs; ++x) {
forkWorker(x, x === 0);
}

@ -72,7 +72,7 @@ define('admin/appearance/skins', function() {
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);
}

@ -103,7 +103,7 @@ define('admin/extend/rewards', function() {
});
break;
case 'text':
html += '<input type="text" name="' + input.name +'" />';
html += '<input type="text" name="' + input.name + '" />';
break;
}
html += '</label><br />';

@ -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<areas.length; ++i) {
for(var i = 0; i < areas.length; ++i) {
var area = areas[i],
widgetArea = $('#widgets .area[data-template="' + area.template + '"][data-location="' + area.location + '"]').find('.widget-area');
widgetArea.html('');
for (var k=0; k<area.data.length; ++k) {
for (var k = 0; k < area.data.length; ++k) {
var widgetData = area.data[k],
widgetEl = $('.available-widgets [data-widget="' + widgetData.widget + '"]').clone(true).removeClass('hide');

@ -91,19 +91,19 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
graphData.rooms = data;
var html = '<div class="text-center pull-left">' +
'<div>'+ data.onlineRegisteredCount +'</div>' +
'<div>' + data.onlineRegisteredCount + '</div>' +
'<div>Users</div>' +
'</div>' +
'<div class="text-center pull-left">' +
'<div>'+ data.onlineGuestCount +'</div>' +
'<div>' + data.onlineGuestCount + '</div>' +
'<div>Guests</div>' +
'</div>' +
'<div class="text-center pull-left">' +
'<div>'+ (data.onlineRegisteredCount + data.onlineGuestCount) +'</div>' +
'<div>' + (data.onlineRegisteredCount + data.onlineGuestCount) + '</div>' +
'<div>Total</div>' +
'</div>' +
'<div class="text-center pull-left">' +
'<div>'+ data.socketCount +'</div>' +
'<div>' + data.socketCount + '</div>' +
'<div>Connections</div>' +
'</div>';
@ -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);

@ -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<numCategories;x++) {
for(var x = 0,numCategories = categories.length;x < numCategories;x++) {
renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid);
}

@ -155,7 +155,7 @@ define('admin/manage/category', [
$('button[data-action="setParent"], button[data-action="changeParent"]').on('click', Category.launchParentSelector);
$('button[data-action="removeParent"]').on('click', function() {
var payload= {};
var payload = {};
payload[ajaxify.data.category.cid] = {
parentCid: 0
};
@ -235,7 +235,7 @@ define('admin/manage/category', [
privs.push(el.getAttribute('data-privilege'));
}
});
for(var x=0,numPrivs=privs.length;x<numPrivs;x++) {
for(var x = 0,numPrivs = privs.length;x < numPrivs;x++) {
var inputs = $('.privilege-table tr[data-group-name]:not([data-group-name="registered-users"],[data-group-name="guests"]) td[data-privilege="' + privs[x] + '"] input');
inputs.each(function(idx, el) {
if (!el.checked) {

@ -100,7 +100,7 @@ define('admin/manage/users', ['translator'], function(translator) {
data[cur.name] = cur.value;
return data;
}, {});
var until = formData.length ? (Date.now() + formData.length * 1000*60*60 * (parseInt(formData.unit, 10) ? 24 : 1)) : 0;
var until = formData.length ? (Date.now() + formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1)) : 0;
socket.emit('user.banUsers', { uids: uids, until: until, reason: formData.reason }, done('User(s) banned!', '.ban', true));
}
}

@ -120,7 +120,7 @@ define('forum/account/header', [
data[cur.name] = cur.value;
return data;
}, {});
var until = formData.length ? (Date.now() + formData.length * 1000*60*60 * (parseInt(formData.unit, 10) ? 24 : 1)) : 0;
var until = formData.length ? (Date.now() + formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1)) : 0;
socket.emit('user.banUsers', { uids: [ajaxify.data.theirid], until: until, reason: formData.reason || '' }, function(err) {
if (err) {

@ -175,7 +175,7 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
}
function isAny(method, tids) {
for(var i=0; i<tids.length; ++i) {
for(var i = 0; i < tids.length; ++i) {
if(method(tids[i])) {
return true;
}
@ -184,7 +184,7 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
}
function areAll(method, tids) {
for(var i=0; i<tids.length; ++i) {
for(var i = 0; i < tids.length; ++i) {
if(!method(tids[i])) {
return false;
}

@ -352,7 +352,7 @@ define('forum/chats', [
messagesList.height($(window).height() - (fromTop + inputHeight + (margin * 4)));
components.get('chat/recent').height($('.expanded-chat').height() - (searchHeight + searchListHeight));
$('[component="chat/search/list"]').css('max-height', components.get('chat/recent').height()/2 + 'px');
$('[component="chat/search/list"]').css('max-height', components.get('chat/recent').height() / 2 + 'px');
}
Chats.setActive();

@ -55,7 +55,7 @@ define('forum/chats/search', ['components'], function(components) {
function displayUser(chatsListEl, userObj) {
function createUserImage() {
return (userObj.picture ?
'<img src="' + userObj.picture + '" title="' + userObj.username +'" />' :
'<img src="' + userObj.picture + '" title="' + userObj.username + '" />' :
'<div class="user-icon" style="background-color: ' + userObj['icon:bgColor'] + '">' + userObj['icon:text'] + '</div>') +
'<i class="fa fa-circle status ' + userObj.status + '"></i> ' + userObj.username;
}

@ -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 + ']]';
}
}

@ -158,7 +158,7 @@ define('forum/topic/events', [
return true;
}
for (var i=0; i<tags.length; ++i) {
for (var i = 0; i < tags.length; ++i) {
if (!$('.tags .tag-item[data-tag="' + tags[i].value + '"]').length) {
return true;
}

@ -47,7 +47,7 @@ define('forum/topic/posts', [
};
function updatePostCounts(posts) {
for (var i=0; i<posts.length; ++i) {
for (var i = 0; i < posts.length; ++i) {
var cmp = components.get('user/postcount', posts[i].uid);
cmp.html(parseInt(cmp.attr('data-postcount'), 10) + 1);
utils.addCommasToNumbers(cmp);

@ -186,7 +186,7 @@ define('forum/topic/threadTools', [
threadEl.find('[component="post"]:not(.deleted) [component="post/reply"], [component="post"]:not(.deleted) [component="post/quote"]').toggleClass('hidden', hideReply);
threadEl.find('[component="post/edit"], [component="post/delete"]').toggleClass('hidden', isLocked);
threadEl.find('[component="post"][data-uid="'+app.user.uid+'"].deleted [component="post/tools"]').toggleClass('hidden', isLocked);
threadEl.find('[component="post"][data-uid="' + app.user.uid + '"].deleted [component="post/tools"]').toggleClass('hidden', isLocked);
$('[component="post/header"] i.fa-lock').toggleClass('hidden', !data.isLocked);
$('[component="post/tools"] .dropdown-menu').html('');

@ -119,7 +119,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
}
function removeTids(tids) {
for(var i=0; i<tids.length; ++i) {
for(var i = 0; i < tids.length; ++i) {
components.get('category/topic', 'tid', tids[i]).remove();
}
}

@ -122,7 +122,7 @@ define('forum/users', ['translator'], function(translator) {
}
function updateUser(data) {
app.updateUserStatus($('#users-container [data-uid="' + data.uid +'"] [component="user/status"]'), data.status);
app.updateUserStatus($('#users-container [data-uid="' + data.uid + '"] [component="user/status"]'), data.status);
}
function getActiveSection() {

@ -132,7 +132,7 @@ define('notifications', ['sounds', 'translator', 'components'], function(sound,
});
translator.toggleTimeagoShorthand();
for(var i=0; i<notifs.length; ++i) {
for(var i = 0; i < notifs.length; ++i) {
notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10)));
}
translator.toggleTimeagoShorthand();

@ -95,7 +95,7 @@ define('search', ['navigator', 'translator'], function(nav, translator) {
// Sort pids numerically & store
Search.current = {
results: pids.sort(function(a, b) {
return a-b;
return a - b;
}),
tid: tid,
term: term
@ -121,11 +121,11 @@ define('search', ['navigator', 'translator'], function(nav, translator) {
};
Search.topicDOM.prev = function() {
Search.topicDOM.update((Search.current.index === 0) ? Search.current.results.length-1 : Search.current.index-1);
Search.topicDOM.update((Search.current.index === 0) ? Search.current.results.length - 1 : Search.current.index - 1);
};
Search.topicDOM.next = function() {
Search.topicDOM.update((Search.current.index === Search.current.results.length-1) ? 0 : Search.current.index+1);
Search.topicDOM.update((Search.current.index === Search.current.results.length - 1) ? 0 : Search.current.index + 1);
};
Search.topicDOM.update = function(index) {
@ -135,7 +135,7 @@ define('search', ['navigator', 'translator'], function(nav, translator) {
Search.topicDOM.start();
if (Search.current.results.length > 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],

@ -114,7 +114,7 @@ define('taskbar', function() {
.addClass(data.options.className)
.html('<a href="#">' +
(data.options.icon ? '<i class="fa ' + data.options.icon + '"></i> ' : '') +
(data.options.image ? '<img src="' + data.options.image + '"/> ': '') +
(data.options.image ? '<img src="' + data.options.image + '"/> ' : '') +
'<span>' + title + '</span>' +
'</a>')
.attr({

@ -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);
}

@ -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;

@ -42,12 +42,12 @@
url: url,
isMobile: utils.isMobile()
}, function(renderedAreas) {
for (var x=0; x<renderedAreas.length; ++x) {
for (var x = 0; x < renderedAreas.length; ++x) {
var renderedWidgets = renderedAreas[x].widgets,
location = renderedAreas[x].location,
html = '';
for (var i=0; i<renderedWidgets.length; ++i) {
for (var i = 0; i < renderedWidgets.length; ++i) {
html += templates.parse(renderedWidgets[i].html, {});
}

@ -135,19 +135,19 @@ var db = require('./database');
var daysArr = [];
day = new Date(day);
day.setDate(day.getDate()+1); // set the date to tomorrow, because getHourlyStatsForSet steps *backwards* 24 hours to sum up the values
day.setDate(day.getDate() + 1); // set the date to tomorrow, because getHourlyStatsForSet steps *backwards* 24 hours to sum up the values
day.setHours(0, 0, 0, 0);
async.whilst(function() {
return numDays--;
}, function(next) {
Analytics.getHourlyStatsForSet(set, day.getTime()-(1000*60*60*24*numDays), 24, function(err, day) {
Analytics.getHourlyStatsForSet(set, day.getTime() - (1000 * 60 * 60 * 24 * numDays), 24, function(err, day) {
if (err) {
return next(err);
}
daysArr.push(day.reduce(function(cur, next) {
return cur+next;
return cur + next;
}));
next();
});

@ -161,7 +161,7 @@ var privileges = require('./privileges');
var categories = results.categories;
var hasRead = results.hasRead;
uid = parseInt(uid, 10);
for(var i=0; i<results.categories.length; ++i) {
for(var i = 0; i < results.categories.length; ++i) {
if (categories[i]) {
categories[i]['unread-class'] = (parseInt(categories[i].topic_count, 10) === 0 || (hasRead[i] && uid !== 0)) ? '' : 'unread';
categories[i].children = results.children[i];

@ -24,7 +24,7 @@ module.exports = function(Categories) {
return next(null, {topics: [], uid: data.uid});
}
for (var i=0; i<topics.length; ++i) {
for (var i = 0; i < topics.length; ++i) {
topics[i].index = data.start + i;
}

@ -7,7 +7,7 @@ var winston = require('winston');
var user = require('../../user');
var groups = require('../../groups');
var plugins =require('../../plugins');
var plugins = require('../../plugins');
var meta = require('../../meta');
var utils = require('../../../public/src/utils');

@ -56,7 +56,7 @@ topicsController.get = function(req, res, callback) {
if (!res.locals.isAPI && (!req.params.slug || results.topic.slug !== tid + '/' + req.params.slug) && (results.topic.slug && results.topic.slug !== tid + '/')) {
var url = '/topic/' + results.topic.slug;
if (req.params.post_index){
url += '/'+req.params.post_index;
url += '/' + req.params.post_index;
}
if (currentPage > 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<topicData.posts.length; ++i) {
for(var i = 0; i < topicData.posts.length; ++i) {
if (parseInt(topicData.posts[i].index, 10) === parseInt(index, 10)) {
return topicData.posts[i];
}

@ -44,7 +44,7 @@ module.exports = function(db, module) {
var map = helpers.toMap(data);
var returnData = [];
for (var i=0; i<keys.length; ++i) {
for (var i = 0; i < keys.length; ++i) {
returnData.push(map[keys[i]]);
}
@ -78,7 +78,7 @@ module.exports = function(db, module) {
_id: 0
};
for(var i=0; i<fields.length; ++i) {
for(var i = 0; i < fields.length; ++i) {
fields[i] = helpers.fieldToString(fields[i]);
_fields[fields[i]] = 1;
}
@ -88,7 +88,7 @@ module.exports = function(db, module) {
}
item = item || {};
var result = {};
for(i=0; i<fields.length; ++i) {
for(i = 0; i < fields.length; ++i) {
result[fields[i]] = item[fields[i]] !== undefined ? item[fields[i]] : null;
}
callback(null, result);
@ -104,7 +104,7 @@ module.exports = function(db, module) {
_key: 1
};
for(var i=0; i<fields.length; ++i) {
for(var i = 0; i < fields.length; ++i) {
fields[i] = helpers.fieldToString(fields[i]);
_fields[fields[i]] = 1;
}
@ -122,10 +122,10 @@ module.exports = function(db, module) {
var returnData = [];
var item;
for (var i=0; i<keys.length; ++i) {
for (var i = 0; i < keys.length; ++i) {
item = map[keys[i]] || {};
for (var k=0; k<fields.length; ++k) {
for (var k = 0; k < fields.length; ++k) {
if (item[fields[k]] === undefined) {
item[fields[k]] = null;
}

@ -4,7 +4,7 @@ var helpers = {};
helpers.toMap = function(data) {
var map = {};
for (var i = 0; i<data.length; ++i) {
for (var i = 0; i < data.length; ++i) {
map[data[i]._key] = data[i];
data[i]._key = undefined;
}

@ -46,7 +46,7 @@ module.exports = function(db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i=0; i<keys.length; ++i) {
for(var i = 0; i < keys.length; ++i) {
bulk.find({_key: keys[i]}).upsert().updateOne({ $addToSet: {
members: {
$each: value
@ -83,7 +83,7 @@ module.exports = function(db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i=0; i<keys.length; ++i) {
for(var i = 0; i < keys.length; ++i) {
bulk.find({_key: keys[i]}).updateOne({$pull: {
members: value
}});
@ -110,7 +110,7 @@ module.exports = function(db, module) {
return callback(null, []);
}
for (var i=0; i<values.length; ++i) {
for (var i = 0; i < values.length; ++i) {
values[i] = helpers.valueToString(values[i]);
}
@ -174,7 +174,7 @@ module.exports = function(db, module) {
});
var returnData = new Array(keys.length);
for(var i=0; i<keys.length; ++i) {
for(var i = 0; i < keys.length; ++i) {
returnData[i] = sets[keys[i]] || [];
}
callback(null, returnData);

@ -37,7 +37,7 @@ module.exports = function(db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i=0; i<scores.length; ++i) {
for(var i = 0; i < scores.length; ++i) {
bulk.find({_key: key, value: values[i]}).upsert().updateOne({$set: {score: parseInt(scores[i], 10)}});
}
@ -55,7 +55,7 @@ module.exports = function(db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i=0; i<keys.length; ++i) {
for(var i = 0; i < keys.length; ++i) {
bulk.find({_key: keys[i], value: value}).upsert().updateOne({$set: {score: parseInt(score, 10)}});
}
@ -315,7 +315,7 @@ module.exports = function(db, module) {
return callback(null, []);
}
var data = new Array(values.length);
for (var i=0; i<values.length; ++i) {
for (var i = 0; i < values.length; ++i) {
data[i] = {key: keys[i], value: values[i]};
}
@ -366,7 +366,7 @@ module.exports = function(db, module) {
returnData = [],
item;
for(var i=0; i<keys.length; ++i) {
for(var i = 0; i < keys.length; ++i) {
item = map[keys[i]];
returnData.push(item ? item.score : null);
}
@ -393,7 +393,7 @@ module.exports = function(db, module) {
var returnData = new Array(values.length);
var score;
for(var i=0; i<values.length; ++i) {
for(var i = 0; i < values.length; ++i) {
score = map[values[i]];
returnData[i] = utils.isNumber(score) ? score : null;
}
@ -470,7 +470,7 @@ module.exports = function(db, module) {
});
var returnData = new Array(keys.length);
for(var i=0; i<keys.length; ++i) {
for(var i = 0; i < keys.length; ++i) {
returnData[i] = sets[keys[i]] || [];
}
callback(null, returnData);

@ -44,7 +44,7 @@ module.exports = function(redisClient, module) {
}
var multi = redisClient.multi();
for(var x=0; x<keys.length; ++x) {
for(var x = 0; x < keys.length; ++x) {
multi.hmget.apply(multi, [keys[x]].concat(fields));
}

@ -5,7 +5,7 @@ var helpers = {};
helpers.multiKeys = function(redisClient, command, keys, callback) {
callback = callback || function() {};
var multi = redisClient.multi();
for (var i=0; i<keys.length; ++i) {
for (var i = 0; i < keys.length; ++i) {
multi[command](keys[i]);
}
multi.exec(callback);
@ -14,7 +14,7 @@ helpers.multiKeys = function(redisClient, command, keys, callback) {
helpers.multiKeysValue = function(redisClient, command, keys, value, callback) {
callback = callback || function() {};
var multi = redisClient.multi();
for (var i=0; i<keys.length; ++i) {
for (var i = 0; i < keys.length; ++i) {
multi[command](keys[i], value);
}
multi.exec(callback);
@ -23,14 +23,14 @@ helpers.multiKeysValue = function(redisClient, command, keys, value, callback) {
helpers.multiKeyValues = function(redisClient, command, key, values, callback) {
callback = callback || function() {};
var multi = redisClient.multi();
for (var i=0; i<values.length; ++i) {
for (var i = 0; i < values.length; ++i) {
multi[command](key, values[i]);
}
multi.exec(callback);
};
helpers.resultsToBool = function(results) {
for (var i=0; i<results.length; ++i) {
for (var i = 0; i < results.length; ++i) {
results[i] = results[i] === 1;
}
return results;

@ -26,7 +26,7 @@ module.exports = function(redisClient, module) {
module.deleteAll = function(keys, callback) {
callback = callback || function() {};
var multi = redisClient.multi();
for(var i=0; i<keys.length; ++i) {
for(var i = 0; i < keys.length; ++i) {
multi.del(keys[i]);
}
multi.exec(function(err, res) {

@ -25,7 +25,7 @@ module.exports = function(redisClient, module) {
var args = [key];
for(var i=0; i<scores.length; ++i) {
for(var i = 0; i < scores.length; ++i) {
args.push(scores[i], values[i]);
}
@ -38,7 +38,7 @@ module.exports = function(redisClient, module) {
callback = callback || function() {};
var multi = redisClient.multi();
for(var i=0; i<keys.length; ++i) {
for(var i = 0; i < keys.length; ++i) {
multi.zadd(keys[i], score, value);
}
@ -67,7 +67,7 @@ module.exports = function(redisClient, module) {
module.sortedSetsRemoveRangeByScore = function(keys, min, max, callback) {
callback = callback || function() {};
var multi = redisClient.multi();
for(var i=0; i<keys.length; ++i) {
for(var i = 0; i < keys.length; ++i) {
multi.zremrangebyscore(keys[i], min, max);
}
multi.exec(function(err) {
@ -109,7 +109,7 @@ module.exports = function(redisClient, module) {
return callback(null, data);
}
var objects = [];
for(var i=0; i<data.length; i+=2) {
for(var i = 0; i < data.length; i += 2) {
objects.push({value: data[i], score: parseInt(data[i + 1], 10)});
}
callback(null, objects);
@ -138,8 +138,8 @@ module.exports = function(redisClient, module) {
return callback(err);
}
var objects = [];
for(var i=0; i<data.length; i+=2) {
objects.push({value: data[i], score: parseInt(data[i+1], 10)});
for(var i = 0; i < data.length; i += 2) {
objects.push({value: data[i], score: parseInt(data[i + 1], 10)});
}
callback(null, objects);
});
@ -158,7 +158,7 @@ module.exports = function(redisClient, module) {
return callback(null, []);
}
var multi = redisClient.multi();
for(var i=0; i<keys.length; ++i) {
for(var i = 0; i < keys.length; ++i) {
multi.zcard(keys[i]);
}
multi.exec(callback);
@ -170,7 +170,7 @@ module.exports = function(redisClient, module) {
module.sortedSetsRanks = function(keys, values, callback) {
var multi = redisClient.multi();
for(var i=0; i<values.length; ++i) {
for(var i = 0; i < values.length; ++i) {
multi.zrank(keys[i], values[i]);
}
multi.exec(callback);
@ -178,7 +178,7 @@ module.exports = function(redisClient, module) {
module.sortedSetRanks = function(key, values, callback) {
var multi = redisClient.multi();
for(var i=0; i<values.length; ++i) {
for(var i = 0; i < values.length; ++i) {
multi.zrank(key, values[i]);
}
multi.exec(callback);
@ -226,7 +226,7 @@ module.exports = function(redisClient, module) {
module.getSortedSetsMembers = function(keys, callback) {
var multi = redisClient.multi();
for (var i=0; i<keys.length; ++i) {
for (var i = 0; i < keys.length; ++i) {
multi.zrange(keys[i], 0, -1);
}
multi.exec(callback);
@ -281,7 +281,7 @@ module.exports = function(redisClient, module) {
}
results = results[1] || [];
var objects = [];
for(var i=0; i<results.length; i+=2) {
for(var i = 0; i < results.length; i += 2) {
objects.push({value: results[i], score: parseInt(results[i + 1], 10)});
}
callback(null, objects);
@ -369,7 +369,7 @@ module.exports = function(redisClient, module) {
}
results = results[1] || [];
var objects = [];
for(var i=0; i<results.length; i+=2) {
for(var i = 0; i < results.length; i += 2) {
objects.push({value: results[i], score: parseFloat(results[i + 1])});
}
callback(null, objects);

@ -22,7 +22,7 @@ file.saveFileToLocal = function(filename, folder, tempPath, callback) {
var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), folder, filename);
winston.verbose('Saving file '+ filename + ' to : ' + uploadPath);
winston.verbose('Saving file ' + filename + ' to : ' + uploadPath);
var is = fs.createReadStream(tempPath);
var os = fs.createWriteStream(uploadPath);

@ -477,7 +477,7 @@ module.exports = function(Groups) {
});
var result = members.map(function(groupNames) {
for (var i=0; i<groupNames.length; ++i) {
for (var i = 0; i < groupNames.length; ++i) {
if (map[groupNames[i]]) {
return true;
}

@ -81,7 +81,7 @@ module.exports = function(Groups) {
},
function(users, next) {
var uids = [];
for(var i=0; i<users.length; ++i) {
for(var i = 0; i < users.length; ++i) {
var field = users[i][searchBy];
if (field.toLowerCase().startsWith(query)) {
uids.push(users[i].uid);

@ -10,7 +10,7 @@ HotSwap.prepare = function(app) {
HotSwap.find = function(id) {
if (stack) {
for(var x=0,numEntries=stack.length;x<numEntries;x++) {
for(var x = 0,numEntries = stack.length;x < numEntries;x++) {
if (stack[x].handle.hotswapId === id) {
return x;
}

@ -26,23 +26,23 @@ image.resizeImage = function(data, callback) {
var w = image.bitmap.width,
h = image.bitmap.height,
origRatio = w/h,
desiredRatio = data.width && data.height ? data.width/data.height : origRatio,
origRatio = w / h,
desiredRatio = data.width && data.height ? data.width / data.height : origRatio,
x = 0,
y = 0,
crop;
if (origRatio !== desiredRatio) {
if (desiredRatio > 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 {

@ -148,7 +148,7 @@ var opts = {
* The format is: io: <uid> <event> <args>
*/
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";

@ -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

@ -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,

@ -43,7 +43,7 @@ module.exports = function(middleware) {
};
var isAllowed = function(url) {
for(var x=0,numAllowed=allowedRoutes.length,route;x<numAllowed;x++) {
for(var x = 0,numAllowed = allowedRoutes.length,route;x < numAllowed;x++) {
route = new RegExp(allowedRoutes[x]);
if (route.test(url)) {
return true;

@ -464,7 +464,7 @@ var utils = require('../public/src/utils');
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers - 1) + titleEscaped + ']]';
}
notifications[modifyIndex].path = set[set.length-1].path;
notifications[modifyIndex].path = set[set.length - 1].path;
break;
case 'new_register':

@ -23,7 +23,7 @@ pagination.create = function(currentPage, pageCount, queryObj) {
var next = Math.min(pageCount, currentPage + 1);
var startPage = currentPage - 2;
for(var i=0; i<5; ++i) {
for(var i = 0; i < 5; ++i) {
pagesToShow.push(startPage + i);
}
@ -42,7 +42,7 @@ pagination.create = function(currentPage, pageCount, queryObj) {
return {page: page, active: page === currentPage, qs: qs.stringify(queryObj)};
});
for (i=pages.length - 1; i>0; --i) {
for (i = pages.length - 1; i > 0; --i) {
if (pages[i - 1].page !== pages[i].page - 1) {
pages.splice(i, 0, {separator: true});
}

@ -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<numPlugins;x++) {
for(var x = 0,numPlugins = Plugins.versionWarning.length;x < numPlugins;x++) {
process.stdout.write(' * '.yellow + Plugins.versionWarning[x] + '\n');
}
process.stdout.write('\n');
@ -271,7 +271,7 @@ var middleware;
var pluginMap = {};
var dependencies = require.main.require('./package.json').dependencies;
apiReturn = apiReturn || [];
for(var i=0; i<apiReturn.length; ++i) {
for(var i = 0; i < apiReturn.length; ++i) {
apiReturn[i].id = apiReturn[i].name;
apiReturn[i].installed = false;
apiReturn[i].active = false;

@ -318,7 +318,7 @@ module.exports = function(Plugins) {
callback(null, pluginData);
} catch(err) {
var pluginDir = pluginPath.split(path.sep);
pluginDir = pluginDir[pluginDir.length -1];
pluginDir = pluginDir[pluginDir.length - 1];
winston.error('[plugins/' + pluginDir + '] Error in plugin.json or package.json! ' + err.message);

@ -44,7 +44,7 @@ var plugins = require('./plugins');
var keys = [];
for (var x=0, numPids=pids.length; x<numPids; ++x) {
for (var x = 0, numPids = pids.length; x < numPids; ++x) {
keys.push('post:' + pids[x]);
}
@ -214,7 +214,7 @@ var plugins = require('./plugins');
return callback(err);
}
for (var i=0; i<indices.length; ++i) {
for (var i = 0; i < indices.length; ++i) {
indices[i] = utils.isNumber(indices[i]) ? parseInt(indices[i], 10) + 1 : 0;
}

@ -140,7 +140,7 @@ module.exports = function(Posts) {
function toObject(key, data) {
var obj = {};
for(var i=0; i<data.length; ++i) {
for(var i = 0; i < data.length; ++i) {
obj[data[i][key]] = data[i];
}
return obj;

@ -84,7 +84,7 @@ module.exports = function(Posts) {
var upvoteSets = [];
var downvoteSets = [];
for (var i=0; i<pids.length; ++i) {
for (var i = 0; i < pids.length; ++i) {
upvoteSets.push('pid:' + pids[i] + ':upvote');
downvoteSets.push('pid:' + pids[i] + ':downvote');
}

@ -66,7 +66,7 @@ module.exports = function(privileges) {
memberData.forEach(function(member) {
member.privileges = {};
for(var x=0,numPrivs=userPrivileges.length;x<numPrivs;x++) {
for(var x = 0,numPrivs = userPrivileges.length;x < numPrivs;x++) {
member.privileges[userPrivileges[x]] = memberSets[x].indexOf(parseInt(member.uid, 10)) !== -1;
}
});
@ -117,7 +117,7 @@ module.exports = function(privileges) {
var memberData = groupNames.map(function(member) {
memberPrivs = {};
for(var x=0,numPrivs=groupPrivileges.length;x<numPrivs;x++) {
for(var x = 0,numPrivs = groupPrivileges.length;x < numPrivs;x++) {
memberPrivs[groupPrivileges[x]] = memberSets[x].indexOf(member) !== -1;
}
return {

@ -32,7 +32,7 @@ function isUserAllowedToCids(privilege, uid, cids, callback) {
}
var userKeys = [], groupKeys = [];
for (var i=0; i<cids.length; ++i) {
for (var i = 0; i < cids.length; ++i) {
userKeys.push('cid:' + cids[i] + ':privileges:' + privilege);
groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege);
}
@ -50,7 +50,7 @@ function isUserAllowedToCids(privilege, uid, cids, callback) {
}
var result = [];
for (var i=0; i<cids.length; ++i) {
for (var i = 0; i < cids.length; ++i) {
result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]);
}
@ -64,7 +64,7 @@ function isUserAllowedToPrivileges(privileges, uid, cid, callback) {
}
var userKeys = [], groupKeys = [];
for (var i=0; i<privileges.length; ++i) {
for (var i = 0; i < privileges.length; ++i) {
userKeys.push('cid:' + cid + ':privileges:' + privileges[i]);
groupKeys.push('cid:' + cid + ':privileges:groups:' + privileges[i]);
}
@ -82,7 +82,7 @@ function isUserAllowedToPrivileges(privileges, uid, cid, callback) {
}
var result = [];
for (var i=0; i<privileges.length; ++i) {
for (var i = 0; i < privileges.length; ++i) {
result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]);
}
@ -105,7 +105,7 @@ helpers.isUsersAllowedTo = function(privilege, uids, cid, callback) {
}
var result = [];
for(var i=0; i<uids.length; ++i) {
for(var i = 0; i < uids.length; ++i) {
result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]);
}
@ -115,7 +115,7 @@ helpers.isUsersAllowedTo = function(privilege, uids, cid, callback) {
function isGuestAllowedToCids(privilege, cids, callback) {
var groupKeys = [];
for (var i=0; i<cids.length; ++i) {
for (var i = 0; i < cids.length; ++i) {
groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege);
}
@ -124,7 +124,7 @@ function isGuestAllowedToCids(privilege, cids, callback) {
function isGuestAllowedToPrivileges(privileges, cid, callback) {
var groupKeys = [];
for (var i=0; i<privileges.length; ++i) {
for (var i = 0; i < privileges.length; ++i) {
groupKeys.push('cid:' + cid + ':privileges:groups:' + privileges[i]);
}

@ -40,7 +40,7 @@ module.exports = function(privileges) {
var privileges = [];
for (var i=0; i<pids.length; ++i) {
for (var i = 0; i < pids.length; ++i) {
var isAdminOrMod = results.isAdmin || results.isModerator[i];
var editable = isAdminOrMod || (results.isOwner[i] && results['posts:edit'][i]);

@ -207,7 +207,7 @@ module.exports = function(privileges) {
var preventTopicDeleteAfterReplies = parseInt(meta.config.preventTopicDeleteAfterReplies, 10) || 0;
if (preventTopicDeleteAfterReplies && (topicData.postcount - 1) >= 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));
}

@ -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()
});

@ -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<hotswapIds.length;x++) {
for(var idx,x = 0;x < hotswapIds.length;x++) {
idx = routers.push(express.Router()) - 1;
routers[idx].hotswapId = hotswapIds[x];
}
@ -130,7 +130,7 @@ module.exports = function(app, middleware, hotswapIds) {
userRoutes(router, middleware, controllers);
groupRoutes(router, middleware, controllers);
for(var x=0;x<routers.length;x++) {
for(var x = 0;x < routers.length;x++) {
app.use(relativePath, routers[x]);
}

@ -37,7 +37,7 @@ sitemap.render = function(callback) {
numPages = Math.ceil(tids.length / numTopics);
}
for(var x=1;x<=numPages;x++) {
for(var x = 1;x <= numPages;x++) {
returnData.topics.push(x);
}
@ -124,10 +124,10 @@ sitemap.getTopicPage = function(page, callback) {
var max = min + numTopics;
if (
sitemap.maps.topics[page-1] &&
Date.now() < parseInt(sitemap.maps.topics[page-1].cacheSetTimestamp, 10) + parseInt(sitemap.maps.topics[page-1].cacheResetPeriod, 10)
sitemap.maps.topics[page - 1] &&
Date.now() < parseInt(sitemap.maps.topics[page - 1].cacheSetTimestamp, 10) + parseInt(sitemap.maps.topics[page - 1].cacheResetPeriod, 10)
) {
return sitemap.maps.topics[page-1].toXML(callback);
return sitemap.maps.topics[page - 1].toXML(callback);
}
var topicUrls = [];
@ -158,13 +158,13 @@ sitemap.getTopicPage = function(page, callback) {
}
});
sitemap.maps.topics[page-1] = sm.createSitemap({
sitemap.maps.topics[page - 1] = sm.createSitemap({
hostname: nconf.get('url'),
cacheTime: 1000 * 60 * 60, // Cached for 1 hour
urls: topicUrls
});
sitemap.maps.topics[page-1].toXML(callback);
sitemap.maps.topics[page - 1].toXML(callback);
});
};

@ -144,7 +144,7 @@ SocketRooms.getLocalStats = function(callback) {
users: {
categories: roomClients.categories ? roomClients.categories.length : 0,
recent: roomClients.recent_topics ? roomClients.recent_topics.length : 0,
unread: roomClients.unread_topics ? roomClients.unread_topics.length: 0,
unread: roomClients.unread_topics ? roomClients.unread_topics.length : 0,
topics: 0,
category: 0
},

@ -21,7 +21,7 @@ User.makeAdmins = function(socket, uids, callback) {
return callback(err);
}
for(var i=0; i<userData.length; i++) {
for(var i = 0; i < userData.length; i++) {
if (userData[i] && parseInt(userData[i].banned, 10) === 1) {
return callback(new Error('[[error:cant-make-banned-users-admin]]'));
}

@ -119,7 +119,7 @@ SocketUser.reset.commit = function(socket, data, callback) {
var uid = results.uid;
var now = new Date();
var parsedDate = now.getFullYear() + '/' + (now.getMonth()+1) + '/' + now.getDate();
var parsedDate = now.getFullYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate();
user.getUserField(uid, 'username', function(err, username) {
if (err) {

@ -149,7 +149,7 @@ var social = require('./social');
var users = _.object(uids, results.users);
var categories = _.object(cids, results.categories);
for (var i=0; i<topics.length; ++i) {
for (var i = 0; i < topics.length; ++i) {
if (topics[i]) {
topics[i].category = categories[topics[i].cid];
topics[i].user = users[topics[i].uid];

@ -327,9 +327,9 @@ module.exports = function(Topics) {
function check(item, min, max, minError, maxError, callback) {
if (!item || item.length < parseInt(min, 10)) {
return callback(new Error('[[error:'+ minError + ', ' + min + ']]'));
return callback(new Error('[[error:' + minError + ', ' + min + ']]'));
} else if (item.length > parseInt(max, 10)) {
return callback(new Error('[[error:'+ maxError + ', ' + max + ']]'));
return callback(new Error('[[error:' + maxError + ', ' + max + ']]'));
}
callback();
}

@ -40,7 +40,7 @@ module.exports = function(Topics) {
Topics.getTopicsData = function(tids, callback) {
var keys = [];
for (var i=0; i<tids.length; ++i) {
for (var i = 0; i < tids.length; ++i) {
keys.push('topic:' + tids[i]);
}

@ -83,7 +83,7 @@ module.exports = function(Topics) {
}
function unfollow(tid, uid, callback) {
removeFromSets('tid:'+ tid + ':followers', 'uid:' + uid + ':followed_tids', tid, uid, callback);
removeFromSets('tid:' + tid + ':followers', 'uid:' + uid + ':followed_tids', tid, uid, callback);
}
function ignore(tid, uid, callback) {
@ -91,7 +91,7 @@ module.exports = function(Topics) {
}
function unignore(tid, uid, callback) {
removeFromSets('tid:'+ tid + ':ignorers', 'uid:' + uid + ':ignored_tids', tid, uid, callback);
removeFromSets('tid:' + tid + ':ignorers', 'uid:' + uid + ':ignored_tids', tid, uid, callback);
}
function addToSets(set1, set2, tid, uid, callback) {

@ -68,7 +68,7 @@ module.exports = function(Topics) {
userData: function(next) {
var uids = [];
for(var i=0; i<postData.length; ++i) {
for(var i = 0; i < postData.length; ++i) {
if (postData[i] && uids.indexOf(postData[i].uid) === -1) {
uids.push(postData[i].uid);
}
@ -89,7 +89,7 @@ module.exports = function(Topics) {
},
editors: function(next) {
var editors = [];
for(var i=0; i<postData.length; ++i) {
for(var i = 0; i < postData.length; ++i) {
if (postData[i] && postData[i].editor && editors.indexOf(postData[i].editor) === -1) {
editors.push(postData[i].editor);
}

@ -317,7 +317,7 @@ module.exports = function(Topics) {
query = query.toLowerCase();
var matches = [];
for(var i=0; i<tags.length; ++i) {
for(var i = 0; i < tags.length; ++i) {
if (tags[i].toLowerCase().startsWith(query)) {
matches.push(tags[i]);
if (matches.length > 19) {

@ -126,7 +126,7 @@ module.exports = function(User) {
user.status = User.getStatus(user);
}
for(var i=0; i<fieldsToRemove.length; ++i) {
for(var i = 0; i < fieldsToRemove.length; ++i) {
user[fieldsToRemove[i]] = undefined;
}

@ -96,14 +96,14 @@ var utils = require('../../public/src/utils');
return next();
}
for(var i=0; i<notifications.length; ++i) {
for(var i = 0; i < notifications.length; ++i) {
if (notifications[i].image && notifications[i].image.indexOf('http') !== 0) {
notifications[i].image = nconf.get('url') + notifications[i].image;
}
}
emailer.send('digest', userObj.uid, {
subject: '[' + meta.config.title + '] [[email:digest.subject, ' + (now.getFullYear()+ '/' + (now.getMonth()+1) + '/' + now.getDate()) + ']]',
subject: '[' + meta.config.title + '] [[email:digest.subject, ' + (now.getFullYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate()) + ']]',
username: userObj.username,
userslug: userObj.userslug,
url: nconf.get('url'),

@ -36,7 +36,7 @@ module.exports = function(User) {
return callback(err);
}
for (var i=0; i<settings.length; ++i) {
for (var i = 0; i < settings.length; ++i) {
settings[i] = settings[i] || {};
settings[i].uid = uids[i];
}

@ -29,22 +29,22 @@
if(!testDbConfig){
errorText = 'test_database is not defined';
winston.info(
'\n===========================================================\n'+
'Please, add parameters for test database in config.json\n'+
'For example (redis):\n'+
'\n===========================================================\n' +
'Please, add parameters for test database in config.json\n' +
'For example (redis):\n' +
'"test_database": {' + '\n' +
' "host": "127.0.0.1",' + '\n' +
' "port": "6379",' + '\n' +
' "password": "",' + '\n' +
' "database": "1"' + '\n' +
'}\n'+
'}\n' +
' or (mongo):\n' +
'"test_database": {' + '\n' +
' "host": "127.0.0.1",' + '\n' +
' "port": "27017",' + '\n' +
' "password": "",' + '\n' +
' "database": "1"' + '\n' +
'}\n'+
'}\n' +
' or (mongo) in a replicaset' + '\n' +
'"test_database": {' + '\n' +
' "host": "127.0.0.1,127.0.0.1,127.0.0.1",' + '\n' +
@ -52,7 +52,7 @@
' "username": "",' + '\n' +
' "password": "",' + '\n' +
' "database": "nodebb_test"' + '\n' +
'}\n'+
'}\n' +
'==========================================================='
);
winston.error(errorText);

@ -124,7 +124,7 @@ describe('User', function() {
});
it('should allow a post if the last post time is > 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({

Loading…
Cancel
Save