an http based roguelike rpg about jelqing
Blame: src/ui.html
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 1 | <!DOCTYPE html> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 2 | <html> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 3 | <head> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 4 | <meta charset="utf-8"> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 5 | <title>jelqd</title> |
782069860236 | atagen | 2026-10-10 12:44 UTC | 6 | <style>pre { white-space: pre-wrap; } pre, li, p { overflow-wrap: anywhere; }</style> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 7 | </head> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 8 | <body> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 9 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 10 | <h1 id="status">jelqd</h1> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 11 | <p id="detail">A roguelike played over HTTP. Press POST /runs to begin.</p> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 12 | <ul id="links"></ul> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 13 | <ul id="headers"></ul> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 14 | <pre id="body"></pre> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 15 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 16 | <hr> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 17 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 18 | <h2>Run</h2> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 19 | <p> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 20 | Run <input id="run" size="20" placeholder="/runs/..."> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 21 | seed <input id="seed" size="12" placeholder="(unranked)"> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 22 | <button onclick="start()">POST /runs</button> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 23 | </p> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 24 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 25 | <h2>JELQ</h2> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 26 | <p> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 27 | technique |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 28 | <select id="technique"> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 29 | <option>warmup</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 30 | <option>wet</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 31 | <option>dry</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 32 | <option>stretch</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 33 | <option>uli</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 34 | <option>edge</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 35 | <option>pump</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 36 | <option>ice</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 37 | <option>supplement</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 38 | </select> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 39 | or combo <input id="combo" size="14" placeholder="wet,stretch"> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 40 | intensity <input id="intensity" type="number" min="1" max="10" value="5" size="3"> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 41 | Content-Type |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 42 | <select id="lube"> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 43 | <option value="">(none)</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 44 | <option>application/baby-oil</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 45 | <option>application/coconut-oil</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 46 | <option>application/lotion</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 47 | <option>application/vaseline</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 48 | <option>text/plain; charset=spit</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 49 | <option>image/jpeg</option> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 50 | </select> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 51 | <button onclick="jelq()">JELQ</button> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 52 | </p> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 53 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 54 | <h2>Methods</h2> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 55 | <ul> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 56 | <li>the run: <button onclick="go('GET', '')">GET</button> <button onclick="go('HEAD', '')">HEAD</button> <button onclick="go('PUT', '')">PUT</button> <button onclick="go('OPTIONS', '')">OPTIONS</button> <button onclick="go('TRACE', '')">TRACE</button> <button onclick="go('DELETE', '')">DELETE</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 57 | <li>/floor: <button onclick="go('GET', '/floor')">GET</button> <button onclick="go('POST', '/floor')">POST</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 58 | <li>/drawer: <button onclick="go('POST', '/drawer')">POST</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 59 | <li>/inventory: <button onclick="go('GET', '/inventory')">GET</button> item <input id="item" size="16"> <button onclick="go('GET', '/inventory/' + val('item'))">GET</button> <button onclick="go('DELETE', '/inventory/' + val('item'))">DELETE</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 60 | <li>/techniques: <button onclick="go('GET', '/techniques')">GET</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 61 | <li>/length: <button onclick="go('GET', '/length')">GET</button> <button onclick="go('HEAD', '/length')">HEAD</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 62 | <li>/foreskin: <button onclick="go('GET', '/foreskin')">GET</button> <button onclick="go('DELETE', '/foreskin')">DELETE</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 63 | <li>/branches: <button onclick="go('POST', '/branches/forum')">POST forum</button> <button onclick="go('POST', '/branches/close-tab')">POST close-tab</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 64 | <li>/shop: <button onclick="go('GET', '/shop')">GET</button> item <input id="buy" size="16"> <button onclick="go('POST', '/shop/' + val('buy'))">POST</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 65 | <li>/portal: <button onclick="go('GET', '/portal')">GET</button> <button onclick="go('POST', '/portal')">POST</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 66 | <li>/elder: <button onclick="go('GET', '/elder')">GET</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 67 | <li>/grip: <button onclick="go('GET', '/grip')">GET</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 68 | <li>/diagnosis: <button onclick="go('GET', '/diagnosis')">GET</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 69 | <li>PATCH the run, as application/json-patch+json:<br> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 70 | <textarea id="patch" rows="2" cols="60">[{"op": "test", "path": "/length", "value": 6}]</textarea> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 71 | <button onclick="go('PATCH', '', [['Content-Type', 'application/json-patch+json']], val('patch'))">PATCH</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 72 | <li>anything: method <input id="method" size="8" value="GET"> path <input id="path" size="30" value="/leaderboard"> <button onclick="send(val('method'), val('path'))">Send</button></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 73 | </ul> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 74 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 75 | <h2>Headers</h2> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 76 | <p>Sent with every request when filled in.</p> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 77 | <ul> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 78 | <li>Authorization <input id="authorization" size="50" placeholder='Excuse "homework"'></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 79 | <li>Proxy-Authorization <input id="proxy-authorization" size="30" placeholder="Ruler 5.4"></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 80 | <li>If-Match <input id="if-match" size="24"></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 81 | <li>If-None-Match <input id="if-none-match" size="24"></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 82 | <li>If-Modified-Since <input id="if-modified-since" size="32"></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 83 | <li>Range <input id="range" size="16" placeholder="inches=0-2"></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 84 | <li>Accept <input id="accept" size="30"></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 85 | <li>Accept-Encoding <input id="accept-encoding" size="10"></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 86 | <li>Expect <input id="expect" size="16"></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 87 | <li>Upgrade <input id="upgrade" size="16" placeholder="underhand"></li> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 88 | </ul> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 89 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 90 | <hr> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 91 | <p><a href="/leaderboard">/leaderboard</a> <a href="/graveyard">/graveyard</a> <a href="/forum/threads/2009">/forum/threads/2009</a></p> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 92 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 93 | <script> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 94 | const HEADERS = ["Authorization", "Proxy-Authorization", "If-Match", "If-None-Match", "If-Modified-Since", "Range", "Accept", "Accept-Encoding", "Expect", "Upgrade"]; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 95 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 96 | function val(id) { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 97 | return document.getElementById(id).value.trim(); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 98 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 99 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 100 | function put(id, text) { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 101 | document.getElementById(id).textContent = text; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 102 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 103 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 104 | function item(list, text, onclick) { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 105 | const li = document.createElement("li"); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 106 | if (onclick) { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 107 | const button = document.createElement("button"); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 108 | button.textContent = text; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 109 | button.onclick = onclick; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 110 | li.appendChild(button); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 111 | } else { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 112 | li.textContent = text; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 113 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 114 | document.getElementById(list).appendChild(li); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 115 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 116 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 117 | function hrefs(value, found) { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 118 | if (value && typeof value === "object") { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 119 | if (typeof value.href === "string") found.push([value.method || "GET", value.href]); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 120 | for (const key in value) hrefs(value[key], found); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 121 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 122 | return found; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 123 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 124 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 125 | async function send(method, path, extra, body) { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 126 | const headers = HEADERS.map(name => [name, val(name.toLowerCase())]).filter(h => h[1]); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 127 | if (val("upgrade")) headers.push(["Connection", "upgrade"]); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 128 | const response = await fetch("/ui/send", { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 129 | method: "POST", |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 130 | headers: {"Content-Type": "application/json"}, |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 131 | body: JSON.stringify({method, path, headers: headers.concat(extra || []), body: body || ""}), |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 132 | }); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 133 | show(await response.json(), path); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 134 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 135 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 136 | function show(r, path) { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 137 | put("status", r.status + " " + (r.reason || "")); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 138 | let parsed = null; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 139 | try { parsed = JSON.parse(r.body); } catch (e) {} |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 140 | put("detail", parsed && parsed.detail ? parsed.detail : ""); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 141 | put("body", r.body); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 142 | document.getElementById("headers").replaceChildren(); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 143 | document.getElementById("links").replaceChildren(); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 144 | for (const [name, value] of r.headers) item("headers", name + ": " + value); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 145 | const location = r.headers.find(h => h[0] === "location"); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 146 | if (location && path === "/runs" && r.status === 201) document.getElementById("run").value = location[1]; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 147 | if (location) item("links", "GET " + location[1], () => send("GET", location[1])); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 148 | for (const [method, href] of hrefs(parsed, [])) item("links", method + " " + href, () => send(method, href)); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 149 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 150 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 151 | function go(method, sub, extra, body) { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 152 | if (!val("run")) { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 153 | put("status", "No run"); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 154 | put("detail", "Press POST /runs first."); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 155 | return; |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 156 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 157 | send(method, val("run") + sub, extra, body); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 158 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 159 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 160 | function start() { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 161 | send("POST", val("seed") ? "/runs?seed=" + encodeURIComponent(val("seed")) : "/runs"); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 162 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 163 | |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 164 | function jelq() { |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 165 | const technique = val("combo") || val("technique"); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 166 | const query = "?technique=" + encodeURIComponent(technique) + "&intensity=" + encodeURIComponent(val("intensity")); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 167 | const lube = val("lube"); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 168 | go("JELQ", query, lube ? [["Content-Type", lube]] : []); |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 169 | } |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 170 | </script> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 171 | </body> |
99524cf9f17c | atagen | 2026-10-10 10:53 UTC | 172 | </html> |