User:Ultimate Dark Carnage/chat.js

if (wgCanonicalSpecialPageName == 'Chat'){ var $trigger = $('Actions'); $trigger.on('click', function(event){           event.preventDefault;            if ($(event.target.hash).length) return;            else {                ChatWindow.append(function{ var $blackout = $(' ').attr('id', 'UserActions'), $modal = $(''), $modal_header = $('') .html([                                               $('').text('User Actions'),                                                $('').on('click', function(e){ e.preventDefault; $(e.target.hash).removeClass('show'); })                                           ]),                        $modal_content = $(''), $modal_footer = $(''); $modal_content.html(function{                       var user_list = ' ';                        mainRoom.viewUsers.model.users.models.map(function(userdata){ return userdata.attributes.name; }).sort.forEach(function(name, index, array){ var limit = 4, limit_indexed = limit - 1, attr = mainRoom.model.users.findByName(name).attributes; if (index % limit === limit_indexed && index !== array.length - 1){ user_list = user_list.concat(' \                                   \                                        \                                        '.concat(name) + '\                                    \                                     \                                '); user_list = user_list.concat('</ul> '); } else { user_list = user_list.concat(' \                                   <label for="item-user-'.concat(index) + '" class="user-item-wrapper user">\                                        <img src="'.concat(attr.avatarSrc) + '" alt="'.concat(name) + '" class="avatar" />\                                        '.concat(name) + '\                                    \                                    <input type="checkbox" class="item-user-checkbox hidden" value="'.concat(name) + '" id="item-user-'.concat(index) + '" /> \                                </li>'); }                       });                        user_list = user_list.concat('</ul> ');                        return user_list;                    }); $modal_content.find('.item-user-checkbox').on('click change', function(_e){                       if ($(_e.target).is(':checked')){                            $(_e.target).parent.addClass('selected');                        } else {                            $(_e.target).parent.removeClass('selected');                        }                    }); $modal_footer.html(function{                       var buttons = [                            $('<a href="#UserActions" class="modal-button button">Close</a>')                                .on('click', function(e){ e.preventDefault; $(e.target.hash).remove; }),                           $('<nav class="modal-button modal-menu-button button" />')                                .html(function{ var $menu = $(' '), $menu_list = $('<ul class="modal-menu-wrapper controls" />'), actions = { 'PM': function(_e_){ _e_.preventDefault; let el = $(_e_.target.hash), selected = null; if (el.find('.item.selected').length > 0){ selected = []; el.find('.item.selected').each(function(index){                                                       selected[selected.length] = $(this).attr('data-user');                                                    }); } else { selected = $('.item.selected').attr('data-user'); }                                               mainRoom.openPrivateChat(selected); },                                           'Kick': function(_e_){ _e_.preventDefault; let el = $(_e_.target.hash), selected = null; if (el.find('.item.selected').length > 1){ selected = []; el.find('.item.selected').each(function(index){                                                       selected[selected.length] = $(this).attr('data-user');                                                    }); } else { selected = $('.item.selected').attr('data-user'); }                                               if (typeof selected == 'object' && selected instanceof Array){ Array.prototype.forEach.call(selected, function(user){                                                       mainRoom.kick({ name: user });                                                   });                                                } else if (typeof selected == 'string'){ mainRoom.kick({                                                       name: selected                                                    }); } else { return; }                                           },                                            'Ban': function(_e_){ _e_.preventDefault; let el = $(_e_.target.hash), selected = null; if (el.find('.item.selected').length > 1){ selected = []; el.find('.item.selected').each(function(index){                                                       selected[selected.length] = $(this).attr('data-user');                                                    }); } else { selected = $('.item.selected').attr('data-user'); }                                           }                                        };                                    for (var title in actions){ var $item = $(''); $item.html($('<a href="#UserActions" class="control-link">' + title + '</a>').on('click', actions[title])); $menu_list.append($item); }                                   $menu.html($menu_list); return $menu; })                       ];                        return buttons;                    }); $modal.html([$modal_header, $modal_content, $modal_footer]); $blackout.html($modal); return $blackout; });           }        });        if (!$('#UserActionsTrigger').length) $('#Write .message').append($trigger); } else { window.open('/wiki/Special:Chat', '_blank'); } })(this.mediaWiki, this.jQuery, window, document, ($(document.body).is('.ChatWindow') ? $('.ChatWindow') : $(document.body)));
 * (function(mw, $, window, document, ChatWindow){