Pick the simulator's stage map from a drop-down, and make the QLC+ show optional.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
df05c8ca49
commit
a295fefac0
8 files changed
+154
-20
No files matched your search
+41
-9
@@ -9,6 +9,7 @@ const detailEl = document.getElementById("detail");
|
||||
const detailTitle = document.getElementById("detail-title");
|
||||
const detailMeta = document.getElementById("detail-meta");
|
||||
const channelsEl = document.getElementById("channels");
|
||||
const stageFileEl = document.getElementById("stage-file");
|
||||
|
||||
let stage = null;
|
||||
let state = { fixtures: {}, age: null, rate: 0, universe: null, packets: 0 };
|
||||
@@ -592,18 +593,49 @@ canvas.addEventListener("pointercancel", () => {
|
||||
|
||||
window.addEventListener("resize", resize);
|
||||
|
||||
function showStage(loaded) {
|
||||
stage = loaded;
|
||||
selected = null;
|
||||
detailEl.hidden = true;
|
||||
nameEl.textContent = stage.name || "xchc";
|
||||
document.title = stage.name || "xchc";
|
||||
originEl.textContent = stage.origin || "";
|
||||
const show = stage.show ? stage.show : "addresses from the stage map";
|
||||
const target = stage.output_ip ? ` · QLC+ output ${stage.output_ip}` : "";
|
||||
patchEl.textContent = `${show}${target}`;
|
||||
buildList();
|
||||
resize();
|
||||
}
|
||||
|
||||
async function loadStageList() {
|
||||
const { current, stages } = await fetch("/api/stages").then((response) => response.json());
|
||||
stageFileEl.replaceChildren(
|
||||
...stages.map((name) => new Option(name.replace(/\.json$/, ""), name, false, name === current)),
|
||||
);
|
||||
stageFileEl.disabled = stages.length < 2;
|
||||
}
|
||||
|
||||
stageFileEl.addEventListener("change", async () => {
|
||||
stageFileEl.disabled = true;
|
||||
try {
|
||||
const response = await fetch("/api/stage", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ file: stageFileEl.value }),
|
||||
});
|
||||
if (!response.ok) throw new Error("bad stage");
|
||||
showStage(await response.json());
|
||||
} catch {
|
||||
statusEl.textContent = "could not load that stage";
|
||||
}
|
||||
await loadStageList().catch(() => {});
|
||||
});
|
||||
|
||||
fetch("/api/stage")
|
||||
.then((response) => response.json())
|
||||
.then((loaded) => {
|
||||
stage = loaded;
|
||||
nameEl.textContent = stage.name || "xchc";
|
||||
document.title = stage.name || "xchc";
|
||||
originEl.textContent = stage.origin || "";
|
||||
const show = stage.show ? stage.show : "stage file";
|
||||
const target = stage.output_ip ? ` · QLC+ output ${stage.output_ip}` : "";
|
||||
patchEl.textContent = `${show}${target}`;
|
||||
buildList();
|
||||
resize();
|
||||
showStage(loaded);
|
||||
loadStageList().catch(() => {});
|
||||
poll();
|
||||
setInterval(poll, 50);
|
||||
requestAnimationFrame(frame);
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
<h1 id="stage-name">xchc</h1>
|
||||
<p id="origin"></p>
|
||||
</div>
|
||||
<label class="stage-pick">Stage
|
||||
<select id="stage-file" aria-label="Stage map"></select>
|
||||
</label>
|
||||
<p id="status" class="pill">waiting for Art-Net</p>
|
||||
</header>
|
||||
<main>
|
||||
|
||||
@@ -30,8 +30,9 @@ body {
|
||||
header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
gap: 8px 16px;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
@@ -44,12 +45,32 @@ h1, h2 {
|
||||
|
||||
h2 { font-size: 14px; }
|
||||
|
||||
.titles { flex: 1 1 240px; }
|
||||
|
||||
.titles p, .meta {
|
||||
margin: 2px 0 0;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.stage-pick {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-left: auto;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.stage-pick select {
|
||||
padding: 3px 6px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
background: var(--panel);
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.pill {
|
||||
margin: 0;
|
||||
padding: 4px 10px;
|
||||
|
||||
Reference in new issue
Block a user