MediaWiki:Common.js: Difference between revisions

From jugglingpatterns
Content deleted Content added
No edit summary
Tag: Reverted
No edit summary
 
(38 intermediate revisions by the same user not shown)
Line 1: Line 1:
function loadModule(src) {
/* Any JavaScript here will be loaded for all users on every page load. */
const s = document.createElement('script');
s.type = 'module';
s.src = src;
document.head.appendChild(s);
}


// deine beiden Dateien laden
<div class="horizontal-split">
loadModule('/js/animation.js');
<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';


// use by using Template:AnimateSiteswap which provides the matching html
// Get the siteswapnr from the data attribute of the element
console.log("importing animations");
const animationPlace = document.getElementById('siteswapanimation');
const siteswapnr = animationPlace.dataset.siteswapnr;


if (mw.config.get('wgNamespaceNumber') == 6 && mw.config.get('wgAction') == 'view') {
// Use siteswapnr to create the Siteswap object
mw.loader.load('//imagemapedit.toolforge.org/ime.js');
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 15:28, 9 January 2026

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

if (mw.config.get('wgNamespaceNumber') == 6 && mw.config.get('wgAction') == 'view') {
    mw.loader.load('//imagemapedit.toolforge.org/ime.js');
}