mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
removed api: from client side socket calls
This commit is contained in:
@@ -36,7 +36,7 @@ var socket,
|
|||||||
app.uid = data.uid;
|
app.uid = data.uid;
|
||||||
|
|
||||||
app.showLoginMessage();
|
app.showLoginMessage();
|
||||||
socket.emit('api:meta.updateHeader', {
|
socket.emit('meta.updateHeader', {
|
||||||
fields: ['username', 'picture', 'userslug']
|
fields: ['username', 'picture', 'userslug']
|
||||||
}, app.updateHeader);
|
}, app.updateHeader);
|
||||||
});
|
});
|
||||||
@@ -77,14 +77,14 @@ var socket,
|
|||||||
}
|
}
|
||||||
app.enterRoom(room, true);
|
app.enterRoom(room, true);
|
||||||
|
|
||||||
socket.emit('api:meta.reconnected');
|
socket.emit('meta.reconnected');
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
reconnectEl.removeClass('active').addClass("hide");
|
reconnectEl.removeClass('active').addClass("hide");
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:meta.updateHeader', {
|
socket.emit('meta.updateHeader', {
|
||||||
fields: ['username', 'picture', 'userslug']
|
fields: ['username', 'picture', 'userslug']
|
||||||
}, app.updateHeader);
|
}, app.updateHeader);
|
||||||
});
|
});
|
||||||
@@ -235,7 +235,7 @@ var socket,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:meta.rooms.enter', {
|
socket.emit('meta.rooms.enter', {
|
||||||
'enter': room,
|
'enter': room,
|
||||||
'leave': app.currentRoom
|
'leave': app.currentRoom
|
||||||
});
|
});
|
||||||
@@ -251,7 +251,7 @@ var socket,
|
|||||||
uids.push(this.getAttribute('data-uid'));
|
uids.push(this.getAttribute('data-uid'));
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.emit('api:user.get_online_users', uids, function (users) {
|
socket.emit('user.get_online_users', uids, function (users) {
|
||||||
jQuery('a.username-field').each(function () {
|
jQuery('a.username-field').each(function () {
|
||||||
if (this.processed === true)
|
if (this.processed === true)
|
||||||
return;
|
return;
|
||||||
@@ -449,7 +449,7 @@ var socket,
|
|||||||
url = a.pathname.slice(1);
|
url = a.pathname.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:meta.buildTitle', url, function(title, numNotifications) {
|
socket.emit('meta.buildTitle', url, function(title, numNotifications) {
|
||||||
titleObj.titles[0] = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
|
titleObj.titles[0] = (numNotifications > 0 ? '(' + numNotifications + ') ' : '') + title;
|
||||||
app.alternatingTitle('');
|
app.alternatingTitle('');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ define(['forum/accountheader'], function(header) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
followBtn.on('click', function() {
|
followBtn.on('click', function() {
|
||||||
socket.emit('api:user.follow', {
|
socket.emit('user.follow', {
|
||||||
uid: theirid
|
uid: theirid
|
||||||
}, function(success) {
|
}, function(success) {
|
||||||
if (success) {
|
if (success) {
|
||||||
@@ -50,7 +50,7 @@ define(['forum/accountheader'], function(header) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
unfollowBtn.on('click', function() {
|
unfollowBtn.on('click', function() {
|
||||||
socket.emit('api:user.unfollow', {
|
socket.emit('user.unfollow', {
|
||||||
uid: theirid
|
uid: theirid
|
||||||
}, function(success) {
|
}, function(success) {
|
||||||
if (success) {
|
if (success) {
|
||||||
@@ -72,9 +72,9 @@ define(['forum/accountheader'], function(header) {
|
|||||||
ajaxify.go($(this).attr('topic-url'));
|
ajaxify.go($(this).attr('topic-url'));
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:user.isOnline', Account.handleUserOnline);
|
socket.on('user.isOnline', Account.handleUserOnline);
|
||||||
|
|
||||||
socket.emit('api:user.isOnline', theirid, Account.handleUserOnline);
|
socket.emit('user.isOnline', theirid, Account.handleUserOnline);
|
||||||
|
|
||||||
socket.on('event:new_post', function(data) {
|
socket.on('event:new_post', function(data) {
|
||||||
var html = templates.prepare(templates['account'].blocks['posts']).parse(data);
|
var html = templates.prepare(templates['account'].blocks['posts']).parse(data);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) {
|
|||||||
signature: $('#inputSignature').val()
|
signature: $('#inputSignature').val()
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('api:user.updateProfile', userData, function(err, data) {
|
socket.emit('user.updateProfile', userData, function(err, data) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
app.alertSuccess('Your profile has been updated successfully!');
|
app.alertSuccess('Your profile has been updated successfully!');
|
||||||
if (data.picture) {
|
if (data.picture) {
|
||||||
@@ -108,7 +108,7 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) {
|
|||||||
|
|
||||||
uploadedPicture = imageUrlOnServer;
|
uploadedPicture = imageUrlOnServer;
|
||||||
|
|
||||||
socket.emit('api:meta.updateHeader', {
|
socket.emit('meta.updateHeader', {
|
||||||
fields: ['username', 'picture', 'userslug']
|
fields: ['username', 'picture', 'userslug']
|
||||||
}, app.updateHeader);
|
}, app.updateHeader);
|
||||||
});
|
});
|
||||||
@@ -174,7 +174,7 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) {
|
|||||||
$('#changePasswordBtn').on('click', function() {
|
$('#changePasswordBtn').on('click', function() {
|
||||||
|
|
||||||
if (passwordvalid && passwordsmatch && currentPassword.val()) {
|
if (passwordvalid && passwordsmatch && currentPassword.val()) {
|
||||||
socket.emit('api:user.changePassword', {
|
socket.emit('user.changePassword', {
|
||||||
'currentPassword': currentPassword.val(),
|
'currentPassword': currentPassword.val(),
|
||||||
'newPassword': password.val()
|
'newPassword': password.val()
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
@@ -206,7 +206,7 @@ define(['forum/accountheader', 'uploader'], function(header, uploader) {
|
|||||||
type: type
|
type: type
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('api:user.changePicture', userData, function(success) {
|
socket.emit('user.changePicture', userData, function(success) {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
app.alertError('There was an error changing picture!');
|
app.alertError('There was an error changing picture!');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ define(['forum/accountheader'], function(header) {
|
|||||||
showemail: $('#showemailCheckBox').is(':checked') ? 1 : 0
|
showemail: $('#showemailCheckBox').is(':checked') ? 1 : 0
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('api:user.saveSettings', settings, function(err) {
|
socket.emit('user.saveSettings', settings, function(err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
app.alertSuccess('Settings saved!');
|
app.alertSuccess('Settings saved!');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ define(['uploader'], function(uploader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
socket.emit('api:admin.categories.update', modified_categories);
|
socket.emit('admin.categories.update', modified_categories);
|
||||||
modified_categories = {};
|
modified_categories = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ define(['uploader'], function(uploader) {
|
|||||||
order: $('.admin-categories #entry-container').children().length + 1
|
order: $('.admin-categories #entry-container').children().length + 1
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('api:admin.categories.create', category, function(err, data) {
|
socket.emit('admin.categories.create', category, function(err, data) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
app.alert({
|
app.alert({
|
||||||
alert_id: 'category_created',
|
alert_id: 'category_created',
|
||||||
@@ -223,7 +223,7 @@ define(['uploader'], function(uploader) {
|
|||||||
clearTimeout(searchDelay);
|
clearTimeout(searchDelay);
|
||||||
|
|
||||||
searchDelay = setTimeout(function() {
|
searchDelay = setTimeout(function() {
|
||||||
socket.emit('api:admin.categories.search', {
|
socket.emit('admin.categories.search', {
|
||||||
username: searchEl.value,
|
username: searchEl.value,
|
||||||
cid: cid
|
cid: cid
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
@@ -257,7 +257,7 @@ define(['uploader'], function(uploader) {
|
|||||||
privilege = this.getAttribute('data-priv');
|
privilege = this.getAttribute('data-priv');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
socket.emit('api:admin.categories.setPrivilege', {
|
socket.emit('admin.categories.setPrivilege', {
|
||||||
cid: cid,
|
cid: cid,
|
||||||
uid: uid,
|
uid: uid,
|
||||||
privilege: privilege,
|
privilege: privilege,
|
||||||
@@ -275,7 +275,7 @@ define(['uploader'], function(uploader) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// User Groups and privileges
|
// User Groups and privileges
|
||||||
socket.emit('api:admin.categories.groupsList', cid, function(err, results) {
|
socket.emit('admin.categories.groupsList', cid, function(err, results) {
|
||||||
var groupsFrag = document.createDocumentFragment(),
|
var groupsFrag = document.createDocumentFragment(),
|
||||||
numResults = results.length,
|
numResults = results.length,
|
||||||
trEl = document.createElement('tr'),
|
trEl = document.createElement('tr'),
|
||||||
@@ -303,7 +303,7 @@ define(['uploader'], function(uploader) {
|
|||||||
gid = btnEl.parents('tr[data-gid]').attr('data-gid'),
|
gid = btnEl.parents('tr[data-gid]').attr('data-gid'),
|
||||||
privilege = this.getAttribute('data-gpriv');
|
privilege = this.getAttribute('data-gpriv');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
socket.emit('api:admin.categories.setGroupPrivilege', cid, gid, privilege, !btnEl.hasClass('active'), function(err) {
|
socket.emit('admin.categories.setGroupPrivilege', cid, gid, privilege, !btnEl.hasClass('active'), function(err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
btnEl.toggleClass('active');
|
btnEl.toggleClass('active');
|
||||||
}
|
}
|
||||||
@@ -317,7 +317,7 @@ define(['uploader'], function(uploader) {
|
|||||||
var modalEl = $('#category-permissions-modal'),
|
var modalEl = $('#category-permissions-modal'),
|
||||||
readMembers = modalEl.find('#category-permissions-read'),
|
readMembers = modalEl.find('#category-permissions-read'),
|
||||||
writeMembers = modalEl.find('#category-permissions-write');
|
writeMembers = modalEl.find('#category-permissions-write');
|
||||||
socket.emit('api:admin.categories.getPrivilegeSettings', cid, function(err, privilegeList) {
|
socket.emit('admin.categories.getPrivilegeSettings', cid, function(err, privilegeList) {
|
||||||
var readLength = privilegeList['+r'].length,
|
var readLength = privilegeList['+r'].length,
|
||||||
writeLength = privilegeList['+w'].length,
|
writeLength = privilegeList['+w'].length,
|
||||||
readFrag = document.createDocumentFragment(),
|
readFrag = document.createDocumentFragment(),
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ jQuery('document').ready(function() {
|
|||||||
}, false);
|
}, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.emit('api:admin.config.get', function(config) {
|
socket.emit('admin.config.get', function(config) {
|
||||||
app.config = config;
|
app.config = config;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ define(function() {
|
|||||||
errorEl = $('#create-modal-error'),
|
errorEl = $('#create-modal-error'),
|
||||||
errorText;
|
errorText;
|
||||||
|
|
||||||
socket.emit('api:admin.groups.create', submitObj, function(err, data) {
|
socket.emit('admin.groups.create', submitObj, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case 'group-exists':
|
case 'group-exists':
|
||||||
@@ -63,14 +63,14 @@ define(function() {
|
|||||||
case 'delete':
|
case 'delete':
|
||||||
bootbox.confirm('Are you sure you wish to delete this group?', function(confirm) {
|
bootbox.confirm('Are you sure you wish to delete this group?', function(confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
socket.emit('api:admin.groups.delete', gid, function(err, data) {
|
socket.emit('admin.groups.delete', gid, function(err, data) {
|
||||||
if (data === 'OK') ajaxify.go('admin/groups');
|
if (data === 'OK') ajaxify.go('admin/groups');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'members':
|
case 'members':
|
||||||
socket.emit('api:admin.groups.get', gid, function(err, groupObj) {
|
socket.emit('admin.groups.get', gid, function(err, groupObj) {
|
||||||
var formEl = detailsModal.find('form'),
|
var formEl = detailsModal.find('form'),
|
||||||
nameEl = formEl.find('#change-group-name'),
|
nameEl = formEl.find('#change-group-name'),
|
||||||
descEl = formEl.find('#change-group-desc'),
|
descEl = formEl.find('#change-group-desc'),
|
||||||
@@ -120,7 +120,7 @@ define(function() {
|
|||||||
foundUserImg = foundUser.getElementsByTagName('img')[0];
|
foundUserImg = foundUser.getElementsByTagName('img')[0];
|
||||||
foundUserLabel = foundUser.getElementsByTagName('span')[0];
|
foundUserLabel = foundUser.getElementsByTagName('span')[0];
|
||||||
|
|
||||||
socket.emit('api:admin.user.search', searchText, function(err, results) {
|
socket.emit('admin.user.search', searchText, function(err, results) {
|
||||||
if (!err && results && results.length > 0) {
|
if (!err && results && results.length > 0) {
|
||||||
var numResults = results.length,
|
var numResults = results.length,
|
||||||
resultsSlug = document.createDocumentFragment(),
|
resultsSlug = document.createDocumentFragment(),
|
||||||
@@ -152,7 +152,7 @@ define(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (members.indexOf(uid) === -1) {
|
if (members.indexOf(uid) === -1) {
|
||||||
socket.emit('api:admin.groups.join', {
|
socket.emit('admin.groups.join', {
|
||||||
gid: gid,
|
gid: gid,
|
||||||
uid: uid
|
uid: uid
|
||||||
}, function(err, data) {
|
}, function(err, data) {
|
||||||
@@ -167,7 +167,7 @@ define(function() {
|
|||||||
var uid = this.getAttribute('data-uid'),
|
var uid = this.getAttribute('data-uid'),
|
||||||
gid = detailsModal.attr('data-gid');
|
gid = detailsModal.attr('data-gid');
|
||||||
|
|
||||||
socket.emit('api:admin.groups.leave', {
|
socket.emit('admin.groups.leave', {
|
||||||
gid: gid,
|
gid: gid,
|
||||||
uid: uid
|
uid: uid
|
||||||
}, function(err, data) {
|
}, function(err, data) {
|
||||||
@@ -183,7 +183,7 @@ define(function() {
|
|||||||
descEl = formEl.find('#change-group-desc'),
|
descEl = formEl.find('#change-group-desc'),
|
||||||
gid = detailsModal.attr('data-gid');
|
gid = detailsModal.attr('data-gid');
|
||||||
|
|
||||||
socket.emit('api:admin.groups.update', {
|
socket.emit('admin.groups.update', {
|
||||||
gid: gid,
|
gid: gid,
|
||||||
values: {
|
values: {
|
||||||
name: nameEl.val(),
|
name: nameEl.val(),
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ define(function() {
|
|||||||
var Admin = {};
|
var Admin = {};
|
||||||
|
|
||||||
Admin.init = function() {
|
Admin.init = function() {
|
||||||
ajaxify.register_events(['api:meta.rooms.getAll']);
|
ajaxify.register_events(['meta.rooms.getAll']);
|
||||||
|
|
||||||
app.enterRoom('admin');
|
app.enterRoom('admin');
|
||||||
socket.emit('api:meta.rooms.getAll', Admin.updateRoomUsage);
|
socket.emit('meta.rooms.getAll', Admin.updateRoomUsage);
|
||||||
socket.on('event:meta.rooms.update', Admin.updateRoomUsage);
|
socket.on('event:meta.rooms.update', Admin.updateRoomUsage);
|
||||||
|
|
||||||
$('#logout-link').on('click', function() {
|
$('#logout-link').on('click', function() {
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ define(function() {
|
|||||||
if (numPlugins > 0) {
|
if (numPlugins > 0) {
|
||||||
pluginsList.on('click', 'button[data-action="toggleActive"]', function() {
|
pluginsList.on('click', 'button[data-action="toggleActive"]', function() {
|
||||||
pluginID = $(this).parents('li').attr('data-plugin-id');
|
pluginID = $(this).parents('li').attr('data-plugin-id');
|
||||||
socket.emit('api:admin.plugins.toggle', pluginID);
|
socket.emit('admin.plugins.toggle', pluginID);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:admin.plugins.toggle', function(status) {
|
socket.on('admin.plugins.toggle', function(status) {
|
||||||
pluginTgl = document.querySelector('.plugins li[data-plugin-id="' + status.id + '"] button');
|
pluginTgl = document.querySelector('.plugins li[data-plugin-id="' + status.id + '"] button');
|
||||||
pluginTgl.innerHTML = '<i class="fa fa-power-off"></i> ' + (status.active ? 'Dea' : 'A') + 'ctivate';
|
pluginTgl.innerHTML = '<i class="fa fa-power-off"></i> ' + (status.active ? 'Dea' : 'A') + 'ctivate';
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ define(['uploader'], function(uploader) {
|
|||||||
value = fields[x].value;
|
value = fields[x].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:admin.config.set', {
|
socket.emit('admin.config.set', {
|
||||||
key: key,
|
key: key,
|
||||||
value: value
|
value: value
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
@@ -119,7 +119,7 @@ define(['uploader'], function(uploader) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Settings.remove = function(key) {
|
Settings.remove = function(key) {
|
||||||
socket.emit('api:admin.config.remove', key);
|
socket.emit('admin.config.remove', key);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Settings;
|
return Settings;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ define(function() {
|
|||||||
cssSrc = parentEl.attr('data-css'),
|
cssSrc = parentEl.attr('data-css'),
|
||||||
themeId = parentEl.attr('data-theme');
|
themeId = parentEl.attr('data-theme');
|
||||||
|
|
||||||
socket.emit('api:admin.themes.set', {
|
socket.emit('admin.themes.set', {
|
||||||
type: themeType,
|
type: themeType,
|
||||||
id: themeId,
|
id: themeId,
|
||||||
src: cssSrc
|
src: cssSrc
|
||||||
@@ -47,7 +47,7 @@ define(function() {
|
|||||||
revertEl.addEventListener('click', function() {
|
revertEl.addEventListener('click', function() {
|
||||||
bootbox.confirm('Are you sure you wish to remove the custom theme and restore the NodeBB default theme?', function(confirm) {
|
bootbox.confirm('Are you sure you wish to remove the custom theme and restore the NodeBB default theme?', function(confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
socket.emit('api:admin.themes.set', {
|
socket.emit('admin.themes.set', {
|
||||||
type: 'local',
|
type: 'local',
|
||||||
id: 'nodebb-theme-cerulean'
|
id: 'nodebb-theme-cerulean'
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
@@ -64,7 +64,7 @@ define(function() {
|
|||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// Installed Themes
|
// Installed Themes
|
||||||
socket.emit('api:admin.themes.getInstalled', function(themes) {
|
socket.emit('admin.themes.getInstalled', function(themes) {
|
||||||
var instListEl = document.getElementById('installed_themes'),
|
var instListEl = document.getElementById('installed_themes'),
|
||||||
themeFrag = document.createDocumentFragment(),
|
themeFrag = document.createDocumentFragment(),
|
||||||
liEl = document.createElement('li');
|
liEl = document.createElement('li');
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ define(function() {
|
|||||||
switch (action) {
|
switch (action) {
|
||||||
case 'pin':
|
case 'pin':
|
||||||
if (!$this.hasClass('active')) {
|
if (!$this.hasClass('active')) {
|
||||||
socket.emit('api:topics.pin', {
|
socket.emit('topics.pin', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, Topics.pin);
|
}, Topics.pin);
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:topics.unpin', {
|
socket.emit('topics.unpin', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, Topics.unpin);
|
}, Topics.unpin);
|
||||||
}
|
}
|
||||||
@@ -27,11 +27,11 @@ define(function() {
|
|||||||
|
|
||||||
case 'lock':
|
case 'lock':
|
||||||
if (!$this.hasClass('active')) {
|
if (!$this.hasClass('active')) {
|
||||||
socket.emit('api:topics.lock', {
|
socket.emit('topics.lock', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, Topics.lock);
|
}, Topics.lock);
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:topics.unlock', {
|
socket.emit('topics.unlock', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, Topics.unlock);
|
}, Topics.unlock);
|
||||||
}
|
}
|
||||||
@@ -39,11 +39,11 @@ define(function() {
|
|||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
if (!$this.hasClass('active')) {
|
if (!$this.hasClass('active')) {
|
||||||
socket.emit('api:topics.delete', {
|
socket.emit('topics.delete', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, Topics.setDeleted);
|
}, Topics.setDeleted);
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:topics.restore', {
|
socket.emit('topics.restore', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, Topics.restore);
|
}, Topics.restore);
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ define(function() {
|
|||||||
var lastTid = parseInt(topics[topics.length - 1].getAttribute('data-tid'));
|
var lastTid = parseInt(topics[topics.length - 1].getAttribute('data-tid'));
|
||||||
|
|
||||||
this.innerHTML = '<i class="fa fa-refresh fa-spin"></i> Retrieving topics';
|
this.innerHTML = '<i class="fa fa-refresh fa-spin"></i> Retrieving topics';
|
||||||
socket.emit('api:admin.topics.getMore', {
|
socket.emit('admin.topics.getMore', {
|
||||||
limit: 10,
|
limit: 10,
|
||||||
after: lastTid
|
after: lastTid
|
||||||
}, function(topics) {
|
}, function(topics) {
|
||||||
|
|||||||
@@ -68,14 +68,14 @@ define(function() {
|
|||||||
|
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
if (isBanned) {
|
if (isBanned) {
|
||||||
socket.emit('api:admin.user.unbanUser', uid);
|
socket.emit('admin.user.unbanUser', uid);
|
||||||
banBtn.removeClass('btn-warning');
|
banBtn.removeClass('btn-warning');
|
||||||
parent.attr('data-banned', 0);
|
parent.attr('data-banned', 0);
|
||||||
updateUserAdminButtons();
|
updateUserAdminButtons();
|
||||||
} else {
|
} else {
|
||||||
bootbox.confirm('Do you really want to ban "' + parent.attr('data-username') + '"?', function(confirm) {
|
bootbox.confirm('Do you really want to ban "' + parent.attr('data-username') + '"?', function(confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
socket.emit('api:admin.user.banUser', uid);
|
socket.emit('admin.user.banUser', uid);
|
||||||
banBtn.addClass('btn-warning');
|
banBtn.addClass('btn-warning');
|
||||||
parent.attr('data-banned', 1);
|
parent.attr('data-banned', 1);
|
||||||
updateUserAdminButtons();
|
updateUserAdminButtons();
|
||||||
@@ -103,7 +103,7 @@ define(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (!isAdmin) {
|
else if (!isAdmin) {
|
||||||
socket.emit('api:admin.user.makeAdmin', uid);
|
socket.emit('admin.user.makeAdmin', uid);
|
||||||
adminBtn.attr('value', 'UnMake Admin').html('Remove Admin');
|
adminBtn.attr('value', 'UnMake Admin').html('Remove Admin');
|
||||||
parent.attr('data-admin', 1);
|
parent.attr('data-admin', 1);
|
||||||
updateUserBanButtons();
|
updateUserBanButtons();
|
||||||
@@ -111,7 +111,7 @@ define(function() {
|
|||||||
} else if(uid !== yourid) {
|
} else if(uid !== yourid) {
|
||||||
bootbox.confirm('Do you really want to remove this user as admin "' + parent.attr('data-username') + '"?', function(confirm) {
|
bootbox.confirm('Do you really want to remove this user as admin "' + parent.attr('data-username') + '"?', function(confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
socket.emit('api:admin.user.removeAdmin', uid);
|
socket.emit('admin.user.removeAdmin', uid);
|
||||||
adminBtn.attr('value', 'Make Admin').html('Make Admin');
|
adminBtn.attr('value', 'Make Admin').html('Make Admin');
|
||||||
parent.attr('data-admin', 0);
|
parent.attr('data-admin', 0);
|
||||||
updateUserBanButtons();
|
updateUserBanButtons();
|
||||||
@@ -147,7 +147,7 @@ define(function() {
|
|||||||
password: password
|
password: password
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('api:admin.user.createUser', user, function(err, data) {
|
socket.emit('admin.user.createUser', user, function(err, data) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return errorEl.html('<strong>Error</strong><p>' + err + '</p>').removeClass('hide');
|
return errorEl.html('<strong>Error</strong><p>' + err + '</p>').removeClass('hide');
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ define(function() {
|
|||||||
|
|
||||||
jQuery('.fa-spinner').removeClass('none');
|
jQuery('.fa-spinner').removeClass('none');
|
||||||
|
|
||||||
socket.emit('api:admin.user.search', username, function(err, data) {
|
socket.emit('admin.user.search', username, function(err, data) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
@@ -242,7 +242,7 @@ define(function() {
|
|||||||
|
|
||||||
if (set) {
|
if (set) {
|
||||||
loadingMoreUsers = true;
|
loadingMoreUsers = true;
|
||||||
socket.emit('api:user.loadMore', {
|
socket.emit('user.loadMore', {
|
||||||
set: set,
|
set: set,
|
||||||
after: $('#users-container').children().length
|
after: $('#users-container').children().length
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ define(['composer'], function(composer) {
|
|||||||
|
|
||||||
socket.on('event:new_topic', Category.onNewTopic);
|
socket.on('event:new_topic', Category.onNewTopic);
|
||||||
|
|
||||||
socket.emit('api:categories.getRecentReplies', cid, renderRecentReplies);
|
socket.emit('categories.getRecentReplies', cid, renderRecentReplies);
|
||||||
|
|
||||||
$(window).off('scroll').on('scroll', function (ev) {
|
$(window).off('scroll').on('scroll', function (ev) {
|
||||||
var bottom = ($(document).height() - $(window).height()) * 0.9;
|
var bottom = ($(document).height() - $(window).height()) * 0.9;
|
||||||
@@ -81,7 +81,7 @@ define(['composer'], function(composer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
topic.hide().fadeIn('slow');
|
topic.hide().fadeIn('slow');
|
||||||
socket.emit('api:categories.getRecentReplies', templates.get('category_id'), renderRecentReplies);
|
socket.emit('categories.getRecentReplies', templates.get('category_id'), renderRecentReplies);
|
||||||
|
|
||||||
addActiveUser(data);
|
addActiveUser(data);
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ define(['composer'], function(composer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadingMoreTopics = true;
|
loadingMoreTopics = true;
|
||||||
socket.emit('api:categories.loadMore', {
|
socket.emit('categories.loadMore', {
|
||||||
cid: cid,
|
cid: cid,
|
||||||
after: $('#topics-container').children('.category-item').length
|
after: $('#topics-container').children('.category-item').length
|
||||||
}, function (data) {
|
}, function (data) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
define(['notifications', 'chat'], function(Notifications, Chat) {
|
define(['notifications', 'chat'], function(Notifications, Chat) {
|
||||||
|
|
||||||
socket.emit('api:meta.updateHeader', {
|
socket.emit('meta.updateHeader', {
|
||||||
fields: ['username', 'picture', 'userslug']
|
fields: ['username', 'picture', 'userslug']
|
||||||
}, app.updateHeader);
|
}, app.updateHeader);
|
||||||
|
|
||||||
@@ -14,5 +14,5 @@ define(['notifications', 'chat'], function(Notifications, Chat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
socket.on('event:unread.updateCount', updateUnreadCount);
|
socket.on('event:unread.updateCount', updateUnreadCount);
|
||||||
socket.emit('api:user.getUnreadCount', updateUnreadCount);
|
socket.emit('user.getUnreadCount', updateUnreadCount);
|
||||||
});
|
});
|
||||||
@@ -4,21 +4,21 @@ define(function() {
|
|||||||
home.init = function() {
|
home.init = function() {
|
||||||
|
|
||||||
ajaxify.register_events([
|
ajaxify.register_events([
|
||||||
'api:user.count',
|
'user.count',
|
||||||
'post.stats',
|
'meta.getUsageStats',
|
||||||
'api:user.getActiveUsers'
|
'user.getActiveUsers'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
socket.emit('api:user.count', function(data) {
|
socket.emit('user.count', function(data) {
|
||||||
$('#stats_users').html(utils.makeNumberHumanReadable(data.count)).attr('title', data.count);
|
$('#stats_users').html(utils.makeNumberHumanReadable(data.count)).attr('title', data.count);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.emit('api:meta.getUsageStats', function(data) {
|
socket.emit('meta.getUsageStats', function(data) {
|
||||||
$('#stats_topics').html(utils.makeNumberHumanReadable(data.topics)).attr('title', data.topics);
|
$('#stats_topics').html(utils.makeNumberHumanReadable(data.topics)).attr('title', data.topics);
|
||||||
$('#stats_posts').html(utils.makeNumberHumanReadable(data.posts)).attr('title', data.posts);
|
$('#stats_posts').html(utils.makeNumberHumanReadable(data.posts)).attr('title', data.posts);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.emit('api:user.getActiveUsers', function(data) {
|
socket.emit('user.getActiveUsers', function(data) {
|
||||||
$('#stats_online').html(data.users);
|
$('#stats_online').html(data.users);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ define(function() {
|
|||||||
|
|
||||||
Recent.loadMoreTopics = function() {
|
Recent.loadMoreTopics = function() {
|
||||||
Recent.loadingMoreTopics = true;
|
Recent.loadingMoreTopics = true;
|
||||||
socket.emit('api:topics.loadMoreRecentTopics', {
|
socket.emit('topics.loadMoreRecentTopics', {
|
||||||
after: $('#topics-container').children('li').length,
|
after: $('#topics-container').children('li').length,
|
||||||
term: active
|
term: active
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ define(function() {
|
|||||||
if (!utils.isEmailValid(emailEl.val())) {
|
if (!utils.isEmailValid(emailEl.val())) {
|
||||||
showError(email_notify, 'Invalid email address.');
|
showError(email_notify, 'Invalid email address.');
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:user.emailExists', {
|
socket.emit('user.emailExists', {
|
||||||
email: emailEl.val()
|
email: emailEl.val()
|
||||||
}, function(exists) {
|
}, function(exists) {
|
||||||
if (exists === true) {
|
if (exists === true) {
|
||||||
@@ -71,7 +71,7 @@ define(function() {
|
|||||||
} else if (!utils.isUserNameValid(username.val()) || !utils.slugify(username.val())) {
|
} else if (!utils.isUserNameValid(username.val()) || !utils.slugify(username.val())) {
|
||||||
showError(username_notify, 'Invalid username!');
|
showError(username_notify, 'Invalid username!');
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:user.exists', {
|
socket.emit('user.exists', {
|
||||||
username: username.val()
|
username: username.val()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -123,9 +123,9 @@ define(function() {
|
|||||||
validatePasswordConfirm();
|
validatePasswordConfirm();
|
||||||
});
|
});
|
||||||
|
|
||||||
ajaxify.register_events(['api:user.exists', 'api:user.emailExists']);
|
ajaxify.register_events(['user.exists', 'user.emailExists']);
|
||||||
|
|
||||||
socket.on('api:user.exists', function(data) {
|
socket.on('user.exists', function(data) {
|
||||||
if (data.exists === true) {
|
if (data.exists === true) {
|
||||||
showError(username_notify, 'Username already taken!');
|
showError(username_notify, 'Username already taken!');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ define(function() {
|
|||||||
|
|
||||||
document.getElementById('reset').onclick = function() {
|
document.getElementById('reset').onclick = function() {
|
||||||
if (inputEl.value.length > 0 && inputEl.value.indexOf('@') !== -1) {
|
if (inputEl.value.length > 0 && inputEl.value.indexOf('@') !== -1) {
|
||||||
socket.emit('api:user.reset.send', {
|
socket.emit('user.reset.send', {
|
||||||
email: inputEl.value
|
email: inputEl.value
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ define(function() {
|
|||||||
noticeEl.querySelector('p').innerHTML = 'The two passwords you\'ve entered do not match.';
|
noticeEl.querySelector('p').innerHTML = 'The two passwords you\'ve entered do not match.';
|
||||||
noticeEl.style.display = 'block';
|
noticeEl.style.display = 'block';
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:user.reset.commit', {
|
socket.emit('user.reset.commit', {
|
||||||
code: reset_code,
|
code: reset_code,
|
||||||
password: password.value
|
password: password.value
|
||||||
});
|
});
|
||||||
@@ -29,13 +29,13 @@ define(function() {
|
|||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// Enable the form if the code is valid
|
// Enable the form if the code is valid
|
||||||
socket.emit('api:user.reset.valid', {
|
socket.emit('user.reset.valid', {
|
||||||
code: reset_code
|
code: reset_code
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ajaxify.register_events(['api:user.reset.valid', 'api:user.reset.commit']);
|
ajaxify.register_events(['user.reset.valid', 'user.reset.commit']);
|
||||||
socket.on('api:user.reset.valid', function(data) {
|
socket.on('user.reset.valid', function(data) {
|
||||||
if ( !! data.valid) resetEl.disabled = false;
|
if ( !! data.valid) resetEl.disabled = false;
|
||||||
else {
|
else {
|
||||||
var formEl = document.getElementById('reset-form');
|
var formEl = document.getElementById('reset-form');
|
||||||
@@ -45,7 +45,7 @@ define(function() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('api:user.reset.commit', function(data) {
|
socket.on('user.reset.commit', function(data) {
|
||||||
if (data.status === 'ok') {
|
if (data.status === 'ok') {
|
||||||
$('#error').hide();
|
$('#error').hide();
|
||||||
$('#notice').hide();
|
$('#notice').hide();
|
||||||
|
|||||||
@@ -52,14 +52,14 @@ define(['composer'], function(composer) {
|
|||||||
if (thread_state.deleted !== '1') {
|
if (thread_state.deleted !== '1') {
|
||||||
bootbox.confirm('Are you sure you want to delete this thread?', function(confirm) {
|
bootbox.confirm('Are you sure you want to delete this thread?', function(confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
socket.emit('api:topics.delete', {
|
socket.emit('topics.delete', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
bootbox.confirm('Are you sure you want to restore this thread?', function(confirm) {
|
bootbox.confirm('Are you sure you want to restore this thread?', function(confirm) {
|
||||||
if (confirm) socket.emit('api:topics.restore', {
|
if (confirm) socket.emit('topics.restore', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, null);
|
}, null);
|
||||||
});
|
});
|
||||||
@@ -69,11 +69,11 @@ define(['composer'], function(composer) {
|
|||||||
|
|
||||||
$('.lock_thread').on('click', function(e) {
|
$('.lock_thread').on('click', function(e) {
|
||||||
if (thread_state.locked !== '1') {
|
if (thread_state.locked !== '1') {
|
||||||
socket.emit('api:topics.lock', {
|
socket.emit('topics.lock', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, null);
|
}, null);
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:topics.unlock', {
|
socket.emit('topics.unlock', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
@@ -82,11 +82,11 @@ define(['composer'], function(composer) {
|
|||||||
|
|
||||||
$('.pin_thread').on('click', function(e) {
|
$('.pin_thread').on('click', function(e) {
|
||||||
if (thread_state.pinned !== '1') {
|
if (thread_state.pinned !== '1') {
|
||||||
socket.emit('api:topics.pin', {
|
socket.emit('topics.pin', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, null);
|
}, null);
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:topics.unpin', {
|
socket.emit('topics.unpin', {
|
||||||
tid: tid
|
tid: tid
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ define(['composer'], function(composer) {
|
|||||||
|
|
||||||
var loadingEl = document.getElementById('categories-loading');
|
var loadingEl = document.getElementById('categories-loading');
|
||||||
if (loadingEl) {
|
if (loadingEl) {
|
||||||
socket.emit('api:categories.get', function(data) {
|
socket.emit('categories.get', function(data) {
|
||||||
// Render categories
|
// Render categories
|
||||||
var categoriesFrag = document.createDocumentFragment(),
|
var categoriesFrag = document.createDocumentFragment(),
|
||||||
categoryEl = document.createElement('li'),
|
categoryEl = document.createElement('li'),
|
||||||
@@ -145,7 +145,7 @@ define(['composer'], function(composer) {
|
|||||||
$(moveThreadModal).find('.modal-header button').fadeOut(250);
|
$(moveThreadModal).find('.modal-header button').fadeOut(250);
|
||||||
commitEl.innerHTML = 'Moving <i class="fa-spin fa-refresh"></i>';
|
commitEl.innerHTML = 'Moving <i class="fa-spin fa-refresh"></i>';
|
||||||
|
|
||||||
socket.emit('api:topics.move', {
|
socket.emit('topics.move', {
|
||||||
tid: tid,
|
tid: tid,
|
||||||
cid: targetCid
|
cid: targetCid
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
@@ -192,7 +192,7 @@ define(['composer'], function(composer) {
|
|||||||
forkCommit.on('click', createTopicFromPosts);
|
forkCommit.on('click', createTopicFromPosts);
|
||||||
|
|
||||||
function createTopicFromPosts() {
|
function createTopicFromPosts() {
|
||||||
socket.emit('api:topics.createTopicFromPosts', {
|
socket.emit('topics.createTopicFromPosts', {
|
||||||
title: forkModal.find('#fork-title').val(),
|
title: forkModal.find('#fork-title').val(),
|
||||||
pids: pids
|
pids: pids
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
@@ -298,12 +298,12 @@ define(['composer'], function(composer) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('api:topics.followCheck', tid, function(state) {
|
socket.emit('topics.followCheck', tid, function(state) {
|
||||||
set_follow_state(state, true);
|
set_follow_state(state, true);
|
||||||
});
|
});
|
||||||
if (followEl[0]) {
|
if (followEl[0]) {
|
||||||
followEl[0].addEventListener('click', function() {
|
followEl[0].addEventListener('click', function() {
|
||||||
socket.emit('api:topics.follow', tid, function(data) {
|
socket.emit('topics.follow', tid, function(data) {
|
||||||
if (data.status && data.status === 'ok') set_follow_state(data.follow);
|
if (data.status && data.status === 'ok') set_follow_state(data.follow);
|
||||||
else {
|
else {
|
||||||
app.alert({
|
app.alert({
|
||||||
@@ -375,7 +375,7 @@ define(['composer'], function(composer) {
|
|||||||
username = '@' + post.attr('data-username');
|
username = '@' + post.attr('data-username');
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:posts.getRawPost', {pid: pid}, function(data) {
|
socket.emit('posts.getRawPost', {pid: pid}, function(data) {
|
||||||
|
|
||||||
quoted = '> ' + data.post.replace(/\n/g, '\n> ') + '\n\n';
|
quoted = '> ' + data.post.replace(/\n/g, '\n> ') + '\n\n';
|
||||||
|
|
||||||
@@ -389,12 +389,12 @@ define(['composer'], function(composer) {
|
|||||||
var uid = $(this).parents('li').attr('data-uid');
|
var uid = $(this).parents('li').attr('data-uid');
|
||||||
|
|
||||||
if ($(this).attr('data-favourited') == 'false') {
|
if ($(this).attr('data-favourited') == 'false') {
|
||||||
socket.emit('api:posts.favourite', {
|
socket.emit('posts.favourite', {
|
||||||
pid: pid,
|
pid: pid,
|
||||||
room_id: app.currentRoom
|
room_id: app.currentRoom
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:posts.unfavourite', {
|
socket.emit('posts.unfavourite', {
|
||||||
pid: pid,
|
pid: pid,
|
||||||
room_id: app.currentRoom
|
room_id: app.currentRoom
|
||||||
});
|
});
|
||||||
@@ -441,7 +441,7 @@ define(['composer'], function(composer) {
|
|||||||
|
|
||||||
if (confirmDel) {
|
if (confirmDel) {
|
||||||
if(deleteAction) {
|
if(deleteAction) {
|
||||||
socket.emit('api:posts.delete', {
|
socket.emit('posts.delete', {
|
||||||
pid: pid,
|
pid: pid,
|
||||||
tid: tid
|
tid: tid
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
@@ -450,7 +450,7 @@ define(['composer'], function(composer) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('api:posts.restore', {
|
socket.emit('posts.restore', {
|
||||||
pid: pid,
|
pid: pid,
|
||||||
tid: tid
|
tid: tid
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
@@ -488,7 +488,7 @@ define(['composer'], function(composer) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
moveBtn.on('click', function() {
|
moveBtn.on('click', function() {
|
||||||
socket.emit('api:topics.movePost', {pid: pid, tid: topicId.val()}, function(err) {
|
socket.emit('topics.movePost', {pid: pid, tid: topicId.val()}, function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
@@ -515,15 +515,15 @@ define(['composer'], function(composer) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ajaxify.register_events([
|
ajaxify.register_events([
|
||||||
'event:rep_up', 'event:rep_down', 'event:new_post', 'api:get_users_in_room',
|
'event:rep_up', 'event:rep_down', 'event:new_post', 'get_users_in_room',
|
||||||
'event:topic_deleted', 'event:topic_restored', 'event:topic:locked',
|
'event:topic_deleted', 'event:topic_restored', 'event:topic:locked',
|
||||||
'event:topic_unlocked', 'event:topic_pinned', 'event:topic_unpinned',
|
'event:topic_unlocked', 'event:topic_pinned', 'event:topic_unpinned',
|
||||||
'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored',
|
'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored',
|
||||||
'api:posts.favourite'
|
'posts.favourite'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
socket.on('api:get_users_in_room', function(data) {
|
socket.on('get_users_in_room', function(data) {
|
||||||
if(data) {
|
if(data) {
|
||||||
var activeEl = $('.thread_active_users');
|
var activeEl = $('.thread_active_users');
|
||||||
|
|
||||||
@@ -689,7 +689,7 @@ define(['composer'], function(composer) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:posts.favourite', function(data) {
|
socket.on('posts.favourite', function(data) {
|
||||||
if (data.status === 'ok' && data.pid) {
|
if (data.status === 'ok' && data.pid) {
|
||||||
var favBtn = $('li[data-pid="' + data.pid + '"] .favourite');
|
var favBtn = $('li[data-pid="' + data.pid + '"] .favourite');
|
||||||
if(favBtn.length) {
|
if(favBtn.length) {
|
||||||
@@ -700,7 +700,7 @@ define(['composer'], function(composer) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:posts.unfavourite', function(data) {
|
socket.on('posts.unfavourite', function(data) {
|
||||||
if (data.status === 'ok' && data.pid) {
|
if (data.status === 'ok' && data.pid) {
|
||||||
var favBtn = $('li[data-pid="' + data.pid + '"] .favourite');
|
var favBtn = $('li[data-pid="' + data.pid + '"] .favourite');
|
||||||
if(favBtn.length) {
|
if(favBtn.length) {
|
||||||
@@ -861,7 +861,7 @@ define(['composer'], function(composer) {
|
|||||||
favEl = postEl.find('.favourite'),
|
favEl = postEl.find('.favourite'),
|
||||||
replyEl = postEl.find('.post_reply');
|
replyEl = postEl.find('.post_reply');
|
||||||
|
|
||||||
socket.emit('api:posts.getPrivileges', pid, function(privileges) {
|
socket.emit('posts.getPrivileges', pid, function(privileges) {
|
||||||
if (privileges.editable) {
|
if (privileges.editable) {
|
||||||
if (!postEl.hasClass('deleted')) {
|
if (!postEl.hasClass('deleted')) {
|
||||||
toggle_post_tools(pid, false);
|
toggle_post_tools(pid, false);
|
||||||
@@ -1056,7 +1056,7 @@ define(['composer'], function(composer) {
|
|||||||
.fadeIn('slow');
|
.fadeIn('slow');
|
||||||
|
|
||||||
for (var x = 0, numPosts = data.posts.length; x < numPosts; x++) {
|
for (var x = 0, numPosts = data.posts.length; x < numPosts; x++) {
|
||||||
socket.emit('api:posts.getPrivileges', data.posts[x].pid, function(privileges) {
|
socket.emit('posts.getPrivileges', data.posts[x].pid, function(privileges) {
|
||||||
toggle_mod_tools(privileges.pid, privileges.editable);
|
toggle_mod_tools(privileges.pid, privileges.editable);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1087,7 +1087,7 @@ define(['composer'], function(composer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updatePostCount() {
|
function updatePostCount() {
|
||||||
socket.emit('api:topics.postcount', templates.get('topic_id'), function(err, postcount) {
|
socket.emit('topics.postcount', templates.get('topic_id'), function(err, postcount) {
|
||||||
if(!err) {
|
if(!err) {
|
||||||
Topic.postCount = postcount;
|
Topic.postCount = postcount;
|
||||||
$('#topic-post-count').html(Topic.postCount);
|
$('#topic-post-count').html(Topic.postCount);
|
||||||
@@ -1109,7 +1109,7 @@ define(['composer'], function(composer) {
|
|||||||
indicatorEl.fadeIn();
|
indicatorEl.fadeIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:topics.loadMore', {
|
socket.emit('topics.loadMore', {
|
||||||
tid: tid,
|
tid: tid,
|
||||||
after: parseInt($('#post-container .post-row.infiniteloaded').last().attr('data-index'), 10) + 1
|
after: parseInt($('#post-container .post-row.infiniteloaded').last().attr('data-index'), 10) + 1
|
||||||
}, function (data) {
|
}, function (data) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ define(function() {
|
|||||||
ajaxify.register_events([
|
ajaxify.register_events([
|
||||||
'event:new_topic',
|
'event:new_topic',
|
||||||
'event:new_post',
|
'event:new_post',
|
||||||
'api:topics.markAllRead'
|
'topics.markAllRead'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var newTopicCount = 0,
|
var newTopicCount = 0,
|
||||||
@@ -55,7 +55,7 @@ define(function() {
|
|||||||
|
|
||||||
$('#mark-allread-btn').on('click', function() {
|
$('#mark-allread-btn').on('click', function() {
|
||||||
var btn = $(this);
|
var btn = $(this);
|
||||||
socket.emit('api:topics.markAllRead', {}, function(success) {
|
socket.emit('topics.markAllRead', {}, function(success) {
|
||||||
if (success) {
|
if (success) {
|
||||||
btn.remove();
|
btn.remove();
|
||||||
$('#topics-container').empty();
|
$('#topics-container').empty();
|
||||||
@@ -91,7 +91,7 @@ define(function() {
|
|||||||
|
|
||||||
function loadMoreTopics() {
|
function loadMoreTopics() {
|
||||||
loadingMoreTopics = true;
|
loadingMoreTopics = true;
|
||||||
socket.emit('api:topics.loadMoreUnreadTopics', {
|
socket.emit('topics.loadMoreUnreadTopics', {
|
||||||
after: parseInt($('#topics-container').attr('data-next-start'), 10)
|
after: parseInt($('#topics-container').attr('data-next-start'), 10)
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
if (data.topics && data.topics.length) {
|
if (data.topics && data.topics.length) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ define(function() {
|
|||||||
jQuery('#user-notfound-notify').html('<i class="fa fa-spinner fa-spin"></i>');
|
jQuery('#user-notfound-notify').html('<i class="fa fa-spinner fa-spin"></i>');
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
socket.emit('api:admin.user.search', username, function(err, data) {
|
socket.emit('admin.user.search', username, function(err, data) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return app.alert(err.message);
|
return app.alert(err.message);
|
||||||
}
|
}
|
||||||
@@ -80,10 +80,10 @@ define(function() {
|
|||||||
}, 250);
|
}, 250);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:user.isOnline', function(data) {
|
socket.on('user.isOnline', function(data) {
|
||||||
if(getActiveSection() == 'online' && !loadingMoreUsers) {
|
if(getActiveSection() == 'online' && !loadingMoreUsers) {
|
||||||
startLoading('users:online', 0, true);
|
startLoading('users:online', 0, true);
|
||||||
socket.emit('api:user.getOnlineAnonCount', {} , function(anonCount) {
|
socket.emit('user.getOnlineAnonCount', {} , function(anonCount) {
|
||||||
if(parseInt(anonCount, 10) > 0) {
|
if(parseInt(anonCount, 10) > 0) {
|
||||||
$('#users-container .anon-user').removeClass('hide');
|
$('#users-container .anon-user').removeClass('hide');
|
||||||
$('#online_anon_count').html(anonCount);
|
$('#online_anon_count').html(anonCount);
|
||||||
@@ -123,7 +123,7 @@ define(function() {
|
|||||||
|
|
||||||
function startLoading(set, after, emptyContainer) {
|
function startLoading(set, after, emptyContainer) {
|
||||||
loadingMoreUsers = true;
|
loadingMoreUsers = true;
|
||||||
socket.emit('api:user.loadMore', {
|
socket.emit('user.loadMore', {
|
||||||
set: set,
|
set: set,
|
||||||
after: after
|
after: after
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ define(['taskbar', 'string'], function(taskbar, S) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:modules.chats.list', function(chats) {
|
socket.emit('modules.chats.list', function(chats) {
|
||||||
var chatsFrag = document.createDocumentFragment(),
|
var chatsFrag = document.createDocumentFragment(),
|
||||||
chatEl = document.createElement('li'),
|
chatEl = document.createElement('li'),
|
||||||
numChats = chats.length,
|
numChats = chats.length,
|
||||||
@@ -90,7 +90,7 @@ define(['taskbar', 'string'], function(taskbar, S) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkStatus(chatModal, callback) {
|
function checkStatus(chatModal, callback) {
|
||||||
socket.emit('api:user.isOnline', chatModal.touid, function(data) {
|
socket.emit('user.isOnline', chatModal.touid, function(data) {
|
||||||
if(data.online !== chatModal.online) {
|
if(data.online !== chatModal.online) {
|
||||||
if(data.online) {
|
if(data.online) {
|
||||||
module.appendChatMessage(chatModal, chatModal.username + ' is currently online.\n', data.timestamp);
|
module.appendChatMessage(chatModal, chatModal.username + ' is currently online.\n', data.timestamp);
|
||||||
@@ -191,7 +191,7 @@ define(['taskbar', 'string'], function(taskbar, S) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getChatMessages(chatModal, callback) {
|
function getChatMessages(chatModal, callback) {
|
||||||
socket.emit('api:modules.chats.get', {touid:chatModal.touid}, function(messages) {
|
socket.emit('modules.chats.get', {touid:chatModal.touid}, function(messages) {
|
||||||
for(var i = 0; i<messages.length; ++i) {
|
for(var i = 0; i<messages.length; ++i) {
|
||||||
module.appendChatMessage(chatModal, messages[i].content, messages[i].timestamp);
|
module.appendChatMessage(chatModal, messages[i].content, messages[i].timestamp);
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ define(['taskbar', 'string'], function(taskbar, S) {
|
|||||||
var msg = S(chatModal.find('#chat-message-input').val()).stripTags().s;
|
var msg = S(chatModal.find('#chat-message-input').val()).stripTags().s;
|
||||||
if(msg.length) {
|
if(msg.length) {
|
||||||
msg = msg +'\n';
|
msg = msg +'\n';
|
||||||
socket.emit('api:modules.chats.send', { touid:chatModal.touid, message:msg});
|
socket.emit('modules.chats.send', { touid:chatModal.touid, message:msg});
|
||||||
chatModal.find('#chat-message-input').val('');
|
chatModal.find('#chat-message-input').val('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ define(['taskbar'], function(taskbar) {
|
|||||||
|
|
||||||
composer.editPost = function(pid) {
|
composer.editPost = function(pid) {
|
||||||
if(allowed()) {
|
if(allowed()) {
|
||||||
socket.emit('api:modules.composer.push', {
|
socket.emit('modules.composer.push', {
|
||||||
pid: pid
|
pid: pid
|
||||||
}, function(threadData) {
|
}, function(threadData) {
|
||||||
push({
|
push({
|
||||||
@@ -108,7 +108,7 @@ define(['taskbar'], function(taskbar) {
|
|||||||
} else if (parseInt(postData.pid) > 0) {
|
} else if (parseInt(postData.pid) > 0) {
|
||||||
titleEl.val(postData.title);
|
titleEl.val(postData.title);
|
||||||
titleEl.prop('readOnly', true);
|
titleEl.prop('readOnly', true);
|
||||||
socket.emit('api:modules.composer.editCheck', postData.pid, function(editCheck) {
|
socket.emit('modules.composer.editCheck', postData.pid, function(editCheck) {
|
||||||
if (editCheck.titleEditable) {
|
if (editCheck.titleEditable) {
|
||||||
postContainer.find('input').prop('readonly', false);
|
postContainer.find('input').prop('readonly', false);
|
||||||
}
|
}
|
||||||
@@ -434,7 +434,7 @@ define(['taskbar'], function(taskbar) {
|
|||||||
|
|
||||||
// Still here? Let's post.
|
// Still here? Let's post.
|
||||||
if (parseInt(postData.cid) > 0) {
|
if (parseInt(postData.cid) > 0) {
|
||||||
socket.emit('api:topics.post', {
|
socket.emit('topics.post', {
|
||||||
'title' : titleEl.val(),
|
'title' : titleEl.val(),
|
||||||
'content' : bodyEl.val(),
|
'content' : bodyEl.val(),
|
||||||
'category_id' : postData.cid
|
'category_id' : postData.cid
|
||||||
@@ -442,14 +442,14 @@ define(['taskbar'], function(taskbar) {
|
|||||||
composer.discard(post_uuid);
|
composer.discard(post_uuid);
|
||||||
});
|
});
|
||||||
} else if (parseInt(postData.tid) > 0) {
|
} else if (parseInt(postData.tid) > 0) {
|
||||||
socket.emit('api:posts.reply', {
|
socket.emit('posts.reply', {
|
||||||
'topic_id' : postData.tid,
|
'topic_id' : postData.tid,
|
||||||
'content' : bodyEl.val()
|
'content' : bodyEl.val()
|
||||||
}, function() {
|
}, function() {
|
||||||
composer.discard(post_uuid);
|
composer.discard(post_uuid);
|
||||||
});
|
});
|
||||||
} else if (parseInt(postData.pid) > 0) {
|
} else if (parseInt(postData.pid) > 0) {
|
||||||
socket.emit('api:posts.edit', {
|
socket.emit('posts.edit', {
|
||||||
pid: postData.pid,
|
pid: postData.pid,
|
||||||
content: bodyEl.val(),
|
content: bodyEl.val(),
|
||||||
title: titleEl.val()
|
title: titleEl.val()
|
||||||
@@ -568,12 +568,12 @@ define(['taskbar'], function(taskbar) {
|
|||||||
dropDiv.hide();
|
dropDiv.hide();
|
||||||
|
|
||||||
if(file.type.match('image.*')) {
|
if(file.type.match('image.*')) {
|
||||||
uploadFile('api:posts.uploadImage', post_uuid, fileData);
|
uploadFile('posts.uploadImage', post_uuid, fileData);
|
||||||
} else {
|
} else {
|
||||||
if(file.size > parseInt(config.maximumFileSize, 10) * 1024) {
|
if(file.size > parseInt(config.maximumFileSize, 10) * 1024) {
|
||||||
return composerAlert('File too big', 'Maximum allowed file size is ' + config.maximumFileSize + 'kbs');
|
return composerAlert('File too big', 'Maximum allowed file size is ' + config.maximumFileSize + 'kbs');
|
||||||
}
|
}
|
||||||
uploadFile('api:posts.uploadFile', post_uuid, fileData);
|
uploadFile('posts.uploadFile', post_uuid, fileData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -582,7 +582,7 @@ define(['taskbar'], function(taskbar) {
|
|||||||
|
|
||||||
|
|
||||||
function uploadFile(method, post_uuid, img) {
|
function uploadFile(method, post_uuid, img) {
|
||||||
var linkStart = method === 'api:posts.uploadImage' ? '!' : '',
|
var linkStart = method === 'posts.uploadImage' ? '!' : '',
|
||||||
postContainer = $('#cmp-uuid-' + post_uuid),
|
postContainer = $('#cmp-uuid-' + post_uuid),
|
||||||
textarea = postContainer.find('textarea'),
|
textarea = postContainer.find('textarea'),
|
||||||
text = textarea.val(),
|
text = textarea.val(),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ define(function() {
|
|||||||
notifTrigger.addEventListener('click', function(e) {
|
notifTrigger.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (notifContainer.className.indexOf('open') === -1) {
|
if (notifContainer.className.indexOf('open') === -1) {
|
||||||
socket.emit('api:notifications.get', null, function(data) {
|
socket.emit('notifications.get', null, function(data) {
|
||||||
var notifFrag = document.createDocumentFragment(),
|
var notifFrag = document.createDocumentFragment(),
|
||||||
notifEl = document.createElement('li'),
|
notifEl = document.createElement('li'),
|
||||||
numRead = data.read.length,
|
numRead = data.read.length,
|
||||||
@@ -51,7 +51,7 @@ define(function() {
|
|||||||
notifIcon.toggleClass('active', false);
|
notifIcon.toggleClass('active', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('api:modules.notifications.mark_all_read', null, function() {
|
socket.emit('modules.notifications.mark_all_read', null, function() {
|
||||||
notifIcon.toggleClass('active', false);
|
notifIcon.toggleClass('active', false);
|
||||||
app.refreshTitle();
|
app.refreshTitle();
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ define(function() {
|
|||||||
}
|
}
|
||||||
if (target) {
|
if (target) {
|
||||||
var nid = parseInt(target.getAttribute('data-nid'));
|
var nid = parseInt(target.getAttribute('data-nid'));
|
||||||
if (nid > 0) socket.emit('api:modules.notifications.mark_read', nid);
|
if (nid > 0) socket.emit('modules.notifications.mark_read', nid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ define(function() {
|
|||||||
localStorage.setItem('notifications:count', count);
|
localStorage.setItem('notifications:count', count);
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit('api:notifications.getCount', function(err, count) {
|
socket.emit('notifications.getCount', function(err, count) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
updateNotifCount(count);
|
updateNotifCount(count);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user