diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-05-26 17:05:36 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-05-26 17:05:36 +0200 |
| commit | fa0fa1fcb494483020a736a2bc2c5c639a2bd870 (patch) | |
| tree | 909db148c91e9d9650b2f5d8eb1dee04ea8cae1b /web/http | |
| parent | 87852933851674cacbc8b2295d046831db27ab81 (diff) | |
| download | nissy-core-fa0fa1fcb494483020a736a2bc2c5c639a2bd870.tar.gz nissy-core-fa0fa1fcb494483020a736a2bc2c5c639a2bd870.zip | |
Progress with web version
Diffstat (limited to 'web/http')
| l--------- | web/http/tables | 1 | ||||
| -rw-r--r-- | web/http/worker.mjs | 30 |
2 files changed, 21 insertions, 10 deletions
diff --git a/web/http/tables b/web/http/tables new file mode 120000 index 0000000..b3afcac --- /dev/null +++ b/web/http/tables | |||
| @@ -0,0 +1 @@ | |||
| ../../tables/ \ No newline at end of file | |||
diff --git a/web/http/worker.mjs b/web/http/worker.mjs index 831ef09..7ce1070 100644 --- a/web/http/worker.mjs +++ b/web/http/worker.mjs | |||
| @@ -4,14 +4,24 @@ const nissy = await Nissy(); | |||
| 4 | nissy.setLogger(nissy._addCallbackFunction(console.log)); | 4 | nissy.setLogger(nissy._addCallbackFunction(console.log)); |
| 5 | 5 | ||
| 6 | onmessage = (e) => { | 6 | onmessage = (e) => { |
| 7 | var cube = new nissy.Cube(); | 7 | //TODO: try to load from storage first, then download |
| 8 | cube.move(e.data.scramble); | 8 | nissy.initSolverDownload(e.data.solver, "/tables").then( |
| 9 | nissy.solve(e.data.solver, cube, nissy.NissFlag.normal, 0, 17, 1, 99, 4, -1) | 9 | (download_result) => { |
| 10 | .then((solve_result) => { | 10 | if (!download_result) { |
| 11 | if (!solve_result.err.ok()) | 11 | postMessage("Error retrieving the solver data"); |
| 12 | posMessage("Error while solving (solve returned " + | 12 | } else { |
| 13 | solve_result.err.value + ")"); | 13 | var cube = new nissy.Cube(); |
| 14 | else | 14 | cube.move(e.data.scramble); |
| 15 | postMessage(solve_result.solutions) | 15 | |
| 16 | }); | 16 | nissy.solve(e.data.solver, cube, nissy.NissFlag.normal, |
| 17 | 0, 17, 1, 99, 4, -1).then( | ||
| 18 | (solve_result) => { | ||
| 19 | if (!solve_result.err.ok()) | ||
| 20 | postMessage("Error while solving (solve returned " + | ||
| 21 | solve_result.err.value + ")"); | ||
| 22 | else | ||
| 23 | postMessage(solve_result.solutions) | ||
| 24 | }); | ||
| 25 | } | ||
| 26 | }); | ||
| 17 | }; | 27 | }; |
