(track)
| 398 | } |
| 399 | |
| 400 | function applyTrackInfoToPanel(track) { |
| 401 | titleEl.textContent = track.title || "Untitled track"; |
| 402 | bpmChip.textContent = track.bpm ? `${track.bpm} BPM` : "— BPM"; |
| 403 | keyChip.textContent = track.key || "— —"; |
| 404 | updateFooterTrack({ |
| 405 | title: track.title, |
| 406 | thumbnail: track.thumb, |
| 407 | key: track.key, |
| 408 | bpm: track.bpm, |
| 409 | stemCount: (track.audioStems || track.stems || []).filter((s) => (s.name ?? s) !== "original").length || null, |
| 410 | }); |
| 411 | applyStemPresenceCards(track.stemPresence); |
| 412 | |
| 413 | const summaryKey = document.getElementById("summary-key"); |
| 414 | const summaryBpm = document.getElementById("summary-bpm"); |
| 415 | const summaryScale = document.getElementById("summary-scale"); |
| 416 | const summaryScaleName = document.getElementById("summary-scale-name"); |
| 417 | const summaryConfidence = document.getElementById("summary-confidence"); |
| 418 | const summaryConfidenceLabel = document.getElementById("summary-confidence-label"); |
| 419 | const summaryLufs = document.getElementById("summary-lufs"); |
| 420 | const summaryPeak = document.getElementById("summary-peak"); |
| 421 | const summaryDuration = document.getElementById("summary-duration"); |
| 422 | |
| 423 | if (summaryKey) summaryKey.textContent = track.key || "—"; |
| 424 | if (summaryBpm) summaryBpm.textContent = track.bpm ? String(track.bpm) : "—"; |
| 425 | if (summaryScale) summaryScale.textContent = track.scale || ""; |
| 426 | if (summaryScaleName) summaryScaleName.textContent = track.scale || "—"; |
| 427 | if (summaryLufs) summaryLufs.textContent = track.lufs != null ? Number(track.lufs).toFixed(1) : "—"; |
| 428 | if (summaryPeak) summaryPeak.textContent = track.peakDb != null ? `Peak ${Number(track.peakDb).toFixed(1)} dB` : ""; |
| 429 | if (summaryDuration) summaryDuration.textContent = track.duration ? fmtTime(track.duration) : "—"; |
| 430 | |
| 431 | const trackExtracted = document.getElementById("track-extracted"); |
| 432 | const trackSource = document.getElementById("track-source"); |
| 433 | const trackQuality = document.getElementById("track-quality"); |
| 434 | const favBtn = document.getElementById("fav-btn"); |
| 435 | if (trackExtracted) trackExtracted.textContent = fmtExtracted(track.createdAt); |
| 436 | if (trackSource) trackSource.textContent = deriveSource(track.sourceUrl); |
| 437 | if (trackQuality) trackQuality.textContent = deriveQuality(track.sourceUrl); |
| 438 | if (favBtn) { |
| 439 | favBtn.classList.toggle("active", Boolean(track.favorite)); |
| 440 | favBtn.setAttribute("aria-pressed", String(Boolean(track.favorite))); |
| 441 | favBtn.onclick = () => { |
| 442 | if (!_currentTrackId) return; |
| 443 | const t = tracks[_currentTrackId]; |
| 444 | if (!t) return; |
| 445 | t.favorite = !t.favorite; |
| 446 | favBtn.classList.toggle("active", t.favorite); |
| 447 | favBtn.setAttribute("aria-pressed", String(t.favorite)); |
| 448 | saveState(); |
| 449 | }; |
| 450 | } |
| 451 | |
| 452 | const summaryDr = document.getElementById("summary-dr"); |
| 453 | const summaryDrLabel = document.getElementById("summary-dr-label"); |
| 454 | const summaryStability = document.getElementById("summary-stability"); |
| 455 | const summaryStabilityLabel = document.getElementById("summary-stability-label"); |
| 456 | if (summaryDr) summaryDr.textContent = track.dynamicRange != null ? String(track.dynamicRange) : "—"; |
| 457 | if (summaryDrLabel) summaryDrLabel.textContent = track.dynamicRange != null ? drLabel(track.dynamicRange) : ""; |
no test coverage detected