atagen

jelq

public

an http based roguelike rpg about jelqing

Star0
Watch0

Commit 4b690ff501b8

tarball

atagen <boss@atagen.co>2026-10-10 15:15 UTC

1 file changed+13-5
ui: only show request fields the current turn can use

Authorization sat on screen for the whole game though it only matters when Mum, housekeeping or the clinic asks for it, which taught players to ignore it right when it counts.
Modified file: src/ui.html+13 additions−5 deletions
@@ -85,16 +85,14 @@ const FIELDS = {
8585 const BY_TARGET = {
8686 "runs POST": ["seed"],
8787 "run JELQ": ["technique", "also", "intensity", "lube"],
88- "run GET": ["accept"],
8988 "run PATCH": ["patch"],
9089 "length GET": ["range"],
9190 "length HEAD": ["range"],
9291 "foreskin DELETE": ["ifMatch"],
9392 "elder GET": ["proxy", "ifModifiedSince"],
9493 "grip GET": ["upgrade"],
95- "diagnosis GET": ["ifNoneMatch"],
94+ "diagnosis GET": ["authorization", "ifNoneMatch"],
9695 };
97-const ALWAYS = ["authorization", "extra"];
9896 const GLOBALS = [
9997 { key: "runs", name: "start a new run", path: "/runs", methods: ["POST"] },
10098 { key: "global", name: "leaderboard", path: "/leaderboard", methods: ["GET", "HEAD", "OPTIONS"] },
@@ -105,6 +103,7 @@ const GLOBALS = [
105103 let run = null;
106104 let linked = [];
107105 let offered = [];
106+let challenged = false;
108107 let target = "/runs";
109108 let method = "POST";
110109 const values = {};
@@ -190,8 +189,11 @@ function renderMethods() {
190189 }
191190
192191 function fieldNames() {
193- const key = current().key + " " + method;
194- return (BY_TARGET[key] || []).concat(ALWAYS);
192+ const t = current();
193+ const names = BY_TARGET[t.key + " " + method] || [];
194+ const scoped = run && !["runs", "global"].includes(t.key);
195+ const asked = challenged && scoped && !names.includes("authorization");
196+ return (asked ? ["authorization"] : []).concat(names);
195197 }
196198
197199 function renderFields() {
@@ -211,6 +213,10 @@ function renderFields() {
211213 input.oninput = input.onchange = () => { values[name] = input.value; };
212214 table.append(el("tr", {}, el("td", { align: "right", valign: "top", textContent: f.label }), el("td", {}, input)));
213215 }
216+ const extra = el("textarea", { rows: 3, cols: 40, value: fieldValue("extra"), placeholder: FIELDS.extra.placeholder });
217+ extra.oninput = () => { values.extra = extra.value; };
218+ const more = el("details", { open: Boolean(values.extra) }, el("summary", { textContent: "more headers" }), extra);
219+ table.append(el("tr", {}, el("td"), el("td", {}, more)));
214220 $("send").value = method + " " + short(current().path);
215221 }
216222
@@ -281,6 +287,7 @@ function absorb(r, sentMethod, sentPath) {
281287 if ("x-eq" in headers) {
282288 renderStats(headers);
283289 renderAlerts(r.headers);
290+ challenged = r.status === 401 || "via" in headers;
284291 }
285292 if (headers.link) linked = parseLinks(headers.link);
286293 offered = body ? hrefs(body, []) : [];
@@ -291,6 +298,7 @@ function absorb(r, sentMethod, sentPath) {
291298 if (run && (abandoned || DEATHS.includes(problem))) {
292299 log("--- the run has ended ---");
293300 renderAlerts(null);
301+ challenged = false;
294302 run = null;
295303 linked = [];
296304 }