Skip to content

Commit

Permalink
[experiments/mark3] Add an amount and extra-amount parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Dec 23, 2024
1 parent ea82b60 commit 1cb3932
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/sites/experiments.cubing.net/cubing.js/mark3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ import { TwistyPlayer } from "../../../../cubing/twisty";

const currentEventID =
new URL(location.href).searchParams.get("event") ?? "333";
const numScrambles = (() => {
try {
return Number.parseInt(
new URL(location.href).searchParams.get("amount") ?? "5",
);
} catch {
console.error("Could not parse amount, defaulting to 5");
return 5;
}
})();
const numExtraScrambles = (() => {
try {
return Number.parseInt(
new URL(location.href).searchParams.get("extra-amount") ?? "2",
);
} catch {
console.error("Could not parse extra amount, defaulting to 2");
return 2;
}
})();
const eventSelect = document.querySelector("select")!;

for (const [eventID, eventInfo] of Object.entries(twizzleEvents)) {
Expand Down Expand Up @@ -66,5 +86,9 @@ function addBody(num: number, extra: boolean) {
addScramble(tbody, i, extra);
}
}
addBody(5, false);
addBody(2, true);
if (numScrambles > 0) {
addBody(numScrambles, false);
}
if (numExtraScrambles > 0) {
addBody(numExtraScrambles, true);
}

0 comments on commit 1cb3932

Please sign in to comment.