Repository navigation
Expand file tree
/
Copy pathlive-preview.html
More file actions
27 lines (27 loc) · 1.58 KB
/
Copy pathlive-preview.html
File metadata and controls
27 lines (27 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!doctype html><meta charset=utf-8><title>codex-gpui live preview</title>
<style>
body{margin:0;background:#111;color:#ddd;font:14px system-ui}
header{position:sticky;top:0;padding:8px 16px;background:#000;display:flex;gap:16px;align-items:center}
#st{padding:2px 10px;border-radius:10px;font-weight:600}
.ok{background:#1a7f37}.building{background:#9a6700}.failed{background:#cf222e}
main{padding:16px}h2{font-size:13px;margin:16px 0 6px;color:#999}img{max-width:100%;border:1px solid #333}
pre{background:#200;color:#fbb;padding:12px;overflow:auto;max-height:70vh}
</style>
<header><b>codex-gpui live preview</b><span id=st>…</span><span id=info></span></header>
<main><pre id=err hidden></pre><div id=shots></div></main>
<script>
const $=id=>document.getElementById(id);let seen={};
async function tick(){try{
const s=await (await fetch('status.json?'+Date.now())).json();
$('st').textContent=s.state;$('st').className=s.state;
const t=s.last_ok?new Date(s.last_ok*1000).toLocaleTimeString():'never';
$('info').textContent=`last good build ${t} (${s.secs}s)`;
$('err').hidden=s.state!=='failed';$('err').textContent=s.error;
// On failure show no images: they would be stale.
if(s.state==='failed'){$('shots').hidden=true}else{$('shots').hidden=false}
for(const x of s.shots){let img=$('i_'+x.name);
if(!img){$('shots').insertAdjacentHTML('beforeend',`<h2>${x.name}</h2><img id=i_${x.name}>`);img=$('i_'+x.name)}
if(seen[x.name]!==x.v){seen[x.name]=x.v;img.src=`img/${x.name}.png?v=${x.v}`}}
}catch(e){$('st').textContent='offline';$('st').className='failed'}}
tick();setInterval(tick,1000);
</script>