diff options
Diffstat (limited to 'web/http')
| -rw-r--r-- | web/http/index.html | 9 | ||||
| -rw-r--r-- | web/http/nissyapp.mjs | 26 |
2 files changed, 29 insertions, 6 deletions
diff --git a/web/http/index.html b/web/http/index.html index 47ccc0d..04ddf4c 100644 --- a/web/http/index.html +++ b/web/http/index.html | |||
| @@ -9,9 +9,12 @@ | |||
| 9 | <body> | 9 | <body> |
| 10 | <input id="scrambleText" placeholder="Type the scramble here..."> | 10 | <input id="scrambleText" placeholder="Type the scramble here..."> |
| 11 | <select id="solverSelector"> | 11 | <select id="solverSelector"> |
| 12 | <option value="h48h0k4">h48 h=0 k=4 (59Mb)</option> | 12 | <option value="h48h3k2" selected="selected"> |
| 13 | <option value="h48h3k2" selected="selected">h48 h=3 k=2 (283Mb)</option> | 13 | h48 h=4 k=2 (300 Mb) - light |
| 14 | <option value="h48h7k2">h48 h=7 k=2 (3.6Gb)</option> | 14 | </option> |
| 15 | <option value="h48h5k2" selected="selected"> | ||
| 16 | h48 h=5 k=2 (1 Gb) - fastest | ||
| 17 | </option> | ||
| 15 | </select> | 18 | </select> |
| 16 | <button id="solveButton">Solve</button> | 19 | <button id="solveButton">Solve</button> |
| 17 | <div id="confirmDownload" style="display:none"> | 20 | <div id="confirmDownload" style="display:none"> |
diff --git a/web/http/nissyapp.mjs b/web/http/nissyapp.mjs index 55ca198..1f9fa72 100644 --- a/web/http/nissyapp.mjs +++ b/web/http/nissyapp.mjs | |||
| @@ -30,8 +30,8 @@ worker.onmessage = (event) => { | |||
| 30 | function updateResults(label, results, enable) { | 30 | function updateResults(label, results, enable) { |
| 31 | resultsLabel.innerText = label; | 31 | resultsLabel.innerText = label; |
| 32 | resultsText.innerText = results; | 32 | resultsText.innerText = results; |
| 33 | solveButton.disable = !enable; | 33 | solveButton.disabled = !enable; |
| 34 | solverSelector.disable = !enable; | 34 | solverSelector.disabled = !enable; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | var logVisible = false; | 37 | var logVisible = false; |
| @@ -49,7 +49,27 @@ toggleLog.addEventListener("click", () => { | |||
| 49 | solveButton.addEventListener("click", () => { | 49 | solveButton.addEventListener("click", () => { |
| 50 | const solver = solverSelector.options[solverSelector.selectedIndex].value; | 50 | const solver = solverSelector.options[solverSelector.selectedIndex].value; |
| 51 | const scramble = scrField.value; | 51 | const scramble = scrField.value; |
| 52 | loadDataThenSolve(solver, scramble); | 52 | |
| 53 | const callbackId = ++lastCallbackId; | ||
| 54 | callbacks.set(callbackId, { | ||
| 55 | f: (callbackArg, validateResult) => { | ||
| 56 | if (validateResult) { | ||
| 57 | loadDataThenSolve(callbackArg.solver, callbackArg.scramble); | ||
| 58 | } else { | ||
| 59 | updateResults("Scramble is invalid", "", true); | ||
| 60 | } | ||
| 61 | }, | ||
| 62 | arg: { | ||
| 63 | solver: solver, | ||
| 64 | scramble: scramble | ||
| 65 | } | ||
| 66 | }); | ||
| 67 | |||
| 68 | worker.postMessage({ | ||
| 69 | command: "validate scramble", | ||
| 70 | id: lastCallbackId, | ||
| 71 | arg: scramble | ||
| 72 | }); | ||
| 53 | }); | 73 | }); |
| 54 | 74 | ||
| 55 | function loadDataThenSolve(solver, scramble) { | 75 | function loadDataThenSolve(solver, scramble) { |
