MediaWiki:Common.js: Difference between revisions

From jugglingpatterns
No edit summary
No edit summary
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
// use by using Template:AnimateSiteswap which provides the matching html
/* Any JavaScript here will be loaded for all users on every page load. */
import("/js/animation.js");

import("/js/mydarkreader.js");
// In Common.js or another script loaded by MediaWiki

// 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));

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

Latest revision as of 14:03, 16 November 2023

// use by using Template:AnimateSiteswap which provides the matching html
import("/js/animation.js");
import("/js/mydarkreader.js");