From f0a524a0a98a6962fd588cfadf0201b749141d81 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 17 Feb 2026 19:55:19 -0500 Subject: Add character sheet --- assets/charsheet/charsheet.js | 45 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'assets/charsheet/charsheet.js') diff --git a/assets/charsheet/charsheet.js b/assets/charsheet/charsheet.js index 8c16137..d477a68 100644 --- a/assets/charsheet/charsheet.js +++ b/assets/charsheet/charsheet.js @@ -24,6 +24,22 @@ function showContents() { } } +function showError() { + let elem = document.getElementById("error"); + if (elem) { + elem.classList.remove("invisible"); + elem.classList.add("error-anim-unfold"); + let timeout = 500; + for (let c of elem.children) { + setTimeout( + () => c.classList.add("opaque"), + timeout + ); + timeout += 200; + } + } +} + function scaleName() { let elem = document.getElementById("name"); if (elem && elem.firstElementChild) { @@ -167,7 +183,6 @@ function initGL() { UNIFORM_VIEW = GL.getUniformLocation(prog, "view"); UNIFORM_POSITION = GL.getUniformLocation(prog, "position"); const cube = uploadCube(); - uploadImage("./assets/l.png"); VERTS = cube.verts; IDXS = cube.idxs; requestAnimationFrame(render); @@ -197,10 +212,28 @@ function render() { requestAnimationFrame(render); } +function setField(nm, v) { + const elem = document.getElementById("info-" + nm); + if (elem) { + elem.innerText = v.toString(); + } +} + initGL(); -setName("LCOLONQ"); -setTimeout( - () => showContents(), - 1000 -); +const uid = location.hash.slice(1); +const resp = await fetch(`${globalThis.apiServer}/user/info/${uid}`); +if (!resp.ok) { + showError(); +} else { + uploadImage(`${globalThis.apiServer}/user/avatar/${uid}.png`); + const info = await resp.json() + setName(info.properties["name"]); + for (let nm in info.stats) { + setField(nm, info.stats[nm]); + } + for (let nm in info.properties) { + setField(nm, info.properties[nm]); + } + showContents(); +} -- cgit v1.2.3