ESlint object-curly-spacing

v1.18.x
Peter Jaszkowiak 8 years ago
parent 1493afee2a
commit 896c8c7343

@ -46,6 +46,7 @@
"no-prototype-builtins": "off",
"vars-on-top": "off",
"no-restricted-syntax": "off",
"no-shadow": "off",
// "linebreak-style": "off",
// "one-var": "off",
@ -95,8 +96,7 @@
"no-restricted-module": "off",
"no-return-assign": "off",
"no-restricted-modules": "off",
"object-curly-spacing": "off",
"no-shadow": "off",
// "object-curly-spacing": "off",
// "indent": "off",
// "padded-blocks": "off",
// "eol-last": "off",

@ -26,9 +26,9 @@ function hashPassword(password, rounds) {
function done(err, result) {
if (err) {
process.send({err: err.message});
process.send({ err: err.message });
return process.disconnect();
}
process.send({result: result});
process.send({ result: result });
process.disconnect();
}

@ -153,7 +153,7 @@ Loader.restart = function () {
nconf.remove('file');
nconf.use('file', { file: pathToConfig });
fs.readFile(pathToConfig, {encoding: 'utf-8'}, function (err, configFile) {
fs.readFile(pathToConfig, { encoding: 'utf-8' }, function (err, configFile) {
if (err) {
console.log('Error reading config : ' + err.message);
process.exit();

@ -145,7 +145,7 @@ define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, t
var plugins = $('#order-active-plugins-modal .plugin-list').children();
var data = [];
plugins.each(function (index, el) {
data.push({name: $(el).text(), order: index});
data.push({ name: $(el).text(), order: index });
});
socket.emit('admin.plugins.orderActivePlugins', data, function (err) {

@ -28,7 +28,7 @@ define('admin/extend/rewards', ['translator'], function (translator) {
var parent = $(this).parents('[data-id]');
var 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 {
@ -153,7 +153,7 @@ define('admin/extend/rewards', ['translator'], function (translator) {
var activeRewards = [];
$('#active li').each(function () {
var data = {rewards: {}};
var data = { rewards: {} };
var main = $(this).find('form.main').serializeArray();
var rewards = $(this).find('form.rewards').serializeArray();

@ -374,10 +374,10 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
function updateTopicsGraph(topics) {
if (!Object.keys(topics).length) {
topics = {0: {
topics = { 0: {
title: 'No users browsing',
value: 1,
}};
} };
}
var tids = Object.keys(topics);

@ -63,12 +63,12 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
function drop(ev, ui) {
var id = ui.helper.attr('data-id');
var el = $('#active-navigation [data-id="' + id + '"]');
var data = id === 'custom' ? {iconClass: 'fa-navicon'} : available[id];
var data = id === 'custom' ? { iconClass: 'fa-navicon' } : available[id];
data.enabled = false;
data.index = (parseInt($('#enabled').children().last().attr('data-index'), 10) || 0) + 1;
templates.parse('admin/general/navigation', 'navigation', {navigation: [data]}, function (li) {
templates.parse('admin/general/navigation', 'navigation', { navigation: [data] }, function (li) {
translator.translate(li, function (li) {
li = $(translator.unescape(li));
el.after(li);
@ -76,7 +76,7 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
});
});
templates.parse('admin/general/navigation', 'enabled', {enabled: [data]}, function (li) {
templates.parse('admin/general/navigation', 'enabled', { enabled: [data] }, function (li) {
translator.translate(li, function (li) {
li = $(translator.unescape(li));
$('#enabled').append(li);

@ -134,7 +134,7 @@ define('admin/manage/category', [
$('.copy-settings').on('click', function () {
selectCategoryModal(function (cid) {
socket.emit('admin.categories.copySettingsFrom', {fromCid: cid, toCid: ajaxify.data.category.cid}, function (err) {
socket.emit('admin.categories.copySettingsFrom', { fromCid: cid, toCid: ajaxify.data.category.cid }, function (err) {
if (err) {
return app.alertError(err.message);
}
@ -152,7 +152,7 @@ define('admin/manage/category', [
uploader.show({
title: '[[admin/manage/categories:alert.upload-image]]',
route: config.relative_path + '/api/admin/category/uploadpicture',
params: {cid: cid},
params: { cid: cid },
}, function (imageUrlOnServer) {
$('#category-image').val(imageUrlOnServer);
var previewBox = inputEl.parent().parent().siblings('.category-preview');
@ -434,7 +434,7 @@ define('admin/manage/category', [
Category.copyPrivilegesFromCategory = function () {
selectCategoryModal(function (cid) {
socket.emit('admin.categories.copyPrivilegesFrom', {toCid: ajaxify.data.category.cid, fromCid: cid}, function (err) {
socket.emit('admin.categories.copyPrivilegesFrom', { toCid: ajaxify.data.category.cid, fromCid: cid }, function (err) {
if (err) {
return app.alertError(err.message);
}

@ -62,7 +62,7 @@ define('admin/manage/flags', [
}
var pid = btn.parents('[data-pid]').attr('data-pid');
var tid = btn.parents('[data-pid]').attr('data-tid');
socket.emit('posts.delete', {pid: pid, tid: tid}, function (err) {
socket.emit('posts.delete', { pid: pid, tid: tid }, function (err) {
done(err, btn);
});
});

@ -40,7 +40,7 @@ define('admin/manage/group', [
var searchText = groupDetailsSearch.val();
var foundUser;
socket.emit('admin.user.search', {query: searchText}, function (err, results) {
socket.emit('admin.user.search', { query: searchText }, function (err, results) {
if (!err && results && results.users.length > 0) {
var numResults = results.users.length;
var x;
@ -53,7 +53,7 @@ define('admin/manage/group', [
for (x = 0; x < numResults; x += 1) {
foundUser = $('<li />');
foundUser
.attr({title: results.users[x].username,
.attr({ title: results.users[x].username,
'data-uid': results.users[x].uid,
'data-username': results.users[x].username,
'data-userslug': results.users[x].userslug,
@ -96,7 +96,7 @@ define('admin/manage/group', [
'icon:text': userLabel.attr('data-usericon-text'),
};
templates.parse('partials/groups/memberlist', 'members', {group: {isOwner: ajaxify.data.group.isOwner, members: [member]}}, function (html) {
templates.parse('partials/groups/memberlist', 'members', { group: { isOwner: ajaxify.data.group.isOwner, members: [member] } }, function (html) {
translator.translate(html, function (html) {
$('[component="groups/members"] tbody').prepend(html);
});

@ -11,7 +11,7 @@ define('admin/manage/registration', function () {
var username = parent.attr('data-username');
var method = action === 'accept' ? 'admin.user.acceptRegistration' : 'admin.user.rejectRegistration';
socket.emit(method, {username: username}, function (err) {
socket.emit(method, { username: username }, function (err) {
if (err) {
return app.alertError(err.message);
}
@ -39,7 +39,7 @@ define('admin/manage/registration', function () {
if (action === 'delete') {
bootbox.confirm('[[admin/manage/registration:invitations.confirm-delete]]', function (confirm) {
if (confirm) {
socket.emit(method, {email: email, invitedBy: invitedBy}, function (err) {
socket.emit(method, { email: email, invitedBy: invitedBy }, function (err) {
if (err) {
return app.alertError(err.message);
}

@ -61,12 +61,12 @@ define('admin/manage/tags', [
}
timeoutId = setTimeout(function () {
socket.emit('topics.searchAndLoadTags', {query: $('#tag-search').val()}, function (err, result) {
socket.emit('topics.searchAndLoadTags', { query: $('#tag-search').val() }, function (err, result) {
if (err) {
return app.alertError(err.message);
}
app.parseAndTranslate('admin/manage/tags', 'tags', {tags: result.tags}, function (html) {
app.parseAndTranslate('admin/manage/tags', 'tags', { tags: result.tags }, function (html) {
$('.tag-list').html(html);
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
timeoutId = 0;
@ -133,7 +133,7 @@ define('admin/manage/tags', [
tagsToDelete.each(function (index, el) {
tags.push($(el).attr('data-tag'));
});
socket.emit('admin.tags.deleteTags', {tags: tags}, function (err) {
socket.emit('admin.tags.deleteTags', { tags: tags }, function (err) {
if (err) {
return app.alertError(err.message);
}

@ -327,7 +327,7 @@ define('admin/manage/users', ['translator'], function (translator) {
timeoutId = setTimeout(function () {
$('.fa-spinner').removeClass('hidden');
socket.emit('admin.user.search', {searchBy: type, query: $this.val()}, function (err, data) {
socket.emit('admin.user.search', { searchBy: type, query: $this.val() }, function (err, data) {
if (err) {
return app.alertError(err.message);
}

@ -17,7 +17,7 @@ define('admin/settings/email', ['admin/settings'], function (settings) {
function configureEmailTester() {
$('button[data-action="email.test"]').off('click').on('click', function () {
socket.emit('admin.email.test', {template: $('#test-email').val()}, function (err) {
socket.emit('admin.email.test', { template: $('#test-email').val() }, function (err) {
if (err) {
return app.alertError(err.message);
}

@ -29,7 +29,7 @@ $(document).ready(function () {
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
} else if (ev.state.url !== undefined) {
ajaxify.go(ev.state.url, function () {
$(window).trigger('action:popstate', {url: ev.state.url});
$(window).trigger('action:popstate', { url: ev.state.url });
}, true);
}
}
@ -73,7 +73,7 @@ $(document).ready(function () {
// If any listeners alter url and set it to an empty string, abort the ajaxification
if (url === null) {
$(window).trigger('action:ajaxify.end', {url: url, tpl_url: ajaxify.data.template.name, title: ajaxify.data.title});
$(window).trigger('action:ajaxify.end', { url: url, tpl_url: ajaxify.data.template.name, title: ajaxify.data.title });
return false;
}
@ -196,7 +196,7 @@ $(document).ready(function () {
function done() {
count -= 1;
if (count === 0) {
$(window).trigger('action:ajaxify.end', {url: url, tpl_url: tpl_url, title: ajaxify.data.title});
$(window).trigger('action:ajaxify.end', { url: url, tpl_url: tpl_url, title: ajaxify.data.title });
}
}
var count = 2;
@ -205,7 +205,7 @@ $(document).ready(function () {
ajaxify.widgets.render(tpl_url, url, done);
$(window).trigger('action:ajaxify.contentLoaded', {url: url, tpl: tpl_url});
$(window).trigger('action:ajaxify.contentLoaded', { url: url, tpl: tpl_url });
app.processPage();
@ -284,7 +284,7 @@ $(document).ready(function () {
ajaxify.loadData = function (url, callback) {
url = ajaxify.removeRelativePath(url);
$(window).trigger('action:ajaxify.loadingData', {url: url});
$(window).trigger('action:ajaxify.loadingData', { url: url });
apiXHR = $.ajax({
url: RELATIVE_PATH + '/api/' + url,
@ -300,7 +300,7 @@ $(document).ready(function () {
ajaxify.data = data;
data.config = config;
$(window).trigger('action:ajaxify.dataLoaded', {url: url, data: data});
$(window).trigger('action:ajaxify.dataLoaded', { url: url, data: data });
callback(null, data);
},

@ -326,7 +326,7 @@ app.cacheBuster = null;
if (chat.modalExists(roomId)) {
loadAndCenter(chat.getModal(roomId));
} else {
socket.emit('modules.chats.loadRoom', {roomId: roomId, uid: uid || app.user.uid}, function (err, roomData) {
socket.emit('modules.chats.loadRoom', { roomId: roomId, uid: uid || app.user.uid }, function (err, roomData) {
if (err) {
return app.alertError(err.message);
}
@ -350,7 +350,7 @@ app.cacheBuster = null;
return app.alertError('[[error:cant-chat-with-yourself]]');
}
socket.emit('modules.chats.newRoom', {touid: touid}, function (err, roomId) {
socket.emit('modules.chats.newRoom', { touid: touid }, function (err, roomId) {
if (err) {
return app.alertError(err.message);
}

@ -70,7 +70,7 @@ define('forum/account/edit', ['forum/account/header', 'translator', 'components'
function handleImageChange() {
$('#changePictureBtn').on('click', function () {
socket.emit('user.getProfilePictures', {uid: ajaxify.data.uid}, function (err, pictures) {
socket.emit('user.getProfilePictures', { uid: ajaxify.data.uid }, function (err, pictures) {
if (err) {
return app.alertError(err.message);
}
@ -259,7 +259,7 @@ define('forum/account/edit', ['forum/account/header', 'translator', 'components'
});
modal.find('[data-action="remove-uploaded"]').on('click', function () {
socket.emit('user.removeUploadedPicture', {uid: ajaxify.data.theirid}, function (err) {
socket.emit('user.removeUploadedPicture', { uid: ajaxify.data.theirid }, function (err) {
modal.modal('hide');
if (err) {
return app.alertError(err.message);

@ -13,7 +13,7 @@ define('forum/account/info', ['forum/account/header', 'components'], function (h
function handleModerationNote() {
$('[component="account/save-moderation-note"]').on('click', function () {
var note = $('[component="account/moderation-note"]').val();
socket.emit('user.setModerationNote', {uid: ajaxify.data.uid, note: note}, function (err) {
socket.emit('user.setModerationNote', { uid: ajaxify.data.uid, note: note }, function (err) {
if (err) {
return app.alertError(err.message);
}

@ -41,7 +41,7 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
}
function onPostsLoaded(posts, callback) {
app.parseAndTranslate(template, 'posts', {posts: posts}, function (html) {
app.parseAndTranslate(template, 'posts', { posts: posts }, function (html) {
$('[component="posts"]').append(html);
html.find('img:not(.not-responsive)').addClass('img-responsive');
html.find('.timeago').timeago();

@ -69,7 +69,7 @@ define('forum/account/profile', [
return callback();
}
app.parseAndTranslate('account/profile', 'posts', {posts: posts}, function (html) {
app.parseAndTranslate('account/profile', 'posts', { posts: posts }, function (html) {
$('[component="posts"]').append(html);
html.find('.timeago').timeago();

@ -70,7 +70,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
}
function saveSettings(settings) {
socket.emit('user.saveSettings', {uid: ajaxify.data.theirid, settings: settings}, function (err, newSettings) {
socket.emit('user.saveSettings', { uid: ajaxify.data.theirid, settings: settings }, function (err, newSettings) {
if (err) {
return app.alertError(err.message);
}

@ -41,12 +41,12 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
}
function onTopicsLoaded(topics, callback) {
app.parseAndTranslate('account/topics', 'topics', {topics: topics}, function (html) {
app.parseAndTranslate('account/topics', 'topics', { topics: topics }, function (html) {
$('[component="category"]').append(html);
html.find('.timeago').timeago();
app.createUserTooltips();
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
$(window).trigger('action:topics.loaded', {topics: topics});
$(window).trigger('action:topics.loaded', { topics: topics });
callback();
});
}

@ -54,12 +54,12 @@ define('forum/categories', ['components', 'translator'], function (components, t
recentPosts.last().remove();
}
$(window).trigger('action:posts.loaded', {posts: [post]});
$(window).trigger('action:posts.loaded', { posts: [post] });
});
}
function parseAndTranslate(posts, callback) {
templates.parse('categories', '(categories.)?posts', {categories: {posts: posts}}, function (html) {
templates.parse('categories', '(categories.)?posts', { categories: { posts: posts } }, function (html) {
translator.translate(html, function (translatedHTML) {
translatedHTML = $(translatedHTML);
translatedHTML.find('.post-content img:not(.not-responsive)').addClass('img-responsive');

@ -62,8 +62,8 @@ define('forum/category', [
handleIgnoreWatch(cid);
$(window).trigger('action:topics.loaded', {topics: ajaxify.data.topics});
$(window).trigger('action:category.loaded', {cid: ajaxify.data.cid});
$(window).trigger('action:topics.loaded', { topics: ajaxify.data.topics });
$(window).trigger('action:category.loaded', { cid: ajaxify.data.cid });
};
function handleScrollToTopicIndex() {
@ -204,10 +204,10 @@ define('forum/category', [
var editable = !!$('.thread-tools').length;
templates.parse('category', 'topics', {
privileges: {editable: editable},
privileges: { editable: editable },
showSelect: editable,
topics: [topic],
template: {category: true},
template: { category: true },
}, function (html) {
translator.translate(html, function (translatedHTML) {
var topic = $(translatedHTML);
@ -354,7 +354,7 @@ define('forum/category', [
app.createUserTooltips();
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
$(window).trigger('action:topics.loaded', {topics: data.topics});
$(window).trigger('action:topics.loaded', { topics: data.topics });
callback();
});

@ -35,7 +35,7 @@ define('forum/category/tools', [
components.get('topic/lock').on('click', function () {
var tids = topicSelect.getSelectedTids();
if (tids.length) {
socket.emit('topics.lock', {tids: tids, cid: CategoryTools.cid}, onCommandComplete);
socket.emit('topics.lock', { tids: tids, cid: CategoryTools.cid }, onCommandComplete);
}
return false;
});
@ -43,7 +43,7 @@ define('forum/category/tools', [
components.get('topic/unlock').on('click', function () {
var tids = topicSelect.getSelectedTids();
if (tids.length) {
socket.emit('topics.unlock', {tids: tids, cid: CategoryTools.cid}, onCommandComplete);
socket.emit('topics.unlock', { tids: tids, cid: CategoryTools.cid }, onCommandComplete);
}
return false;
});
@ -51,7 +51,7 @@ define('forum/category/tools', [
components.get('topic/pin').on('click', function () {
var tids = topicSelect.getSelectedTids();
if (tids.length) {
socket.emit('topics.pin', {tids: tids, cid: CategoryTools.cid}, onCommandComplete);
socket.emit('topics.pin', { tids: tids, cid: CategoryTools.cid }, onCommandComplete);
}
return false;
});
@ -59,7 +59,7 @@ define('forum/category/tools', [
components.get('topic/unpin').on('click', function () {
var tids = topicSelect.getSelectedTids();
if (tids.length) {
socket.emit('topics.unpin', {tids: tids, cid: CategoryTools.cid}, onCommandComplete);
socket.emit('topics.unpin', { tids: tids, cid: CategoryTools.cid }, onCommandComplete);
}
return false;
});
@ -123,7 +123,7 @@ define('forum/category/tools', [
return;
}
socket.emit('topics.' + command, {tids: tids, cid: CategoryTools.cid}, onDeletePurgeComplete);
socket.emit('topics.' + command, { tids: tids, cid: CategoryTools.cid }, onDeletePurgeComplete);
});
});
}
@ -250,7 +250,7 @@ define('forum/category/tools', [
var pinnedTopics = $('[component="category/topic"].pinned');
pinnedTopics.each(function (index, element) {
data.push({tid: $(element).attr('data-tid'), order: pinnedTopics.length - index - 1});
data.push({ tid: $(element).attr('data-tid'), order: pinnedTopics.length - index - 1 });
});
socket.emit('topics.orderPinnedTopics', data, function (err) {

@ -98,7 +98,7 @@ define('forum/chats', [
}
loading = true;
var start = parseInt($('.chat-content').children('[data-index]').first().attr('data-index'), 10) + 1;
socket.emit('modules.chats.getMessages', {roomId: roomId, uid: uid, start: start}, function (err, data) {
socket.emit('modules.chats.getMessages', { roomId: roomId, uid: uid, start: start }, function (err, data) {
if (err) {
return app.alertError(err.message);
}
@ -170,7 +170,7 @@ define('forum/chats', [
if (oldName === newName) {
return;
}
socket.emit('modules.chats.renameRoom', {roomId: roomId, newName: newName}, function (err) {
socket.emit('modules.chats.renameRoom', { roomId: roomId, newName: newName }, function (err) {
if (err) {
return app.alertError(err.message);
}
@ -235,10 +235,10 @@ define('forum/chats', [
if (event.item === app.user.username) {
return;
}
socket.emit('modules.chats.addUserToRoom', {roomId: data.roomId, username: event.item}, function (err) {
socket.emit('modules.chats.addUserToRoom', { roomId: data.roomId, username: event.item }, function (err) {
if (err) {
app.alertError(err.message);
tagEl.tagsinput('remove', event.item, {nouser: true});
tagEl.tagsinput('remove', event.item, { nouser: true });
}
});
});
@ -262,7 +262,7 @@ define('forum/chats', [
if (event.options && event.options.nouser) {
return;
}
socket.emit('modules.chats.removeUserFromRoom', {roomId: data.roomId, username: event.item}, function (err) {
socket.emit('modules.chats.removeUserFromRoom', { roomId: data.roomId, username: event.item }, function (err) {
if (err) {
return app.alertError(err.message);
}

@ -22,7 +22,7 @@ define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], functi
}
searchInterval = setTimeout(function () {
socket.emit('groups.searchMembers', {groupName: groupName, query: query}, function (err, results) {
socket.emit('groups.searchMembers', { groupName: groupName, query: query }, function (err, results) {
if (err) {
return app.alertError(err.message);
}

@ -54,7 +54,7 @@ define('forum/infinitescroll', function () {
}
loadingMore = true;
var hookData = {method: method, data: data};
var hookData = { method: method, data: data };
$(window).trigger('action:infinitescroll.loadmore', hookData);
socket.emit(hookData.method, hookData.data, function (err, data) {

@ -54,7 +54,7 @@ define('forum/notifications', ['components', 'notifications', 'forum/infinitescr
if (!data.notifications || !data.notifications.length) {
return done();
}
app.parseAndTranslate('notifications', 'notifications', {notifications: data.notifications}, function (html) {
app.parseAndTranslate('notifications', 'notifications', { notifications: data.notifications }, function (html) {
notifList.append(html);
html.find('.timeago').timeago();
done();

@ -26,7 +26,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function (infinit
infinitescroll.init(Recent.loadMoreTopics);
}
$(window).trigger('action:topics.loaded', {topics: ajaxify.data.topics});
$(window).trigger('action:topics.loaded', { topics: ajaxify.data.topics });
};
Recent.watchForNewPosts = function () {
@ -154,14 +154,14 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function (infinit
return callback();
}
app.parseAndTranslate(templateName, 'topics', {topics: topics, showSelect: showSelect}, function (html) {
app.parseAndTranslate(templateName, 'topics', { topics: topics, showSelect: showSelect }, function (html) {
$('#category-no-topics').remove();
$('[component="category"]').append(html);
html.find('.timeago').timeago();
app.createUserTooltips();
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
$(window).trigger('action:topics.loaded', {topics: topics});
$(window).trigger('action:topics.loaded', { topics: topics });
callback();
});
};

@ -19,7 +19,7 @@ define('forum/tags', ['forum/infinitescroll'], function (infinitescroll) {
}
timeoutId = setTimeout(function () {
socket.emit('topics.searchAndLoadTags', {query: $('#tag-search').val()}, function (err, results) {
socket.emit('topics.searchAndLoadTags', { query: $('#tag-search').val() }, function (err, results) {
if (err) {
return app.alertError(err.message);
}
@ -63,7 +63,7 @@ define('forum/tags', ['forum/infinitescroll'], function (infinitescroll) {
function onTagsLoaded(tags, replace, callback) {
callback = callback || function () {};
app.parseAndTranslate('tags', 'tags', {tags: tags}, function (html) {
app.parseAndTranslate('tags', 'tags', { tags: tags }, function (html) {
$('.tag-list')[replace ? 'html' : 'append'](html);
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
callback();

@ -111,7 +111,7 @@ define('forum/topic/events', [
if (topicTitle.length && data.topic.title && topicTitle.html() !== data.topic.title) {
ajaxify.data.title = data.topic.title;
var newUrl = 'topic/' + data.topic.slug + (window.location.search ? window.location.search : '');
history.replaceState({url: newUrl}, null, window.location.protocol + '//' + window.location.host + config.relative_path + '/' + newUrl);
history.replaceState({ url: newUrl }, null, window.location.protocol + '//' + window.location.host + config.relative_path + '/' + newUrl);
topicTitle.fadeOut(250, function () {
topicTitle.html(data.topic.title).fadeIn(250);
@ -149,7 +149,7 @@ define('forum/topic/events', [
});
if (data.topic.tags && tagsUpdated(data.topic.tags)) {
templates.parse('partials/post_bar', 'tags', {tags: data.topic.tags}, function (html) {
templates.parse('partials/post_bar', 'tags', { tags: data.topic.tags }, function (html) {
var tags = $('.tags');
tags.fadeOut(250, function () {

@ -46,7 +46,7 @@ define('forum/topic/flag', [], function () {
if (!pid || !reason) {
return;
}
socket.emit('posts.flag', {pid: pid, reason: reason}, function (err) {
socket.emit('posts.flag', { pid: pid, reason: reason }, function (err) {
if (err) {
return app.alertError(err.message);
}

@ -44,7 +44,7 @@ define('forum/topic/move-post', [], function () {
}
function movePost(post, pid, tid, callback) {
socket.emit('posts.movePost', {pid: pid, tid: tid}, function (err) {
socket.emit('posts.movePost', { pid: pid, tid: tid }, function (err) {
if (err) {
app.alertError(err.message);
return callback();

@ -42,7 +42,7 @@ define('forum/topic/move', function () {
}
function parseModal(categories, callback) {
templates.parse('partials/move_thread_modal', {categories: []}, function (html) {
templates.parse('partials/move_thread_modal', { categories: [] }, function (html) {
require(['translator'], function (translator) {
translator.translate(html, function (html) {
modal = $(html);

@ -38,7 +38,7 @@ define('forum/topic/postTools', [
var pid = postEl.attr('data-pid');
var index = parseInt(postEl.attr('data-index'), 10);
socket.emit('posts.loadPostTools', {pid: pid, cid: ajaxify.data.cid}, function (err, data) {
socket.emit('posts.loadPostTools', { pid: pid, cid: ajaxify.data.cid }, function (err, data) {
if (err) {
return app.alertError(err.message);
}
@ -286,7 +286,7 @@ define('forum/topic/postTools', [
username = getUserName($(content));
range.detach();
}
return {text: selectedText, pid: selectedPid, username: username};
return { text: selectedText, pid: selectedPid, username: username };
}
function bookmarkPost(button, pid) {

@ -87,8 +87,8 @@ define('forum/topic/posts', [
}
function updatePagination() {
$.get(config.relative_path + '/api/topic/pagination/' + ajaxify.data.tid, {page: ajaxify.data.pagination.currentPage}, function (paginationData) {
app.parseAndTranslate('partials/paginator', {pagination: paginationData}, function (html) {
$.get(config.relative_path + '/api/topic/pagination/' + ajaxify.data.tid, { page: ajaxify.data.pagination.currentPage }, function (paginationData) {
app.parseAndTranslate('partials/paginator', { pagination: paginationData }, function (html) {
$('[component="pagination"]').after(html).remove();
});
});
@ -174,7 +174,7 @@ define('forum/topic/posts', [
data.slug = ajaxify.data.slug;
$(window).trigger('action:posts.loading', {posts: data.posts, after: after, before: before});
$(window).trigger('action:posts.loading', { posts: data.posts, after: after, before: before });
app.parseAndTranslate('topic', 'posts', data, function (html) {
html = html.filter(function () {
@ -199,7 +199,7 @@ define('forum/topic/posts', [
infinitescroll.removeExtra($('[component="post"]'), direction, 40);
$(window).trigger('action:posts.loaded', {posts: data.posts});
$(window).trigger('action:posts.loaded', { posts: data.posts });
Posts.processPage(html);

@ -46,9 +46,9 @@ define('forum/topic/replies', ['navigator', 'components', 'forum/topic/posts'],
hideReplies: true,
};
app.parseAndTranslate('topic', 'posts', tplData, function (html) {
$('<div>', {component: 'post/replies'}).html(html).hide().insertAfter(button).slideDown('fast');
$('<div>', { component: 'post/replies' }).html(html).hide().insertAfter(button).slideDown('fast');
posts.processPage(html);
$(window).trigger('action:posts.loaded', {posts: data});
$(window).trigger('action:posts.loaded', { posts: data });
});
});
} else if (close.is(':not(.hidden)')) {

@ -31,22 +31,22 @@ define('forum/topic/threadTools', [
});
topicContainer.on('click', '[component="topic/lock"]', function () {
socket.emit('topics.lock', {tids: [tid], cid: ajaxify.data.cid});
socket.emit('topics.lock', { tids: [tid], cid: ajaxify.data.cid });
return false;
});
topicContainer.on('click', '[component="topic/unlock"]', function () {
socket.emit('topics.unlock', {tids: [tid], cid: ajaxify.data.cid});
socket.emit('topics.unlock', { tids: [tid], cid: ajaxify.data.cid });
return false;
});
topicContainer.on('click', '[component="topic/pin"]', function () {
socket.emit('topics.pin', {tids: [tid], cid: ajaxify.data.cid});
socket.emit('topics.pin', { tids: [tid], cid: ajaxify.data.cid });
return false;
});
topicContainer.on('click', '[component="topic/unpin"]', function () {
socket.emit('topics.unpin', {tids: [tid], cid: ajaxify.data.cid});
socket.emit('topics.unpin', { tids: [tid], cid: ajaxify.data.cid });
return false;
});
@ -91,7 +91,7 @@ define('forum/topic/threadTools', [
});
function changeWatching(type) {
socket.emit('topics.changeWatching', {tid: tid, type: type}, function (err) {
socket.emit('topics.changeWatching', { tid: tid, type: type }, function (err) {
if (err) {
return app.alert({
type: 'danger',
@ -118,7 +118,7 @@ define('forum/topic/threadTools', [
timeout: 5000,
});
$(window).trigger('action:topics.changeWatching', {tid: tid, type: type});
$(window).trigger('action:topics.changeWatching', { tid: tid, type: type });
});
return false;
@ -133,7 +133,7 @@ define('forum/topic/threadTools', [
return;
}
socket.emit('topics.loadTopicTools', {tid: ajaxify.data.tid, cid: ajaxify.data.cid}, function (err, data) {
socket.emit('topics.loadTopicTools', { tid: ajaxify.data.tid, cid: ajaxify.data.cid }, function (err, data) {
if (err) {
return app.alertError(err);
}
@ -155,7 +155,7 @@ define('forum/topic/threadTools', [
return;
}
socket.emit('topics.' + command, {tids: [tid], cid: ajaxify.data.cid}, function (err) {
socket.emit('topics.' + command, { tids: [tid], cid: ajaxify.data.cid }, function (err) {
if (err) {
app.alertError(err.message);
}

@ -82,7 +82,7 @@ define('forum/topic/votes', ['components', 'translator'], function (components,
};
Votes.showVotes = function (pid) {
socket.emit('posts.getVoters', {pid: pid, cid: ajaxify.data.cid}, function (err, data) {
socket.emit('posts.getVoters', { pid: pid, cid: ajaxify.data.cid }, function (err, data) {
if (err) {
if (err.message === '[[error:no-privileges]]') {
return;

@ -19,7 +19,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
recent.watchForNewPosts();
$(window).trigger('action:topics.loaded', {topics: ajaxify.data.topics});
$(window).trigger('action:topics.loaded', { topics: ajaxify.data.topics });
$('#markSelectedRead').on('click', function () {
var tids = topicSelect.getSelectedTids();

@ -98,7 +98,7 @@ define('forum/users', ['translator'], function (translator) {
}
function renderSearchResults(data) {
templates.parse('partials/paginator', {pagination: data.pagination}, function (html) {
templates.parse('partials/paginator', { pagination: data.pagination }, function (html) {
$('.pagination-container').replaceWith(html);
});

@ -42,7 +42,7 @@ $('document').ready(function () {
if ($('form .admin .error').length) {
ev.preventDefault();
$('html, body').animate({scrollTop: '0px'}, 400);
$('html, body').animate({ scrollTop: '0px' }, 400);
return false;
} else {

@ -14,7 +14,7 @@ define('autocomplete', function () {
},
select: onselect,
source: function (request, response) {
socket.emit('user.search', {query: request.term}, function (err, result) {
socket.emit('user.search', { query: request.term }, function (err, result) {
if (err) {
return app.alertError(err.message);
}

@ -75,7 +75,7 @@ define('chat', [
});
}
} else {
socket.emit('modules.chats.loadRoom', {roomId: data.roomId}, function (err, roomData) {
socket.emit('modules.chats.loadRoom', { roomId: data.roomId }, function (err, roomData) {
if (err) {
return app.alertError(err.message);
}
@ -108,7 +108,7 @@ define('chat', [
};
module.loadChatsDropdown = function (chatsListEl) {
socket.emit('modules.chats.getRecentChats', {uid: app.user.uid, after: 0}, function (err, data) {
socket.emit('modules.chats.getRecentChats', { uid: app.user.uid, after: 0 }, function (err, data) {
if (err) {
return app.alertError(err.message);
}

@ -130,7 +130,7 @@ define('notifications', ['sounds', 'translator', 'components'], function (sound,
}
translator.toggleTimeagoShorthand();
templates.parse('partials/notifications_list', {notifications: notifs}, function (html) {
templates.parse('partials/notifications_list', { notifications: notifs }, function (html) {
notifList.translateHtml(html);
});
});

@ -32,7 +32,7 @@ define('pictureCropper', ['translator', 'cropper'], function (translator, croppe
module.handleImageCrop = function (data, callback) {
$('#crop-picture-modal').remove();
templates.parse('modals/crop_picture', {url: data.url}, function (cropperHtml) {
templates.parse('modals/crop_picture', { url: data.url }, function (cropperHtml) {
translator.translate(cropperHtml, function (translated) {
var cropperModal = $(translated);
cropperModal.modal('show');

@ -39,7 +39,7 @@ define('share', function () {
return openShare('https://plus.google.com/share?url=', getPostUrl($(this)), 500, 570);
});
$(window).trigger('action:share.addHandlers', {openShare: openShare});
$(window).trigger('action:share.addHandlers', { openShare: openShare });
};
function addHandler(selector, callback) {

@ -112,7 +112,7 @@ define('uploader', ['translator'], function (translator) {
try {
return $.parseJSON(response);
} catch (e) {
return {error: '[[error:parse-error]]'};
return { error: '[[error:parse-error]]' };
}
}
return response;

@ -84,7 +84,7 @@ if ('undefined' !== typeof window) {
});
}
});
}(jQuery || {fn: {}}));
}(jQuery || { fn: {} }));
(function () {
// FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245

@ -178,7 +178,7 @@ Analytics.getMonthlyPageViews = function (callback) {
if (err) {
return callback(err);
}
callback(null, {thisMonth: scores[0] || 0, lastMonth: scores[1] || 0});
callback(null, { thisMonth: scores[0] || 0, lastMonth: scores[1] || 0 });
});
};

@ -57,7 +57,7 @@ var privileges = require('./privileges');
category.isIgnored = results.isIgnored[0];
category.topic_count = results.topicCount;
plugins.fireHook('filter:category.get', {category: category, uid: data.uid}, next);
plugins.fireHook('filter:category.get', { category: category, uid: data.uid }, next);
},
function (data, next) {
next(null, data.category);
@ -229,7 +229,7 @@ var privileges = require('./privileges');
Categories.getChildren = function (cids, uid, callback) {
var categories = cids.map(function (cid) {
return {cid: cid};
return { cid: cid };
});
async.each(categories, function (category, next) {

@ -43,7 +43,7 @@ module.exports = function (Categories) {
imageClass: 'cover',
};
plugins.fireHook('filter:category.create', {category: category, data: data}, next);
plugins.fireHook('filter:category.create', { category: category, data: data }, next);
},
function (data, next) {
category = data.category;

@ -16,7 +16,7 @@ module.exports = function (Categories) {
async.eachLimit(tids, 10, function (tid, next) {
topics.purgePostsAndTopic(tid, uid, next);
}, next);
}, {alwaysStartAt: 0}, next);
}, { alwaysStartAt: 0 }, next);
},
function (next) {
Categories.getPinnedTids('cid:' + cid + ':tids:pinned', 0, -1, next);

@ -27,7 +27,7 @@ module.exports = function (Categories) {
privileges.posts.filter('read', pids, uid, next);
},
function (pids, next) {
posts.getPostSummaryByPids(pids, uid, {stripTags: true}, next);
posts.getPostSummaryByPids(pids, uid, { stripTags: true }, next);
},
], callback);
};

@ -20,17 +20,17 @@ module.exports = function (Categories) {
},
function (topics, next) {
if (!Array.isArray(topics) || !topics.length) {
return next(null, {topics: [], uid: data.uid});
return next(null, { topics: [], uid: data.uid });
}
for (var i = 0; i < topics.length; i += 1) {
topics[i].index = data.start + i;
}
plugins.fireHook('filter:category.topics.get', {cid: data.cid, topics: topics, uid: data.uid}, next);
plugins.fireHook('filter:category.topics.get', { cid: data.cid, topics: topics, uid: data.uid }, next);
},
function (results, next) {
next(null, {topics: results.topics, nextStart: data.stop + 1});
next(null, { topics: results.topics, nextStart: data.stop + 1 });
},
], callback);
};
@ -64,7 +64,7 @@ module.exports = function (Categories) {
stop = stop === -1 ? stop : start + normalTidsToGet - 1;
if (Array.isArray(set)) {
db[reverse ? 'getSortedSetRevIntersect' : 'getSortedSetIntersect']({sets: set, start: start, stop: stop}, next);
db[reverse ? 'getSortedSetRevIntersect' : 'getSortedSetIntersect']({ sets: set, start: start, stop: stop }, next);
} else {
db[reverse ? 'getSortedSetRevRange' : 'getSortedSetRange'](set, start, stop, next);
}

@ -41,7 +41,7 @@ module.exports = function (Categories) {
}
},
function (next) {
plugins.fireHook('filter:category.update', {category: modifiedFields}, next);
plugins.fireHook('filter:category.update', { category: modifiedFields }, next);
},
function (categoryData, next) {
category = categoryData.category;
@ -57,7 +57,7 @@ module.exports = function (Categories) {
}, next);
},
function (next) {
plugins.fireHook('action:category.update', {cid: cid, modified: category});
plugins.fireHook('action:category.update', { cid: cid, modified: category });
next();
},
], callback);

@ -45,7 +45,7 @@ chatsController.get = function (req, res, callback) {
nextStart: recentChats.nextStart,
allowed: true,
title: '[[pages:chats]]',
breadcrumbs: helpers.buildBreadcrumbs([{text: username, url: '/user/' + req.params.userslug}, {text: '[[pages:chats]]'}]),
breadcrumbs: helpers.buildBreadcrumbs([{ text: username, url: '/user/' + req.params.userslug }, { text: '[[pages:chats]]' }]),
});
}
messaging.isUserInRoom(req.uid, req.params.roomid, next);
@ -87,9 +87,9 @@ chatsController.get = function (req, res, callback) {
room.usernames = messaging.generateUsernames(room.users, req.uid);
room.title = room.roomName || room.usernames || '[[pages:chats]]';
room.breadcrumbs = helpers.buildBreadcrumbs([
{text: username, url: '/user/' + req.params.userslug},
{text: '[[pages:chats]]', url: '/user/' + req.params.userslug + '/chats'},
{text: room.roomName || room.usernames || '[[pages:chats]]'},
{ text: username, url: '/user/' + req.params.userslug },
{ text: '[[pages:chats]]', url: '/user/' + req.params.userslug + '/chats' },
{ text: room.roomName || room.usernames || '[[pages:chats]]' },
]);
room.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
room.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000;

@ -36,7 +36,7 @@ editController.get = function (req, res, callback) {
});
userData.title = '[[pages:account/edit, ' + userData.username + ']]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:edit]]'}]);
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[user:edit]]' }]);
userData.editButtons = [];
plugins.fireHook('filter:user.account.edit', userData, function (err, userData) {
@ -76,9 +76,9 @@ function renderRoute(name, req, res, next) {
userData.title = '[[pages:account/edit/' + name + ', ' + userData.username + ']]';
userData.breadcrumbs = helpers.buildBreadcrumbs([
{text: userData.username, url: '/user/' + userData.userslug},
{text: '[[user:edit]]', url: '/user/' + userData.userslug + '/edit'},
{text: '[[user:' + name + ']]'},
{ text: userData.username, url: '/user/' + userData.userslug },
{ text: '[[user:edit]]', url: '/user/' + userData.userslug + '/edit' },
{ text: '[[user:' + name + ']]' },
]);
res.render('account/edit/' + name, userData);
@ -139,7 +139,7 @@ editController.uploadPicture = function (req, res, next) {
return next(err);
}
res.json([{name: userPhoto.name, url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url}]);
res.json([{ name: userPhoto.name, url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url }]);
});
};

@ -47,7 +47,7 @@ function getFollow(tpl, name, req, res, callback) {
var count = name === 'following' ? userData.followingCount : userData.followerCount;
var pageCount = Math.ceil(count / resultsPerPage);
userData.pagination = pagination.create(page, pageCount);
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:' + name + ']]'}]);
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[user:' + name + ']]' }]);
res.render(tpl, userData);
});

@ -46,7 +46,7 @@ groupsController.get = function (req, res, callback) {
userData.groups = groupsData;
userData.title = '[[pages:account/groups, ' + userData.username + ']]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[global:header.groups]]'}]);
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[global:header.groups]]' }]);
res.render('account/groups', userData);
});
};

@ -52,13 +52,13 @@ helpers.getUserDataByUserSlug = function (userslug, callerUID, callback) {
plugins.fireHook('filter:user.profileLinks', [], next);
},
profile_menu: function (next) {
plugins.fireHook('filter:user.profileMenu', {uid: uid, callerUID: callerUID, links: []}, next);
plugins.fireHook('filter:user.profileMenu', { uid: uid, callerUID: callerUID, links: [] }, next);
},
groups: function (next) {
groups.getUserGroups([uid], next);
},
sso: function (next) {
plugins.fireHook('filter:auth.list', {uid: uid, associations: []}, next);
plugins.fireHook('filter:auth.list', { uid: uid, associations: [] }, next);
},
}, next);
},

@ -36,7 +36,7 @@ infoController.get = function (req, res, callback) {
userData.usernames = data.usernames;
userData.emails = data.emails;
userData.title = '[[pages:account/info]]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:account_info]]'}]);
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[user:account_info]]' }]);
res.render('account/info', userData);
});

@ -14,7 +14,7 @@ notificationsController.get = function (req, res, next) {
notifications: notifications,
nextStart: 40,
title: '[[pages:notifications]]',
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[pages:notifications]]'}]),
breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[pages:notifications]]' }]),
});
});
};

@ -143,7 +143,7 @@ function getFromUserSet(template, req, res, callback) {
userData.noItemsFoundKey = data.noItemsFoundKey;
userData.title = '[[pages:' + data.template + ', ' + userData.username + ']]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: data.crumb}]);
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: data.crumb }]);
res.render(data.template, userData);
});

@ -76,7 +76,7 @@ profileController.get = function (req, res, callback) {
userData.hasPrivateChat = results.hasPrivateChat;
userData.aboutme = results.aboutme;
userData.nextStart = results.posts.nextStart;
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username}]);
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username }]);
userData.title = userData.username;
var pageCount = Math.ceil(userData.postcount / itemsPerPage);
userData.pagination = pagination.create(page, pageCount, req.query);
@ -127,7 +127,7 @@ profileController.get = function (req, res, callback) {
return group && group.name === userData.groupTitle;
});
plugins.fireHook('filter:user.account', {userData: userData, uid: req.uid}, next);
plugins.fireHook('filter:user.account', { userData: userData, uid: req.uid }, next);
},
], function (err, results) {
if (err) {

@ -58,11 +58,11 @@ settingsController.get = function (req, res, callback) {
Object.keys(soundSettings).forEach(function (setting) {
userData[setting] = Object.keys(results.sounds).map(function (name) {
return {name: name, selected: name === results.soundsMapping[soundSettings[setting]]};
return { name: name, selected: name === results.soundsMapping[soundSettings[setting]] };
});
});
plugins.fireHook('filter:user.customSettings', {settings: results.settings, customSettings: [], uid: req.uid}, next);
plugins.fireHook('filter:user.customSettings', { settings: results.settings, customSettings: [], uid: req.uid }, next);
},
function (data, next) {
userData.customSettings = data.customSettings;
@ -75,10 +75,10 @@ settingsController.get = function (req, res, callback) {
}
userData.dailyDigestFreqOptions = [
{value: 'off', name: '[[user:digest_off]]', selected: 'off' === userData.settings.dailyDigestFreq},
{value: 'day', name: '[[user:digest_daily]]', selected: 'day' === userData.settings.dailyDigestFreq},
{value: 'week', name: '[[user:digest_weekly]]', selected: 'week' === userData.settings.dailyDigestFreq},
{value: 'month', name: '[[user:digest_monthly]]', selected: 'month' === userData.settings.dailyDigestFreq},
{ value: 'off', name: '[[user:digest_off]]', selected: 'off' === userData.settings.dailyDigestFreq },
{ value: 'day', name: '[[user:digest_daily]]', selected: 'day' === userData.settings.dailyDigestFreq },
{ value: 'week', name: '[[user:digest_weekly]]', selected: 'week' === userData.settings.dailyDigestFreq },
{ value: 'month', name: '[[user:digest_monthly]]', selected: 'month' === userData.settings.dailyDigestFreq },
];
@ -135,7 +135,7 @@ settingsController.get = function (req, res, callback) {
userData.inTopicSearchAvailable = plugins.hasListeners('filter:topic.search');
userData.title = '[[pages:account/settings]]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:settings]]'}]);
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username, url: '/user/' + userData.userslug }, { text: '[[user:settings]]' }]);
res.render('account/settings', userData);
});
@ -163,7 +163,7 @@ function getHomePageRoutes(callback) {
categoryData = categoryData || [];
plugins.fireHook('filter:homepage.get', {routes: [
plugins.fireHook('filter:homepage.get', { routes: [
{
route: 'categories',
name: 'Categories',
@ -180,7 +180,7 @@ function getHomePageRoutes(callback) {
route: 'popular',
name: 'Popular',
},
].concat(categoryData)}, next);
].concat(categoryData) }, next);
},
function (data, next) {
next(null, data.routes);

@ -34,7 +34,7 @@ groupsController.list = function (req, res, next) {
groups.getGroupsData(groupNames, next);
},
function (groupData, next) {
next(null, {groups: groupData, pagination: pagination.create(page, pageCount)});
next(null, { groups: groupData, pagination: pagination.create(page, pageCount) });
},
], function (err, data) {
if (err) {
@ -59,14 +59,14 @@ groupsController.get = function (req, res, callback) {
if (!exists) {
return callback();
}
groups.get(groupName, {uid: req.uid, truncateUserList: true, userListCount: 20}, next);
groups.get(groupName, { uid: req.uid, truncateUserList: true, userListCount: 20 }, next);
},
], function (err, group) {
if (err) {
return callback(err);
}
group.isOwner = true;
res.render('admin/manage/group', {group: group, allowPrivateGroups: parseInt(meta.config.allowPrivateGroups, 10) === 1});
res.render('admin/manage/group', { group: group, allowPrivateGroups: parseInt(meta.config.allowPrivateGroups, 10) === 1 });
});
};

@ -35,7 +35,7 @@ homePageController.get = function (req, res, next) {
categoryData = [];
}
plugins.fireHook('filter:homepage.get', {routes: [
plugins.fireHook('filter:homepage.get', { routes: [
{
route: 'categories',
name: 'Categories',
@ -48,7 +48,7 @@ homePageController.get = function (req, res, next) {
route: 'popular',
name: 'Popular',
},
].concat(categoryData)}, function (err, data) {
].concat(categoryData) }, function (err, data) {
if (err) {
return next(err);
}

@ -24,7 +24,7 @@ infoController.get = function (req, res, next) {
data.sort(function (a, b) {
return (a.os.hostname < b.os.hostname) ? -1 : (a.os.hostname > b.os.hostname) ? 1 : 0;
});
res.render('admin/development/info', {info: data, infoJSON: JSON.stringify(data, null, 4), host: os.hostname(), port: nconf.get('port')});
res.render('admin/development/info', { info: data, infoJSON: JSON.stringify(data, null, 4), host: os.hostname(), port: nconf.get('port') });
}, 500);
};
@ -33,7 +33,7 @@ pubsub.on('sync:node:info:start', function () {
if (err) {
return winston.error(err);
}
pubsub.publish('sync:node:info:end', {data: data, id: os.hostname() + ':' + nconf.get('port')});
pubsub.publish('sync:node:info:end', { data: data, id: os.hostname() + ':' + nconf.get('port') });
});
});

@ -10,7 +10,7 @@ tagsController.get = function (req, res, next) {
return next(err);
}
res.render('admin/manage/tags', {tags: tags});
res.render('admin/manage/tags', { tags: tags });
});
};

@ -49,7 +49,7 @@ uploadsController.uploadFavicon = function (req, res, next) {
return next(err);
}
res.json([{name: uploadedFile.name, url: image.url}]);
res.json([{ name: uploadedFile.name, url: image.url }]);
});
}
};
@ -87,7 +87,7 @@ uploadsController.uploadTouchIcon = function (req, res, next) {
return next(err);
}
res.json([{name: uploadedFile.name, url: imageObj.url}]);
res.json([{ name: uploadedFile.name, url: imageObj.url }]);
});
});
}
@ -145,7 +145,7 @@ function validateUpload(req, res, next, uploadedFile, allowedTypes) {
}
});
res.json({error: '[[error:invalid-image-type, ' + allowedTypes.join('&#44; ') + ']]'});
res.json({ error: '[[error:invalid-image-type, ' + allowedTypes.join('&#44; ') + ']]' });
return false;
}
@ -163,11 +163,11 @@ function uploadImage(filename, folder, uploadedFile, req, res, next) {
return next(err);
}
res.json([{name: uploadedFile.name, url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url}]);
res.json([{ name: uploadedFile.name, url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url }]);
}
if (plugins.hasListeners('filter:uploadImage')) {
plugins.fireHook('filter:uploadImage', {image: uploadedFile, uid: req.user.uid}, done);
plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.user.uid }, done);
} else {
file.saveFileToLocal(filename, folder, uploadedFile.path, done);
}

@ -71,7 +71,7 @@ usersController.registrationQueue = function (req, res, next) {
user.getRegistrationQueue(start, stop, next);
},
customHeaders: function (next) {
plugins.fireHook('filter:admin.registrationQueue.customHeaders', {headers: []}, next);
plugins.fireHook('filter:admin.registrationQueue.customHeaders', { headers: [] }, next);
},
invites: function (next) {
async.waterfall([

@ -311,7 +311,7 @@ apiController.getModerators = function (req, res, next) {
if (err) {
return next(err);
}
res.json({moderators: moderators});
res.json({ moderators: moderators });
});
};

@ -74,7 +74,7 @@ authenticationController.register = function (req, res, next) {
},
function (queue, next) {
res.locals.processLogin = true; // set it to false in plugin if you wish to just register only
plugins.fireHook('filter:register.check', {req: req, res: res, userData: userData, queue: queue}, next);
plugins.fireHook('filter:register.check', { req: req, res: res, userData: userData, queue: queue }, next);
},
function (data, next) {
if (data.queue) {
@ -133,7 +133,7 @@ function registerAndLoginUser(req, res, userData, callback) {
},
function (next) {
user.deleteInvitationKey(userData.email);
plugins.fireHook('filter:register.complete', {uid: uid, referrer: req.body.referrer || nconf.get('relative_path') + '/'}, next);
plugins.fireHook('filter:register.complete', { uid: uid, referrer: req.body.referrer || nconf.get('relative_path') + '/' }, next);
},
], callback);
}
@ -145,7 +145,7 @@ function addToApprovalQueue(req, userData, callback) {
user.addToApprovalQueue(userData, next);
},
function (next) {
next(null, {message: '[[register:registration-added-to-queue]]'});
next(null, { message: '[[register:registration-added-to-queue]]' });
},
], callback);
}
@ -284,7 +284,7 @@ authenticationController.doLogin = function (req, uid, callback) {
return callback();
}
req.login({uid: uid}, function (err) {
req.login({ uid: uid }, function (err) {
if (err) {
return callback(err);
}
@ -427,7 +427,7 @@ authenticationController.logout = function (req, res, next) {
user.setUserField(uid, 'lastonline', Date.now() - 300000);
plugins.fireHook('static:user.loggedOut', {req: req, res: res, uid: uid}, function () {
plugins.fireHook('static:user.loggedOut', { req: req, res: res, uid: uid }, function () {
res.status(200).send('');
// Force session check for all connected socket.io clients with the same session id

@ -60,7 +60,7 @@ categoriesController.list = function (req, res, next) {
};
if (req.path.startsWith('/api/categories') || req.path.startsWith('/categories')) {
data.breadcrumbs = helpers.buildBreadcrumbs([{text: data.title}]);
data.breadcrumbs = helpers.buildBreadcrumbs([{ text: data.title }]);
}
data.categories.forEach(function (category) {

@ -19,7 +19,7 @@ groupsController.list = function (req, res, next) {
return next(err);
}
data.title = '[[pages:groups]]';
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:groups]]'}]);
data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[pages:groups]]' }]);
res.render('groups/list', data);
});
};
@ -108,7 +108,7 @@ groupsController.details = function (req, res, callback) {
}
results.group.isOwner = results.group.isOwner || results.isAdmin || (results.isGlobalMod && !results.group.system);
results.title = '[[pages:group, ' + results.group.displayName + ']]';
results.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:groups]]', url: '/groups' }, {text: results.group.displayName}]);
results.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[pages:groups]]', url: '/groups' }, { text: results.group.displayName }]);
results.allowPrivateGroups = parseInt(meta.config.allowPrivateGroups, 10) === 1;
res.render('groups/details', results);
@ -145,9 +145,9 @@ groupsController.members = function (req, res, callback) {
}
var breadcrumbs = helpers.buildBreadcrumbs([
{text: '[[pages:groups]]', url: '/groups' },
{text: validator.escape(String(groupName)), url: '/groups/' + req.params.slug},
{text: '[[groups:details.members]]'},
{ text: '[[pages:groups]]', url: '/groups' },
{ text: validator.escape(String(groupName)), url: '/groups/' + req.params.slug },
{ text: '[[groups:details.members]]' },
]);
res.render('groups/members', {
@ -180,7 +180,7 @@ groupsController.uploadCover = function (req, res, next) {
if (err) {
return next(err);
}
res.json([{url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url}]);
res.json([{ url: image.url.startsWith('http') ? image.url : nconf.get('relative_path') + image.url }]);
});
};

@ -164,7 +164,7 @@ helpers.getWatchedCategories = function (uid, selectedCid, callback) {
recursive(category, categoriesData, '');
});
next(null, {categories: categoriesData, selectedCategory: selectedCategory});
next(null, { categories: categoriesData, selectedCategory: selectedCategory });
},
], callback);
};

@ -46,7 +46,7 @@ Controllers.home = function (req, res, next) {
var hook = 'action:homepage.get:' + route;
if (plugins.hasListeners(hook)) {
return plugins.fireHook(hook, {req: req, res: res, next: next});
return plugins.fireHook(hook, { req: req, res: res, next: next });
}
if (route === 'categories' || route === '/') {
@ -83,7 +83,7 @@ Controllers.reset = function (req, res, next) {
displayExpiryNotice: req.session.passwordExpired,
code: req.params.code,
minimumPasswordLength: parseInt(meta.config.minimumPasswordLength, 10),
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]', url: '/reset'}, {text: '[[reset_password:update_password]]'}]),
breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[reset_password:reset_password]]', url: '/reset' }, { text: '[[reset_password:update_password]]' }]),
title: '[[pages:reset]]',
});
@ -92,7 +92,7 @@ Controllers.reset = function (req, res, next) {
} else {
res.render('reset', {
code: null,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]'}]),
breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[reset_password:reset_password]]' }]),
title: '[[pages:reset]]',
});
}
@ -122,7 +122,7 @@ Controllers.login = function (req, res, next) {
data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1 || parseInt(req.query.local, 10) === 1;
data.allowRegistration = registrationType === 'normal' || registrationType === 'admin-approval' || registrationType === 'admin-approval-ip';
data.allowLoginWith = '[[login:' + allowLoginWith + ']]';
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]);
data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[global:login]]' }]);
data.error = req.flash('error')[0] || errorText;
data.title = '[[pages:login]]';
@ -170,7 +170,7 @@ Controllers.register = function (req, res, next) {
}
},
function (next) {
plugins.fireHook('filter:parse.post', {postData: {content: meta.config.termsOfUse || ''}}, next);
plugins.fireHook('filter:parse.post', { postData: { content: meta.config.termsOfUse || '' } }, next);
},
], function (err, termsOfUse) {
if (err) {
@ -188,7 +188,7 @@ Controllers.register = function (req, res, next) {
data.maximumUsernameLength = parseInt(meta.config.maximumUsernameLength, 10);
data.minimumPasswordLength = parseInt(meta.config.minimumPasswordLength, 10);
data.termsOfUse = termsOfUse.postData.content;
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[register:register]]'}]);
data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[register:register]]' }]);
data.regFormEntry = [];
data.error = req.flash('error')[0] || errorText;
data.title = '[[pages:register]]';
@ -329,7 +329,7 @@ Controllers.outgoing = function (req, res) {
var data = {
outgoing: validator.escape(String(url)),
title: meta.config.title,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[notifications:outgoing_link]]'}]),
breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[notifications:outgoing_link]]' }]),
};
if (url) {
@ -343,7 +343,7 @@ Controllers.termsOfUse = function (req, res, next) {
if (!meta.config.termsOfUse) {
return next();
}
res.render('tos', {termsOfUse: meta.config.termsOfUse});
res.render('tos', { termsOfUse: meta.config.termsOfUse });
};
Controllers.ping = function (req, res) {
@ -378,11 +378,11 @@ Controllers.handle404 = function (req, res) {
var path = String(req.path || '');
if (res.locals.isAPI) {
return res.json({path: validator.escape(path.replace(/^\/api/, '')), title: '[[global:404.title]]'});
return res.json({ path: validator.escape(path.replace(/^\/api/, '')), title: '[[global:404.title]]' });
}
var middleware = require('../middleware');
middleware.buildHeader(req, res, function () {
res.render('404', {path: validator.escape(path), title: '[[global:404.title]]'});
res.render('404', { path: validator.escape(path), title: '[[global:404.title]]' });
});
} else {
res.status(404).type('txt').send('Not found');
@ -436,7 +436,7 @@ Controllers.handleErrors = function (err, req, res, next) {
var path = String(req.path || '');
if (res.locals.isAPI) {
res.json({path: validator.escape(path), error: err.message});
res.json({ path: validator.escape(path), error: err.message });
} else {
var middleware = require('../middleware');
middleware.buildHeader(req, res, function () {

@ -52,10 +52,10 @@ popularController.get = function (req, res, next) {
};
if (req.path.startsWith('/api/popular') || req.path.startsWith('/popular')) {
var breadcrumbs = [{text: termToBreadcrumb[term]}];
var breadcrumbs = [{ text: termToBreadcrumb[term] }];
if (req.params.term) {
breadcrumbs.unshift({text: '[[global:header.popular]]', url: '/popular'});
breadcrumbs.unshift({ text: '[[global:header.popular]]', url: '/popular' });
}
data.breadcrumbs = helpers.buildBreadcrumbs(breadcrumbs);

@ -13,7 +13,7 @@ var pagination = require('../pagination');
var recentController = {};
var validFilter = {'': true, new: true, watched: true};
var validFilter = { '': true, new: true, watched: true };
recentController.get = function (req, res, next) {
var page = parseInt(req.query.page, 10) || 1;
@ -84,7 +84,7 @@ recentController.get = function (req, res, next) {
data.pagination = pagination.create(page, pageCount, req.query);
if (req.path.startsWith('/api/recent') || req.path.startsWith('/recent')) {
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[recent:title]]'}]);
data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[recent:title]]' }]);
}
data.querystring = cid ? ('?cid=' + validator.escape(String(cid))) : '';

@ -54,8 +54,8 @@ searchController.search = function (req, res, next) {
}
var categoriesData = [
{value: 'all', text: '[[unread:all_categories]]'},
{value: 'watched', text: '[[category:watched-categories]]'},
{ value: 'all', text: '[[unread:all_categories]]' },
{ value: 'watched', text: '[[category:watched-categories]]' },
].concat(results.categories);
var searchData = results.search;
@ -65,7 +65,7 @@ searchController.search = function (req, res, next) {
searchData.showAsPosts = !req.query.showAs || req.query.showAs === 'posts';
searchData.showAsTopics = req.query.showAs === 'topics';
searchData.title = '[[global:header.search]]';
searchData.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:search]]'}]);
searchData.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[global:search]]' }]);
searchData.expandSearch = !req.query.term;
res.render('search', searchData);

@ -19,7 +19,7 @@ tagsController.getTag = function (req, res, next) {
var templateData = {
topics: [],
tag: tag,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]', url: '/tags'}, {text: tag}]),
breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[tags:tags]]', url: '/tags' }, { text: tag }]),
title: '[[pages:tag, ' + tag + ']]',
};
var settings;
@ -86,7 +86,7 @@ tagsController.getTags = function (req, res, next) {
var data = {
tags: tags,
nextStart: 100,
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[tags:tags]]'}]),
breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[tags:tags]]' }]),
title: '[[pages:tags]]',
};
res.render('tags', data);

@ -125,7 +125,7 @@ topicsController.get = function (req, res, callback) {
topics.modifyPostsByPrivilege(topicData, userPrivileges);
plugins.fireHook('filter:controllers.topic.get', {topicData: topicData, uid: req.uid}, next);
plugins.fireHook('filter:controllers.topic.get', { topicData: topicData, uid: req.uid }, next);
},
function (data, next) {
var breadcrumbs = [
@ -315,7 +315,7 @@ topicsController.teaser = function (req, res, next) {
if (!pid) {
return res.status(404).json('not-found');
}
posts.getPostSummaryByPids([pid], req.uid, {stripTags: false}, next);
posts.getPostSummaryByPids([pid], req.uid, { stripTags: false }, next);
},
], function (err, posts) {
if (err) {

@ -12,7 +12,7 @@ var helpers = require('./helpers');
var unreadController = {};
var validFilter = {'': true, new: true, watched: true};
var validFilter = { '': true, new: true, watched: true };
unreadController.get = function (req, res, next) {
var page = parseInt(req.query.page, 10) || 1;
@ -59,7 +59,7 @@ unreadController.get = function (req, res, next) {
data.selectedCategory = results.watchedCategories.selectedCategory;
if (req.path.startsWith('/api/unread') || req.path.startsWith('/unread')) {
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[unread:title]]'}]);
data.breadcrumbs = helpers.buildBreadcrumbs([{ text: '[[unread:title]]' }]);
}
data.title = '[[pages:unread]]';

@ -59,7 +59,7 @@ function uploadAsImage(req, uploadedFile, callback) {
return next(new Error('[[error:no-privileges]]'));
}
if (plugins.hasListeners('filter:uploadImage')) {
return plugins.fireHook('filter:uploadImage', {image: uploadedFile, uid: req.uid}, callback);
return plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.uid }, callback);
}
file.isFileTypeAllowed(uploadedFile.path, next);
},
@ -155,7 +155,7 @@ uploadsController.uploadThumb = function (req, res, next) {
}
if (plugins.hasListeners('filter:uploadImage')) {
return plugins.fireHook('filter:uploadImage', {image: uploadedFile, uid: req.uid}, next);
return plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.uid }, next);
}
uploadFile(req.uid, uploadedFile, next);
@ -166,11 +166,11 @@ uploadsController.uploadThumb = function (req, res, next) {
uploadsController.uploadGroupCover = function (uid, uploadedFile, callback) {
if (plugins.hasListeners('filter:uploadImage')) {
return plugins.fireHook('filter:uploadImage', {image: uploadedFile, uid: uid}, callback);
return plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: uid }, callback);
}
if (plugins.hasListeners('filter:uploadFile')) {
return plugins.fireHook('filter:uploadFile', {file: uploadedFile, uid: uid}, callback);
return plugins.fireHook('filter:uploadFile', { file: uploadedFile, uid: uid }, callback);
}
file.isFileTypeAllowed(uploadedFile.path, function (err) {
@ -183,7 +183,7 @@ uploadsController.uploadGroupCover = function (uid, uploadedFile, callback) {
function uploadFile(uid, uploadedFile, callback) {
if (plugins.hasListeners('filter:uploadFile')) {
return plugins.fireHook('filter:uploadFile', {file: uploadedFile, uid: uid}, callback);
return plugins.fireHook('filter:uploadFile', { file: uploadedFile, uid: uid }, callback);
}
if (!uploadedFile) {

@ -146,22 +146,22 @@ usersController.renderUsersPage = function (set, req, res, next) {
usersController.getUsers = function (set, uid, query, callback) {
var setToData = {
'users:postcount': {title: '[[pages:users/sort-posts]]', crumb: '[[users:top_posters]]'},
'users:reputation': {title: '[[pages:users/sort-reputation]]', crumb: '[[users:most_reputation]]'},
'users:joindate': {title: '[[pages:users/latest]]', crumb: '[[global:users]]'},
'users:online': {title: '[[pages:users/online]]', crumb: '[[global:online]]'},
'users:banned': {title: '[[pages:users/banned]]', crumb: '[[user:banned]]'},
'users:flags': {title: '[[pages:users/most-flags]]', crumb: '[[users:most_flags]]'},
'users:postcount': { title: '[[pages:users/sort-posts]]', crumb: '[[users:top_posters]]' },
'users:reputation': { title: '[[pages:users/sort-reputation]]', crumb: '[[users:most_reputation]]' },
'users:joindate': { title: '[[pages:users/latest]]', crumb: '[[global:users]]' },
'users:online': { title: '[[pages:users/online]]', crumb: '[[global:online]]' },
'users:banned': { title: '[[pages:users/banned]]', crumb: '[[user:banned]]' },
'users:flags': { title: '[[pages:users/most-flags]]', crumb: '[[users:most_flags]]' },
};
if (!setToData[set]) {
setToData[set] = {title: '', crumb: ''};
setToData[set] = { title: '', crumb: '' };
}
var breadcrumbs = [{text: setToData[set].crumb}];
var breadcrumbs = [{ text: setToData[set].crumb }];
if (set !== 'users:joindate') {
breadcrumbs.unshift({text: '[[global:users]]', url: '/users'});
breadcrumbs.unshift({ text: '[[global:users]]', url: '/users' });
}
var page = parseInt(query.page, 10) || 1;

@ -9,7 +9,7 @@ module.exports = function (db, module) {
return callback();
}
db.collection('objects').update({_key: key}, {$set: data}, {upsert: true, w: 1}, function (err) {
db.collection('objects').update({ _key: key }, { $set: data }, { upsert: true, w: 1 }, function (err) {
callback(err);
});
};
@ -29,14 +29,14 @@ module.exports = function (db, module) {
if (!key) {
return callback();
}
db.collection('objects').findOne({_key: key}, {_id: 0, _key: 0}, callback);
db.collection('objects').findOne({ _key: key }, { _id: 0, _key: 0 }, callback);
};
module.getObjects = function (keys, callback) {
if (!Array.isArray(keys) || !keys.length) {
return callback(null, []);
}
db.collection('objects').find({_key: {$in: keys}}, {_id: 0}).toArray(function (err, data) {
db.collection('objects').find({ _key: { $in: keys } }, { _id: 0 }).toArray(function (err, data) {
if (err) {
return callback(err);
}
@ -61,7 +61,7 @@ module.exports = function (db, module) {
_id: 0,
};
_fields[field] = 1;
db.collection('objects').findOne({_key: key}, {fields: _fields}, function (err, item) {
db.collection('objects').findOne({ _key: key }, { fields: _fields }, function (err, item) {
if (err || !item) {
return callback(err, null);
}
@ -82,7 +82,7 @@ module.exports = function (db, module) {
fields[i] = helpers.fieldToString(fields[i]);
_fields[fields[i]] = 1;
}
db.collection('objects').findOne({_key: key}, {fields: _fields}, function (err, item) {
db.collection('objects').findOne({ _key: key }, { fields: _fields }, function (err, item) {
if (err) {
return callback(err);
}
@ -109,7 +109,7 @@ module.exports = function (db, module) {
_fields[fields[i]] = 1;
}
db.collection('objects').find({_key: {$in: keys}}, {fields: _fields}).toArray(function (err, items) {
db.collection('objects').find({ _key: { $in: keys } }, { fields: _fields }).toArray(function (err, items) {
if (err) {
return callback(err);
}
@ -166,7 +166,7 @@ module.exports = function (db, module) {
var data = {};
field = helpers.fieldToString(field);
data[field] = '';
db.collection('objects').findOne({_key: key}, {fields: data}, function (err, item) {
db.collection('objects').findOne({ _key: key }, { fields: data }, function (err, item) {
callback(err, !!item && item[field] !== undefined && item[field] !== null);
});
};
@ -182,7 +182,7 @@ module.exports = function (db, module) {
data[field] = '';
});
db.collection('objects').findOne({_key: key}, {fields: data}, function (err, item) {
db.collection('objects').findOne({ _key: key }, { fields: data }, function (err, item) {
if (err) {
return callback(err);
}
@ -216,7 +216,7 @@ module.exports = function (db, module) {
data[field] = '';
});
db.collection('objects').update({_key: key}, {$unset: data}, function (err) {
db.collection('objects').update({ _key: key }, { $unset: data }, function (err) {
callback(err);
});
};
@ -240,7 +240,7 @@ module.exports = function (db, module) {
field = helpers.fieldToString(field);
data[field] = value;
db.collection('objects').findAndModify({_key: key}, {}, {$inc: data}, {new: true, upsert: true}, function (err, result) {
db.collection('objects').findAndModify({ _key: key }, {}, { $inc: data }, { new: true, upsert: true }, function (err, result) {
callback(err, result && result.value ? result.value[field] : null);
});
};

@ -18,7 +18,7 @@ module.exports = function (db, module) {
}
if (exists) {
db.collection('objects').update({_key: key}, {$push: {array: {$each: [value], $position: 0}}}, {upsert: true, w: 1 }, function (err, res) {
db.collection('objects').update({ _key: key }, { $push: { array: { $each: [value], $position: 0 } } }, { upsert: true, w: 1 }, function (err, res) {
callback(err);
});
} else {
@ -33,7 +33,7 @@ module.exports = function (db, module) {
return callback();
}
value = helpers.valueToString(value);
db.collection('objects').update({ _key: key }, { $push: { array: value } }, {upsert: true, w: 1}, function (err, res) {
db.collection('objects').update({ _key: key }, { $push: { array: value } }, { upsert: true, w: 1 }, function (err, res) {
callback(err);
});
};
@ -48,7 +48,7 @@ module.exports = function (db, module) {
return callback(err);
}
db.collection('objects').update({_key: key }, { $pop: { array: 1 } }, function (err, result) {
db.collection('objects').update({ _key: key }, { $pop: { array: 1 } }, function (err, result) {
callback(err, (value && value.length) ? value[0] : null);
});
});
@ -61,7 +61,7 @@ module.exports = function (db, module) {
}
value = helpers.valueToString(value);
db.collection('objects').update({_key: key }, { $pull: { array: value } }, function (err, res) {
db.collection('objects').update({ _key: key }, { $pull: { array: value } }, function (err, res) {
callback(err);
});
};
@ -76,7 +76,7 @@ module.exports = function (db, module) {
return callback(err);
}
db.collection('objects').update({_key: key}, {$set: {array: value}}, function (err, res) {
db.collection('objects').update({ _key: key }, { $set: { array: value } }, function (err, res) {
callback(err);
});
});
@ -87,7 +87,7 @@ module.exports = function (db, module) {
return callback();
}
db.collection('objects').findOne({_key: key}, { array: 1}, function (err, data) {
db.collection('objects').findOne({ _key: key }, { array: 1 }, function (err, data) {
if (err || !(data && data.array)) {
return callback(err, []);
}

@ -23,7 +23,7 @@ module.exports = function (db, module) {
if (!key) {
return callback();
}
db.collection('objects').findOne({_key: key}, function (err, item) {
db.collection('objects').findOne({ _key: key }, function (err, item) {
callback(err, item !== undefined && item !== null);
});
};
@ -33,7 +33,7 @@ module.exports = function (db, module) {
if (!key) {
return callback();
}
db.collection('objects').remove({_key: key}, function (err, res) {
db.collection('objects').remove({ _key: key }, function (err, res) {
callback(err);
});
};
@ -43,7 +43,7 @@ module.exports = function (db, module) {
if (!Array.isArray(keys) || !keys.length) {
return callback();
}
db.collection('objects').remove({_key: {$in: keys}}, function (err, res) {
db.collection('objects').remove({ _key: { $in: keys } }, function (err, res) {
callback(err);
});
};
@ -60,7 +60,7 @@ module.exports = function (db, module) {
if (!key) {
return callback();
}
var data = {value: value};
var data = { value: value };
module.setObject(key, data, callback);
};
@ -69,14 +69,14 @@ module.exports = function (db, module) {
if (!key) {
return callback();
}
db.collection('objects').findAndModify({_key: key}, {}, {$inc: {value: 1}}, {new: true, upsert: true}, function (err, result) {
db.collection('objects').findAndModify({ _key: key }, {}, { $inc: { value: 1 } }, { new: true, upsert: true }, function (err, result) {
callback(err, result && result.value ? result.value.value : null);
});
};
module.rename = function (oldKey, newKey, callback) {
callback = callback || helpers.noop;
db.collection('objects').update({_key: oldKey}, {$set: {_key: newKey}}, {multi: true}, function (err, res) {
db.collection('objects').update({ _key: oldKey }, { $set: { _key: newKey } }, { multi: true }, function (err, res) {
callback(err);
});
};

@ -47,11 +47,11 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for (var i = 0; i < keys.length; i += 1) {
bulk.find({_key: keys[i]}).upsert().updateOne({ $addToSet: {
bulk.find({ _key: keys[i] }).upsert().updateOne({ $addToSet: {
members: {
$each: value,
},
}});
} });
}
bulk.execute(function (err, res) {
@ -69,7 +69,7 @@ module.exports = function (db, module) {
array[index] = helpers.valueToString(element);
});
db.collection('objects').update({_key: key}, {$pullAll: {members: value}}, function (err, res) {
db.collection('objects').update({ _key: key }, { $pullAll: { members: value } }, function (err, res) {
callback(err);
});
};
@ -84,9 +84,9 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for (var i = 0; i < keys.length; i += 1) {
bulk.find({_key: keys[i]}).updateOne({$pull: {
bulk.find({ _key: keys[i] }).updateOne({ $pull: {
members: value,
}});
} });
}
bulk.execute(function (err, res) {
@ -100,7 +100,7 @@ module.exports = function (db, module) {
}
value = helpers.valueToString(value);
db.collection('objects').findOne({_key: key, members: value}, {_id: 0, members: 0}, function (err, item) {
db.collection('objects').findOne({ _key: key, members: value }, { _id: 0, members: 0 }, function (err, item) {
callback(err, item !== null && item !== undefined);
});
};
@ -114,7 +114,7 @@ module.exports = function (db, module) {
values[i] = helpers.valueToString(values[i]);
}
db.collection('objects').findOne({_key: key}, {_id: 0, _key: 0}, function (err, items) {
db.collection('objects').findOne({ _key: key }, { _id: 0, _key: 0 }, function (err, items) {
if (err) {
return callback(err);
}
@ -133,7 +133,7 @@ module.exports = function (db, module) {
}
value = helpers.valueToString(value);
db.collection('objects').find({_key: {$in: sets}, members: value}, {_id: 0, members: 0}).toArray(function (err, result) {
db.collection('objects').find({ _key: { $in: sets }, members: value }, { _id: 0, members: 0 }).toArray(function (err, result) {
if (err) {
return callback(err);
}
@ -154,7 +154,7 @@ module.exports = function (db, module) {
if (!key) {
return callback(null, []);
}
db.collection('objects').findOne({_key: key}, {members: 1}, {_id: 0, _key: 0}, function (err, data) {
db.collection('objects').findOne({ _key: key }, { members: 1 }, { _id: 0, _key: 0 }, function (err, data) {
callback(err, data ? data.members : []);
});
};
@ -163,7 +163,7 @@ module.exports = function (db, module) {
if (!Array.isArray(keys) || !keys.length) {
return callback(null, []);
}
db.collection('objects').find({_key: {$in: keys}}, {_id: 0, _key: 1, members: 1}).toArray(function (err, data) {
db.collection('objects').find({ _key: { $in: keys } }, { _id: 0, _key: 1, members: 1 }).toArray(function (err, data) {
if (err) {
return callback(err);
}
@ -185,7 +185,7 @@ module.exports = function (db, module) {
if (!key) {
return callback(null, 0);
}
db.collection('objects').findOne({_key: key}, {_id: 0}, function (err, data) {
db.collection('objects').findOne({ _key: key }, { _id: 0 }, function (err, data) {
callback(err, data ? data.members.length : 0);
});
};
@ -205,7 +205,7 @@ module.exports = function (db, module) {
module.setRemoveRandom = function (key, callback) {
callback = callback || function () {};
db.collection('objects').findOne({_key: key}, function (err, data) {
db.collection('objects').findOne({ _key: key }, function (err, data) {
if (err || !data) {
return callback(err);
}

@ -32,13 +32,13 @@ module.exports = function (db, module) {
return callback();
}
var fields = {_id: 0, value: 1};
var fields = { _id: 0, value: 1 };
if (withScores) {
fields.score = 1;
}
if (Array.isArray(key)) {
key = {$in: key};
key = { $in: key };
}
var limit = stop - start + 1;
@ -46,10 +46,10 @@ module.exports = function (db, module) {
limit = 0;
}
db.collection('objects').find({_key: key}, {fields: fields})
db.collection('objects').find({ _key: key }, { fields: fields })
.limit(limit)
.skip(start)
.sort({score: sort})
.sort({ score: sort })
.toArray(function (err, data) {
if (err || !data) {
return callback(err);
@ -89,25 +89,25 @@ module.exports = function (db, module) {
count = 0;
}
var query = {_key: key};
var query = { _key: key };
if (min !== '-inf') {
query.score = {$gte: min};
query.score = { $gte: min };
}
if (max !== '+inf') {
query.score = query.score || {};
query.score.$lte = max;
}
var fields = {_id: 0, value: 1};
var fields = { _id: 0, value: 1 };
if (withScores) {
fields.score = 1;
}
db.collection('objects').find(query, {fields: fields})
db.collection('objects').find(query, { fields: fields })
.limit(count)
.skip(start)
.sort({score: sort})
.sort({ score: sort })
.toArray(function (err, data) {
if (err) {
return callback(err);
@ -128,9 +128,9 @@ module.exports = function (db, module) {
return callback();
}
var query = {_key: key};
var query = { _key: key };
if (min !== '-inf') {
query.score = {$gte: min};
query.score = { $gte: min };
}
if (max !== '+inf') {
query.score = query.score || {};
@ -146,7 +146,7 @@ module.exports = function (db, module) {
if (!key) {
return callback(null, 0);
}
db.collection('objects').count({_key: key}, function (err, count) {
db.collection('objects').count({ _key: key }, function (err, count) {
count = parseInt(count, 10);
callback(err, count ? count : 0);
});
@ -158,7 +158,7 @@ module.exports = function (db, module) {
}
var pipeline = [
{ $match: { _key: { $in: keys } } },
{ $group: { _id: {_key: '$_key'}, count: { $sum: 1 } } },
{ $group: { _id: { _key: '$_key' }, count: { $sum: 1 } } },
{ $project: { _id: 1, count: '$count' } },
];
db.collection('objects').aggregate(pipeline, function (err, results) {
@ -213,7 +213,7 @@ module.exports = function (db, module) {
}
var data = new Array(values.length);
for (var i = 0; i < values.length; i += 1) {
data[i] = {key: keys[i], value: values[i]};
data[i] = { key: keys[i], value: values[i] };
}
async.map(data, function (item, next) {
@ -244,7 +244,7 @@ module.exports = function (db, module) {
return callback();
}
value = helpers.valueToString(value);
db.collection('objects').findOne({_key: key, value: value}, {fields: {_id: 0, score: 1}}, function (err, result) {
db.collection('objects').findOne({ _key: key, value: value }, { fields: { _id: 0, score: 1 } }, function (err, result) {
callback(err, result ? result.score : null);
});
};
@ -254,7 +254,7 @@ module.exports = function (db, module) {
return callback();
}
value = helpers.valueToString(value);
db.collection('objects').find({_key: {$in: keys}, value: value}, {_id: 0, _key: 1, score: 1}).toArray(function (err, result) {
db.collection('objects').find({ _key: { $in: keys }, value: value }, { _id: 0, _key: 1, score: 1 }).toArray(function (err, result) {
if (err) {
return callback(err);
}
@ -277,7 +277,7 @@ module.exports = function (db, module) {
return callback();
}
values = values.map(helpers.valueToString);
db.collection('objects').find({_key: key, value: {$in: values}}, {_id: 0, value: 1, score: 1}).toArray(function (err, result) {
db.collection('objects').find({ _key: key, value: { $in: values } }, { _id: 0, value: 1, score: 1 }).toArray(function (err, result) {
if (err) {
return callback(err);
}
@ -304,7 +304,7 @@ module.exports = function (db, module) {
return callback();
}
value = helpers.valueToString(value);
db.collection('objects').findOne({_key: key, value: value}, {_id: 0, value: 1}, function (err, result) {
db.collection('objects').findOne({ _key: key, value: value }, { _id: 0, value: 1 }, function (err, result) {
callback(err, !!result);
});
};
@ -314,7 +314,7 @@ module.exports = function (db, module) {
return callback();
}
values = values.map(helpers.valueToString);
db.collection('objects').find({_key: key, value: {$in: values}}, {fields: {_id: 0, value: 1}}).toArray(function (err, results) {
db.collection('objects').find({ _key: key, value: { $in: values } }, { fields: { _id: 0, value: 1 } }).toArray(function (err, results) {
if (err) {
return callback(err);
}
@ -335,7 +335,7 @@ module.exports = function (db, module) {
return callback();
}
value = helpers.valueToString(value);
db.collection('objects').find({_key: {$in: keys}, value: value}, {fields: {_id: 0, _key: 1, value: 1}}).toArray(function (err, results) {
db.collection('objects').find({ _key: { $in: keys }, value: value }, { fields: { _id: 0, _key: 1, value: 1 } }).toArray(function (err, results) {
if (err) {
return callback(err);
}
@ -355,7 +355,7 @@ module.exports = function (db, module) {
if (!Array.isArray(keys) || !keys.length) {
return callback(null, []);
}
db.collection('objects').find({_key: {$in: keys}}, {_id: 0, _key: 1, value: 1}).toArray(function (err, data) {
db.collection('objects').find({ _key: { $in: keys } }, { _id: 0, _key: 1, value: 1 }).toArray(function (err, data) {
if (err) {
return callback(err);
}
@ -383,7 +383,7 @@ module.exports = function (db, module) {
value = helpers.valueToString(value);
data.score = parseFloat(increment);
db.collection('objects').findAndModify({_key: key, value: value}, {}, {$inc: data}, {new: true, upsert: true}, function (err, result) {
db.collection('objects').findAndModify({ _key: key, value: value }, {}, { $inc: data }, { new: true, upsert: true }, function (err, result) {
// if there is duplicate key error retry the upsert
// https://github.com/NodeBB/NodeBB/issues/4467
// https://jira.mongodb.org/browse/SERVER-14322
@ -416,11 +416,11 @@ module.exports = function (db, module) {
count = 0;
}
var query = {_key: key};
var query = { _key: key };
buildLexQuery(query, min, max);
db.collection('objects').find(query, {_id: 0, value: 1})
.sort({value: sort})
db.collection('objects').find(query, { _id: 0, value: 1 })
.sort({ value: sort })
.skip(start)
.limit(count === -1 ? 0 : count)
.toArray(function (err, data) {
@ -437,7 +437,7 @@ module.exports = function (db, module) {
module.sortedSetRemoveRangeByLex = function (key, min, max, callback) {
callback = callback || helpers.noop;
var query = {_key: key};
var query = { _key: key };
buildLexQuery(query, min, max);
db.collection('objects').remove(query, function (err) {
@ -448,11 +448,11 @@ module.exports = function (db, module) {
function buildLexQuery(query, min, max) {
if (min !== '-') {
if (min.match(/^\(/)) {
query.value = {$gt: min.slice(1)};
query.value = { $gt: min.slice(1) };
} else if (min.match(/^\[/)) {
query.value = {$gte: min.slice(1)};
query.value = { $gte: min.slice(1) };
} else {
query.value = {$gte: min};
query.value = { $gte: min };
}
}
if (max !== '+') {
@ -470,9 +470,9 @@ module.exports = function (db, module) {
module.processSortedSet = function (setKey, process, batch, callback) {
var done = false;
var ids = [];
var cursor = db.collection('objects').find({_key: setKey})
.sort({score: 1})
.project({_id: 0, value: 1})
var cursor = db.collection('objects').find({ _key: setKey })
.sort({ score: 1 })
.project({ _id: 0, value: 1 })
.batchSize(batch);
async.whilst(

@ -14,7 +14,7 @@ module.exports = function (db, module) {
value = helpers.valueToString(value);
db.collection('objects').update({_key: key, value: value}, {$set: {score: parseFloat(score)}}, {upsert: true, w: 1}, function (err) {
db.collection('objects').update({ _key: key, value: value }, { $set: { score: parseFloat(score) } }, { upsert: true, w: 1 }, function (err) {
if (err && err.message.startsWith('E11000 duplicate key error')) {
return process.nextTick(module.sortedSetAdd, key, score, value, callback);
}
@ -35,7 +35,7 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for (var i = 0; i < scores.length; i += 1) {
bulk.find({_key: key, value: values[i]}).upsert().updateOne({$set: {score: parseFloat(scores[i])}});
bulk.find({ _key: key, value: values[i] }).upsert().updateOne({ $set: { score: parseFloat(scores[i]) } });
}
bulk.execute(function (err) {
@ -53,7 +53,7 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for (var i = 0; i < keys.length; i += 1) {
bulk.find({_key: keys[i], value: value}).upsert().updateOne({$set: {score: parseFloat(score)}});
bulk.find({ _key: keys[i], value: value }).upsert().updateOne({ $set: { score: parseFloat(score) } });
}
bulk.execute(function (err) {

@ -7,9 +7,9 @@ module.exports = function (db, module) {
}
var pipeline = [
{ $match: { _key: {$in: keys}} },
{ $group: { _id: {value: '$value'}, count: {$sum: 1}} },
{ $match: { count: keys.length} },
{ $match: { _key: { $in: keys } } },
{ $group: { _id: { value: '$value' }, count: { $sum: 1 } } },
{ $match: { count: keys.length } },
{ $group: { _id: null, count: { $sum: 1 } } },
];
@ -47,7 +47,7 @@ module.exports = function (db, module) {
limit = 0;
}
var pipeline = [{ $match: { _key: {$in: sets}} }];
var pipeline = [{ $match: { _key: { $in: sets } } }];
weights.forEach(function (weight, index) {
if (weight !== 1) {
@ -70,9 +70,9 @@ module.exports = function (db, module) {
}
});
pipeline.push({ $group: { _id: {value: '$value'}, totalScore: aggregate, count: {$sum: 1}} });
pipeline.push({ $match: { count: sets.length} });
pipeline.push({ $sort: { totalScore: params.sort} });
pipeline.push({ $group: { _id: { value: '$value' }, totalScore: aggregate, count: { $sum: 1 } } });
pipeline.push({ $match: { count: sets.length } });
pipeline.push({ $sort: { totalScore: params.sort } });
if (start) {
pipeline.push({ $skip: start });
@ -82,7 +82,7 @@ module.exports = function (db, module) {
pipeline.push({ $limit: limit });
}
var project = { _id: 0, value: '$_id.value'};
var project = { _id: 0, value: '$_id.value' };
if (params.withScores) {
project.score = '$totalScore';
}

@ -14,10 +14,10 @@ module.exports = function (db, module) {
if (Array.isArray(value)) {
value = value.map(helpers.valueToString);
db.collection('objects').remove({_key: key, value: {$in: value}}, done);
db.collection('objects').remove({ _key: key, value: { $in: value } }, done);
} else {
value = helpers.valueToString(value);
db.collection('objects').remove({_key: key, value: value}, done);
db.collection('objects').remove({ _key: key, value: value }, done);
}
};
@ -28,7 +28,7 @@ module.exports = function (db, module) {
}
value = helpers.valueToString(value);
db.collection('objects').remove({_key: {$in: keys}, value: value}, function (err) {
db.collection('objects').remove({ _key: { $in: keys }, value: value }, function (err) {
callback(err);
});
};
@ -38,10 +38,10 @@ module.exports = function (db, module) {
if (!Array.isArray(keys) || !keys.length) {
return callback();
}
var query = {_key: {$in: keys}};
var query = { _key: { $in: keys } };
if (min !== '-inf') {
query.score = {$gte: min};
query.score = { $gte: min };
}
if (max !== '+inf') {
query.score = query.score || {};

@ -7,8 +7,8 @@ module.exports = function (db, module) {
}
var pipeline = [
{ $match: { _key: {$in: keys} } },
{ $group: { _id: {value: '$value' } } },
{ $match: { _key: { $in: keys } } },
{ $group: { _id: { value: '$value' } } },
{ $group: { _id: null, count: { $sum: 1 } } },
];
@ -47,9 +47,9 @@ module.exports = function (db, module) {
}
var pipeline = [
{ $match: { _key: {$in: params.sets}} },
{ $group: { _id: {value: '$value'}, totalScore: aggregate} },
{ $sort: { totalScore: params.sort} },
{ $match: { _key: { $in: params.sets } } },
{ $group: { _id: { value: '$value' }, totalScore: aggregate } },
{ $sort: { totalScore: params.sort } },
];
if (params.start) {

@ -28,7 +28,7 @@ module.exports = function (redisClient, module) {
function sortedSetRange(method, key, start, stop, withScores, callback) {
if (Array.isArray(key)) {
return module.sortedSetUnion({method: method, sets: key, start: start, stop: stop, withScores: withScores}, callback);
return module.sortedSetUnion({ method: method, sets: key, start: start, stop: stop, withScores: withScores }, callback);
}
var params = [key, start, stop];
@ -45,7 +45,7 @@ module.exports = function (redisClient, module) {
}
var objects = [];
for (var i = 0; i < data.length; i += 2) {
objects.push({value: data[i], score: parseFloat(data[i + 1])});
objects.push({ value: data[i], score: parseFloat(data[i + 1]) });
}
callback(null, objects);
});
@ -74,7 +74,7 @@ module.exports = function (redisClient, module) {
}
var objects = [];
for (var i = 0; i < data.length; i += 2) {
objects.push({value: data[i], score: parseFloat(data[i + 1])});
objects.push({ value: data[i], score: parseFloat(data[i + 1]) });
}
callback(null, objects);
});

@ -70,7 +70,7 @@ module.exports = function (redisClient, module) {
results = results[1] || [];
var objects = [];
for (var i = 0; i < results.length; i += 2) {
objects.push({value: results[i], score: parseFloat(results[i + 1])});
objects.push({ value: results[i], score: parseFloat(results[i + 1]) });
}
callback(null, objects);
});

@ -50,7 +50,7 @@ module.exports = function (redisClient, module) {
results = results[1] || [];
var objects = [];
for (var i = 0; i < results.length; i += 2) {
objects.push({value: results[i], score: parseFloat(results[i + 1])});
objects.push({ value: results[i], score: parseFloat(results[i + 1]) });
}
callback(null, objects);
});

@ -130,6 +130,6 @@ var utils = require('../public/src/utils');
batch.processSortedSet('events:time', function (eids, next) {
events.deleteEvents(eids, next);
}, {alwaysStartAt: 0}, callback);
}, { alwaysStartAt: 0 }, callback);
};
}(module.exports));

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save