Improvment: Replacing change EPG menu.

This commit is contained in:
Johnnybegood90
2026-03-14 01:18:38 +01:00
4 changed files with 77 additions and 8 deletions
+39
View File
@@ -184,3 +184,42 @@
} }
.source-select:hover { border-color: var(--accent2); color: var(--accent2) !important; } .source-select:hover { border-color: var(--accent2); color: var(--accent2) !important; }
.source-select option { background: #111 !important; color: #eee !important; font-family: sans-serif; } .source-select option { background: #111 !important; color: #eee !important; font-family: sans-serif; }
/* ── SOURCE DROPDOWN ─────────────────────────────────────────────────────── */
.source-dropdown {
position: relative;
flex-shrink: 0;
}
.source-dropdown-btn {
display: flex; align-items: center; gap: 6px;
background: var(--surface2); border: 1px solid var(--border-bright);
color: var(--text); font-family: var(--font-mono); font-size: 11px;
letter-spacing: 0.06em; padding: 5px 10px; height: 28px;
cursor: pointer; white-space: nowrap;
transition: border-color 0.15s, color 0.15s;
}
.source-dropdown-btn:hover { border-color: var(--accent2); color: var(--accent2); }
.source-dropdown-arrow { font-size: 8px; opacity: 0.6; }
.source-dropdown-menu {
display: none; position: absolute; top: calc(100% + 4px); left: 0;
background: var(--surface); border: 1px solid var(--border-bright);
min-width: 160px; z-index: 1000;
flex-direction: column;
box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
.source-dropdown-menu.open { display: flex; }
.source-dropdown-item {
background: none; border: none; color: var(--text);
font-family: var(--font-mono); font-size: 11px;
letter-spacing: 0.06em; padding: 10px 14px;
text-align: left; cursor: pointer; white-space: nowrap;
transition: background 0.1s, color 0.1s;
border-bottom: 1px solid var(--border);
}
.source-dropdown-item:last-child { border-bottom: none; }
.source-dropdown-item:hover { background: var(--surface2); color: var(--accent2); }
.source-dropdown-item.active { color: var(--accent); }
.source-dropdown-personal { color: var(--accent2); }
+2 -4
View File
@@ -13,8 +13,7 @@ window.addEventListener('load', () => {
if (epg) { if (epg) {
currentEpgUrl = epg; currentEpgUrl = epg;
currentM3uUrl = m3u; currentM3uUrl = m3u;
const sel = document.getElementById('sourceSelect'); updateSourceDropdownLabel('✏ Personal EPG');
if (sel) sel.value = 'personal';
loadEPG(epg); loadEPG(epg);
if (m3u) loadM3U(m3u); if (m3u) loadM3U(m3u);
return; return;
@@ -26,8 +25,7 @@ window.addEventListener('load', () => {
activeSourceIndex = idx; activeSourceIndex = idx;
currentEpgUrl = src.epg_url; currentEpgUrl = src.epg_url;
currentM3uUrl = src.m3u_url ?? ''; currentM3uUrl = src.m3u_url ?? '';
const sel = document.getElementById('sourceSelect'); if (src) updateSourceDropdownLabel(src.name);
if (sel) sel.value = idx;
} }
} }
loadEPG(currentEpgUrl); loadEPG(currentEpgUrl);
+22
View File
@@ -49,6 +49,7 @@ function applyPersonalEpg() {
localStorage.setItem('gridtv-personal-epg', epg); localStorage.setItem('gridtv-personal-epg', epg);
localStorage.setItem('gridtv-personal-m3u', m3u); localStorage.setItem('gridtv-personal-m3u', m3u);
localStorage.setItem('gridtv-active-source', 'personal'); localStorage.setItem('gridtv-active-source', 'personal');
updateSourceDropdownLabel('✏ Personal EPG');
currentEpgUrl = epg; currentEpgUrl = epg;
currentM3uUrl = m3u; currentM3uUrl = m3u;
const sel = document.getElementById('sourceSelect'); const sel = document.getElementById('sourceSelect');
@@ -58,3 +59,24 @@ function applyPersonalEpg() {
if (m3u) loadM3U(m3u); if (m3u) loadM3U(m3u);
} }
function toggleSourceDropdown() {
document.getElementById('sourceDropdownMenu')?.classList.toggle('open');
}
function closeSourceDropdown() {
document.getElementById('sourceDropdownMenu')?.classList.remove('open');
}
// Fermer si clic en dehors
document.addEventListener('click', e => {
if (!e.target.closest('.source-dropdown')) closeSourceDropdown();
});
function updateSourceDropdownLabel(label) {
const el = document.getElementById('sourceDropdownLabel');
if (el) el.textContent = label;
// Mettre à jour la classe active
document.querySelectorAll('.source-dropdown-item').forEach((btn, i) => {
btn.classList.toggle('active', i === activeSourceIndex);
});
}
+14 -4
View File
@@ -14,14 +14,24 @@
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php if (count($epg_sources) > 1 || $allow_personal_epg): ?> <?php if (count($epg_sources) > 1 || $allow_personal_epg): ?>
<select class="source-select" id="sourceSelect" onchange="switchSource(this.value)" title="Source EPG"> <div class="source-dropdown" id="sourceDropdown">
<button class="source-dropdown-btn" onclick="toggleSourceDropdown()" id="sourceDropdownBtn">
<span id="sourceDropdownLabel"><?= htmlspecialchars($epg_sources[0]['name'] ?? 'EPG') ?></span>
<span class="source-dropdown-arrow">&#9660;</span>
</button>
<div class="source-dropdown-menu" id="sourceDropdownMenu">
<?php foreach ($epg_sources as $i => $src): ?> <?php foreach ($epg_sources as $i => $src): ?>
<option value="<?= $i ?>"><?= htmlspecialchars($src['name']) ?></option> <button class="source-dropdown-item<?= $i === 0 ? ' active' : '' ?>" onclick="switchSource(<?= $i ?>); closeSourceDropdown()">
<?= htmlspecialchars($src['name']) ?>
</button>
<?php endforeach; ?> <?php endforeach; ?>
<?php if ($allow_personal_epg): ?> <?php if ($allow_personal_epg): ?>
<option value="personal">✏ Personal EPG</option> <button class="source-dropdown-item source-dropdown-personal" onclick="switchSource('personal'); closeSourceDropdown()">
&#9998; Personal EPG
</button>
<?php endif; ?> <?php endif; ?>
</select> </div>
</div>
<?php endif; ?> <?php endif; ?>
<select class="theme-select" id="themeSelect" onchange="setTheme(this.value)" title="Thème"> <select class="theme-select" id="themeSelect" onchange="setTheme(this.value)" title="Thème">
<?php <?php