MediaWiki:Common.js:修订间差异

MediaWiki界面页面
无编辑摘要
无编辑摘要
第1行: 第1行:
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
function addCssFile(cssUrl) {
if (mw.config.get('wgPageName') === '首页'){
    var link = document.createElement("link");
importScript( 'MediaWiki:Mainpage.js' );
    link.rel = "stylesheet";
} else {
    link.href = cssUrl;
    document.head.appendChild(link);
}
 
function addJsFile(jsUrl) {
    var script = document.createElement("script");
    script.src = jsUrl;
    document.head.appendChild(script);
}
 
const pageScripts = {
    '首页': 'MediaWiki:Mainpage.js'
};
 
const currentPageName = mw.config.get('wgPageName');
const scriptToImport = pageScripts[currentPageName];
 
if (scriptToImport) {
    importScript(scriptToImport);
}
}

2023年9月27日 (三) 19:27的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
if (mw.config.get('wgPageName') === '首页'){
importScript( 'MediaWiki:Mainpage.js' );
} else {
}