From jugglingpatterns
Content deleted Content added
No edit summary |
No edit summary |
||
| (34 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| ⚫ | |||
/* Any JavaScript here will be loaded for all users on every page load. */ |
|||
const s = document.createElement('script'); |
|||
s.type = 'module'; |
|||
| ⚫ | |||
document.head.appendChild(s); |
|||
} |
|||
// deine beiden Dateien laden |
|||
// Wait for the document to be ready |
|||
loadModule('/js/animation.js'); |
|||
| ⚫ | |||
// Get the element with id 'siteswapanimation' |
|||
var animationPlace = document.getElementById('siteswapanimation'); |
|||
// use by using Template:AnimateSiteswap which provides the matching html |
|||
// Check if the element exists |
|||
console.log("importing animations"); |
|||
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."); |
|||
} |
|||
}); |
|||
Latest revision as of 19:20, 8 September 2025
function loadModule(src) {
const s = document.createElement('script');
s.type = 'module';
s.src = src;
document.head.appendChild(s);
}
// deine beiden Dateien laden
loadModule('/js/animation.js');
// use by using Template:AnimateSiteswap which provides the matching html
console.log("importing animations");