File size: 2,937 Bytes
e35b538
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
body { margin: 0; font: 15px system-ui, sans-serif; color: #17212d; background: #fff; }
video { display: block; width: 100%; max-height: 248px; background: #111; border-radius: 8px; }
label { display: block; margin: 8px 0; }
input { width: calc(100% - 4px); margin: 0; }
#predictions { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
article { border: 1px solid #bbc4cf; border-radius: 8px; padding: 10px; }
h2 { font-size: 14px; margin: 0 0 6px; }
p { margin: 4px 0; }
@media (prefers-color-scheme: dark) {
  body { color: #e5e7eb; background: #111827; }
  article { border-color: #667185; }
}
</style>
</head>
<body>
<video id="video" controls preload="none" playsinline hidden></video>
<p id="status" role="status"></p>
<label for="position">Playback time <output id="seconds" for="position">0.00 s</output></label>
<input type="range" id="position" min="0" step="0.01">
<section id="predictions" aria-label="Model predictions"></section>
<script>
const data = /* PAYLOAD */;
const video = document.getElementById("video");
const slider = document.getElementById("position");
const status = document.getElementById("status");
const seconds = document.getElementById("seconds");
const cards = {};
slider.max = data.duration;
if (data.video) {
    video.hidden = false;
    video.src = data.video;
    video.addEventListener("error", () => {
        status.textContent = "This browser could not play the source video. You can still use the timeline slider.";
    });
}
for (const [arm, name] of Object.entries(data.arms)) {
    const card = document.createElement("article");
    const title = document.createElement("h2");
    title.textContent = name;
    const guess = document.createElement("p");
    const confirmed = document.createElement("p");
    card.append(title, guess, confirmed);
    document.getElementById("predictions").append(card);
    cards[arm] = {guess, confirmed};
}
function update(time) {
    slider.value = time;
    seconds.textContent = time.toFixed(2) + " s";
    for (const [arm, {guess, confirmed}] of Object.entries(cards)) {
        const result = data.predictions[arm];
        let last;
        for (const tick of result.ticks) {
            if (tick.time > time) break;
            last = tick;
        }
        guess.textContent = "Current guess: " + (last?.label ?? "—");
        confirmed.textContent = "Confirmed: " + (
            result.early && result.early.time <= time
                ? result.early.label + " at " + result.early.time.toFixed(2) + " s"
                : "—"
        );
    }
}
slider.addEventListener("input", () => {
    const time = Number(slider.value);
    if (data.video && video.readyState >= 1) video.currentTime = time;
    update(time);
});
video.addEventListener("timeupdate", () => update(video.currentTime));
update(0);
</script>
</body>
</html>