atagen

jelq

public

an http based roguelike rpg about jelqing

Star0
Watch0
08ffcd6cbba5702c7a8c5fed1f54f9d3e2f51c8b
1
ssh://brewery@pls.lobotomise.me:33/atagen/jelq.git

Blame: src/ui.html

99524cf9f17catagen2026-10-10 10:53 UTC1
<!DOCTYPE html>
99524cf9f17catagen2026-10-10 10:53 UTC2
<html>
99524cf9f17catagen2026-10-10 10:53 UTC3
<head>
99524cf9f17catagen2026-10-10 10:53 UTC4
<meta charset="utf-8">
99524cf9f17catagen2026-10-10 10:53 UTC5
<title>jelqd</title>
185851447cebatagen2026-10-10 12:58 UTC6
<style>
185851447cebatagen2026-10-10 12:58 UTC7
.frame { border: 2px inset; background: #fff; height: 85vh; overflow: scroll; padding: 4px; }
185851447cebatagen2026-10-10 12:58 UTC8
#log { white-space: pre-wrap; margin: 0; }
185851447cebatagen2026-10-10 12:58 UTC9
pre, li, p, td, label { overflow-wrap: anywhere; }
185851447cebatagen2026-10-10 12:58 UTC10
</style>
99524cf9f17catagen2026-10-10 10:53 UTC11
</head>
99524cf9f17catagen2026-10-10 10:53 UTC12
<body>
99524cf9f17catagen2026-10-10 10:53 UTC13
185851447cebatagen2026-10-10 12:58 UTC14
<h1>jelqd</h1>
a8269407e054atagen2026-10-13 12:44 UTC15
<p>A roguelike played over HTTP.</p>
a8269407e054atagen2026-10-13 12:44 UTC16
<p>Pick a resource, pick a method, send it.<br>The log on the right is everything the server has said to you.</p>
a8269407e054atagen2026-10-13 12:44 UTC17
<p>Language <select id="locale"><option>en-GB</option><option>en-US</option><option>en-AU</option></select></p>
185851447cebatagen2026-10-10 12:58 UTC18
185851447cebatagen2026-10-10 12:58 UTC19
<table width="100%" cellspacing="6">
185851447cebatagen2026-10-10 12:58 UTC20
<tr>
185851447cebatagen2026-10-10 12:58 UTC21
<td width="45%" valign="top">
185851447cebatagen2026-10-10 12:58 UTC22
<div class="frame">
185851447cebatagen2026-10-10 12:58 UTC23
431c1bc8ded1atagen2026-10-10 13:20 UTC24
<div id="alerts"></div>
431c1bc8ded1atagen2026-10-10 13:20 UTC25
185851447cebatagen2026-10-10 12:58 UTC26
<form id="form">
185851447cebatagen2026-10-10 12:58 UTC27
<h3>Method</h3>
185851447cebatagen2026-10-10 12:58 UTC28
<div id="methods"></div>
f16ab17c8ff6atagen2026-10-13 11:14 UTC29
<datalist id="excuses"></datalist>
185851447cebatagen2026-10-10 12:58 UTC30
185851447cebatagen2026-10-10 12:58 UTC31
<h3>Request</h3>
185851447cebatagen2026-10-10 12:58 UTC32
<table id="fields" cellpadding="2"></table>
185851447cebatagen2026-10-10 12:58 UTC33
185851447cebatagen2026-10-10 12:58 UTC34
<p><input type="submit" id="send" value="Send" style="font-size: 1.3em"></p>
185851447cebatagen2026-10-10 12:58 UTC35
185851447cebatagen2026-10-10 12:58 UTC36
<h3>Stats</h3>
185851447cebatagen2026-10-10 12:58 UTC37
<table id="stats" border="1" cellspacing="0" cellpadding="3"></table>
185851447cebatagen2026-10-10 12:58 UTC38
185851447cebatagen2026-10-10 12:58 UTC39
<h3>Resource</h3>
185851447cebatagen2026-10-10 12:58 UTC40
<div id="targets"></div>
185851447cebatagen2026-10-10 12:58 UTC41
</form>
185851447cebatagen2026-10-10 12:58 UTC42
185851447cebatagen2026-10-10 12:58 UTC43
<p><small>Every request goes through <code>/ui/send</code>, which replays it inside the server, so the page can show redirects and send methods and headers that browsers refuse.</small></p>
185851447cebatagen2026-10-10 12:58 UTC44
</div>
185851447cebatagen2026-10-10 12:58 UTC45
</td>
185851447cebatagen2026-10-10 12:58 UTC46
<td valign="top">
185851447cebatagen2026-10-10 12:58 UTC47
<div class="frame" id="frame"><pre id="log"></pre></div>
185851447cebatagen2026-10-10 12:58 UTC48
</td>
185851447cebatagen2026-10-10 12:58 UTC49
</tr>
185851447cebatagen2026-10-10 12:58 UTC50
</table>
99524cf9f17catagen2026-10-10 10:53 UTC51
99524cf9f17catagen2026-10-10 10:53 UTC52
<script>
185851447cebatagen2026-10-10 12:58 UTC53
const REL = "https://jelq.dev/rels/";
6619c458c23eatagen2026-10-14 08:08 UTC54
const METHODS = ["JELQ", "HOLD", "GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS", "TRACE"];
0a0bfee8329eatagen2026-10-11 05:11 UTC55
const ALL_LUBES = ["", "application/baby-oil", "application/coconut-oil", "application/lotion", "application/vaseline", "text/plain; charset=spit", "image/jpeg"];
e028a4184d00atagen2026-10-14 10:49 UTC56
const DEATHS = ["ruptured", "caught", "opened", "banned", "degloved", "zip", "watermelon", "overstayed", "run-ended"];
0a0bfee8329eatagen2026-10-11 05:11 UTC57
let stocked = null;
f16ab17c8ff6atagen2026-10-13 11:14 UTC58
let excuses = [];
f16ab17c8ff6atagen2026-10-13 11:14 UTC59
let nonce = null;
14de3e1e8dc2atagen2026-10-11 06:19 UTC60
let inventorySeq = 0;
185851447cebatagen2026-10-10 12:58 UTC61
const STATS = [
185851447cebatagen2026-10-10 12:58 UTC62
  ["x-floor", "Floor"],
185851447cebatagen2026-10-10 12:58 UTC63
  ["x-self-reported-length", "Self-reported length"],
185851447cebatagen2026-10-10 12:58 UTC64
  ["x-girth", "Girth"],
185851447cebatagen2026-10-10 12:58 UTC65
  ["x-foreskin", "Foreskin"],
5dfebcc0ac43atagen2026-10-11 05:28 UTC66
  ["x-friction", "Friction"],
e028a4184d00atagen2026-10-14 10:49 UTC67
  ["x-eq", "EQ"],
185851447cebatagen2026-10-10 12:58 UTC68
  ["x-stamina", "Stamina"],
185851447cebatagen2026-10-10 12:58 UTC69
  ["x-suspicion", "Suspicion"],
185851447cebatagen2026-10-10 12:58 UTC70
  ["x-shame", "Shame"],
185851447cebatagen2026-10-10 12:58 UTC71
  ["x-cash", "Cash"],
185851447cebatagen2026-10-10 12:58 UTC72
];
f39b10e20a0batagen2026-10-10 14:33 UTC73
const MEASURED = ["x-length", "Length"];
ddcf8b3a91dcatagen2026-10-14 11:03 UTC74
const GROWTH = new Set(["x-length", "x-self-reported-length", "x-girth", "x-foreskin"]);
08ffcd6cbba5atagen2026-10-14 11:19 UTC75
const BETTER = { "x-length": 1, "x-self-reported-length": 1, "x-girth": 1, "x-foreskin": 1, "x-friction": -1, "x-stamina": 1, "x-suspicion": -1, "x-shame": -1, "x-cash": 1, "x-floor": 1 };
ddcf8b3a91dcatagen2026-10-14 11:03 UTC76
let lastStats = {};
f39b10e20a0batagen2026-10-10 14:33 UTC77
const QUIET = new Set(["link", "set-cookie", "server", "x-powered-by", "cache-control", "content-length", "content-type", "date"].concat(STATS.map(s => s[0]), MEASURED[0]));
99524cf9f17catagen2026-10-10 10:53 UTC78
185851447cebatagen2026-10-10 12:58 UTC79
const FIELDS = {
185851447cebatagen2026-10-10 12:58 UTC80
  seed: { label: "seed (unranked)", kind: "text" },
58e1fb3943e6atagen2026-10-10 13:30 UTC81
  technique: { label: "technique", kind: "select" },
58e1fb3943e6atagen2026-10-10 13:30 UTC82
  also: { label: "combo with", kind: "select" },
185851447cebatagen2026-10-10 12:58 UTC83
  intensity: { label: "intensity, 1 to 10", kind: "number", value: "5" },
58e1fb3943e6atagen2026-10-10 13:30 UTC84
  lube: { label: "Content-Type", header: "Content-Type", kind: "select" },
185851447cebatagen2026-10-10 12:58 UTC85
  range: { label: "Range", header: "Range", kind: "text", placeholder: "inches=0-2" },
185851447cebatagen2026-10-10 12:58 UTC86
  ifMatch: { label: "If-Match", header: "If-Match", kind: "text" },
185851447cebatagen2026-10-10 12:58 UTC87
  ifNoneMatch: { label: "If-None-Match", header: "If-None-Match", kind: "text" },
185851447cebatagen2026-10-10 12:58 UTC88
  ifModifiedSince: { label: "If-Modified-Since", header: "If-Modified-Since", kind: "text", placeholder: "an HTTP-date" },
185851447cebatagen2026-10-10 12:58 UTC89
  proxy: { label: "Proxy-Authorization", header: "Proxy-Authorization", kind: "text", placeholder: "Ruler 5.4" },
185851447cebatagen2026-10-10 12:58 UTC90
  upgrade: { label: "Upgrade", header: "Upgrade", kind: "select", options: ["", "underhand", "overhand"] },
185851447cebatagen2026-10-10 12:58 UTC91
  authorization: { label: "Authorization", header: "Authorization", kind: "text", placeholder: 'Excuse "homework"' },
185851447cebatagen2026-10-10 12:58 UTC92
  extra: { label: "other headers, one per line", kind: "textarea", placeholder: "Expect: gains" },
185851447cebatagen2026-10-10 12:58 UTC93
};
185851447cebatagen2026-10-10 12:58 UTC94
const BY_TARGET = {
185851447cebatagen2026-10-10 12:58 UTC95
  "runs POST": ["seed"],
185851447cebatagen2026-10-10 12:58 UTC96
  "length GET": ["range"],
185851447cebatagen2026-10-10 12:58 UTC97
  "length HEAD": ["range"],
185851447cebatagen2026-10-10 12:58 UTC98
  "foreskin DELETE": ["ifMatch"],
185851447cebatagen2026-10-10 12:58 UTC99
  "elder GET": ["proxy", "ifModifiedSince"],
185851447cebatagen2026-10-10 12:58 UTC100
  "grip GET": ["upgrade"],
4b690ff501b8atagen2026-10-10 13:27 UTC101
  "diagnosis GET": ["authorization", "ifNoneMatch"],
185851447cebatagen2026-10-10 12:58 UTC102
};
d604371299fbatagen2026-10-10 13:54 UTC103
const GROUPS = [
d604371299fbatagen2026-10-10 13:54 UTC104
  ["play", "Play"],
7d3fb63208bfatagen2026-10-11 04:38 UTC105
  ["shop", "Shop"],
d604371299fbatagen2026-10-10 13:54 UTC106
  ["you", "You"],
d604371299fbatagen2026-10-10 13:54 UTC107
  ["said", "From the last response"],
d604371299fbatagen2026-10-10 13:54 UTC108
  ["reading", "Reading"],
d604371299fbatagen2026-10-10 13:54 UTC109
  ["meta", "Meta"],
d604371299fbatagen2026-10-10 13:54 UTC110
];
7d3fb63208bfatagen2026-10-11 04:38 UTC111
const GROUP_OF = { run: "play", floor: "play", drawer: "play", shop: "play", "shop-item": "shop", kitchen: "play", portal: "play", elder: "play", diagnosis: "play", length: "you", foreskin: "you", grip: "you", inventory: "you", footage: "you", techniques: "reading", thread: "reading" };
d604371299fbatagen2026-10-10 13:54 UTC112
const NAMES = { run: "the run", thread: "the 2009 forum thread" };
185851447cebatagen2026-10-10 12:58 UTC113
const GLOBALS = [
d604371299fbatagen2026-10-10 13:54 UTC114
  { key: "runs", group: "play", name: "start a new run", path: "/runs", methods: ["POST"] },
d604371299fbatagen2026-10-10 13:54 UTC115
  { key: "global", group: "meta", name: "leaderboard", path: "/leaderboard", methods: ["GET", "HEAD", "OPTIONS"] },
d604371299fbatagen2026-10-10 13:54 UTC116
  { key: "global", group: "meta", name: "graveyard", path: "/graveyard", methods: ["GET", "HEAD", "OPTIONS"] },
185851447cebatagen2026-10-10 12:58 UTC117
];
185851447cebatagen2026-10-10 12:58 UTC118
185851447cebatagen2026-10-10 12:58 UTC119
let run = null;
185851447cebatagen2026-10-10 12:58 UTC120
let linked = [];
58e1fb3943e6atagen2026-10-10 13:30 UTC121
let techniques = [];
185851447cebatagen2026-10-10 12:58 UTC122
let offered = [];
4b690ff501b8atagen2026-10-10 13:27 UTC123
let challenged = false;
ec6fd4bb5b60atagen2026-10-11 04:34 UTC124
const etags = {};
185851447cebatagen2026-10-10 12:58 UTC125
let target = "/runs";
185851447cebatagen2026-10-10 12:58 UTC126
let method = "POST";
185851447cebatagen2026-10-10 12:58 UTC127
const values = {};
185851447cebatagen2026-10-10 12:58 UTC128
185851447cebatagen2026-10-10 12:58 UTC129
const $ = id => document.getElementById(id);
185851447cebatagen2026-10-10 12:58 UTC130
185851447cebatagen2026-10-10 12:58 UTC131
function short(path) {
185851447cebatagen2026-10-10 12:58 UTC132
  return path.replace(/[0-9a-f]{32}/, id => id.slice(0, 6) + "…");
99524cf9f17catagen2026-10-10 10:53 UTC133
}
99524cf9f17catagen2026-10-10 10:53 UTC134
185851447cebatagen2026-10-10 12:58 UTC135
function el(tag, props, ...children) {
185851447cebatagen2026-10-10 12:58 UTC136
  const node = Object.assign(document.createElement(tag), props || {});
185851447cebatagen2026-10-10 12:58 UTC137
  for (const child of children) node.append(child);
185851447cebatagen2026-10-10 12:58 UTC138
  return node;
99524cf9f17catagen2026-10-10 10:53 UTC139
}
99524cf9f17catagen2026-10-10 10:53 UTC140
58e1fb3943e6atagen2026-10-10 13:30 UTC141
function titled(text) {
58e1fb3943e6atagen2026-10-10 13:30 UTC142
  return text.charAt(0).toUpperCase() + text.slice(1);
58e1fb3943e6atagen2026-10-10 13:30 UTC143
}
58e1fb3943e6atagen2026-10-10 13:30 UTC144
58e1fb3943e6atagen2026-10-10 13:30 UTC145
function technique(name) {
58e1fb3943e6atagen2026-10-10 13:30 UTC146
  return techniques.find(t => t.name === name);
58e1fb3943e6atagen2026-10-10 13:30 UTC147
}
58e1fb3943e6atagen2026-10-10 13:30 UTC148
58e1fb3943e6atagen2026-10-10 13:30 UTC149
function clashes(a, b) {
58e1fb3943e6atagen2026-10-10 13:30 UTC150
  const rules = [a.lubricant, b.lubricant];
58e1fb3943e6atagen2026-10-10 13:30 UTC151
  return rules.includes("required") && rules.includes("forbidden");
58e1fb3943e6atagen2026-10-10 13:30 UTC152
}
58e1fb3943e6atagen2026-10-10 13:30 UTC153
58e1fb3943e6atagen2026-10-10 13:30 UTC154
// The options a field can take right now, or null for free text.
58e1fb3943e6atagen2026-10-10 13:30 UTC155
function options(name) {
58e1fb3943e6atagen2026-10-10 13:30 UTC156
  if (name === "technique") return techniques.map(t => t.name);
58e1fb3943e6atagen2026-10-10 13:30 UTC157
  if (name === "also") {
58e1fb3943e6atagen2026-10-10 13:30 UTC158
    const first = technique(fieldValue("technique"));
e028a4184d00atagen2026-10-14 10:49 UTC159
    if (!first || !first.intensity) return [""];
e028a4184d00atagen2026-10-14 10:49 UTC160
    const partners = techniques.filter(t => t.intensity && t.name !== first.name && !clashes(first, t));
58e1fb3943e6atagen2026-10-10 13:30 UTC161
    return [""].concat(partners.map(t => t.name));
58e1fb3943e6atagen2026-10-10 13:30 UTC162
  }
0a0bfee8329eatagen2026-10-11 05:11 UTC163
  if (name === "lube") {
0a0bfee8329eatagen2026-10-11 05:11 UTC164
    const lubes = stocked === null ? ALL_LUBES : ALL_LUBES.filter(l => l === "" || l.includes("/") && !l.startsWith("application/") || stocked.includes(l.replace("application/", "")));
0a0bfee8329eatagen2026-10-11 05:11 UTC165
    return lubeRule() === "required" ? lubes.filter(Boolean) : lubes;
0a0bfee8329eatagen2026-10-11 05:11 UTC166
  }
58e1fb3943e6atagen2026-10-10 13:30 UTC167
  return FIELDS[name].options || null;
58e1fb3943e6atagen2026-10-10 13:30 UTC168
}
58e1fb3943e6atagen2026-10-10 13:30 UTC169
58e1fb3943e6atagen2026-10-10 13:30 UTC170
function raw(name) {
58e1fb3943e6atagen2026-10-10 13:30 UTC171
  return values[name] ?? FIELDS[name].value ?? "";
58e1fb3943e6atagen2026-10-10 13:30 UTC172
}
58e1fb3943e6atagen2026-10-10 13:30 UTC173
58e1fb3943e6atagen2026-10-10 13:30 UTC174
function fieldValue(name) {
58e1fb3943e6atagen2026-10-10 13:30 UTC175
  const allowed = options(name);
58e1fb3943e6atagen2026-10-10 13:30 UTC176
  const value = raw(name);
58e1fb3943e6atagen2026-10-10 13:30 UTC177
  if (allowed && !allowed.includes(value)) return allowed[0] ?? "";
58e1fb3943e6atagen2026-10-10 13:30 UTC178
  return value;
58e1fb3943e6atagen2026-10-10 13:30 UTC179
}
58e1fb3943e6atagen2026-10-10 13:30 UTC180
58e1fb3943e6atagen2026-10-10 13:30 UTC181
function lubeRule() {
58e1fb3943e6atagen2026-10-10 13:30 UTC182
  const picked = [technique(fieldValue("technique")), technique(fieldValue("also"))].filter(Boolean);
ec6fd4bb5b60atagen2026-10-11 04:34 UTC183
  if (!picked.some(t => t.lubricant)) return "none";
58e1fb3943e6atagen2026-10-10 13:30 UTC184
  for (const rule of ["forbidden", "required"]) {
58e1fb3943e6atagen2026-10-10 13:30 UTC185
    if (picked.some(t => t.lubricant === rule)) return rule;
58e1fb3943e6atagen2026-10-10 13:30 UTC186
  }
58e1fb3943e6atagen2026-10-10 13:30 UTC187
  return "optional";
58e1fb3943e6atagen2026-10-10 13:30 UTC188
}
58e1fb3943e6atagen2026-10-10 13:30 UTC189
58e1fb3943e6atagen2026-10-10 13:30 UTC190
function allowedMethods(t) {
58e1fb3943e6atagen2026-10-10 13:30 UTC191
  return t.key === "run" && !techniques.length ? t.methods.filter(m => m !== "JELQ") : t.methods;
58e1fb3943e6atagen2026-10-10 13:30 UTC192
}
58e1fb3943e6atagen2026-10-10 13:30 UTC193
185851447cebatagen2026-10-10 12:58 UTC194
function targets() {
d604371299fbatagen2026-10-10 13:54 UTC195
  const listed = run ? linked : [];
d604371299fbatagen2026-10-10 13:54 UTC196
  const known = new Set(listed.concat(GLOBALS).map(t => t.path));
d604371299fbatagen2026-10-10 13:54 UTC197
  const fresh = offered.filter((t, i) => !known.has(t.path) && offered.findIndex(o => o.path === t.path) === i);
d604371299fbatagen2026-10-10 13:54 UTC198
  return listed.concat(fresh, GLOBALS);
185851447cebatagen2026-10-10 12:58 UTC199
}
185851447cebatagen2026-10-10 12:58 UTC200
185851447cebatagen2026-10-10 12:58 UTC201
function current() {
185851447cebatagen2026-10-10 12:58 UTC202
  return targets().find(t => t.path === target) || GLOBALS[0];
185851447cebatagen2026-10-10 12:58 UTC203
}
185851447cebatagen2026-10-10 12:58 UTC204
185851447cebatagen2026-10-10 12:58 UTC205
function chooseTarget(t) {
58e1fb3943e6atagen2026-10-10 13:30 UTC206
  const allowed = allowedMethods(t);
185851447cebatagen2026-10-10 12:58 UTC207
  target = t.path;
58e1fb3943e6atagen2026-10-10 13:30 UTC208
  method = allowed.includes("JELQ") ? "JELQ" : allowed.find(m => m !== "HEAD" && m !== "OPTIONS") || allowed[0];
185851447cebatagen2026-10-10 12:58 UTC209
  render();
185851447cebatagen2026-10-10 12:58 UTC210
}
185851447cebatagen2026-10-10 12:58 UTC211
185851447cebatagen2026-10-10 12:58 UTC212
function renderStats(headers) {
185851447cebatagen2026-10-10 12:58 UTC213
  const table = $("stats");
185851447cebatagen2026-10-10 12:58 UTC214
  table.replaceChildren();
f39b10e20a0batagen2026-10-10 14:33 UTC215
  const stats = STATS.map(s => s[0] === "x-self-reported-length" && headers && MEASURED[0] in headers ? MEASURED : s);
f39b10e20a0batagen2026-10-10 14:33 UTC216
  for (let i = 0; i < stats.length; i += 2) {
185851447cebatagen2026-10-10 12:58 UTC217
    const row = el("tr");
f39b10e20a0batagen2026-10-10 14:33 UTC218
    for (const [name, label] of stats.slice(i, i + 2)) {
185851447cebatagen2026-10-10 12:58 UTC219
      const value = headers ? headers[name] : undefined;
08ffcd6cbba5atagen2026-10-14 11:19 UTC220
      const cell = el("td", {}, value === undefined ? "—" : value);
08ffcd6cbba5atagen2026-10-14 11:19 UTC221
      const changed = value === undefined ? null : change(name, value);
08ffcd6cbba5atagen2026-10-14 11:19 UTC222
      if (changed) cell.append(" ", changed);
08ffcd6cbba5atagen2026-10-14 11:19 UTC223
      row.append(el("th", { align: "left", textContent: label }), cell);
185851447cebatagen2026-10-10 12:58 UTC224
    }
185851447cebatagen2026-10-10 12:58 UTC225
    table.append(row);
99524cf9f17catagen2026-10-10 10:53 UTC226
  }
ddcf8b3a91dcatagen2026-10-14 11:03 UTC227
  lastStats = headers || {};
185851447cebatagen2026-10-10 12:58 UTC228
}
185851447cebatagen2026-10-10 12:58 UTC229
08ffcd6cbba5atagen2026-10-14 11:19 UTC230
function change(name, value) {
08ffcd6cbba5atagen2026-10-14 11:19 UTC231
  const before = lastStats[name];
08ffcd6cbba5atagen2026-10-14 11:19 UTC232
  if (before === undefined || before === value) return null;
08ffcd6cbba5atagen2026-10-14 11:19 UTC233
  if (name === "x-eq") return el("small", { textContent: "(was " + before + ")" });
08ffcd6cbba5atagen2026-10-14 11:19 UTC234
  const delta = parseFloat(value) - parseFloat(before);
08ffcd6cbba5atagen2026-10-14 11:19 UTC235
  if (!(Math.abs(delta) >= 0.005)) return null;
08ffcd6cbba5atagen2026-10-14 11:19 UTC236
  const text = (delta > 0 ? "+" : "") + (GROWTH.has(name) ? delta.toFixed(2) : delta);
08ffcd6cbba5atagen2026-10-14 11:19 UTC237
  return el("b", { textContent: text, style: "color: " + (Math.sign(delta) === BETTER[name] ? "green" : "red") });
08ffcd6cbba5atagen2026-10-14 11:19 UTC238
}
08ffcd6cbba5atagen2026-10-14 11:19 UTC239
431c1bc8ded1atagen2026-10-10 13:20 UTC240
function renderAlerts(list) {
431c1bc8ded1atagen2026-10-10 13:20 UTC241
  const box = $("alerts");
431c1bc8ded1atagen2026-10-10 13:20 UTC242
  box.replaceChildren();
431c1bc8ded1atagen2026-10-10 13:20 UTC243
  const alerts = [];
431c1bc8ded1atagen2026-10-10 13:20 UTC244
  for (const [name, value] of list || []) {
ef7d6dee5976atagen2026-10-10 13:23 UTC245
    if (name === "via") alerts.push(titled(value.split(" ").pop()) + " is at the door.");
ef7d6dee5976atagen2026-10-10 13:23 UTC246
    if (name === "x-observed-by") alerts.push((value === "cat" ? "The cat" : titled(value)) + " is watching.");
431c1bc8ded1atagen2026-10-10 13:20 UTC247
    if (name === "warning") {
431c1bc8ded1atagen2026-10-10 13:20 UTC248
      const text = (value.match(/"([^"]*)"/) || [, value])[1];
aef6f6498ea2atagen2026-10-13 11:23 UTC249
      alerts.push(titled(text) + (/[.!?]$/.test(text) ? "" : "."));
431c1bc8ded1atagen2026-10-10 13:20 UTC250
    }
431c1bc8ded1atagen2026-10-10 13:20 UTC251
  }
e76ab808e7adatagen2026-10-10 13:46 UTC252
  const stamina = (list || []).find(([name]) => name === "x-stamina");
a6caa2f99786atagen2026-10-12 10:38 UTC253
  if (stamina && stamina[1].startsWith("0/")) alerts.push("Exhausted. HOLD for the refractory period.");
431c1bc8ded1atagen2026-10-10 13:20 UTC254
  for (const alert of alerts) box.append(el("h2", { textContent: alert }));
431c1bc8ded1atagen2026-10-10 13:20 UTC255
}
431c1bc8ded1atagen2026-10-10 13:20 UTC256
185851447cebatagen2026-10-10 12:58 UTC257
function renderTargets() {
185851447cebatagen2026-10-10 12:58 UTC258
  const box = $("targets");
185851447cebatagen2026-10-10 12:58 UTC259
  box.replaceChildren();
d604371299fbatagen2026-10-10 13:54 UTC260
  const all = targets();
d604371299fbatagen2026-10-10 13:54 UTC261
  for (const [group, title] of GROUPS) {
d604371299fbatagen2026-10-10 13:54 UTC262
    const members = all.filter(t => t.group === group);
d604371299fbatagen2026-10-10 13:54 UTC263
    if (!members.length) continue;
d604371299fbatagen2026-10-10 13:54 UTC264
    box.append(el("h4", { textContent: title }));
d604371299fbatagen2026-10-10 13:54 UTC265
    for (const t of members) {
d604371299fbatagen2026-10-10 13:54 UTC266
      const radio = el("input", { type: "radio", name: "target", checked: t.path === target, onchange: () => chooseTarget(t) });
d604371299fbatagen2026-10-10 13:54 UTC267
      box.append(el("label", {}, radio, " " + t.name + " ", el("small", { textContent: short(t.path) })), el("br"));
d604371299fbatagen2026-10-10 13:54 UTC268
    }
185851447cebatagen2026-10-10 12:58 UTC269
  }
185851447cebatagen2026-10-10 12:58 UTC270
}
185851447cebatagen2026-10-10 12:58 UTC271
185851447cebatagen2026-10-10 12:58 UTC272
function renderMethods() {
185851447cebatagen2026-10-10 12:58 UTC273
  const box = $("methods");
185851447cebatagen2026-10-10 12:58 UTC274
  box.replaceChildren();
58e1fb3943e6atagen2026-10-10 13:30 UTC275
  const allowed = allowedMethods(current());
58e1fb3943e6atagen2026-10-10 13:30 UTC276
  for (const m of METHODS.filter(m => allowed.includes(m))) {
58e1fb3943e6atagen2026-10-10 13:30 UTC277
    const radio = el("input", { type: "radio", name: "method", checked: m === method, onchange: () => { method = m; render(); } });
185851447cebatagen2026-10-10 12:58 UTC278
    const label = el("label", {}, radio, " ");
185851447cebatagen2026-10-10 12:58 UTC279
    label.append(m === "JELQ" ? el("big", {}, el("b", { textContent: "JELQ" })) : m);
185851447cebatagen2026-10-10 12:58 UTC280
    box.append(label, " ");
185851447cebatagen2026-10-10 12:58 UTC281
  }
185851447cebatagen2026-10-10 12:58 UTC282
}
185851447cebatagen2026-10-10 12:58 UTC283
185851447cebatagen2026-10-10 12:58 UTC284
function fieldNames() {
4b690ff501b8atagen2026-10-10 13:27 UTC285
  const t = current();
58e1fb3943e6atagen2026-10-10 13:30 UTC286
  const key = t.key + " " + method;
58e1fb3943e6atagen2026-10-10 13:30 UTC287
  let names = BY_TARGET[key] || [];
58e1fb3943e6atagen2026-10-10 13:30 UTC288
  if (key === "run JELQ") {
58e1fb3943e6atagen2026-10-10 13:30 UTC289
    const chosen = technique(fieldValue("technique"));
58e1fb3943e6atagen2026-10-10 13:30 UTC290
    names = ["technique"];
58e1fb3943e6atagen2026-10-10 13:30 UTC291
    if (options("also").length > 1) names.push("also");
e028a4184d00atagen2026-10-14 10:49 UTC292
    if (chosen && chosen.intensity) names.push("intensity");
58e1fb3943e6atagen2026-10-10 13:30 UTC293
    if (["required", "optional"].includes(lubeRule())) names.push("lube");
58e1fb3943e6atagen2026-10-10 13:30 UTC294
  }
4b690ff501b8atagen2026-10-10 13:27 UTC295
  const scoped = run && !["runs", "global"].includes(t.key);
4b690ff501b8atagen2026-10-10 13:27 UTC296
  const asked = challenged && scoped && !names.includes("authorization");
4b690ff501b8atagen2026-10-10 13:27 UTC297
  return (asked ? ["authorization"] : []).concat(names);
185851447cebatagen2026-10-10 12:58 UTC298
}
185851447cebatagen2026-10-10 12:58 UTC299
f16ab17c8ff6atagen2026-10-13 11:14 UTC300
function renderExcuses() {
f16ab17c8ff6atagen2026-10-13 11:14 UTC301
  const said = excuses.concat(["the truth"]);
f16ab17c8ff6atagen2026-10-13 11:14 UTC302
  $("excuses").replaceChildren(...said.map(e => el("option", {
f16ab17c8ff6atagen2026-10-13 11:14 UTC303
    value: nonce ? 'Digest username="' + e + '", nonce="' + nonce + '"' : 'Excuse "' + e + '"',
f16ab17c8ff6atagen2026-10-13 11:14 UTC304
  })));
f16ab17c8ff6atagen2026-10-13 11:14 UTC305
}
f16ab17c8ff6atagen2026-10-13 11:14 UTC306
185851447cebatagen2026-10-10 12:58 UTC307
function renderFields() {
185851447cebatagen2026-10-10 12:58 UTC308
  const table = $("fields");
185851447cebatagen2026-10-10 12:58 UTC309
  table.replaceChildren();
185851447cebatagen2026-10-10 12:58 UTC310
  for (const name of fieldNames()) {
185851447cebatagen2026-10-10 12:58 UTC311
    const f = FIELDS[name];
ec6fd4bb5b60atagen2026-10-11 04:34 UTC312
    let value = fieldValue(name);
ec6fd4bb5b60atagen2026-10-11 04:34 UTC313
    if (name === "ifMatch" && !value) value = values.ifMatch = etags[current().path] || "";
58e1fb3943e6atagen2026-10-10 13:30 UTC314
    const choices = options(name);
185851447cebatagen2026-10-10 12:58 UTC315
    let input;
58e1fb3943e6atagen2026-10-10 13:30 UTC316
    if (choices) {
58e1fb3943e6atagen2026-10-10 13:30 UTC317
      input = el("select", {}, ...choices.map(o => el("option", { value: o, textContent: o || "(none)", selected: o === value })));
185851447cebatagen2026-10-10 12:58 UTC318
    } else if (f.kind === "textarea") {
185851447cebatagen2026-10-10 12:58 UTC319
      input = el("textarea", { rows: 3, cols: 40, value, placeholder: f.placeholder || "" });
185851447cebatagen2026-10-10 12:58 UTC320
    } else {
cddf59e37d5fatagen2026-10-13 12:37 UTC321
      const hint = name === "authorization" && nonce ? 'Digest username="helping Nan", nonce="' + nonce + '"' : f.placeholder || "";
cddf59e37d5fatagen2026-10-13 12:37 UTC322
      input = el("input", { type: f.kind, value, placeholder: hint, size: 30 });
185851447cebatagen2026-10-10 12:58 UTC323
    }
58e1fb3943e6atagen2026-10-10 13:30 UTC324
    input.oninput = () => { values[name] = input.value; };
58e1fb3943e6atagen2026-10-10 13:30 UTC325
    input.onchange = () => { values[name] = input.value; if (choices) renderFields(); };
7d3fb63208bfatagen2026-10-11 04:38 UTC326
    if (name === "authorization") input.setAttribute("list", "excuses");
185851447cebatagen2026-10-10 12:58 UTC327
    table.append(el("tr", {}, el("td", { align: "right", valign: "top", textContent: f.label }), el("td", {}, input)));
185851447cebatagen2026-10-10 12:58 UTC328
  }
58e1fb3943e6atagen2026-10-10 13:30 UTC329
  const extra = el("textarea", { rows: 3, cols: 40, value: raw("extra"), placeholder: FIELDS.extra.placeholder });
4b690ff501b8atagen2026-10-10 13:27 UTC330
  extra.oninput = () => { values.extra = extra.value; };
4b690ff501b8atagen2026-10-10 13:27 UTC331
  const more = el("details", { open: Boolean(values.extra) }, el("summary", { textContent: "more headers" }), extra);
4b690ff501b8atagen2026-10-10 13:27 UTC332
  table.append(el("tr", {}, el("td"), el("td", {}, more)));
185851447cebatagen2026-10-10 12:58 UTC333
  $("send").value = method + " " + short(current().path);
185851447cebatagen2026-10-10 12:58 UTC334
}
185851447cebatagen2026-10-10 12:58 UTC335
185851447cebatagen2026-10-10 12:58 UTC336
function render() {
58e1fb3943e6atagen2026-10-10 13:30 UTC337
  if (!allowedMethods(current()).includes(method)) return chooseTarget(current());
185851447cebatagen2026-10-10 12:58 UTC338
  renderTargets();
185851447cebatagen2026-10-10 12:58 UTC339
  renderMethods();
185851447cebatagen2026-10-10 12:58 UTC340
  renderFields();
185851447cebatagen2026-10-10 12:58 UTC341
}
185851447cebatagen2026-10-10 12:58 UTC342
185851447cebatagen2026-10-10 12:58 UTC343
function parseLinks(header) {
58e1fb3943e6atagen2026-10-10 13:30 UTC344
  const resources = [];
58e1fb3943e6atagen2026-10-10 13:30 UTC345
  const moves = [];
185851447cebatagen2026-10-10 12:58 UTC346
  for (const match of header.matchAll(/<([^>]*)>((?:\s*;\s*[a-z-]+="[^"]*")*)/g)) {
185851447cebatagen2026-10-10 12:58 UTC347
    const params = Object.fromEntries([...match[2].matchAll(/([a-z-]+)="([^"]*)"/g)].map(p => [p[1], p[2]]));
185851447cebatagen2026-10-10 12:58 UTC348
    const name = (params.rel || "").replace(REL, "");
58e1fb3943e6atagen2026-10-10 13:30 UTC349
    if (name === "technique") {
e028a4184d00atagen2026-10-14 10:49 UTC350
      moves.push({ name: params.title, lubricant: params.lubricant || null, intensity: params.intensity || null });
58e1fb3943e6atagen2026-10-10 13:30 UTC351
      continue;
58e1fb3943e6atagen2026-10-10 13:30 UTC352
    }
185851447cebatagen2026-10-10 12:58 UTC353
    const methods = (params.allow || "GET").split(",").map(s => s.trim());
d46f9d0b953aatagen2026-10-10 14:41 UTC354
    resources.push({ key: name, group: GROUP_OF[name] || "play", name: NAMES[name] || params.title || name, path: match[1], methods });
185851447cebatagen2026-10-10 12:58 UTC355
  }
58e1fb3943e6atagen2026-10-10 13:30 UTC356
  return [resources, moves];
99524cf9f17catagen2026-10-10 10:53 UTC357
}
99524cf9f17catagen2026-10-10 10:53 UTC358
99524cf9f17catagen2026-10-10 10:53 UTC359
function hrefs(value, found) {
99524cf9f17catagen2026-10-10 10:53 UTC360
  if (value && typeof value === "object") {
185851447cebatagen2026-10-10 12:58 UTC361
    if (typeof value.href === "string") {
185851447cebatagen2026-10-10 12:58 UTC362
      const name = value.title || value.item || value.name || value.href.split("/").pop();
d604371299fbatagen2026-10-10 13:54 UTC363
      found.push({ key: "offered", group: "said", name, path: value.href, methods: [value.method || "GET"] });
185851447cebatagen2026-10-10 12:58 UTC364
    }
99524cf9f17catagen2026-10-10 10:53 UTC365
    for (const key in value) hrefs(value[key], found);
99524cf9f17catagen2026-10-10 10:53 UTC366
  }
99524cf9f17catagen2026-10-10 10:53 UTC367
  return found;
99524cf9f17catagen2026-10-10 10:53 UTC368
}
99524cf9f17catagen2026-10-10 10:53 UTC369
185851447cebatagen2026-10-10 12:58 UTC370
function log(text) {
585e6b7ce086atagen2026-10-10 13:43 UTC371
  $("log").prepend(text + "\n\n");
585e6b7ce086atagen2026-10-10 13:43 UTC372
  $("frame").scrollTop = 0;
99524cf9f17catagen2026-10-10 10:53 UTC373
}
99524cf9f17catagen2026-10-10 10:53 UTC374
185851447cebatagen2026-10-10 12:58 UTC375
function describe(r) {
185851447cebatagen2026-10-10 12:58 UTC376
  const lines = ["< " + r.status + " " + r.reason];
185851447cebatagen2026-10-10 12:58 UTC377
  for (const [name, value] of r.headers) {
185851447cebatagen2026-10-10 12:58 UTC378
    if (!QUIET.has(name)) lines.push("< " + name + ": " + short(value));
185851447cebatagen2026-10-10 12:58 UTC379
  }
185851447cebatagen2026-10-10 12:58 UTC380
  let body = null;
185851447cebatagen2026-10-10 12:58 UTC381
  try { body = JSON.parse(r.body); } catch (e) {}
185851447cebatagen2026-10-10 12:58 UTC382
  if (body && typeof body === "object") {
185851447cebatagen2026-10-10 12:58 UTC383
    const rest = Object.assign({}, body);
185851447cebatagen2026-10-10 12:58 UTC384
    if (rest.detail) lines.push("  " + rest.detail);
185851447cebatagen2026-10-10 12:58 UTC385
    for (const key of ["type", "title", "status", "detail"]) delete rest[key];
185851447cebatagen2026-10-10 12:58 UTC386
    if (Object.keys(rest).length) lines.push(short(JSON.stringify(rest, null, 2)).replace(/^/gm, "  "));
185851447cebatagen2026-10-10 12:58 UTC387
  } else if (r.body) {
e76ab808e7adatagen2026-10-10 13:46 UTC388
    const range = (r.headers.find(h => h[0] === "content-range") || [])[1] || "";
e76ab808e7adatagen2026-10-10 13:46 UTC389
    const partial = r.status === 206 && range.match(/^bytes (\d+)-(\d+)\/(\d+)$/);
185851447cebatagen2026-10-10 12:58 UTC390
    lines.push("  " + r.body);
ec6fd4bb5b60atagen2026-10-11 04:34 UTC391
    if (partial) lines.push("  [bytes " + partial[1] + "-" + partial[2] + " of " + partial[3] + ". Half-mast.]");
185851447cebatagen2026-10-10 12:58 UTC392
  }
185851447cebatagen2026-10-10 12:58 UTC393
  return lines.join("\n");
99524cf9f17catagen2026-10-10 10:53 UTC394
}
99524cf9f17catagen2026-10-10 10:53 UTC395
185851447cebatagen2026-10-10 12:58 UTC396
function absorb(r, sentMethod, sentPath) {
185851447cebatagen2026-10-10 12:58 UTC397
  const headers = Object.fromEntries(r.headers.map(([n, v]) => [n.toLowerCase(), v]));
ec6fd4bb5b60atagen2026-10-11 04:34 UTC398
  if (headers.etag) etags[sentPath] = headers.etag;
ec6fd4bb5b60atagen2026-10-11 04:34 UTC399
  const digest = (headers["www-authenticate"] || "").match(/nonce="([^"]*)"/);
f16ab17c8ff6atagen2026-10-13 11:14 UTC400
  if ("www-authenticate" in headers) nonce = digest ? digest[1] : null;
f16ab17c8ff6atagen2026-10-13 11:14 UTC401
  renderExcuses();
185851447cebatagen2026-10-10 12:58 UTC402
  let body = null;
185851447cebatagen2026-10-10 12:58 UTC403
  try { body = JSON.parse(r.body); } catch (e) {}
185851447cebatagen2026-10-10 12:58 UTC404
  const problem = body && typeof body.type === "string" ? body.type.split("/").pop() : null;
58e1fb3943e6atagen2026-10-10 13:30 UTC405
  const started = r.status === 201 && (sentPath === "/runs" || sentPath.startsWith("/runs?"));
185851447cebatagen2026-10-10 12:58 UTC406
58e1fb3943e6atagen2026-10-10 13:30 UTC407
  if (started) {
58e1fb3943e6atagen2026-10-10 13:30 UTC408
    run = headers.location;
ddcf8b3a91dcatagen2026-10-14 11:03 UTC409
    lastStats = {};
58e1fb3943e6atagen2026-10-10 13:30 UTC410
    log("--- a new run has started at " + short(run) + " ---");
185851447cebatagen2026-10-10 12:58 UTC411
  }
431c1bc8ded1atagen2026-10-10 13:20 UTC412
  if ("x-eq" in headers) {
431c1bc8ded1atagen2026-10-10 13:20 UTC413
    renderStats(headers);
431c1bc8ded1atagen2026-10-10 13:20 UTC414
    renderAlerts(r.headers);
4b690ff501b8atagen2026-10-10 13:27 UTC415
    challenged = r.status === 401 || "via" in headers;
431c1bc8ded1atagen2026-10-10 13:20 UTC416
  }
58e1fb3943e6atagen2026-10-10 13:30 UTC417
  if (headers.link) [linked, techniques] = parseLinks(headers.link);
0a0bfee8329eatagen2026-10-11 05:11 UTC418
  if (run) {
139164489032atagen2026-10-11 05:46 UTC419
    const active = run;
14de3e1e8dc2atagen2026-10-11 06:19 UTC420
    const seq = ++inventorySeq;
0a0bfee8329eatagen2026-10-11 05:11 UTC421
    fetch("/ui/send", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ method: "GET", path: run + "/inventory", headers: [], body: "" }) })
0a0bfee8329eatagen2026-10-11 05:11 UTC422
      .then(r => r.json())
0a0bfee8329eatagen2026-10-11 05:11 UTC423
      .then(r => {
14de3e1e8dc2atagen2026-10-11 06:19 UTC424
        if (run !== active || seq !== inventorySeq) return;
f16ab17c8ff6atagen2026-10-13 11:14 UTC425
        try {
f16ab17c8ff6atagen2026-10-13 11:14 UTC426
          const held = JSON.parse(r.body);
f16ab17c8ff6atagen2026-10-13 11:14 UTC427
          stocked = (held.items || []).map(i => i.name);
f16ab17c8ff6atagen2026-10-13 11:14 UTC428
          excuses = held.excuses || [];
f16ab17c8ff6atagen2026-10-13 11:14 UTC429
          renderExcuses();
f16ab17c8ff6atagen2026-10-13 11:14 UTC430
          render();
f16ab17c8ff6atagen2026-10-13 11:14 UTC431
        } catch (e) {}
0a0bfee8329eatagen2026-10-11 05:11 UTC432
      });
0a0bfee8329eatagen2026-10-11 05:11 UTC433
  }
185851447cebatagen2026-10-10 12:58 UTC434
  offered = body ? hrefs(body, []) : [];
58e1fb3943e6atagen2026-10-10 13:30 UTC435
  if (headers.location && !started) {
d604371299fbatagen2026-10-10 13:54 UTC436
    offered.unshift({ key: "offered", group: "said", name: short(headers.location).split("/").pop() + " (Location)", path: headers.location, methods: ["GET"] });
185851447cebatagen2026-10-10 12:58 UTC437
  }
185851447cebatagen2026-10-10 12:58 UTC438
  const abandoned = sentMethod === "DELETE" && sentPath === run && r.status === 204;
185851447cebatagen2026-10-10 12:58 UTC439
  if (run && (abandoned || DEATHS.includes(problem))) {
185851447cebatagen2026-10-10 12:58 UTC440
    log("--- the run has ended ---");
431c1bc8ded1atagen2026-10-10 13:20 UTC441
    renderAlerts(null);
4b690ff501b8atagen2026-10-10 13:27 UTC442
    challenged = false;
185851447cebatagen2026-10-10 12:58 UTC443
    run = null;
185851447cebatagen2026-10-10 12:58 UTC444
    linked = [];
58e1fb3943e6atagen2026-10-10 13:30 UTC445
    techniques = [];
185851447cebatagen2026-10-10 12:58 UTC446
  }
185851447cebatagen2026-10-10 12:58 UTC447
  if (started || !targets().some(t => t.path === target)) {
185851447cebatagen2026-10-10 12:58 UTC448
    const home = linked.find(t => t.key === "run");
58e1fb3943e6atagen2026-10-10 13:30 UTC449
    chooseTarget(home || GLOBALS[0]);
185851447cebatagen2026-10-10 12:58 UTC450
  } else {
185851447cebatagen2026-10-10 12:58 UTC451
    render();
99524cf9f17catagen2026-10-10 10:53 UTC452
  }
99524cf9f17catagen2026-10-10 10:53 UTC453
}
99524cf9f17catagen2026-10-10 10:53 UTC454
185851447cebatagen2026-10-10 12:58 UTC455
async function go(event) {
185851447cebatagen2026-10-10 12:58 UTC456
  event.preventDefault();
185851447cebatagen2026-10-10 12:58 UTC457
  const t = current();
185851447cebatagen2026-10-10 12:58 UTC458
  const key = t.key + " " + method;
185851447cebatagen2026-10-10 12:58 UTC459
  const value = name => fieldValue(name).trim();
185851447cebatagen2026-10-10 12:58 UTC460
  const headers = [];
185851447cebatagen2026-10-10 12:58 UTC461
  let path = t.path;
185851447cebatagen2026-10-10 12:58 UTC462
  for (const name of fieldNames()) {
185851447cebatagen2026-10-10 12:58 UTC463
    const f = FIELDS[name];
185851447cebatagen2026-10-10 12:58 UTC464
    if (f.header && value(name)) headers.push([f.header, value(name)]);
185851447cebatagen2026-10-10 12:58 UTC465
  }
185851447cebatagen2026-10-10 12:58 UTC466
  if (fieldNames().includes("upgrade") && value("upgrade")) headers.push(["Connection", "upgrade"]);
58e1fb3943e6atagen2026-10-10 13:30 UTC467
  for (const line of raw("extra").split("\n")) {
185851447cebatagen2026-10-10 12:58 UTC468
    const at = line.indexOf(":");
185851447cebatagen2026-10-10 12:58 UTC469
    if (at > 0) headers.push([line.slice(0, at).trim(), line.slice(at + 1).trim()]);
185851447cebatagen2026-10-10 12:58 UTC470
  }
185851447cebatagen2026-10-10 12:58 UTC471
  if (key === "run JELQ") {
58e1fb3943e6atagen2026-10-10 13:30 UTC472
    const names = fieldNames();
58e1fb3943e6atagen2026-10-10 13:30 UTC473
    const chosen = [value("technique")].concat(names.includes("also") && value("also") ? [value("also")] : []);
58e1fb3943e6atagen2026-10-10 13:30 UTC474
    path += "?technique=" + encodeURIComponent(chosen.join(","));
58e1fb3943e6atagen2026-10-10 13:30 UTC475
    if (names.includes("intensity")) path += "&intensity=" + encodeURIComponent(value("intensity"));
08ffcd6cbba5atagen2026-10-14 11:19 UTC476
    delete values.also;
185851447cebatagen2026-10-10 12:58 UTC477
  }
185851447cebatagen2026-10-10 12:58 UTC478
  if (key === "runs POST" && value("seed")) path += "?seed=" + encodeURIComponent(value("seed"));
99524cf9f17catagen2026-10-10 10:53 UTC479
585e6b7ce086atagen2026-10-10 13:43 UTC480
  const sent = ["> " + method + " " + short(path)].concat(headers.map(([name, v]) => "> " + name + ": " + v)).join("\n");
cddf59e37d5fatagen2026-10-13 12:37 UTC481
  delete values.authorization;
ef7d6dee5976atagen2026-10-10 13:23 UTC482
  headers.push(["Accept-Language", $("locale").value]);
7288fc269bb6atagen2026-10-10 13:36 UTC483
  let r;
7288fc269bb6atagen2026-10-10 13:36 UTC484
  try {
7288fc269bb6atagen2026-10-10 13:36 UTC485
    const response = await fetch("/ui/send", {
7288fc269bb6atagen2026-10-10 13:36 UTC486
      method: "POST",
7288fc269bb6atagen2026-10-10 13:36 UTC487
      headers: { "Content-Type": "application/json" },
6619c458c23eatagen2026-10-14 08:08 UTC488
      body: JSON.stringify({ method, path, headers }),
7288fc269bb6atagen2026-10-10 13:36 UTC489
    });
7288fc269bb6atagen2026-10-10 13:36 UTC490
    r = await response.json();
7288fc269bb6atagen2026-10-10 13:36 UTC491
  } catch (error) {
585e6b7ce086atagen2026-10-10 13:43 UTC492
    log(sent + "\n! The server did not answer. Is jelqd still running? (" + error.message + ")");
7288fc269bb6atagen2026-10-10 13:36 UTC493
    return;
7288fc269bb6atagen2026-10-10 13:36 UTC494
  }
7288fc269bb6atagen2026-10-10 13:36 UTC495
  if (!Array.isArray(r.headers)) {
585e6b7ce086atagen2026-10-10 13:43 UTC496
    log(sent + "\n! The page could not read that reply:\n  " + JSON.stringify(r));
7288fc269bb6atagen2026-10-10 13:36 UTC497
    return;
7288fc269bb6atagen2026-10-10 13:36 UTC498
  }
585e6b7ce086atagen2026-10-10 13:43 UTC499
  log(sent + "\n" + describe(r));
185851447cebatagen2026-10-10 12:58 UTC500
  absorb(r, method, path);
99524cf9f17catagen2026-10-10 10:53 UTC501
}
185851447cebatagen2026-10-10 12:58 UTC502
185851447cebatagen2026-10-10 12:58 UTC503
$("form").onsubmit = go;
ef7d6dee5976atagen2026-10-10 13:23 UTC504
$("locale").value = localStorage.getItem("locale") || "en-GB";
ef7d6dee5976atagen2026-10-10 13:23 UTC505
$("locale").onchange = () => localStorage.setItem("locale", $("locale").value);
185851447cebatagen2026-10-10 12:58 UTC506
renderStats(null);
185851447cebatagen2026-10-10 12:58 UTC507
render();
585e6b7ce086atagen2026-10-10 13:43 UTC508
log("Welcome. Choose \"start a new run\" and send POST to begin. The newest turn is always at the top.");
99524cf9f17catagen2026-10-10 10:53 UTC509
</script>
99524cf9f17catagen2026-10-10 10:53 UTC510
</body>
99524cf9f17catagen2026-10-10 10:53 UTC511
</html>