MediaWiki:Common.js

From WikiMSK

Revision as of 11:03, 3 September 2020 by Jeremy (talk | contribs)

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(){

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];
	}
    
});
	
$( '.lekarska_kalkulacka').each( function() {
    var idName = $( this ).attr( 'id' );
    var scriptUrl = mw.config.get("wgServer") + mw.config.get("wgScriptPath") + '/wiki/MediaWiki:Calculator/' + idName.replace( 'lekarska_kalkulacka_', '') + '.js&action=raw&ctype=text/javascript';
    mw.loader.load( scriptUrl );
});

//docReady(formatDPLGallery);