Special:Badtitle/NS274:Divination

Shuffle  ( => { 'use strict';

const source = { async prng(lo, hi) { return (Math.rand*(hi - lo) + lo)|0; } }["${source}"];

const slots=Array.of( document.querySelectorAll("[data-divination-id='{$id}']") ).map(v => { return {  link: v.querySelector("a"),  img: v.querySelector("img") }});

async function shuffle(deck) { let cards = []; for(let i = 0; i < slots.length; ++i) { cards.push(deck[await source(0, i)]); }

return cards; }

function setCard(slot, card) { slot.link.href= card.link; slot.img.src = card.img; }

document.getElementById("{$id}-button").addEventListener("click", async => {  let cards = await shuffle(deck);  for(let i = 0; i < slots.length; ++i) {    setCard(slots[i], cards[i]);  } }); });