Community Central
Community Central

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// <nowiki>
/**
 * @name            AjaxEdit
 * @version         v1.2
 * @author          TheGoldenPatrik1
 * @description     Edit without opening the editor.
 * @protect         <nowiki>
 */
require([
    'wikia.window',
    'jquery',
    'mw',
    'BannerNotification',
    'ext.wikia.design-system.loading-spinner',
    'wikia.browserDetect'
], function (window, $, mw, BannerNotification, Spinner, browserDetect) {
    'use strict';
    var config = mw.config.get([
        'wgAction',
        'wgArticleId',
        'wgCurRevisionId',
        'wgPageName',
        'wgScript',
        'wgUserGroups',
        'wgUserLanguage'
    ]);
    if (
        window.AjaxEditLoaded ||
        !$('#ca-edit').exists() ||
        $('.UserProfileActionButton').find('img').first().attr('class') === 'sprite lock' ||
        config.wgAction !== 'view' ||
        config.wgUserGroups.indexOf('autoconfirmed') === -1
    ) {
        return;
    }
    window.AjaxEditLoaded = true;
    var $button;
    var $edit;
    var $text;
    var $minor;
    var $summary;
    var $spinner;
    var $article = $('#mw-content-text');
    var $rail = $('#WikiaRail');
    var $wrapper = $('#WikiaMainContent');
    /**
     * @class Main
     * @description Central AjaxEdit class
     */
    var Main = {
        /**
         * @method publish
         * @description Publishes the edit
         * @returns {void}
         */
        publish: function () {
            if (this.diffModal) {
                this.diffModal.close();
            }
            if (this.previewModal) {
                this.previewModal.close();
            }
            $spinner.show();
            this.api.post({
                action: 'edit',
                title: config.wgPageName,
                summary: $summary.cleanedVal(),
                text: $text.val(),
                minor: $minor.prop('checked') ? true : undefined,
                token: mw.user.tokens.get('editToken'),
                watchlist: this.options.watchlist
            })
            .done(
                $.proxy(this.success, this)
            )
            .fail(
                $.proxy(this.fail, this)
            );
        },
        /**
         * @method success
         * @description Outputs .done results
         * @param {JSON} d - Data retured from .done
         * @returns {void}
         */
        success: function (d) {
            $spinner.hide();
            if (d.error) {
                this.notif(
                    this.i18n('errorKnown', d.error.code).escape(),
                    'error'
                );
            } else {
                if (
                    this.options.reload ||
                    mw.util.getParamValue('diff') ||
                    mw.util.getParamValue('oldid') ||
                    config.wgArticleId === 0
                ) {
                    this.reload();
                } else {
                    $article.load(
                        window.location.href + ' #mw-content-text',
                        $.proxy(this.refresh, this)
                    );
                }
            }
        },
        /**
         * @method fail
         * @description Outputs .fail results
         * @returns {void}
         */
        fail: function () {
            $spinner.hide();
            this.notif(
                this.i18n('errorUnknown').escape(),
                'error'
            );
        },
        /**
         * @method reload
         * @description Reloads the page
         * @returns {void}
         */
        reload: function () {
            window.location.href = mw.util.getUrl(config.wgPageName);
        },
        /**
         * @method refresh
         * @description Reloads the page without reloading
         * @returns {void}
         */
        refresh: function () {
            this.back();
            $edit.remove();
            this.rev += 1;
            this.content = $text.val();
            this.fireHook();
            this.notif(
                this.i18n('success').escape(),
                'confirm'
            );
        },
        /**
         * @method back
         * @description Returns to viewing the article
         * @returns {void}
         */
        back: function () {
            $edit.hide();
            $article.show();
            this.changeButton();
            if (this.options.hideRail) {
                $rail.show();
                if (!this.mobile) {
                    $wrapper.css(
                        'width',
                        ($('.WikiaPageContentWrapper').width() - 330) + 'px'
                    );
                }
            }
        },
        /**
         * @method restart
         * @description Reverts all changes
         * @returns {void}
         */
        restart: function () {
            $text.val(this.content);
            $summary.val('');
            $minor.prop('checked', this.options.minor);
        },
        /**
         * @method diff
         * @description Gets the diff
         * @returns {void}
         */
        diff: function () {
            $spinner.show();
            $.post(
                config.wgScript + '?' + $.param({
                    action: 'ajax',
                    rs: 'EditPageLayoutAjax',
                    title: config.wgPageName
                }),
                {
                    page: 'SpecialCustomEditPage',
                    method: 'diff',
                    content: $text.val(),
                    section: 0
                },
                $.proxy(this.loadDiff, this)
            );
        },
        /**
         * @method loadDiff
         * @description Outputs the diff in a modal
         * @param {JSON} d - The diff data
         * @returns {void}
         */
        loadDiff: function (d) {
            var diffModalContent = $('<div>', {
                'class': 'ajax-edit__diff-modal',
                'append': d.html
            }).prop('outerHTML');
            if (this.diffModal) {
                this.diffModal.setContent(diffModalContent).show();
                $spinner.hide();
                return;
            }
            this.diffModal = new this.modal({
                content: diffModalContent,
                id: 'ajax-edit__diff',
                size: 'large',
                title: this.i18n('diffButton').escape(),
                buttons: [
                    {
                        text: this.i18n('publishButton').escape(),
                        primary: true,
                        event: 'publish'
                    },
                    {
                        text: this.i18n('close').escape(),
                        event: 'close'
                    }
                ],
                events: {
                    publish: $.proxy(this.publish, this)
                }
            });
            this.diffModal.create();
            this.diffModal.show();
            $spinner.hide();
        },
        /**
         * @method preview
         * @description Gets the preview data
         * @returns {void}
         */
        preview: function () {
            $spinner.show();
            $.post(
                config.wgScript + '?' + $.param({
                    action: 'ajax',
                    rs: 'EditPageLayoutAjax',
                    title: config.wgPageName
                }),
                {
                    page: 'SpecialCustomEditPage',
                    method: 'preview',
                    summary: $summary.cleanedVal(),
                    content: $text.val(),
                    section: ''
                },
                $.proxy(this.loadPreview, this)
            );
        },
        /**
         * @method loadPreview
         * @description Outputs the preview in a modal
         * @param {JSON} d - The preview data
         * @returns {void}
         */
        loadPreview: function (d) {
            var previewModalContent = $('<div>', {
                'class': 'ajax-edit__preview-modal',
                'append': d.html
            }).prop('outerHTML');
            if (this.previewModal) {
                this.previewModal.setContent(previewModalContent).show();
                this.fireHook(true);
                $spinner.hide();
                return;
            }
            this.previewModal = new this.modal({
                content: previewModalContent,
                id: 'ajax-edit__preview',
                size: 'large',
                title: this.i18n('previewButton').escape(),
                buttons: [
                    {
                        text: this.i18n('publishButton').escape(),
                        primary: true,
                        event: 'publish'
                    },
                    {
                        text: this.i18n('close').escape(),
                        event: 'close'
                    }
                ],
                events: {
                    publish: $.proxy(this.publish, this)
                }
            });
            this.previewModal.create().then(
                $.proxy(this.displayPreview, this)
            );
        },
        /**
         * @method displayPreview
         * @description Displays the preview modal
         * @returns {void}
         */
        displayPreview: function () {
            this.previewModal.show();
            this.fireHook(true);
            $spinner.hide();
        },
        /**
         * @method replace
         * @description Outputs the replace modal
         * @returns {void}
         */
        replace: function () {
            if (this.replaceModal) {
                this.replaceModal.show();
                return;
            }
            var replaceModalContent = $('<div>', {
                'class': 'ajax-edit__replace-modal'
            }).append(
                $('<p>').append(
                    this.i18n('farFind').escape(),
                    $('<textarea>', {
                        'rows': '4',
                        'wrap': 'off',
                        'id': 'ajax-edit__replace-find'
                    })
                ),
                $('<p>').append(
                    this.i18n('farReplace').escape(),
                    $('<textarea>', {
                        'rows': '4',
                        'wrap': 'off',
                        'id': 'ajax-edit__replace-replace',
                    })
                ),
                $('<p>').append(
                    this.i18n('farGlobal').escape(),
                    '<input type="checkbox" id="ajax-edit__replace-global"' +
                    (this.options.replaceGlobal ? 'checked' : 'unchecked') +
                    '/>'
                ),
                $('<p>').append(
                    this.i18n('farCase').escape(),
                    '<input type="checkbox" id="ajax-edit__replace-case"' +
                    (this.options.replaceCase ? 'checked' : 'unchecked') +
                    '/>'
                ),
                $('<p>').append(
                    this.i18n('farRegex').escape(),
                    '<input type="checkbox" id="ajax-edit__replace-regex"' +
                    (this.options.replaceRegex ? 'checked' : 'unchecked') +
                    '/>'
                )
            ).prop('outerHTML');
            this.replaceModal = new this.modal({
                content: replaceModalContent,
                id: 'ajax-edit__replace',
                size: 'medium',
                title: this.i18n('replaceButton').escape(),
                buttons: [
                    {
                        text: this.i18n('farExecute').escape(),
                        primary: true,
                        event: 'execute'
                    },
                    {
                        text: this.i18n('close').escape(),
                        event: 'close'
                    }
                ],
                events: {
                    execute: $.proxy(this.loadReplace, this)
                }
            });
            this.replaceModal.create();
            this.replaceModal.show();
        },
        /**
         * @method loadReplace
         * @description Performs the replace action
         * @returns {void}
         */
        loadReplace: function () {
            var searchfor = '',
                searchexp,
                $find = $('#ajax-edit__replace-find').val(),
                replacewith = $('#ajax-edit__replace-replace').val().replace(/\r/gi, ''),
                text = $text.val().replace(/\r/gi, ''),
                flagg = 'g',
                flagi = 'i',
                enableregex = false;
            if ($('#ajax-edit__replace-global').prop('checked') === false) {
                flagg = '';
            }
            if ($('#ajax-edit__replace-case').prop('checked') === true) {
                flagi = '';
            }
            if ($('#ajax-edit__replace-regex').prop('checked') === true) {
                enableregex = true;
            }
            var flags = flagg + flagi + 'm';
            if (enableregex) {
               searchfor = $find;
            } else {
                searchfor = $find.replace(/\r/gi, '').replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
            }
            searchexp = new RegExp(searchfor, flags);
            var rcount = 0;
            var matched = text.match(searchexp);
            if (matched !== null) {
                rcount = matched.length;
            }
            text = text.replace(searchexp, replacewith);
            $text.val(text);
            $('#ajax-edit__replace-tally').html(
                '<br/>' + this.i18n('farFound', rcount).escape()
            );
            this.replaceModal.close();
        },
        /**
         * @method notif
         * @description Outputs a BannerNotification
         * @param {String} text - The notif text
         * @param {String} type - The notif type
         * @returns {void}
         */
        notif: function (text, type) {
            new BannerNotification(
                text,
                type
            ).show();
        },
        /**
         * @method fireHook
         * @description Fires the wikipage.content hook for display purposes
         * @param {Boolean} type - What the hook should be fire on
         * @returns {void}
         */
        fireHook: function (type) {
            mw.hook('wikipage.content').fire(
                type ?
                $('.ajax-edit__preview-modal #' + mw.util.$content[0].id) :
                $article
            );
        },
        /**
         * @method create
         * @description Creates the AjaxEdit interface
         * @returns {void}
         */
        create: function () {
            $('#WikiaArticle').prepend(
                $('<div>', {
                    'class': 'ajax-edit__edit ajax-edit__' + (this.mobile ? 'mobile' : 'desktop')
                }).append(
                    $('<div>', {
                        'id': 'ajax-edit__edit-publisharea'
                    }).append(
                        $('<label>', {
                            'for': 'ajax-edit-minor',
                            'text': this.i18n('minor').plain()
                        }),
                        $('<input>', {
                            'type': 'checkbox',
                            'id': 'ajax-edit__edit-minor',
                            'name': 'ajax-edit-minor'
                        }),
                        $('<label>', {
                            'for': 'ajax-edit-summary',
                            'text': this.i18n('summary').plain()
                        }),
                        $('<input>', {
                            'type': 'text',
                            'id': 'ajax-edit__edit-summary',
                            'name': 'ajax-edit-summary'
                        }),
                        $('<br/>'),
                        $('<div>', {
                            'id': 'ajax-edit__edit-buttons'
                        }).append(
                            this.button('back'),
                            this.button('restart'),
                            this.button('diff'),
                            this.button('preview'),
                            this.button('replace'),
                            this.button('publish')
                        ),
                        $('<span>', {
                            'id': 'ajax-edit__replace-tally'
                        })
                    ),
                    $('<textarea>', {
                        id: 'ajax-edit__edit-text',
                        css: {
                            height: this.options.height
                        }
                    })
                )
            );
            $edit = $('.ajax-edit__edit');
            $text = $('#ajax-edit__edit-text');
            $minor = $('#ajax-edit__edit-minor');
            $summary = $('#ajax-edit__edit-summary');
            $summary.cleanedVal = $.proxy(function () {
                return (
                    this.options.summaryNotice ? '[AjaxEdit] ' : ''
                ) +
                $summary.val().trim();
            }, this);
            $text.val(this.content);
            if ($article.find('#mw-clearyourcache').length === 0) {
                $edit.addClass('ajax-edit__codepage');
                $text.linksuggest();
            } else {
                $edit.addClass('ajax-edit__articlepage');
                $('#ajax-edit__buttons-preview').remove();
            }
            $minor.prop('checked', this.options.minor);
            var keys = {};
            $summary.on('keydown', $.proxy(function (e) {
                keys[e.which] = true;
                if (keys[13]) {
                    this.publish();
                }
            }, this))
            .on('keyup', function (e) {
                keys[e.which] = false;
            });
            if (this.options.summaries) {
                $summary.after(
                    $('<select>', {
                        'id': 'ajax-edit__edit-summaries',
                        'change': function () {
                            $summary.val(
                                $(this).val()
                            );
                        }
                    }).append(
                        $('<option>', {
                            disabled: true,
                            text: this.i18n('summaries').plain()
                        })
                    )
                );
                $.each(this.options.summaries, function (k, v) {
                    $('#ajax-edit__edit-summaries').append(
                        $('<option>', {
                            'value': v,
                            'text': k
                        })
                    );
                });
            }
            if (this.options.buttons) {
                if (this.options.buttons === 'defaults') {
                    this.options.buttons = [
                        {
                            label: this.i18n('inputBold').plain(),
                            open: '\'\'\'',
                            close: '\'\'\''
                        },
                        {
                            label: this.i18n('inputItalics').plain(),
                            open: '\'\'',
                            close: '\'\''
                        },
                        {
                            label: this.i18n('inputLink').plain(),
                            open: '[[',
                            close: ']]'
                        },
                        {
                            label: this.i18n('inputHeader').plain(),
                            open: '== ',
                            close: ' =='
                        },
                        {
                            label: this.i18n('inputNowiki').plain(),
                            open: '<nowiki>',
                            close: '</' + 'nowiki>'
                        },
                        {
                            label: this.i18n('inputSig').plain(),
                            middle: '~~~~'
                        },
                    ];
                }
                $.each(this.options.buttons, function (k, v) {
                    $('#ajax-edit__edit-buttons').append(
                        $('<a>', {
                            'class': 'button',
                            'click': function () {
                                var textarea = document.getElementById('ajax-edit__edit-text');
                                var start = textarea.selectionStart;
                                var stop = textarea.selectionEnd;
                                var selectedText = textarea.value.slice(start, stop);
                                textarea.value =
                                    textarea.value.slice(0, start) +
                                    (v.open || '') +
                                    (v.middle || selectedText) +
                                    (v.close || '') +
                                    textarea.value.slice(stop);
                            },
                            'text': v.label
                        })
                    );
                });
                $('#ajax-edit__buttons-publish').after('<br/>');
            }
            $spinner.hide();
            mw.hook('AjaxEdit.session').fire(this);
        },
        /**
         * @method button
         * @description Creates a button
         * @param {String} name - The button name
         * @returns {function}
         */
        button: function (name) {
           return $('<a>', {
                'class': 'button',
                'id': 'ajax-edit__buttons-' + name,
                'click': $.proxy(this[name], this),
                'text': this.i18n(name + 'Button').plain(),
                'title': this.i18n(name + 'Title').plain()
            });
        },
        /**
         * @method loadData
         * @description Processes the data from the API
         * @param {String} d - The page source
         * @returns {void}
         */
        loadData: function (d) {
            this.content = d;
            this.create();
        },
        /**
         * @method returnData
         * @description Processes the data
         * @param {JSON} d - The data from the API request
         * @returns {void}
         */
        returnData: function (d) {
            if (d.error) {
                this.reload();
            } else {
                this.loadData(
                    d.query.pages[config.wgArticleId].revisions[0]['*']
                );
            }
        },
        /**
         * @method click
         * @description Gets the content and loads the interface
         * @returns {void}
         */
        click: function () {
            if (this.rev !== 0) {
                $spinner.show();
                this.create();
            } else if (this.content && !this.options.reloadContent) {
                $edit.show();
                if (this.options.restart) {
                    $text.val(this.content);
                }
            } else {
                if ($spinner) {
                    $spinner.show();
                } else {
                    $('<div>', {
                        id: 'ajax-edit__throbber',
                        html:
                            new Spinner(38, 2).html
                            .replace('wds-block', 'wds-spinner__block')
                            .replace('wds-path', 'wds-spinner__stroke')
                            .replace('stroke-width=""', 'stroke-width="3"')
                    }).appendTo(document.body);
                    $spinner = $('#ajax-edit__throbber');
                }
                if (config.wgArticleId === 0) {
                    this.loadData('');
                } else {
                    this.api.get({
                        smaxage: 0,
                        maxage: 0,
                        action: 'query',
                        revids:
                            mw.util.getParamValue('diff') ||
                            mw.util.getParamValue('oldid') ||
                            config.wgCurRevisionId,
                        prop: 'revisions',
                        rvprop: 'content'
                    })
                    .done(
                        $.proxy(this.returnData, this)
                    )
                    .fail(
                        $.proxy(this.reload, this)
                    );
                }
            }
            $article.hide();
            this.changeButton();
            if (this.options.hideRail) {
                $rail.hide();
                if (!this.mobile) {
                    $wrapper.css('width', '100%');
                }
            }
        },
        /**
         * @method changeButton
         * @description Changes the AjaxEdit button
         */
        changeButton: function () {
            var isEdit = false;
            if ($button.data('id') === 'edit') {
                isEdit = true;
            }
            $button.text(
                this.i18n(isEdit ? 'backButton' : 'buttonText').plain()
            );
            $button.attr(
                'title',
                this.i18n(isEdit ? 'backTitle' : 'buttonTitle').plain()
            );
            $button.data(
                'id',
                isEdit ? 'back' : 'edit'
            );
        },
        /**
         * @method init
         * @description Initiates the script
         * @param {String} i18n - Variable for I18n-js
         * @returns {void}
         */
        init: function (i18n) {
            this.i18n = i18n.msg;
            if (this.options.button) {
                var action = '.UserProfileActionButton';
                var $action = $(action).length === 0;
                $(
                    $action ?
                    '.page-header__contribution-buttons .wds-button-group' :
                    action
                )[
                    $action ?
                    'after' :
                    'append'
                ](
                    $('<a>', {
                       'class':
                            $action ?
                            'wds-button wds-is-squished wds-is-secondary' :
                            'button',
                        id: 'ca-ajax-edit',
                        'data-id': 'edit',
                        text: this.i18n('buttonText').plain(),
                        title: this.i18n('buttonTitle').plain()
                   })
                );
            } else {
               $(
                    this.placement.element('editdropdown')
                )[this.placement.type('append')](
                    $('<li>').append(
                        $('<a>', {
                            id: 'ca-ajax-edit',
                            'data-id': 'edit',
                            text: this.i18n('buttonText').plain(),
                            title: this.i18n('buttonTitle').plain()
                        })
                    )
                );
            }
            $button = $('#ca-ajax-edit');
            $button.click($.proxy(function () {
                if ($button.data('id') === 'edit') {
                    this.click();
                } else {
                    this.back();
                }
            }, this));
            if (mw.util.getParamValue('ajaxedit') !== null) {
                this.click();
            }
        },
        /**
         * @method preload
         * @description Preloads the script
         * @returns {void}
         */
        preload: function () {
            if (--this.preloads === 0) {
                this.placement = window.dev.placement.loader;
                this.placement.script('AjaxEdit');
                this.modal = window.dev.modal.Modal;
                window.dev.i18n.loadMessages('AjaxEdit').then(
                    $.proxy(this.init, this)
                );
            }
        },
        /**
         * @method hooks
         * @description Preloads the hooks and imports
         * @returns {void}
         */
        hooks: function () {
            this.preloads = 3;
            this.rev = 0;
            this.mobile = browserDetect.isMobile();
            this.api = new mw.Api();
            this.options = $.extend(
                {
                    minor: mw.user.options.get('minordefault') === '1',
                    reloadContent: false,
                    restart: false,
                    watchlist: 'preferences',
                    hideRail: false,
                    height: this.mobile ? '750px' : '500px',
                    replaceGlobal: true,
                    replaceCase: false,
                    replaceRegex: false,
                    summaries: false,
                    summaryNotice: false,
                    buttons: false,
                    reload: false,
                    button: false
                },
                window.AjaxEdit
            );
            mw.hook('dev.i18n').add(
                $.proxy(this.preload, this)
            );
            mw.hook('dev.modal').add(
                $.proxy(this.preload, this)
            );
            mw.hook('dev.placement').add(
                $.proxy(this.preload, this)
            );
            importArticles(
                {
                    type: 'script',
                    articles: [
                        'u:dev:MediaWiki:I18n-js/code.js',
                        'u:dev:MediaWiki:Modal.js',
                        'u:dev:MediaWiki:Placement.js'
                    ]
                },
                {
                    type: 'style',
                    articles: [
                        'u:dev:MediaWiki:AjaxEdit.css'
                    ]
                }
            );
        }
    };
    mw.loader.using([
        'mediawiki.api',
        'mediawiki.util',
        'mediawiki.user',
        'ext.wikia.LinkSuggest'
    ]).then(
        $.proxy(Main.hooks, Main)
    );
});
// Config
var config = mw.config.get([
    'wgCityId',
    'wgNamespaceNumber',
    'wgPageName'
]);
// Custom Edit Buttons
if (mwCustomEditButtons) {
    mwCustomEditButtons[mwCustomEditButtons.length] = {
        'speedTip': 'Signature',
        'tagOpen': '{{User:TheGoldenPatrik1/sig.css|~~~~~}}'
    };
}
// Configurations
window.dev = window.dev || {};
window.dev.placement = window.dev.placement || {};
window.dev.placement.PortableListUsers = {
    'type': 'append',
    'element': 'wikinav'
};
window.nullEditDelay = 500;
window.massCategorizationDelay = 750;
window.massEditConfig = {
    editInterval: 750
};
window.WHAMDelay = 400;
window.WHAMDeleteReason = 'Cleanup';
window.WHAMBlockReason = '[[w:Help:Vandalism|Vandalism]]';
window.AjaxUndoMinor = true;
window.UnhideUserMasthead = {
    unhideLinks: true
};
window.AjaxEdit = {
    button: true,
    buttons: [
        {
            label: 'Sig',
            open: '{{User:TheGoldenPatrik1/sig.css|~~~~~}}'
        }
    ],
    hideRail: true,
    reload: config.wgPageName.endsWith('.js') && config.wgNamespaceNumber === 8
};
window.AutoCreateUserPagesConfig = {
    content: {
        2: '{{w:User:$1}}',
        3: '{{w:User talk:$1}}',
        1202: '{{w:Message Wall Greeting:$1}}'
    },
    summary: 'Automatic'
};
window.customCodeQuickLinks = {
    replaceAllDefaultLinks: false,
    linkSet: {
        userFiles: [
            {
                name: 'Universal.css',
                href: '//c.fandom.com/wiki/User:TheGoldenPatrik1/universal.css'
            },
            {
                name: 'Sandbox',
                href: mw.util.getUrl('Special:MyPage/Sandbox')
            },
            {
                name: 'To Do List',
                href: mw.util.getUrl('User:TheGoldenPatrik1/To Do List')
            }
        ],
        siteFiles: [
            {
                name: 'Themes.css',
                href: mw.util.getUrl('MediaWiki:Themes.css')
            },
            {
                name: 'Staff.css',
                href: mw.util.getUrl('MediaWiki:Staff.css')
            },
            {
                name: 'ProfileTags',
                href: mw.util.getUrl('MediaWiki:ProfileTags')
            }
        ],
    }
};
window.AjaxThreadDeleteConfig = {
    fastDelete: true,
    reason: 'Cleanup'
};
window.AjaxDelete = {
    deleteReasons: {
        'Unused Redirect': 'Redirect',
        '[[w:Help:Spam|Spam]]': 'Spam',
        'Cleanup': 'Cleanup',
        'Marked for Deletion': 'MFD',
        'Housekeeping': 'Housekeeping'
    },
    imageDeleteReasons: {
        '[[w:Help:Spam|Spam]]': 'Spam',
        'Unused': 'Unused',
        'Housekeeping': 'Housekeeping',
        'Cleanup': 'Cleanup'
    },
    autoCheckWatch: false
};
window.announcementsIgnore = {
    option: 'opt-out-all', 
    exceptWikiIds: [
        177,
        1399015,
        1542998
    ]
};
window.unsafeScriptsConfig = {
    'usesitejs': false,
    'usesitecss': false,
    'close': true
};
window.lastEdited = {
    diffModal: false
};
window.pageCreatorConfig = {
    namespaces: 'all',
    useTimeago: true
};
window.dev.editSummaries = {
    css: false,
    select: [
        'Summaries',
        'CVN', [
            '[[w:Help:Vandalism|Vandalism]]',
            '[[w:Help:Spam|Spam]]'
         ],
        'VSTF', [
            '+4 Reports from Wikia Watchers',
            '+5 Reports from Wikia Watchers',
            '+6 Reports from Wikia Watchers',
            '+7 Reports from Wikia Watchers',
            '+8 Reports from Wikia Watchers'
        ],
        'Standard', [
            'Marking for Deletion',
            'Whatlinkshere',
            'Miscellaneous Cleanup',
            'Formatting'
        ]
    ]
};
window.globalNavButtons = [
//Debug
{
    text: 'Debug',
    url: new mw.Uri().extend({debug: '1'}).toString(),
    isMain: true,
    whoIsMain: false,
    shortName: 'd'
}, {
    text: 'Site JS',
    url: new mw.Uri().extend({usesitejs: '0'}).toString(),
    isMain: false,
    whoIsMain: 'd',
    shortName: 's-js'
}, {
    text: 'User JS',
    url: new mw.Uri().extend({useuserjs: '0'}).toString(),
    isMain: false,
    whoIsMain: 'd',
    shortName: 'u-js'
}, {
    text: 'Site CSS',
    url: new mw.Uri().extend({usesitecss: '0'}).toString(),
    isMain: false,
    whoIsMain: 'd',
    shortName: 's-css'
}, {
    text: 'User CSS',
    url: new mw.Uri().extend({useusercss: '0'}).toString(),
    isMain: false,
    whoIsMain: 'd',
    shortName: 'u-css'
}, {
    text: 'All JS',
    url: new mw.Uri().extend({usesitejs: '0', useuserjs: '0'}).toString(),
    isMain: false,
    whoIsMain: 'd',
    shortName: 'a-js'
}, {
    text: 'All CSS',
    url: new mw.Uri().extend({usesitecss: '0', useusercss: '0'}).toString(),
    isMain: false,
    whoIsMain: 'd',
    shortName: 'a-css'
}, {
    text: 'Everything',
    url: new mw.Uri().extend({usesitejs: '0', useuserjs: '0', usesitecss: '0', useusercss: '0'}).toString(),
    isMain: false,
    whoIsMain: 'd',
    shortName: 'eve'
},
//Pages
{
    text: 'Pages',
    url: mw.util.getUrl('Special:AllPages'),
    isMain: true,
    whoIsMain: false,
    shortName: 'p'
}, {
    text: 'RC',
    url: mw.util.getUrl('Special:Recentchanges'),
    isMain: false,
    whoIsMain: 'p',
    shortName: 'rc'
}, {
    text: 'Prefindex',
    url: mw.util.getUrl('Special:PrefixIndex'),
    isMain: false,
    whoIsMain: 'p',
    shortName: 'pref'
}, {
    text: 'Shortpages',
    url: mw.util.getUrl('Special:Shortpages'),
    isMain: false,
    whoIsMain: 'p',
    shortName: 'sp'
}, {
    text: 'Watchlist',
    url: '//thegoldenpatrik1.fandom.com/wiki/Watchlist',
    isMain: false,
    whoIsMain: 'p',
    shortName: 't-w'
},
//Contact
{
    text: 'SC',
    url: mw.util.getUrl('Special:Contact/general'),
    isMain: true,
    whoIsMain: false,
    shortName: 'c'
}, {
    text: 'S:C/bug',
    url: mw.util.getUrl('Special:Contact/bug'),
    isMain: false,
    whoIsMain: 'c',
    shortName: 'c-b'
}, {
    text: 'S:C/feedback',
    url: mw.util.getUrl('Special:Contact/feedback'),
    isMain: false,
    whoIsMain: 'c',
    shortName: 'c-f'
}, {
    text: 'CC S:C',
    url: '//c.fandom.com/wiki/Special:Contact/general',
    isMain: false,
    whoIsMain: 'c',
    shortName: 's-c'
},
//Logs
{
    text: 'Logs',
    url: mw.util.getUrl('Special:Log'),
    isMain: true,
    whoIsMain: false,
    shortName: 'l'
}, {
    text: 'URL',
    url: mw.util.getUrl('Special:Log/rights'),
    isMain: false,
    whoIsMain: 'l',
    shortName: 'url'
}, {
    text: 'DL',
    url: mw.util.getUrl('Special:Log/delete'),
    isMain: false,
    whoIsMain: 'l',
    shortName: 'dl'
}, {
    text: 'PL',
    url: mw.util.getUrl('Special:Log/protect'),
    isMain: false,
    whoIsMain: 'l',
    shortName: 'pl'
}, {
    text: 'BL',
    url: mw.util.getUrl('Special:Log/block'),
    isMain: false,
    whoIsMain: 'l',
    shortName: 'bl'
}, {
    text: 'ML',
    url: mw.util.getUrl('Special:Log/move'),
    isMain: false,
    whoIsMain: 'l',
    shortName: 'ml'
}, {
    text: 'CC URL',
    url: '//c.fandom.com/wiki/Special:Log/rights',
    isMain: false,
    whoIsMain: 'l',
    shortName: 'cc-url'
},
//VSTF
{
    text: 'VSTF',
    url: '//vstf.fandom.com/wiki/Special:Recentchanges',
    isMain: true,
    whoIsMain: false,
    shortName: 'v'
}, {
    text: 'Spam',
    url: '//vstf.fandom.com/wiki/Report:Spam',
    isMain: false,
    whoIsMain: 'v',
    shortName: 'v-s'
}, {
    text: 'Vandalism',
    url: '//vstf.fandom.com/wiki/Report:Vandalism',
    isMain: false,
    whoIsMain: 'v',
    shortName: 'v-v'
}, {
    text: 'Profiles',
    url: '//vstf.fandom.com/wiki/Report:User_profile_headers',
    isMain: false,
    whoIsMain: 'v',
    shortName: 'v-p'
}, {
    text: 'Wikis',
    url: '//vstf.fandom.com/wiki/Report:Wiki',
    isMain: false,
    whoIsMain: 'v',
    shortName: 'v-w'
}, {
    text: 'Biglist',
    url: '//vstf.fandom.com/wiki/Report:Spam/Biglist',
    isMain: false,
    whoIsMain: 'v',
    shortName: 'v-b'
}];
// Device Specific Imports
require(['wikia.browserDetect'], function (detect) {
    if (detect.isMobile()) {
        importArticle({
            type: 'script',
            article: 'u:dev:ChromeToolbarColor.js'
        });
    } else {
        importArticles({
            type: 'script',
            articles: [
                'u:dev:FindAndReplace/code.js',
                'u:dev:MaximizeAce.js',
                'u:dev:PortableCSSPad/code.js',
                'u:dev:Standard Edit Summary/code.js',
                'u:dev:StickySummary.js',
                'u:dev:UnhideAceDiff.js'
            ]
        });
    }
});
// General Imports
importArticles({
    type: 'script',
    articles: [
        'u:dev:AjaxDelete/code.js',
        //'u:dev:AjaxEdit.js',
        'u:dev:AjaxThreadDelete/code.js',
        'u:dev:AjaxUndo/code.js',
        'u:dev:AnchoredRollback/code.js',
        'u:dev:AnnouncementsIgnore.js',
        'u:dev:BlogLink/code.js',
        'u:dev:CodeEditor.js',
        'u:dev:CodeQuickLinks/code.js',
        'u:dev:ContribsButtons.js',
        'u:dev:DisableDrafts.js',
        'u:dev:EditConflictAlert/code.js',
        'u:dev:FileLogs.js',
        'u:dev:GlobalEditcount/code.js',
        'u:dev:GlobalNavButtons.js',
        'u:dev:LastEdited/code.js',
        'u:dev:LinkToDiscussionsProfileIfTheyDontHaveLivePosts/code.js',
        'u:dev:MassCategorization/code.js',
        'u:dev:MassEdit/code.js',
        'u:dev:MassNullEdit/code.js',
        'u:dev:MastheadGender/code.js',
        'u:dev:MinimalTemplateClassification.js',
        'u:dev:NoImageLightbox/code.js',
        'u:dev:NullEditButton/code.js',
        'u:dev:PageCreator/code2.js',
        'u:dev:PageEditInfo/code.js',
        'u:dev:PortableListUsers.js',
        'u:dev:ProtectionIcons.js',
        'u:dev:QuickDiff/code.js',
        'u:dev:RevealAnonIP/usercode.js',
        'u:dev:SeeMoreActivityButton/code.js',
        'u:dev:ShowUserGroups.js',
        'u:dev:UnhideUserMasthead/code.js',
        'u:dev:UnsafeScripts/code.js',
        'u:dev:UserAccountAge/code2.js',
        'u:dev:ViewDeleted/code.js',
        'u:dev:View Source/code.js',
        'u:dev:VSTFReport.js',
        'u:dev:WallGreetingButton/code.js',
        'u:dev:WHAM/code.2.js',
        'u:dev:WLHEditLinks/code.js',
        'u:kocka:User:KockaAdmiralac/AutoCreateUserPages.javascript',
        'u:kocka:User:KockaAdmiralac/LinkModifications.javascript',
        'u:kocka:User:KockaAdmiralac/UnhideLinks.javascript',
        'u:thegoldenpatrik1:BlankUndo.js',
        'u:thegoldenpatrik1:Rollback.js',
        'u:thegoldenpatrik1:SignatureCreator.js'
    ]
});
// Wiki Specific Imports
if (config.wgCityId === '65099') {
    importArticle(
        {
            type: 'style',
            article: 'u:dev:MediaWiki:FANSUN.css'
        },
        {
            type: 'script',
            article: 'u:dev:FANSUN.js'
        }
    );
}