|
|
@ -19,7 +19,7 @@ define(function() {
|
|
|
|
return parent.attr('data-uid');
|
|
|
|
return parent.attr('data-uid');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateUserButtons() {
|
|
|
|
function updateUserBanButtons() {
|
|
|
|
jQuery('.ban-btn').each(function(index, element) {
|
|
|
|
jQuery('.ban-btn').each(function(index, element) {
|
|
|
|
var banBtn = $(element);
|
|
|
|
var banBtn = $(element);
|
|
|
|
var uid = getUID(banBtn);
|
|
|
|
var uid = getUID(banBtn);
|
|
|
@ -27,15 +27,37 @@ define(function() {
|
|
|
|
banBtn.addClass('disabled');
|
|
|
|
banBtn.addClass('disabled');
|
|
|
|
else if (isUserBanned(banBtn))
|
|
|
|
else if (isUserBanned(banBtn))
|
|
|
|
banBtn.addClass('btn-warning');
|
|
|
|
banBtn.addClass('btn-warning');
|
|
|
|
|
|
|
|
else if (!isUserAdmin(banBtn))
|
|
|
|
|
|
|
|
banBtn.removeClass('disabled');
|
|
|
|
else
|
|
|
|
else
|
|
|
|
banBtn.removeClass('btn-warning');
|
|
|
|
banBtn.removeClass('btn-warning');
|
|
|
|
|
|
|
|
updateUserAdminButtons();
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateUserAdminButtons() {
|
|
|
|
|
|
|
|
jQuery('.admin-btn').each(function(index, element) {
|
|
|
|
|
|
|
|
var banBtn = $(element);
|
|
|
|
|
|
|
|
var uid = getUID(banBtn);
|
|
|
|
|
|
|
|
if (isUserAdmin(banBtn) || uid === yourid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
banBtn.attr('value', 'UnMake Admin').html('Remove as Admin');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else if (isUserBanned(banBtn))
|
|
|
|
|
|
|
|
banBtn.addClass('disabled');
|
|
|
|
|
|
|
|
else if (!isUserBanned(banBtn))
|
|
|
|
|
|
|
|
banBtn.removeClass('disabled');
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
banBtn.removeClass('btn-warning');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function initUsers() {
|
|
|
|
function initUsers() {
|
|
|
|
|
|
|
|
|
|
|
|
updateUserButtons();
|
|
|
|
updateUserBanButtons();
|
|
|
|
|
|
|
|
updateUserAdminButtons();
|
|
|
|
|
|
|
|
|
|
|
|
$('#users-container').on('click', '.ban-btn', function() {
|
|
|
|
$('#users-container').on('click', '.ban-btn', function() {
|
|
|
|
var banBtn = $(this);
|
|
|
|
var banBtn = $(this);
|
|
|
@ -49,17 +71,51 @@ define(function() {
|
|
|
|
socket.emit('api:admin.user.unbanUser', uid);
|
|
|
|
socket.emit('api:admin.user.unbanUser', uid);
|
|
|
|
banBtn.removeClass('btn-warning');
|
|
|
|
banBtn.removeClass('btn-warning');
|
|
|
|
parent.attr('data-banned', 0);
|
|
|
|
parent.attr('data-banned', 0);
|
|
|
|
|
|
|
|
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('api:admin.user.banUser', uid);
|
|
|
|
banBtn.addClass('btn-warning');
|
|
|
|
banBtn.addClass('btn-warning');
|
|
|
|
parent.attr('data-banned', 1);
|
|
|
|
parent.attr('data-banned', 1);
|
|
|
|
|
|
|
|
updateUserAdminButtons();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#users-container').on('click', '.admin-btn', function() {
|
|
|
|
|
|
|
|
var adminBtn = $(this);
|
|
|
|
|
|
|
|
var isAdmin = isUserAdmin(adminBtn);
|
|
|
|
|
|
|
|
var parent = adminBtn.parents('.users-box');
|
|
|
|
|
|
|
|
var isBanned = isUserBanned(adminBtn);
|
|
|
|
|
|
|
|
var uid = getUID(adminBtn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(uid === yourid){
|
|
|
|
|
|
|
|
alert("you can't remove yourself as admin");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!isAdmin) {
|
|
|
|
|
|
|
|
socket.emit('api:admin.user.makeAdmin', uid);
|
|
|
|
|
|
|
|
adminBtn.attr('value', 'UnMake Admin').html('Remove as Admin');
|
|
|
|
|
|
|
|
parent.attr('data-admin', 1);
|
|
|
|
|
|
|
|
updateUserBanButtons();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if(uid !== yourid) {
|
|
|
|
|
|
|
|
bootbox.confirm('Do you really want to remove this user as admin "' + parent.attr('data-username') + '"?', function(confirm) {
|
|
|
|
|
|
|
|
if (confirm) {
|
|
|
|
|
|
|
|
socket.emit('api:admin.user.removeAdmin', uid);
|
|
|
|
|
|
|
|
adminBtn.attr('value', 'Make Admin').html('Make Admin');
|
|
|
|
|
|
|
|
parent.attr('data-admin', 0);
|
|
|
|
|
|
|
|
updateUserBanButtons();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|