MediaWiki:Common.js
From jugglingpatterns
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
<div class="horizontal-split">
<div id="siteswapanimation" data-siteswapnr="your_siteswap_value_here"></div>
</div>
<script type="module">
import Siteswap from '/js/siteswap.mjs';
import AnimationWidget from '/js/animation-widget-standalone.mjs';
// Get the siteswapnr from the data attribute of the element
const animationPlace = document.getElementById('siteswapanimation');
const siteswapnr = animationPlace.dataset.siteswapnr;
// Use siteswapnr to create the Siteswap object
const sw = new Siteswap(siteswapnr);
// Your other logic for creating jif and AnimationWidget
console.log(JSON.stringify(sw));
const myjson = { jugglers: 2, limbs: "ABCD" };
myjson.props = Array.apply(null, Array(sw.nProps)).map(function () { return {}; });