diff --git a/index.html b/index.html
index c7c84a5..5919d4c 100644
--- a/index.html
+++ b/index.html
@@ -1333,10 +1333,13 @@
onclick: () => exportSolve({token, n, solution: s, problem, maxTime,
name: solveLabel(token, n)}),
}, "Export"));
- if (problem) {
+ // The problem may be on hand (a solve queued from this tab) or, for a
+ // solve opened via a share link, fetched from the server by token on
+ // click — the same lazy lookup exportSolve uses.
+ if (problem || token) {
actions.append(" ", el("button", {
class: "mini", type: "button",
- onclick: () => applyProblem(problem, maxTime),
+ onclick: () => loadParamsIntoForm(problem, maxTime, token),
}, "Load parameters into form"));
}
out.append(actions);
@@ -1647,8 +1650,27 @@
reader.readAsText(file);
}
+ // Backs the "Load parameters into form" button. Uses the problem we
+ // already hold for a locally-queued solve, otherwise fetches it from the
+ // server by token (a share-link viewer never had it locally).
+ async function loadParamsIntoForm(problem, maxTime, token) {
+ let prob = problem, mt = maxTime;
+ if (!prob && token) {
+ try {
+ const r = await fetch("/solve/" + encodeURIComponent(token));
+ if (r.ok) prob = (await r.json()).problem;
+ } catch (e) {/* fall through: nothing to load */}
+ }
+ if (!prob) {
+ document.getElementById("error").textContent =
+ "Could not load this solve's parameters (it may have been evicted).";
+ return;
+ }
+ applyProblem(prob, mt);
+ }
+
// Load a problem's input parameters back into the form, replacing the
- // current inputs. Backs the "Load parameters into form" button.
+ // current inputs.
function applyProblem(problem, maxTime) {
if (!problem) return;
const setVal = (id, v) => {