aboutsummaryrefslogtreecommitdiffstats
path: root/static/modules
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-26 11:16:40 +0100
committerDanilo M. <danix@danix.xyz>2026-11-26 11:16:40 +0100
commitd842b3c49fe4c03993f32fb9bebbef954c54675d (patch)
treee88f36e59793104cf220642ad792ca8df3a9a392 /static/modules
parent6496d0660abf781ff2a76f97f9a5c03034d6cf45 (diff)
downloaddeck-it-d842b3c49fe4c03993f32fb9bebbef954c54675d.tar.gz
deck-it-d842b3c49fe4c03993f32fb9bebbef954c54675d.zip
feat(xbox): list, view and download uploaded captures
The slow read also searches mediahub for the user's screenshots and game clips. Their CDN URIs are signed, so the tab shows thumbnails and opens a capture in a dialog (outside the redrawn part, so a data change leaves it open) with a download link and a close button, straight from Microsoft. Only captures the console uploaded appear; an in-game photo mode (e.g. Rockstar's) is not an Xbox capture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'static/modules')
-rw-r--r--static/modules/xbox.js45
1 files changed, 42 insertions, 3 deletions
diff --git a/static/modules/xbox.js b/static/modules/xbox.js
index 7c569ed..094b1c0 100644
--- a/static/modules/xbox.js
+++ b/static/modules/xbox.js
@@ -208,6 +208,37 @@ function gameTile(t) {
return tile;
}
+// The viewer lives outside the redrawn part, so a data change leaves it open.
+// The links are signed CDN URIs; the CDN answers octet-stream, so the link downloads.
+function view(c, dlg) {
+ const media = c.kind === "clip" ? h("video", "xb-vmedia") : img(c.url, "xb-vmedia");
+ if (c.kind === "clip") Object.assign(media, { src: c.url, controls: true, autoplay: true, playsInline: true });
+ const a = h("a", "ib xb-vdl", "Download");
+ a.href = c.url;
+ a.download = `${c.id}.${c.kind === "clip" ? "mp4" : "png"}`;
+ a.referrerPolicy = "no-referrer";
+ const foot = h("div", "xb-vfoot");
+ foot.append(h("div", "xb-gmeta", [c.title, new Date(c.date).toLocaleString(),
+ c.expires ? `kept until ${new Date(c.expires).toLocaleDateString()}` : null].filter(Boolean).join(" · ")));
+ foot.append(a);
+ const close = h("button", "ib nf xb-vclose", "\u{F0156}");
+ close.setAttribute("aria-label", "Close");
+ close.onclick = () => dlg.close();
+ dlg.replaceChildren(media, foot, close);
+ dlg.onclose = () => dlg.replaceChildren(); // stops a clip still playing
+ dlg.showModal();
+}
+
+function captureTile(c, dlg) {
+ const tile = h("button", "xb-game xb-cap");
+ const art = h("div", "xb-gart");
+ art.append(img(c.thumb, "xb-gcover xb-ccover"));
+ if (c.kind === "clip") art.append(h("span", "xb-badge", `Clip · ${c.seconds ?? "?"} s`));
+ tile.append(art, h("div", "xb-gname", c.title ?? ""), h("div", "xb-gmeta", ago(c.date)));
+ tile.onclick = () => view(c, dlg);
+ return tile;
+}
+
function row(pic, title, sub, side, cls = "") {
const r = h("div", `xb-row ${cls}`);
const text = h("div", "xb-rtext");
@@ -240,7 +271,7 @@ function signIn(box, st) {
box.append(wrap);
}
-function render(box, st) {
+function render(box, st, dlg) {
box.textContent = "";
const p = st.profile ?? {};
const head = h("div", "xb-head");
@@ -267,6 +298,13 @@ function render(box, st) {
for (const t of st.titles ?? []) games.append(gameTile(t));
box.append(games);
+ if (st.captures?.length) {
+ box.append(h("div", "xb-section", "Captures"));
+ const caps = h("div", "xb-games");
+ for (const c of st.captures) caps.append(captureTile(c, dlg));
+ box.append(caps);
+ }
+
const lists = h("div", "xb-lists");
const ach = h("div", "xb-card xb-list");
ach.append(h("div", "xb-section", "Achievements"));
@@ -288,7 +326,8 @@ export default {
peek: (st) => sessionPeek(st),
mount(el) {
- el.innerHTML = '<div class="xbox"><div class="xb-off"></div><div class="xb-on"></div></div>';
+ el.innerHTML = '<div class="xbox"><div class="xb-off"></div><div class="xb-on"></div>' +
+ '<dialog class="xb-view" closedby="any"></dialog></div>';
},
update(st, el) {
@@ -315,7 +354,7 @@ export default {
on._key = key;
if (st.signed_in === false) signIn(on, st);
else if (st.loading) on.replaceChildren(h("div", "xb-loading", "Loading Xbox Live…"));
- else render(on, st);
+ else render(on, st, el.querySelector(".xb-view"));
}
const c = on.querySelector(".xb-clock");
if (c) c.textContent = clock(st.session);