fix: persist active EPG source selection in localStorage
This commit is contained in:
@@ -1279,9 +1279,9 @@ function switchSource(value) {
|
||||
activeSourceIndex = idx;
|
||||
currentEpgUrl = src.epg_url;
|
||||
currentM3uUrl = src.m3u_url ?? '';
|
||||
localStorage.setItem('gridtv-active-source', idx);
|
||||
loadEPG(currentEpgUrl);
|
||||
if (currentM3uUrl) loadM3U(currentM3uUrl);
|
||||
// Mettre à jour les boutons copy
|
||||
updateCopyButtons();
|
||||
}
|
||||
|
||||
@@ -1298,11 +1298,13 @@ function openPersonalEpgModal() {
|
||||
modal.classList.add('visible');
|
||||
}
|
||||
|
||||
function closePersonalEpgModal() {
|
||||
function closePersonalEpgModal(applied) {
|
||||
document.getElementById('personalEpgModal').classList.remove('visible');
|
||||
// Si annulé, remettre le select sur la source précédente
|
||||
// Si annulé (pas applied), remettre le select sur la source précédente
|
||||
if (!applied) {
|
||||
const sel = document.getElementById('sourceSelect');
|
||||
if (sel) sel.value = activeSourceIndex;
|
||||
if (sel) sel.value = localStorage.getItem('gridtv-active-source') === 'personal' ? 'personal' : activeSourceIndex;
|
||||
}
|
||||
}
|
||||
|
||||
function applyPersonalEpg() {
|
||||
@@ -1311,9 +1313,12 @@ function applyPersonalEpg() {
|
||||
if (!epg) { alert('URL EPG obligatoire'); return; }
|
||||
localStorage.setItem('gridtv-personal-epg', epg);
|
||||
localStorage.setItem('gridtv-personal-m3u', m3u);
|
||||
localStorage.setItem('gridtv-active-source', 'personal');
|
||||
currentEpgUrl = epg;
|
||||
currentM3uUrl = m3u;
|
||||
closePersonalEpgModal();
|
||||
const sel = document.getElementById('sourceSelect');
|
||||
if (sel) sel.value = 'personal';
|
||||
closePersonalEpgModal(true);
|
||||
loadEPG(epg);
|
||||
if (m3u) loadM3U(m3u);
|
||||
}
|
||||
@@ -1460,7 +1465,34 @@ window.addEventListener('resize', () => {
|
||||
if (m !== lastMobile) { lastMobile=m; scrollListenerAdded=false; if (channels.length) renderAll(); }
|
||||
});
|
||||
|
||||
window.addEventListener('load', () => { loadEPG(DEFAULT_EPG_URL); loadM3U(DEFAULT_M3U_URL); });
|
||||
window.addEventListener('load', () => {
|
||||
const savedSource = localStorage.getItem('gridtv-active-source');
|
||||
if (savedSource === 'personal') {
|
||||
const epg = localStorage.getItem('gridtv-personal-epg');
|
||||
const m3u = localStorage.getItem('gridtv-personal-m3u') ?? '';
|
||||
if (epg) {
|
||||
currentEpgUrl = epg;
|
||||
currentM3uUrl = m3u;
|
||||
const sel = document.getElementById('sourceSelect');
|
||||
if (sel) sel.value = 'personal';
|
||||
loadEPG(epg);
|
||||
if (m3u) loadM3U(m3u);
|
||||
return;
|
||||
}
|
||||
} else if (savedSource !== null) {
|
||||
const idx = parseInt(savedSource);
|
||||
const src = EPG_SOURCES[idx];
|
||||
if (src) {
|
||||
activeSourceIndex = idx;
|
||||
currentEpgUrl = src.epg_url;
|
||||
currentM3uUrl = src.m3u_url ?? '';
|
||||
const sel = document.getElementById('sourceSelect');
|
||||
if (sel) sel.value = idx;
|
||||
}
|
||||
}
|
||||
loadEPG(currentEpgUrl);
|
||||
loadM3U(currentM3uUrl);
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- MODAL PERSONAL EPG -->
|
||||
|
||||
Reference in New Issue
Block a user