// ── HELPERS ────────────────────────────────────────────────────────────────── function getNowPlaying(chId) { const now = new Date(); const p = (programs[chId] || []).find(p => p.start <= now && p.stop > now); return p ? p.title : null; } // ── TOOLTIP ─────────────────────────────────────────────────────────────────── function showTooltip(e, p) { const ep = fmtEpisode(p.season, p.episode); const genres = formatCategories(p.categories); const title = p.title + (p.subtitle ? ` - ${p.subtitle}` : '') + (ep ? ' ' + ep : ''); const meta = [p.airDate, p.rating, genres].filter(Boolean).join(' · '); document.getElementById('tt-title').textContent = title; document.getElementById('tt-time').textContent = `${fmtTime(p.start)} — ${fmtTime(p.stop)} · ${Math.round((p.stop-p.start)/60000)} min` + (meta ? ` · ${meta}` : ''); document.getElementById('tt-desc').textContent = p.desc || '—'; document.getElementById('tooltip').classList.add('visible'); moveTooltip(e); } function moveTooltip(e) { const tt = document.getElementById('tooltip'); const x=e.clientX+16, y=e.clientY+16; tt.style.left = (x+tt.offsetWidth >window.innerWidth ? x-tt.offsetWidth -32 : x)+'px'; tt.style.top = (y+tt.offsetHeight>window.innerHeight ? y-tt.offsetHeight-32 : y)+'px'; } function hideTooltip() { document.getElementById('tooltip').classList.remove('visible'); }