MediaWiki:Common.js
From WikiMSK
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
function docReady(fn) {
// see if DOM is already available
if (document.readyState === "complete" || document.readyState === "interactive") {
// call on next available tick
setTimeout(fn, 1);
} else {
document.addEventListener("DOMContentLoaded", fn);
}
}
function formatDPLGallery(){
var galleryText = document.querySelectorAll('.gallerytext');
var linkList = [];
for (i = 0; i < galleryText.length; i++) {
let pageLink = galleryText[i].innerHTML
let endLinkIndex = pageLink.indexOf("</a>")
pageLink = pageLink.slice(0,endLinkIndex);
pageLink += "</a></p>"
linkList.push(pageLink);
}
for (i = 0; i < galleryText.length; i++) {
document.querySelectorAll('.gallerytext')[i].innerHTML = linkList[i]
}
}
docReady(formatDPLGallery);