46 lines
1.8 KiB
JavaScript
46 lines
1.8 KiB
JavaScript
// ── PROGRAM MODAL ─────────────────────────────────────────────────────────────
|
|
function openProgramModal(ch, p) {
|
|
const now = new Date();
|
|
const isLive = p.start <= now && p.stop > now;
|
|
const dur = Math.round((p.stop - p.start) / 60000);
|
|
const ep = fmtEpisode(p.season, p.episode);
|
|
|
|
document.getElementById('pm-title').textContent = p.title;
|
|
document.getElementById('pm-channel').textContent = ch.name;
|
|
document.getElementById('pm-time').textContent =
|
|
`${fmtTime(p.start)} — ${fmtTime(p.stop)} · ${dur} ${L.duration_min}` +
|
|
(ep ? ` · ${ep}` : '');
|
|
document.getElementById('pm-desc').textContent = p.desc || '';
|
|
document.getElementById('pm-desc').style.display = p.desc ? 'block' : 'none';
|
|
|
|
// Bouton Watch now — seulement si live ET M3U fourni pour la source active
|
|
const watchBtn = document.getElementById('pm-watch');
|
|
if (isLive && currentM3uUrl) {
|
|
watchBtn.style.display = 'inline-flex';
|
|
watchBtn.onclick = () => { closeProgramModal(); openPip(ch.name, p.title); };
|
|
} else {
|
|
watchBtn.style.display = 'none';
|
|
}
|
|
|
|
// Bouton IMDb
|
|
document.getElementById('pm-imdb').href =
|
|
`https://www.imdb.com/find/?q=${encodeURIComponent(p.title)}&s=tt`;
|
|
|
|
document.getElementById('programModal').classList.add('visible');
|
|
}
|
|
|
|
function closeProgramModal() {
|
|
document.getElementById('programModal').classList.remove('visible');
|
|
}
|
|
|
|
// Fermer sur clic overlay
|
|
document.addEventListener('click', e => {
|
|
const modal = document.getElementById('programModal');
|
|
if (e.target === modal) closeProgramModal();
|
|
});
|
|
|
|
// Fermer sur Escape
|
|
document.addEventListener('keydown', e => {
|
|
if (e.key === 'Escape') closeProgramModal();
|
|
});
|