MediaWiki:Common.js: Difference between revisions

From jugglingpatterns
No edit summary
Tag: Reverted
No edit summary
 
(25 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");
<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 {}; });

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