// No network, no session: the host sends {session, handle, vms, agents, vouches} over tp-data. const status = document.querySelector('.status') const list = (id, items, text) => document.getElementById(id).replaceChildren(...(items.length ? items : [null]).map((x) => Object.assign(document.createElement('li'), x ? { textContent: text(x) } : { className: 'muted', textContent: 'none' }))) try { const { addDataHandler, listen } = await import('/.well-known/web-tiles/data.js') addDataHandler((s) => { status.textContent = s.session === 'signed-in' ? `${s.handle}` : 'Sign in on the host page.' list('vms', s.vms ?? [], (v) => `${v.vm}: ${v.cpus} vCPUs, ${v.mem} GiB, until ${v.expires}`) list('agents', s.agents ?? [], (a) => `${a.nick} (${a.subhandle}) on ${a.vm}`) list('vouches', s.vouches ?? [], (v) => `${v.subject}${v.reason ? `: ${v.reason}` : ''}`) }) listen() } catch (error) { status.textContent = `This tile needs a host that speaks tp-data: ${error.message}` }