blame.ts
typescript
sha256:a34090cc4a394a78bd72cbbe34b08cc59525141e19135b6c0ab154f10611b9ef
debug(push/stream): instrument O-frame decode path with INF…
Sonnet 4.6
patch
121 days ago
| 1 | /** |
| 2 | * blame.ts — MIDI note tooltip wiring for the blame page. |
| 3 | * |
| 4 | * For MIDI blame views, wires mouseenter/mouseleave on .blame2-note elements |
| 5 | * to show/hide the floating #blame2-tooltip panel. |
| 6 | * |
| 7 | * Registered as: window.MusePages['blame'] |
| 8 | */ |
| 9 | |
| 10 | function initMidiTooltip(): void { |
| 11 | const tip = document.getElementById('blame2-tooltip'); |
| 12 | if (!tip) return; |
| 13 | |
| 14 | document.querySelectorAll<HTMLElement>('.blame2-note').forEach((note) => { |
| 15 | note.addEventListener('mouseenter', () => { |
| 16 | const r = note.getBoundingClientRect(); |
| 17 | tip.innerHTML = |
| 18 | `<div class="blame2-tip-sha">${note.dataset['sha'] ?? ''}</div>` + |
| 19 | `<div class="blame2-tip-msg">${note.dataset['msg'] ?? ''}</div>` + |
| 20 | `<div class="blame2-tip-row"><span>Author</span><span>${note.dataset['author'] ?? ''}</span></div>` + |
| 21 | `<div class="blame2-tip-row"><span>Pitch</span><span>${note.dataset['pitch'] ?? ''}</span></div>` + |
| 22 | `<div class="blame2-tip-row"><span>Beat</span><span>${note.dataset['beat'] ?? ''}</span></div>` + |
| 23 | `<div class="blame2-tip-row"><span>Velocity</span><span>${note.dataset['vel'] ?? ''}</span></div>` + |
| 24 | `<div class="blame2-tip-row"><span>Duration</span><span>${note.dataset['dur'] ?? ''}</span></div>`; |
| 25 | tip.removeAttribute('aria-hidden'); |
| 26 | tip.style.display = 'block'; |
| 27 | const tipW = tip.offsetWidth; |
| 28 | const left = Math.min(r.left + window.scrollX, window.innerWidth - tipW - 12); |
| 29 | tip.style.left = `${left}px`; |
| 30 | tip.style.top = `${r.bottom + window.scrollY + 6}px`; |
| 31 | }); |
| 32 | |
| 33 | note.addEventListener('mouseleave', () => { |
| 34 | tip.style.display = 'none'; |
| 35 | tip.setAttribute('aria-hidden', 'true'); |
| 36 | }); |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | export function initBlame(data: Record<string, unknown>): void { |
| 41 | if (data['blameType'] === 'midi') { |
| 42 | initMidiTooltip(); |
| 43 | } |
| 44 | } |
File History
1 commit
sha256:a34090cc4a394a78bd72cbbe34b08cc59525141e19135b6c0ab154f10611b9ef
debug(push/stream): instrument O-frame decode path with INF…
Sonnet 4.6
patch
121 days ago