an http based roguelike rpg about jelqing
Commit 431c1bc8ded1
tarball1 file changed+23-3
@@ -19,6 +19,8 @@ pre, li, p, td, label { overflow-wrap: anywhere; }
1919
<td width="45%" valign="top">2020
<div class="frame">2121
22
+<div id="alerts"></div>23
+2224
<form id="form">2325
<h3>Method</h3>2426
<div id="methods"></div>@@ -59,9 +61,8 @@ const STATS = [
5961
["x-suspicion", "Suspicion"],6062
["x-shame", "Shame"],6163
["x-cash", "Cash"],62
- ["x-observed-by", "Being watched by"],63
- ["via", "At the door"],6464
];65
+const OBSERVERS = { cat: "The cat is watching.", greg: "Greg is watching.", nan: "Nan is watching." };6566
const QUIET = new Set(["link", "set-cookie", "server", "x-powered-by", "cache-control", "content-length", "content-type", "date"].concat(STATS.map(s => s[0])));6667
6768
const FIELDS = {@@ -148,6 +149,21 @@ function renderStats(headers) {
148149
}149150
}150151
152
+function renderAlerts(list) {153
+ const box = $("alerts");154
+ box.replaceChildren();155
+ const alerts = [];156
+ for (const [name, value] of list || []) {157
+ if (name === "via" && value.includes("mum")) alerts.push("Mum is at the door.");158
+ if (name === "x-observed-by") alerts.push(OBSERVERS[value] || "Someone is watching.");159
+ if (name === "warning") {160
+ const text = (value.match(/"([^"]*)"/) || [, value])[1];161
+ alerts.push(text.charAt(0).toUpperCase() + text.slice(1) + ".");162
+ }163
+ }164
+ for (const alert of alerts) box.append(el("h2", { textContent: alert }));165
+}166
+151167
function renderTargets() {152168
const box = $("targets");153169
box.replaceChildren();@@ -258,7 +274,10 @@ function absorb(r, sentMethod, sentPath) {
258274
log("--- a new run has started at " + short(run) + " ---");259275
}260276
}261
- if ("x-eq" in headers) renderStats(headers);277
+ if ("x-eq" in headers) {278
+ renderStats(headers);279
+ renderAlerts(r.headers);280
+ }262281
if (headers.link) linked = parseLinks(headers.link);263282
offered = body ? hrefs(body, []) : [];264283
if (headers.location && !(sentPath === "/runs" || sentPath.startsWith("/runs?"))) {@@ -267,6 +286,7 @@ function absorb(r, sentMethod, sentPath) {
267286
const abandoned = sentMethod === "DELETE" && sentPath === run && r.status === 204;268287
if (run && (abandoned || DEATHS.includes(problem))) {269288
log("--- the run has ended ---");289
+ renderAlerts(null);270290
run = null;271291
linked = [];272292
}