diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-16 17:44:47 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-16 17:44:47 +0100 |
| commit | a81ad9738e9013557b2bd3cbdd7014d981f032fe (patch) | |
| tree | ebe846a59dbc99f22ff2e021c293f39e24764bb2 /static/modules/xbox.js | |
| parent | df7b5062118467dc02d3baade9a6b74390c050ba (diff) | |
| download | deck-it-a81ad9738e9013557b2bd3cbdd7014d981f032fe.tar.gz deck-it-a81ad9738e9013557b2bd3cbdd7014d981f032fe.zip | |
feat(xbox): one games list with installed badges
Diffstat (limited to 'static/modules/xbox.js')
| -rw-r--r-- | static/modules/xbox.js | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/static/modules/xbox.js b/static/modules/xbox.js index 858d4c1..b6b1c45 100644 --- a/static/modules/xbox.js +++ b/static/modules/xbox.js @@ -99,26 +99,6 @@ function presenceLine(st) { // "XboxSeriesX" -> "Xbox Series X" const model = (t) => (t ?? "").replace(/([a-z])([A-Z])/g, "$1 $2"); -// The installed list stays open across redraws once opened. -let appsOpen = false; - -function appsList(apps) { - const box = h("details", "xb-apps"); - box.open = appsOpen; - box.ontoggle = () => { appsOpen = box.open; }; - const total = apps.reduce((n, a) => n + a.size, 0); - box.append(h("summary", "xb-section", `Installed · ${apps.length} · ${gb(total)}`)); - for (const a of apps) { - const sub = [a.version != null ? `v${a.version}` : null, a.updated ? `updated ${ago(a.updated)}` : null, - a.last ? `played ${ago(a.last)}` : null].filter(Boolean).join(" · "); - const r = h("div", `xb-app${a.game ? " game" : ""}`); - const text = h("div", "xb-rtext"); - text.append(h("div", "xb-rtitle", a.name ?? ""), h("div", "xb-rsub", sub)); - r.append(text, h("span", "xb-rside num", gb(a.size))); - box.append(r); - } - return box; -} function consoleCard(c, apps) { const on = c.power === "On"; @@ -162,7 +142,9 @@ function consoleCard(c, apps) { if (on_ != null) flags.append(h("span", `xb-flag${on_ ? " on" : ""}`, `${text} ${on_ ? "on" : "off"}`)); } card.append(flags); - if (apps?.length) card.append(appsList(apps)); + if (apps?.length) { + card.append(h("div", "xb-cmodel", `${apps.length} installed · ${gb(apps.reduce((n, a) => n + a.size, 0))}`)); + } card.append(h("div", "xb-err")); return card; } @@ -189,7 +171,15 @@ function nowPlaying(st) { function gameTile(t) { const tile = h("div", "xb-game"); - tile.append(img(t.cover, "xb-gcover"), h("div", "xb-gname", t.name ?? "")); + const art = h("div", "xb-gart"); + art.append(img(t.cover, "xb-gcover")); + if (t.installed) { + const badge = h("span", "xb-badge", `Installed · ${gb(t.installed.size)}`); + badge.title = [t.installed.version != null ? `v${t.installed.version}` : null, + t.installed.updated ? `updated ${ago(t.installed.updated)}` : null].filter(Boolean).join(" · "); + art.append(badge); + } + tile.append(art, h("div", "xb-gname", t.name ?? "")); if (t.type === "Game") { const a = t.achievements; const bar = h("div", "gbar"); @@ -251,7 +241,7 @@ function render(box, st) { } box.append(top); - box.append(h("div", "xb-section", "Recent games")); + box.append(h("div", "xb-section", "Games")); const games = h("div", "xb-games"); for (const t of st.titles ?? []) games.append(gameTile(t)); box.append(games); |
