MediaWiki:Common.js: Difference between revisions

From Good Creations! MC Wiki
Jump to navigation Jump to search
Created page with "Any JavaScript here will be loaded for all users on every page load.: mw.loader.using("mediawiki.util").then(function () { function loadIFrame(button) { var container = button.nextElementSibling; // Gets the next div var url = button.getAttribute("data-url"); // Gets the iframe URL // Hide button button.style.display = "none"; // Insert iframe dynamically container.innerHTML = '<iframe src="' + url + '" height="3..."
 
Tag: Replaced
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. */
mw.loader.using("mediawiki.util").then(function () {
    function loadIFrame(button) {
        var container = button.nextElementSibling; // Gets the next div
        var url = button.getAttribute("data-url"); // Gets the iframe URL
        // Hide button
        button.style.display = "none";
        // Insert iframe dynamically
        container.innerHTML = '<iframe src="' + url + '" height="300" width="100%" style="border: none;"></iframe>';
        container.style.display = "block";
    }
    // Attach event listener to all buttons with class "tap-to-load"
    document.addEventListener("click", function (event) {
        if (event.target.matches(".tap-to-load")) {
            loadIFrame(event.target);
        }
    });
});

Revision as of 09:23, 15 February 2025

/* Any JavaScript here will be loaded for all users on every page load. */