MediaWiki:Common.js: Difference between revisions

From jugglingpatterns
No edit summary
No edit summary
Tag: Reverted
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */


<div class="horizontal-split">
$(function () {
<div id="siteswapanimation" data-siteswapnr="your_siteswap_value_here"></div>
var animationPlace = document.getElementById('siteswapanimation');
</div>
siteswap=animationPlace.innerHTML;
<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 {}; });

Revision as of 16:03, 14 November 2023

/* 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 {}; });