PageSourceSearch

https://irisxu02.github.io/rubik/modules/solutionService.js

js irisxu02.github.io collected 2026-10-03 09:21:19 UTC 917 bytes, 25 lines download raw bytes

1import { isAutoSolveMode, setAutoSolve, resetMode } from './modes.js';
2import { makeAutoMove } from './action_utils.js';
3import { getSolution } from './api.js';
4
5export async function handleSolve() {
6    if (isAutoSolveMode()) return;
7    setAutoSolve(true);
8    const display = document.getElementById("solution-display");
9    display.textContent = "Solving…";
10    try {
11        const data = await getSolution();
12        if (typeof data?.solutionString !== "string" || !Array.isArray(data.parsedMoves)) {
13            throw new Error("The solver returned an invalid response.");
14        }
15        display.textContent = data.solutionString || "Already solved.";
16        for (const move of data.parsedMoves.flat()) {
17            await makeAutoMove(move, true);
18        }
19    } catch (error) {
20        display.textContent = error.message;
21    } finally {
22        resetMode();
23    }
24}
25window.handleSolve = handleSolve;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.