This commit is contained in:
2026-05-09 22:01:20 +02:00
parent df64db6437
commit b6781414e1
4 changed files with 37 additions and 25 deletions
+10 -4
View File
@@ -17,6 +17,7 @@ let skippedIndices = [];
let lastElapsed = 0;
let lastUpdateTime = 0;
let currentRealTotal = 1;
let timeOffset = 0;
function toggleSection(id) {
document.getElementById(id).classList.toggle("collapsed");
@@ -90,10 +91,17 @@ function wsSend(obj) {
ws.send(JSON.stringify(obj));
}
// ─── Message Handling ────────────────────────────────────────────────────────
function handleMessage(msg) {
if(msg.time && timeOffset != 0) {
const now = performance.now() / 1000;
const lag = now - (msg.time + offset);
document.getElementById("ping-status").textContent = lag;
}
switch (msg.event) {
case "time": {
const localNow = performance.now() / 1000;
timeOffset = localNow - msg.data;
}
case "state": {
const d = msg.data || {};
if (d.dirs) updateDirs(d.dirs);
@@ -144,8 +152,6 @@ function renderAll() {
renderPlaylist();
}
// ─── Track State ─────────────────────────────────────────────────────────────
function trackLabel(track, index) {
const prefix = track.official ? "(official) " : "(unofficial) ";
return prefix + track.path.replace(basePath, "").slice(1);