|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
|
|
|
|
|
var yourid = templates.get('yourid');
|
|
|
|
@ -24,19 +23,19 @@
|
|
|
|
|
var adminBtn = $(element);
|
|
|
|
|
var uid = getUID(adminBtn);
|
|
|
|
|
|
|
|
|
|
if(isUserAdmin(adminBtn))
|
|
|
|
|
if (isUserAdmin(adminBtn))
|
|
|
|
|
adminBtn.addClass('btn-success');
|
|
|
|
|
else
|
|
|
|
|
adminBtn.removeClass('btn-success');
|
|
|
|
|
|
|
|
|
|
if(uid === yourid)
|
|
|
|
|
if (uid === yourid)
|
|
|
|
|
adminBtn.addClass('disabled');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jQuery('.delete-btn').each(function(index, element) {
|
|
|
|
|
var deleteBtn = $(element);
|
|
|
|
|
|
|
|
|
|
if(isUserAdmin(deleteBtn))
|
|
|
|
|
if (isUserAdmin(deleteBtn))
|
|
|
|
|
deleteBtn.addClass('disabled');
|
|
|
|
|
else
|
|
|
|
|
deleteBtn.show();
|
|
|
|
@ -45,9 +44,9 @@
|
|
|
|
|
jQuery('.ban-btn').each(function(index, element) {
|
|
|
|
|
var banBtn = $(element);
|
|
|
|
|
|
|
|
|
|
if(isUserAdmin(banBtn))
|
|
|
|
|
if (isUserAdmin(banBtn))
|
|
|
|
|
banBtn.addClass('disabled');
|
|
|
|
|
else if(isUserBanned(banBtn))
|
|
|
|
|
else if (isUserBanned(banBtn))
|
|
|
|
|
banBtn.addClass('btn-warning');
|
|
|
|
|
else
|
|
|
|
|
banBtn.removeClass('btn-warning');
|
|
|
|
@ -65,14 +64,14 @@
|
|
|
|
|
var parent = adminBtn.parents('.users-box');
|
|
|
|
|
var uid = getUID(adminBtn);
|
|
|
|
|
|
|
|
|
|
if(isAdmin && uid != yourid) {
|
|
|
|
|
if (isAdmin && uid != yourid) {
|
|
|
|
|
socket.emit('api:admin.user.removeAdmin', uid);
|
|
|
|
|
adminBtn.removeClass('btn-success');
|
|
|
|
|
parent.find('.delete-btn').removeClass('disabled');
|
|
|
|
|
parent.attr('data-admin', 0);
|
|
|
|
|
} else if(uid != yourid) {
|
|
|
|
|
bootbox.confirm('Do you really want to make "' + parent.attr('data-username') +'" an admin?', function(confirm) {
|
|
|
|
|
if(confirm) {
|
|
|
|
|
} else if (uid != yourid) {
|
|
|
|
|
bootbox.confirm('Do you really want to make "' + parent.attr('data-username') + '" an admin?', function(confirm) {
|
|
|
|
|
if (confirm) {
|
|
|
|
|
socket.emit('api:admin.user.makeAdmin', uid);
|
|
|
|
|
adminBtn.addClass('btn-success');
|
|
|
|
|
parent.find('.delete-btn').addClass('disabled');
|
|
|
|
@ -90,8 +89,8 @@
|
|
|
|
|
var parent = deleteBtn.parents('.users-box');
|
|
|
|
|
var uid = getUID(deleteBtn);
|
|
|
|
|
|
|
|
|
|
if(!isAdmin) {
|
|
|
|
|
bootbox.confirm('Do you really want to delete "' + parent.attr('data-username') +'"?', function(confirm) {
|
|
|
|
|
if (!isAdmin) {
|
|
|
|
|
bootbox.confirm('Do you really want to delete "' + parent.attr('data-username') + '"?', function(confirm) {
|
|
|
|
|
if (confirm) {
|
|
|
|
|
socket.emit('api:admin.user.deleteUser', uid);
|
|
|
|
|
}
|
|
|
|
@ -108,13 +107,13 @@
|
|
|
|
|
var parent = banBtn.parents('.users-box');
|
|
|
|
|
var uid = getUID(banBtn);
|
|
|
|
|
|
|
|
|
|
if(!isAdmin) {
|
|
|
|
|
if(isBanned) {
|
|
|
|
|
if (!isAdmin) {
|
|
|
|
|
if (isBanned) {
|
|
|
|
|
socket.emit('api:admin.user.unbanUser', uid);
|
|
|
|
|
banBtn.removeClass('btn-warning');
|
|
|
|
|
parent.attr('data-banned', 0);
|
|
|
|
|
} 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) {
|
|
|
|
|
socket.emit('api:admin.user.banUser', uid);
|
|
|
|
|
banBtn.addClass('btn-warning');
|
|
|
|
@ -136,7 +135,7 @@
|
|
|
|
|
|
|
|
|
|
var url = window.location.href,
|
|
|
|
|
parts = url.split('/'),
|
|
|
|
|
active = parts[parts.length-1];
|
|
|
|
|
active = parts[parts.length - 1];
|
|
|
|
|
|
|
|
|
|
jQuery('.nav-pills li').removeClass('active');
|
|
|
|
|
jQuery('.nav-pills li a').each(function() {
|
|
|
|
@ -146,8 +145,8 @@
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jQuery('#search-user').on('keyup', function () {
|
|
|
|
|
if(timeoutId !== 0) {
|
|
|
|
|
jQuery('#search-user').on('keyup', function() {
|
|
|
|
|
if (timeoutId !== 0) {
|
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
|
timeoutId = 0;
|
|
|
|
|
}
|
|
|
|
@ -174,14 +173,13 @@
|
|
|
|
|
userListEl.innerHTML = html;
|
|
|
|
|
jQuery('.icon-spinner').addClass('none');
|
|
|
|
|
|
|
|
|
|
if(data && data.length === 0) {
|
|
|
|
|
if (data && data.length === 0) {
|
|
|
|
|
$('#user-notfound-notify').html('User not found!')
|
|
|
|
|
.show()
|
|
|
|
|
.addClass('label-danger')
|
|
|
|
|
.removeClass('label-success');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$('#user-notfound-notify').html(data.length + ' user'+(data.length>1?'s':'') + ' found!')
|
|
|
|
|
} else {
|
|
|
|
|
$('#user-notfound-notify').html(data.length + ' user' + (data.length > 1 ? 's' : '') + ' found!')
|
|
|
|
|
.show()
|
|
|
|
|
.addClass('label-success')
|
|
|
|
|
.removeClass('label-danger');
|
|
|
|
@ -191,28 +189,30 @@
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function onUsersLoaded(users) {
|
|
|
|
|
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({ users: users });
|
|
|
|
|
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
|
|
|
|
|
users: users
|
|
|
|
|
});
|
|
|
|
|
$('#users-container').append(html);
|
|
|
|
|
updateUserButtons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadMoreUsers() {
|
|
|
|
|
var set = '';
|
|
|
|
|
if(active === 'latest') {
|
|
|
|
|
if (active === 'latest') {
|
|
|
|
|
set = 'users:joindate';
|
|
|
|
|
} else if(active === 'sort-posts') {
|
|
|
|
|
} else if (active === 'sort-posts') {
|
|
|
|
|
set = 'users:postcount';
|
|
|
|
|
} else if(active === 'sort-reputation') {
|
|
|
|
|
} else if (active === 'sort-reputation') {
|
|
|
|
|
set = 'users:reputation';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(set) {
|
|
|
|
|
if (set) {
|
|
|
|
|
loadingMoreUsers = true;
|
|
|
|
|
socket.emit('api:users.loadMore', {
|
|
|
|
|
set: set,
|
|
|
|
|
after: $('#users-container').children().length
|
|
|
|
|
}, function(data) {
|
|
|
|
|
if(data.users.length) {
|
|
|
|
|
if (data.users.length) {
|
|
|
|
|
onUsersLoaded(data.users);
|
|
|
|
|
}
|
|
|
|
|
loadingMoreUsers = false;
|
|
|
|
|