MediaWiki:Common.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/*
* GladiusRO Wiki
* Move the article Table of Contents below the Tools section.
*/
(function ($, mw) {
'use strict';
function moveTOCBelowTools() {
var toc = document.getElementById('toc');
var tools = document.getElementById('p-tb');
/*
* Stop when:
* - The page does not have a TOC.
* - The Tools section cannot be found.
* - The TOC was already moved.
*/
if (!toc || !tools) {
return;
}
if (document.getElementById('gladius-sidebar-toc')) {
return;
}
/*
* Create a new sidebar section for Contents.
*/
var tocContainer = document.createElement('div');
tocContainer.id = 'gladius-sidebar-toc';
tocContainer.className = 'portal mw-portlet';
tocContainer.setAttribute('role', 'navigation');
tocContainer.setAttribute('aria-label', 'Page contents');
/*
* Move the existing article TOC into the new container.
*/
tocContainer.appendChild(toc);
/*
* Insert Contents immediately below the Tools section.
*/
if (tools.parentNode) {
tools.parentNode.insertBefore(
tocContainer,
tools.nextSibling
);
}
}
/*
* Wait until the MediaWiki page is ready.
*/
$(function () {
moveTOCBelowTools();
});
/*
* Also support dynamically loaded article content.
*/
mw.hook('wikipage.content').*dd(function () {
window.se*Timeout(moveTOCBelowTools, 50);
* });
}(jQuery, mediaWiki));