跳转到内容

MediaWiki:Gadget-mainpage-customization.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
var MainPageCustomization = {};

MainPageCustomization.set = function(p) {
    if (MainPageCustomization.pageName == undefined) {
        MainPageCustomization.pageName = p;
    } else {
        MainPageCustomization.pageName = null;
        alert('You chose more than one main page style.');
        window.location.href = mw.config.get('wgScript') + '?title=Special:Preferences#prefsection-8';
    }
};

$(function() {
    if (mw.config.get('wgIsMainPage')) {
        if ((mw.config.get('wgAction') == 'view' || mw.config.get('wgAction') == 'purge') && MainPageCustomization.pageName) {
            // #article is for some old skins
            jQuery('.mw-content-ltr').text('Loading customized main page...').show().load(mw.config.get('wgScript'), {
                action: 'render',
                title: MainPageCustomization.pageName
            }, function(response, status, xhr) {
                if (status == 'error') {
                    jQuery('.mw-content-ltr').text('Sorry, but there was an error when '
                        + 'loading customized main page: ' + xhr.status + ' ' + xhr.statusText
                    );
                }
            });
        } else {
            jQuery('.mw-content-ltr').show();
        }
    }
});