User:Ultimate Dark Carnage/wikia.js

var mwVars = mw.config.get(['wgUserName', 'wgUserGroups', 'wgAction', 'wgPageName', 'wgCanonicalSpecialPageName', 'wgServer', 'wgDBname']), groups = mwVars.wgUserGroups, isAdmin = ((groups.indexOf('admin'.replace('admin', 'sysop')) + groups.indexOf('bureaucrat') + groups.indexOf('vstf') + groups.indexOf('helper') + groups.indexOf('staff')) > -5) ? true : false; $html = $('  '), $fa = $(' '), _actions = { 'block': function block{ function close($modal, callback){ if (callback instanceof Function || typeof callback == 'function') Function.prototype.apply.call(callback, window, []); $modal.closeModal; }               var _block_html_ ' \ \                           User \  \ \                       \                            Expiry \  \  \  \ 12 hours \ 1 day \ 3 days \ 7 days</li> \ 2 weeks</li> \ 1 month</li> \ 3 months</li> \ 6 months</li> \ 1 year</li> \ infinite</li> \ </ul> \ \                       \                        \                            <label for="block-reason-box" class="form-section-label form-label">Reason \ <textarea id="block-reason-box" class="form-section-input form-input" cols="18" rows="24"> \ \                   ',                    $modal = isAdmin ? $.showCustomModal('Block', _block_html_, {                       width: 650,                        id: 'BlockModal',                        buttons: [{                            message: 'Cancel',                            id: 'block-cancel',                            handler: close($modal)                        }, {                            message: 'Confirm',                            id: 'block-confirm',                            handler: close($modal, function init{ var user = $('#block-user-input').val, expiry = $('#block-expiry-input').val, reason = $('#block-reason-box').val; $.ajax({                                   method: 'POST',                                    dataType: 'json',                                    url: mw.util.wikiScript('api'),                                    data: {                                        action: 'block',                                        user: user,                                        expiry: expiry,                                        reason: reason,                                        nocreate: ,                                        allowusertalk: ,                                        autoblock: 0,                                        format: 'json',                                        token: mw.user.tokens.values.editToken                                    }                                }); })                       }]                    }) : '';            }        };    $html.find('> header').addClass('tools-header header') .html(function{           var html =                '<h2 class="user-info"> \                    <a href="/wiki/User:' + encodeURIComponent(mwVars.wgUserName) + '">' + mwVars.wgUserName + '</a> \                    <img class="user-avatar tools-avatar" alt="' + wgUserName + '" src="';            $.ajax({                method: 'GET',                url: mw.util.wikiScript('index'),                dataType: 'html',                data: {                    title: 'User:' + encodeURIComponent(mwVars.wgUserName)                }            }).success(function retrieve(data){                var $data = $(data),                    avatar = $data.find('.masthead-avatar .avatar'),                    avatar_src = avatar.attr('src');                html += avatar_src;            }).fail(function useDefault(error){                html += 'http://vignette4.wikia.nocookie.net/messaging/images/1/19/Avatar.jpg/revision/latest/scale-to-width-down/150?format=jpg'; });           html += '" /> \                    </a> \                ';            return html;        });    $html.find('> nav').addClass('tools custom-tools');    $.ajax({        method: 'GET',        url: mw.util.wikiScript('index'),        dataType: 'text',        data: {            title: tools.URL || 'User:' + encodeURIComponent(mwVars.wgUserName) + '/tools',            action: 'raw'        }    }).success(function getToolData(data){        var regex = {            heading: /\-(?:\s+|)(.*)(?:\s+|)\-/g,            item: /\*(?:\s+|)(.*)\:(.*)/g        },            line = data.split(/\n/),            tools_html = '',            _replaceL = function _replace(key, title, link){                var _i = '<a href="/wiki/[link]">[name]</a></li>';                _i = _i.replace('[name]', title);                _i = _i.replace('[link]', link);                return _i; };       for (var l = 0; l < line.length; l++){ var _line = line[l]; if (regex.heading.test(_line)){ if (l === 0){ tools_html += '<ul class="tools-section">'; tools_html += '' + _line.replace(regex.heading, '$1') + '</li>'; tools_html += '<ul class="tools-subsection tools-items items">'; } else { tools_html += '</ul></ul>'; tools_html += '<ul class="tools-section">'; tools_html += '' + _line.replace(regex.heading, '$1') + '</li>'; tools_html += '<ul class="tools-subsection tools-items items">'; }           } else if (regex.item.test(_line)){ if (l !== line.length - 1) tools_html += _line.replace(regex.item, _replaceL); else { tools_html += _line.replace(regex.item, _replaceL); tools_html += '</ul></ul>'; }           }        }        $('.custom-tools').html(tools_html); }).fail(function _error(err){ $('.custom-tools').html(' Cannot load the toolbar. Try again later '); });   $('.WikiaSiteWrapper').append($html); })(this.jQuery, this.mediaWiki, window, this.tools || {});
 * (function($, mw, window, tools){