MediaWiki:Common.js:修订间差异

来自神国维基
跳到导航跳到搜索
七叶​(留言 | 贡献)
无编辑摘要
七叶​(留言 | 贡献)
无编辑摘要
第7行: 第7行:
return;
return;
}
}
// 已经搬过了就不重复
//  
if ( document.getElementById( 'p-toc' ) ) {
if ( document.getElementById( 'p-toc' ) ) {
return;
return;

2026年10月5日 (一) 19:11的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
/* 
( function () {
	function moveTOC() {
		// 
		if ( !window.matchMedia( '(min-width: 768px)' ).matches ) {
			return;
		}
		// 
		if ( document.getElementById( 'p-toc' ) ) {
			return;
		}
		var toc = document.querySelector( '.mw-table-of-contents-container' )
			|| document.querySelector( '.mw-table-of-contents' )
			|| document.getElementById( 'toc' );
		var sidebar = document.getElementById( 'column-one' );
		if ( !toc || !sidebar ) {
			return;
		}

		var portlet = document.createElement( 'div' );
		portlet.className = 'portlet';
		portlet.id = 'p-toc';

		var h3 = document.createElement( 'h3' );
		h3.textContent = '目录';

		var body = document.createElement( 'div' );
		body.className = 'pBody';
		body.appendChild( toc );   // 

		portlet.appendChild( h3 );
		portlet.appendChild( body );
		sidebar.appendChild( portlet );   // 
	}

	if ( document.readyState === 'loading' ) {
		document.addEventListener( 'DOMContentLoaded', moveTOC );
	} else {
		moveTOC();
	}
}() );