跳转至内容

MediaWiki:Common.js

来自 Wikibooks,面向开放世界的开放书籍
注意:保存后,更改可能不会立即生效。点击此处了解如何绕过浏览器的缓存。
  • Mozilla / Firefox / Safari:按住 Shift 的同时点击 重新加载,或按 Ctrl-Shift-R(Apple Mac 上为 Cmd-Shift-R);
  • Internet Explorer:按住 Ctrl 的同时点击 刷新,或按 Ctrl-F5
  • Konqueror:只需点击 重新加载 按钮,或按 F5
  • Opera 用户可能需要在 工具→首选项 中彻底清除缓存。
/**
 * Redirect User:Name/skin.js and skin.css to the current skin's pages
 * (unless the 'skin' page really exists).
 *
 * Dependencies: mediawiki.util
 *
 * @source https://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 * @revision 2016-04-13
 */
if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
	mw.loader.using( 'mediawiki.util', function () {
		var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
		// Make sure there was a part before and after the slash
		// And that the latter is 'skin.js' or 'skin.css'
		if ( titleParts.length == 2 ) {
			var userSkinPage = titleParts[0] + '/' + mw.config.get( 'skin' );
			if ( titleParts[1] === 'skin.js' ) {
				location.href = mw.util.getUrl( userSkinPage + '.js' );
			} else if ( titleParts[1] === 'skin.css' ) {
				location.href = mw.util.getUrl( userSkinPage + '.css' );
			}
		}
	} );
}

// Book specific
mw.config.set( 'wgBookName', ( mw.config.get( 'wgPageName' ).split( '/', 1 )[0] || '' ).split( ':', 2 ).join( ':' ) );

if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
	importStylesheet( 'MediaWiki:Common.css/Watchlist.css' );
	importScript('MediaWiki:Common.js/WatchlistNotice.js');
} else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Recentchanges' ) {
	importStylesheet( 'MediaWiki:Common.css/Recentchanges.css' );
} else if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit', 'upload'] ) !== -1 ) {
	importScript('MediaWiki:Common.js/Toolbox.js');
}

/*
 * Use Gadgets whenever possible to minimize loading for all users for every page.
 * Wait for mediawiki.util to be ready because some things assume its availability.
 */
mw.loader.using( 'mediawiki.util', function() {	
	// Page specific - lynchpin for [[Help:Dialog|dialog]] [[Category:Dialog javascript pages]]
	importScript( 'MediaWiki:Common.js/w/' + mw.config.get( 'wgPageName' ) );

	// Imported scripts
	importScript('MediaWiki:Common.js/Relics.js');
	importScript('MediaWiki:Common.js/ExtraTools.js');
	importScript('MediaWiki:Common.js/CollapseElements.js');
	importScript('MediaWiki:Common.js/NavigationTabs.js');
	importScript('MediaWiki:Common.js/Displaytitle.js');
	// importScript('MediaWiki:Common.js/RandomBook.js');
	importScript('MediaWiki:Common.js/Perbook.js');
	importScript('MediaWiki:Common.js/tabs.js');
	importScript('MediaWiki:Common.js/top.js');
	importScript('MediaWiki:Common.js/review.js');
	importScript('MediaWiki:Common.js/Categories.js');
	importScript('MediaWiki:Common.js/use.js');
	importScript('MediaWiki:Common.js/Slideshows.js');
// DO NOT ADD CODE BELOW THIS LINE
});
华夏公益教科书