v1.18.x
Baris Usakli 12 years ago
parent 08ba911738
commit aeb831eeff

@ -1,6 +1,8 @@
(function() { (function() {
var yourid = templates.get('yourid');
function initUsers() { function initUsers() {
function isUserAdmin(element) { function isUserAdmin(element) {
@ -21,12 +23,15 @@
jQuery('.admin-btn').each(function(index, element) { jQuery('.admin-btn').each(function(index, element) {
var adminBtn = $(element); var adminBtn = $(element);
var isAdmin = isUserAdmin(adminBtn); var isAdmin = isUserAdmin(adminBtn);
var uid = getUID(adminBtn);
if(isAdmin) if(isAdmin)
adminBtn.addClass('btn-success'); adminBtn.addClass('btn-success');
else else
adminBtn.removeClass('btn-success'); adminBtn.removeClass('btn-success');
if(uid === yourid)
adminBtn.addClass('disabled');
}); });
jQuery('.delete-btn').each(function(index, element) { jQuery('.delete-btn').each(function(index, element) {
@ -59,13 +64,12 @@
var parent = adminBtn.parents('.users-box'); var parent = adminBtn.parents('.users-box');
var uid = getUID(adminBtn); var uid = getUID(adminBtn);
if(isAdmin) { if(isAdmin && uid != yourid) {
socket.emit('api:admin.user.removeAdmin', uid); socket.emit('api:admin.user.removeAdmin', uid);
adminBtn.removeClass('btn-success'); adminBtn.removeClass('btn-success');
parent.find('.delete-btn').removeClass('disabled'); parent.find('.delete-btn').removeClass('disabled');
parent.attr('data-admin', 0); parent.attr('data-admin', 0);
} } else if(uid != yourid) {
else {
bootbox.confirm('Do you really want to make "' + parent.attr('data-username') +'" an admin?', function(confirm) { bootbox.confirm('Do you really want to make "' + parent.attr('data-username') +'" an admin?', function(confirm) {
if(confirm) { if(confirm) {
socket.emit('api:admin.user.makeAdmin', uid); socket.emit('api:admin.user.makeAdmin', uid);
@ -122,8 +126,7 @@
jQuery('document').ready(function() { jQuery('document').ready(function() {
var yourid = templates.get('yourid'), var timeoutId = 0,
timeoutId = 0,
loadingMoreUsers = false; loadingMoreUsers = false;
var url = window.location.href, var url = window.location.href,

Loading…
Cancel
Save