MediaWiki:FandomizedChat/statsmenu.js

(function($, mw, FandomizedChat, mainRoom){   function StatsMenu(user, room){        this.fc = FandomizedChat;        this.room = typeof room !== 'undefined' ? room : mainRoom;        this.loaded = false;        this.show = $.Deferred;        this.userData = this.fc.getUserData(user);        this.self = this.fc.self;        this.isMod = this.fc.isMember(this.self, 'mod');        this.isAdmin = this.fc.isMember(this.self, 'admin');    }    StatsMenu.prototype.items = $.extend(FandomizedChat.statsMenu, { profile: { type: 'main', id: 'statsmenu-profile', message: 'stats_menu_profile', link: '/wiki/User:$username' },       talk: { type: 'main', id: 'statsmenu-usertalk', message: 'stats_menu_userTalk', link: '/wiki/User_talk:$username', show: !FandomizedChat.hasMessageWall },       messagewall: { type: 'main', id: 'statsmenu-messagewall', message: 'stats_menu_messageWall', link: '/wiki/Message_Wall:$username', show: FandomizedChat.hasMessageWall },       contributions: { type: 'main', id: 'statsmenu-contributions', message: 'stats_menu_contributions', link: '/wiki/Special:Contributions/$username' },       messageblocker: { type: 'main', id: 'statsmenu-messageblocker', message: 'stats_menu_messageBlocker', state: false, handler: function(target){ var messageBlocker = FandomizedChat.performAction('messageBlocker', target); messageBlocker.block; },           inverse: { id: 'statsmenu-messageunblocker', message: 'stats_menu_messageUnblocker', handler: function(target){ var messageBlocker = FandomizedChat.performAction('messageBlocker', target); messageBlocker.unblock; }           }        },        blockpms: { type: 'main', id: 'statsmenu-blockpms', message: 'stats_menu_blockPMs', state: false, handler: function(target){ mainRoom.blockPrivate({ name: target }); return target; },           inverse: { id: 'statsmenu-allowpms', message: 'stats_menu_allowPMs', handler: function(target){ mainRoom.allowPrivate({ name: target }); }           }        },        kick: { type: 'mod', id: 'statsmenu-kick', message: 'stats_menu_kick', handler: function(target){ mainRoom.kick({ name: target }); }       },        ban: { type: 'mod', id: 'statsmenu-ban', message: 'stats_menu_ban', handler: function(target){ var banModal = FandomizedChat.BanModal({ value: target }); $.when(banModal.submit).done(function(modal){                   modal.init;                }); }       },        block: { type: 'admin', id: 'statsmenu-block', message: 'stats_menu_block', handler: function(target){ var blockModal = FandomizedChat.BlockModal({ value: target }); $.when(blockModal.submit).done(function(modal){                   modal.init;                }); }       }    });    StatsMenu.prototype.open = function{        var statsMenu = $(' ').addClass('StatsMenu user-stats-menu'),            header = $(' ').addClass('StatsMenuHeader user-stats-menu-header'),            content = $(' ').addClass('StatsMenuContent user-stats-menu-content'),            commands = { main: [], mod: [], admin: [] },            mainCommands = $(' ').addClass('StatsMenuSection user-stats-menu-main-commands'),            modCommands = $(' ').addClass('StatsMenuSection user-stats-menu-mod-commands'),            adminCommands = $(' ').addClass('StatsMenuSection user-stats-menu-admin-commands'),            keys = Object.keys(this.items), index = 0;    }; }(jQuery, mediaWiki, window.FandomizedChat, mainRoom));