randomise cube, and separate out setup function
This commit is contained in:
parent
717bae78f5
commit
5e83230768
4 changed files with 39 additions and 27 deletions
|
@ -1,4 +1,4 @@
|
|||
function shuffle<A>(subject: A[]): A[] {
|
||||
export function shuffle<A>(subject: A[]): A[] {
|
||||
const res = Array.from(subject);
|
||||
|
||||
for (let i = 0; i < res.length - 1; ++i) {
|
||||
|
@ -38,11 +38,11 @@ function group<A>(subject: A[], keepTogether: A[][]): A[][] {
|
|||
return res;
|
||||
}
|
||||
|
||||
function groupedShuffle<A>(subject: A[], keepTogether: A[][]): A[] {
|
||||
export function groupedShuffle<A>(subject: A[], keepTogether: A[][]): A[] {
|
||||
return shuffle(group(subject, keepTogether)).flat();
|
||||
}
|
||||
|
||||
function shuffleAll() {
|
||||
export function setup() {
|
||||
const groups = [group('myno', 'abyss'), group('clip', 'cervine')];
|
||||
|
||||
for (const elem of Array.from(document.getElementsByClassName('shuffle'))) {
|
||||
|
@ -59,7 +59,3 @@ function shuffleAll() {
|
|||
return elements.every(x => x) ? elements as HTMLElement[] : [];
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', shuffleAll);
|
||||
|
||||
export {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue