MediaWiki:Common.js: Difference between revisions

From jugglingpatterns
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. */

// In Common.js or another script loaded by MediaWiki


// Wait for the document to be ready
// Wait for the document to be ready
Line 21: Line 19:
console.log(JSON.stringify(sw));
console.log(JSON.stringify(sw));


// ... rest of your script ...
}).catch((error) => {
}).catch((error) => {
console.error("Error loading module:", error);
console.error("Error loading module:", error);

Revision as of 16:09, 14 November 2023

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

// Wait for the document to be ready
$(function () {
    // Get the element with id 'siteswapanimation'
    var animationPlace = document.getElementById('siteswapanimation');

    // Check if the element exists
    if (animationPlace) {
        // Extract the siteswapnr value from the innerHTML of the element
        var siteswapnr = animationPlace.innerHTML.trim();

        // Perform your logic with siteswapnr
        console.log("siteswapnr " + siteswapnr);

        // The rest of your script...
        import('/js/siteswap.mjs').then(({ default: Siteswap }) => {
            var sw = new Siteswap(siteswapnr);
            console.log(JSON.stringify(sw));

        }).catch((error) => {
            console.error("Error loading module:", error);
        });
    } else {
        console.error("Element with id 'siteswapanimation' not found.");
    }
});