(trackId, sections, duration)
| 23 | // ─── Public API ─────────────────────────────────────────── |
| 24 | |
| 25 | export function initSections(trackId, sections, duration) { |
| 26 | _trackId = trackId; |
| 27 | _duration = Math.max(1, duration || 0); |
| 28 | _sections = (sections || []).map((s) => ({ ...s })); |
| 29 | _container = document.getElementById("daw-sections"); |
| 30 | if (!_container) return; |
| 31 | |
| 32 | // Wire the static "Add" button in the label area (may already be wired) |
| 33 | const addBtn = document.getElementById("sectionsAddBtn"); |
| 34 | if (addBtn && !addBtn.dataset.sectionsWired) { |
| 35 | addBtn.dataset.sectionsWired = "1"; |
| 36 | addBtn.addEventListener("click", () => _addSection()); |
| 37 | } |
| 38 | |
| 39 | _render(); |
| 40 | } |
| 41 | |
| 42 | export function destroySections() { |
| 43 | // Flush any pending debounced save before clearing state so switching tracks |
no test coverage detected