atagen

jelq

public

an http based roguelike rpg about jelqing

Star0
Watch0

Commit 585e6b7ce086

tarball

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

1 file changed+7-8
ui: put the newest turn at the top of the log

Each turn is now built as one block before it is prepended, so lines within a turn keep their reading order.
Modified file: src/ui.html+7 additions−8 deletions
@@ -310,8 +310,8 @@ function hrefs(value, found) {
310310 }
311311
312312 function log(text) {
313- $("log").append(text + "\n");
314- $("frame").scrollTop = $("frame").scrollHeight;
313+ $("log").prepend(text + "\n\n");
314+ $("frame").scrollTop = 0;
315315 }
316316
317317 function describe(r) {
@@ -399,8 +399,7 @@ async function go(event) {
399399 body = value("patch");
400400 }
401401
402- log("> " + method + " " + short(path));
403- for (const [name, v] of headers) log("> " + name + ": " + v);
402+ const sent = ["> " + method + " " + short(path)].concat(headers.map(([name, v]) => "> " + name + ": " + v)).join("\n");
404403 headers.push(["Accept-Language", $("locale").value]);
405404 let r;
406405 try {
@@ -411,14 +410,14 @@ async function go(event) {
411410 });
412411 r = await response.json();
413412 } catch (error) {
414- log("! The server did not answer. Is jelqd still running? (" + error.message + ")\n");
413+ log(sent + "\n! The server did not answer. Is jelqd still running? (" + error.message + ")");
415414 return;
416415 }
417416 if (!Array.isArray(r.headers)) {
418- log("! The page could not read that reply:\n " + JSON.stringify(r) + "\n");
417+ log(sent + "\n! The page could not read that reply:\n " + JSON.stringify(r));
419418 return;
420419 }
421- log(describe(r) + "\n");
420+ log(sent + "\n" + describe(r));
422421 absorb(r, method, path);
423422 }
424423
@@ -427,7 +426,7 @@ $("locale").value = localStorage.getItem("locale") || "en-GB";
427426 $("locale").onchange = () => localStorage.setItem("locale", $("locale").value);
428427 renderStats(null);
429428 render();
430-log("Welcome. Choose \"start a new run\" and send POST to begin.\n");
429+log("Welcome. Choose \"start a new run\" and send POST to begin. The newest turn is always at the top.");
431430 </script>
432431 </body>
433432 </html>