MediaWiki:Common.js:修订间差异
来自神国维基
跳到导航跳到搜索
无编辑摘要 |
无编辑摘要 |
||
| (未显示同一用户的1个中间版本) | |||
| 第1行: | 第1行: | ||
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | /* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | ||
( function () { | ( function () { | ||
function moveTOC() { | function moveTOC() { | ||
var toc = document.getElementById( 'toc' ) | |||
if ( ! | || document.querySelector( '.mw-table-of-contents-container' ) | ||
|| document.querySelector( '.mw-table-of-contents' ); | |||
var sidebar = document.getElementById( 'column-one' ) | |||
|| document.getElementById( 'mw-panel' ); | |||
if ( !toc || !sidebar || document.getElementById( 'p-toc' ) ) { | |||
return; | return; | ||
} | } | ||
var box = document.createElement( 'div' ); | |||
box.className = 'portlet'; | |||
box.id = 'p-toc'; | |||
var title = document.createElement( 'h3' ); | |||
var | title.textContent = '目录'; | ||
var inner = document.createElement( 'div' ); | |||
inner.className = 'pBody'; | |||
inner.appendChild( toc ); | |||
box.appendChild( title ); | |||
box.appendChild( inner ); | |||
sidebar.appendChild( box ); | |||
var | |||
var | |||
sidebar.appendChild( | |||
} | } | ||
if ( document.readyState === 'loading' ) { | if ( document.readyState === 'loading' ) { | ||
document.addEventListener( 'DOMContentLoaded', moveTOC ); | document.addEventListener( 'DOMContentLoaded', moveTOC ); | ||
2026年10月5日 (一) 19:18的最新版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
( function () {
function moveTOC() {
var toc = document.getElementById( 'toc' )
|| document.querySelector( '.mw-table-of-contents-container' )
|| document.querySelector( '.mw-table-of-contents' );
var sidebar = document.getElementById( 'column-one' )
|| document.getElementById( 'mw-panel' );
if ( !toc || !sidebar || document.getElementById( 'p-toc' ) ) {
return;
}
var box = document.createElement( 'div' );
box.className = 'portlet';
box.id = 'p-toc';
var title = document.createElement( 'h3' );
title.textContent = '目录';
var inner = document.createElement( 'div' );
inner.className = 'pBody';
inner.appendChild( toc );
box.appendChild( title );
box.appendChild( inner );
sidebar.appendChild( box );
}
if ( document.readyState === 'loading' ) {
document.addEventListener( 'DOMContentLoaded', moveTOC );
} else {
moveTOC();
}
}() );