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. */ |
|||
⚫ | |||
⚫ | |||
// Wait for the document to be ready |
|||
⚫ | |||
⚫ | |||
⚫ | |||
// 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 }) => { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} 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); });