MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 96: | Line 96: | ||
); | ); | ||
}()); | }()); | ||
/* | |||
* GladiusRO Wiki | |||
* Hide technical sidebar links from visitors who are not logged in. | |||
*/ | |||
(function (mw) { | |||
'use strict'; | |||
function hidePublicSidebarLinks() { | |||
/* | |||
* wgUserName is null when the visitor is not logged in. | |||
* Logged-in administrators will continue seeing these links. | |||
*/ | |||
if (mw.config.get('wgUserName') !== null) { | |||
return; | |||
} | |||
/* | |||
* Hide Recent changes, Random page and MediaWiki Help. | |||
*/ | |||
var navigationItem* = [ | |||
'n-recentchanges', | |||
'n-randompage', | |||
'n-help' | |||
]; | |||
navigationItems.forEach(function (id) { | |||
var item = document.getElementById(id); | |||
if (item) { | |||
item.style.setProperty( | |||
'display', | |||
'none', | |||
'important' | |||
); | |||
} | |||
}); | |||
/* | |||
* Hide the complete Tools section, including: | |||
* - What links here | |||
* - Related changes | |||
* - Special pages | |||
* - Printable version | |||
* - Permanent link | |||
* - Page information | |||
*/ | |||
var toolsPanel = document.getElementById('p-tb'); | |||
if (toolsPanel) { | |||
toolsPanel.style.setProperty( | |||
'display', | |||
'none', | |||
'important' | |||
); | |||
} | |||
} | |||
/* | |||
* Run after the page structure is ready. | |||
*/ | |||
if (document.readyState === 'loading') { | |||
document.addEventListener( | |||
'DOMContentLoaded', | |||
hidePublicSidebarLinks | |||
); | |||
} else { | |||
hidePublicSidebarLinks(); | |||
} | |||
/* | |||
* Run once more after all skin components load. | |||
*/ | |||
window.addEventListener( | |||
* 'load', | |||
hidePublicSide*arLinks | |||
); | |||
}(mediaWiki)); | |||
Revision as of 03:01, 2 August 2026
/*
* GladiusRO Wiki
* Move Contents below the Tools section.
*/
(function () {
'use strict';
var attempts = 0;
var maximumAttempts = 30;
function moveGladiusTOC() {
var toc = document.getElementById('toc');
var tools = document.getElementById('p-tb');
var existingContainer =
document.getElementById('gladius-sidebar-toc');
/*
* Stop if Contents was already moved.
*/
if (existingContainer) {
return true;
}
/*
* Wait until both the article TOC
* and the Tools sidebar panel exist.
*/
if (!toc || !tools || !tools.parentNode) {
return false;
}
/*
* Create a new container.
*/
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 original TOC out of the article.
*/
tocContainer.appendChild(toc);
/*
* Insert Contents immediately after Tools.
*/
tools.insertAdjacentElement(
'afterend',
tocContainer
);
return true;
}
function retryMoveGladiusTOC() {
attempts++;
if (moveGladiusTOC()) {
return;
}
if (attempts < maximumAttempts) {
window.setTimeout(
retryMoveGladiusTOC,
200
);
}
}
/*
* Start after the complete page has loaded.
*/
if (document.readyState === 'loading') {
document.addEventListener(
'DOMContentLoaded',
retryMoveGladiusTOC
);
} else {
retryMoveGladiusTOC();
}
/*
* Try once more after all images and skin
* components have loaded.
*/
window.addEventListener(
'load',
retryMoveGladiusTOC
);
}());
/*
* GladiusRO Wiki
* Hide technical sidebar links from visitors who are not logged in.
*/
(function (mw) {
'use strict';
function hidePublicSidebarLinks() {
/*
* wgUserName is null when the visitor is not logged in.
* Logged-in administrators will continue seeing these links.
*/
if (mw.config.get('wgUserName') !== null) {
return;
}
/*
* Hide Recent changes, Random page and MediaWiki Help.
*/
var navigationItem* = [
'n-recentchanges',
'n-randompage',
'n-help'
];
navigationItems.forEach(function (id) {
var item = document.getElementById(id);
if (item) {
item.style.setProperty(
'display',
'none',
'important'
);
}
});
/*
* Hide the complete Tools section, including:
* - What links here
* - Related changes
* - Special pages
* - Printable version
* - Permanent link
* - Page information
*/
var toolsPanel = document.getElementById('p-tb');
if (toolsPanel) {
toolsPanel.style.setProperty(
'display',
'none',
'important'
);
}
}
/*
* Run after the page structure is ready.
*/
if (document.readyState === 'loading') {
document.addEventListener(
'DOMContentLoaded',
hidePublicSidebarLinks
);
} else {
hidePublicSidebarLinks();
}
/*
* Run once more after all skin components load.
*/
window.addEventListener(
* 'load',
hidePublicSide*arLinks
);
}(mediaWiki));