MediaWiki:Common.js
From Eli's Software Encyclopedia
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.
/* Any JavaScript here will be loaded for all users on every page load. */
moveRefs();
function moveRefs() {
var sectionIds = ["References", "Links"];
for (var i = 0; i < sectionIds.length; i++) {
var id = sectionIds[i];
var headline = document.querySelector('h2 > span.mw-headline#' + id);
if (!headline) continue;
var sectionH2 = headline.closest("h2");
// Create wrapper section
var wrapper = document.createElement("section");
wrapper.className = "section-" + id.toLowerCase();
var current = sectionH2;
while (current) {
var next = current.nextSibling;
// Stop if we hit another h2 or a div (but skip the first h2)
if (current !== sectionH2 && current.nodeType === 1 &&
(current.tagName.toLowerCase() === "h2" || current.tagName.toLowerCase() === "div")) {
break;
}
wrapper.appendChild(current);
current = next;
}
// Insert before #catlinks
var catlinks = document.getElementById("catlinks");
if (catlinks && catlinks.parentNode) {
catlinks.parentNode.insertBefore(wrapper, catlinks);
}
moveCiteReferences();
}
}
function moveCiteReferences(){
const references = document.querySelector('.mw-references-wrap');
const footer = document.querySelector('.section-links');
if (references && footer) {
footer.append(references);
}
}
