MediaWiki:Common.js:修订间差异

MediaWiki界面页面
标签替换
无编辑摘要
第1行: 第1行:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using(['mediawiki.util']).done(function () {
    /* Begin of mw.loader.using callback */
    // 异步加载非关键JavaScript模块
    function loadNonCriticalModules() {
        // 假设 "nonCriticalModule.js" 包含了addEditIntro等函数
        import('/path/to/nonCriticalModule.js')
            .then(module => {
                // 当前页面是文章命名空间时执行相关函数
                if (mw.config.get('wgNamespaceNumber') === 0) {
                    if (document.getElementById('disambigbox')) {
                        module.addEditIntro('Template:Disambig_editintro');
                    }
                    var cats = mw.config.get('wgCategories');
                    if (cats && ($.inArray('Living people', cats) !== -1 || $.inArray('Possibly living people', cats) !== -1)) {
                        module.addEditIntro('Template:BLP_editintro');
                    }
                }
            })
            .catch(err => {
                console.error('Error loading the non-critical module:', err);
            });
    }
    // 当DOM内容加载完成后,加载非关键脚本
    document.addEventListener("DOMContentLoaded", loadNonCriticalModules);
    /* End of mw.loader.using callback */
});
/* DO NOT ADD CODE BELOW THIS LINE */

2024年1月26日 (五) 14:04的版本

/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using(['mediawiki.util']).done(function () {
    /* Begin of mw.loader.using callback */

    // 异步加载非关键JavaScript模块
    function loadNonCriticalModules() {
        // 假设 "nonCriticalModule.js" 包含了addEditIntro等函数
        import('/path/to/nonCriticalModule.js')
            .then(module => {
                // 当前页面是文章命名空间时执行相关函数
                if (mw.config.get('wgNamespaceNumber') === 0) {
                    if (document.getElementById('disambigbox')) {
                        module.addEditIntro('Template:Disambig_editintro');
                    }

                    var cats = mw.config.get('wgCategories');
                    if (cats && ($.inArray('Living people', cats) !== -1 || $.inArray('Possibly living people', cats) !== -1)) {
                        module.addEditIntro('Template:BLP_editintro');
                    }
                }
            })
            .catch(err => {
                console.error('Error loading the non-critical module:', err);
            });
    }

    // 当DOM内容加载完成后,加载非关键脚本
    document.addEventListener("DOMContentLoaded", loadNonCriticalModules);

    /* End of mw.loader.using callback */
});
/* DO NOT ADD CODE BELOW THIS LINE */