User:Ultimate Dark Carnage/chat.js

jQuery(document).ready(function($){   var users = mainRoom.model.users.map(function(child){ return child.attributes.name; }).sort,       groups = {            chatmoderator: 'Chat Moderators',            sysop: 'Administrators',            bureaucrat: 'Bureaucrats',            vstf: 'VSTFs',            helper: 'Fandom Helpers',            staff: 'Fandom Staff'        },        users_controls = {            pm: {                name: 'PM',                action: function(event, item){                    if (item.username){                        mainRoom.openPrivateChat(item.username);                    }                }            },            hide: {                name: 'Hide Messages',                action: function(event, item){                    var $message = $('.Chat [data-user="' + item.username + '"]');                    if (item.username === mw.config.get('wgUserName', wgUserName)){                        var $inline_alert = $('');                        $inine_alert.html('Error: You cannot block your own messages.'); $('.Chat ul').append($inline_alert); } else { if (item.name == 'Hide Messages'){ $message.hide(500); item.change_name('Show Messages'); } else { $message.show(500); item.change_name('Hide Messages'); }                   }                }            },            kick: { name: 'Kick User', groups: ['chatmoderator', 'sysop', 'bureaucrat', 'vstf', 'helper', 'staff'], action: function(event, item){ if (item.username === mw.config.get('wgUserName', wgUserName)){ var $inline_alert = $(''); $inine_alert.html('Error: You cannot kick yourself.'); $('.Chat ul').append($inline_alert); } else { mainRoom.kick(item.username); }               }            },            ban: { name: 'Ban User', groups: ['chatmoderator', 'sysop', 'bureaucrat', 'vstf', 'helper', 'staff'], action: function(event, item){ if (item.username === mw.config.get('wgUserName', wgUserName)){ var $inline_alert = $(''); $inine_alert.html('Error: You cannot ban yourself.'); $('.Chat ul').append($inline_alert); } else { mainRoom.ban(item.username); }               }            },            give_chatmod: { name: 'Promote to Chat Mod', groups: ['sysop', 'bureaucrat', 'vstf', 'helper', 'staff'], actions: function(event, item){ var user_data = mainRoom.model.users.findByName(item.username), isMod = user_data.attributes.isModerator, isStaff = user_data.attributes.isStaff; if (isMod || isStaff){ var $inline_alert = $(''); $inine_alert.html('Error: This user is already a chat moderator.'); $('.Chat ul').append($inline_alert); } else if (item.username === mw.config.get('wgUserName', wgUserName)){ var $inline_alert = $(''); $inine_alert.html('Error: You cannot promote yourself as a chat moderator.'); $('.Chat ul').append($inline_alert); } else { mainRoom.giveChatMod(item.username); }               }            }        },        option_controls = { }; });