MediaWiki:Common.js: Difference between revisions
From WikiMSK
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
function docReady(fn) { | //function docReady(fn) { | ||
// see if DOM is already available | // 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(){ | //function formatDPLGallery(){ |
Revision as of 19:09, 29 August 2020
/* 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(){
mw.hook('wikipage.content').add(function hook_handler() {
var galleryText = document.querySelectorAll('.gallerytext');
var linkList = [];
for (i = 0; i < galleryText.length; i++) {
var pageLink = galleryText[i].innerHTML;
var 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);