an http based roguelike rpg about jelqing
Commit ddcf8b3a91dc
tarball1 file changed+7-1
@@ -71,6 +71,8 @@ const STATS = [
7171
["x-cash", "Cash"],7272
];7373
const MEASURED = ["x-length", "Length"];74
+const GROWTH = new Set(["x-length", "x-self-reported-length", "x-girth", "x-foreskin"]);75
+let lastStats = {};7476
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]));7577
7678
const FIELDS = {@@ -214,10 +216,13 @@ function renderStats(headers) {
214216
const row = el("tr");215217
for (const [name, label] of stats.slice(i, i + 2)) {216218
const value = headers ? headers[name] : undefined;217
- row.append(el("th", { align: "left", textContent: label }), el("td", { textContent: value === undefined ? "—" : value }));219
+ const delta = GROWTH.has(name) ? parseFloat(value) - parseFloat(lastStats[name]) : NaN;220
+ const shown = value === undefined ? "—" : value + (Math.abs(delta) >= 0.005 ? " (" + (delta > 0 ? "+" : "") + delta.toFixed(2) + ")" : "");221
+ row.append(el("th", { align: "left", textContent: label }), el("td", { textContent: shown }));218222
}219223
table.append(row);220224
}225
+ lastStats = headers || {};221226
}222227
223228
function renderAlerts(list) {@@ -389,6 +394,7 @@ function absorb(r, sentMethod, sentPath) {
389394
390395
if (started) {391396
run = headers.location;397
+ lastStats = {};392398
log("--- a new run has started at " + short(run) + " ---");393399
}394400
if ("x-eq" in headers) {