28 lines
1.4 KiB
JavaScript
28 lines
1.4 KiB
JavaScript
// ── 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);
|
|
document.getElementById('tt-title').textContent = p.title + (ep ? ' ' + ep : '');
|
|
document.getElementById('tt-time').textContent = `${fmtTime(p.start)} — ${fmtTime(p.stop)} · ${Math.round((p.stop-p.start)/60000)} min`;
|
|
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'); }
|
|
|
|
|
|
|
|
|