MediaWiki:Common.js: Difference between revisions

From jugglingpatterns
No edit summary
No edit summary
Line 1: Line 1:
mw.loader.load('/load.php?modules=&only=scripts&target=js/siteswap.mjs')
/* Any JavaScript here will be loaded for all users on every page load. */
.then(function () {

var sw = new Siteswap("531");
// Wait for the document to be ready
console.log(JSON.stringify(sw));
$(function () {
})
// Get the element with id 'siteswapanimation'
.catch(function (error) {
var animationPlace = document.getElementById('siteswapanimation');
console.error("Error loading script:", error);

});
// 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.");
}
});

Revision as of 09:51, 15 November 2023

mw.loader.load('/load.php?modules=&only=scripts&target=js/siteswap.mjs')
    .then(function () {
        var sw = new Siteswap("531");
        console.log(JSON.stringify(sw));
    })
    .catch(function (error) {
        console.error("Error loading script:", error);
    });