Opdateringer
This commit is contained in:
@@ -6,198 +6,182 @@
|
||||
<title>LineDance — Live</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #0a0b0d;
|
||||
--surface: #13151a;
|
||||
--border: #252830;
|
||||
--accent: #e8a020;
|
||||
--text: #eceef4;
|
||||
--muted: #60687a;
|
||||
--green: #27ae60;
|
||||
--gray: #3a3f4b;
|
||||
--bg: #0a0b0d;
|
||||
--surface: #13151a;
|
||||
--border: #252830;
|
||||
--accent: #e8a020;
|
||||
--text: #eceef4;
|
||||
--muted: #60687a;
|
||||
--green: #27ae60;
|
||||
--played: #2d3a2e;
|
||||
--skip: #2a2020;
|
||||
}
|
||||
.light {
|
||||
--bg: #f5f4ef;
|
||||
--surface: #ffffff;
|
||||
--border: #dddbd3;
|
||||
--accent: #c47a10;
|
||||
--text: #1a1c22;
|
||||
--muted: #7a7a6a;
|
||||
--green: #1e8449;
|
||||
--played: #eaf4ea;
|
||||
--skip: #f4eaea;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
html, body { height: 100%; }
|
||||
body {
|
||||
background: var(--bg); color: var(--text);
|
||||
font-family: 'Segoe UI', system-ui, sans-serif;
|
||||
min-height: 100vh; display: flex; flex-direction: column;
|
||||
transition: background .3s, color .3s;
|
||||
}
|
||||
|
||||
/* ── Header ── */
|
||||
header {
|
||||
padding: .75rem 1.5rem;
|
||||
padding: .6rem 1.25rem;
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
border-bottom: 1px solid var(--border); flex-shrink: 0;
|
||||
}
|
||||
.logo { font-size: .85rem; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
|
||||
.logo { font-size: .8rem; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
|
||||
.logo b { color: var(--accent); }
|
||||
.live-dot {
|
||||
display: flex; align-items: center; gap: .4rem;
|
||||
font-size: .75rem; color: var(--muted);
|
||||
|
||||
.header-right { display: flex; align-items: center; gap: .75rem; }
|
||||
|
||||
/* Countdown ring */
|
||||
.countdown-wrap { display: flex; align-items: center; gap: .4rem; }
|
||||
.countdown-svg { width: 24px; height: 24px; flex-shrink: 0; }
|
||||
.countdown-bg { fill: none; stroke: var(--border); stroke-width: 3; }
|
||||
.countdown-arc {
|
||||
fill: none; stroke: var(--accent); stroke-width: 3;
|
||||
stroke-linecap: round;
|
||||
stroke-dasharray: 56.5;
|
||||
stroke-dashoffset: 0;
|
||||
transform: rotate(-90deg);
|
||||
transform-origin: 50% 50%;
|
||||
transition: stroke-dashoffset .9s linear;
|
||||
}
|
||||
.dot {
|
||||
width: 7px; height: 7px; border-radius: 50%;
|
||||
background: var(--muted); transition: background .3s;
|
||||
.countdown-num {
|
||||
font-size: .7rem; color: var(--muted);
|
||||
font-variant-numeric: tabular-nums; min-width: 1.2rem;
|
||||
}
|
||||
|
||||
/* Live dot */
|
||||
.live-dot { display: flex; align-items: center; gap: .35rem; font-size: .72rem; color: var(--muted); }
|
||||
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); transition: background .3s; }
|
||||
.dot.active { background: var(--green); animation: pulse 2s infinite; }
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; } 50% { opacity: .4; }
|
||||
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }
|
||||
|
||||
/* Theme toggle */
|
||||
.theme-btn {
|
||||
background: none; border: 1px solid var(--border); border-radius: 6px;
|
||||
padding: .25rem .5rem; cursor: pointer; color: var(--muted);
|
||||
font-size: .78rem; transition: all .15s;
|
||||
}
|
||||
.theme-btn:hover { border-color: var(--accent); color: var(--text); }
|
||||
|
||||
/* ── Now playing ── */
|
||||
#now-playing {
|
||||
padding: 2rem 1.5rem 1.5rem;
|
||||
flex-shrink: 0;
|
||||
padding: 1.75rem 1.25rem 1.25rem; flex-shrink: 0;
|
||||
}
|
||||
.np-label {
|
||||
font-size: .7rem; letter-spacing: .15em; text-transform: uppercase;
|
||||
color: var(--accent); font-weight: 600; margin-bottom: .6rem;
|
||||
}
|
||||
.np-title {
|
||||
font-size: clamp(1.8rem, 6vw, 3.5rem);
|
||||
font-weight: 700; line-height: 1.1;
|
||||
color: var(--text); margin-bottom: .3rem;
|
||||
}
|
||||
.np-artist {
|
||||
font-size: clamp(1rem, 3vw, 1.6rem);
|
||||
color: var(--muted); margin-bottom: .75rem;
|
||||
font-size: .65rem; letter-spacing: .18em; text-transform: uppercase;
|
||||
color: var(--accent); font-weight: 700; margin-bottom: .5rem;
|
||||
}
|
||||
/* Dans er primær */
|
||||
.np-dance {
|
||||
display: inline-block;
|
||||
font-size: clamp(.85rem, 2.5vw, 1.2rem);
|
||||
font-weight: 600; color: #111;
|
||||
background: var(--accent); padding: .3rem .9rem;
|
||||
border-radius: 6px; margin-bottom: 1rem;
|
||||
font-size: clamp(2rem, 7vw, 4.5rem);
|
||||
font-weight: 800; line-height: 1; color: var(--text);
|
||||
margin-bottom: .4rem; letter-spacing: -.02em;
|
||||
}
|
||||
.np-dance:empty { display: none; }
|
||||
.np-dance:empty::before { content: '—'; color: var(--muted); }
|
||||
/* Sang + artist sekundær */
|
||||
.np-song {
|
||||
font-size: clamp(.9rem, 2.5vw, 1.3rem);
|
||||
color: var(--muted); margin-bottom: 1rem; line-height: 1.3;
|
||||
}
|
||||
.np-song span { color: var(--text); font-weight: 500; }
|
||||
|
||||
/* Progress bar */
|
||||
.progress-bar {
|
||||
height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
|
||||
margin-bottom: .5rem;
|
||||
}
|
||||
.progress-fill {
|
||||
height: 100%; background: var(--accent);
|
||||
border-radius: 2px; transition: width .3s;
|
||||
width: 0%;
|
||||
}
|
||||
.progress-text {
|
||||
font-size: .75rem; color: var(--muted);
|
||||
display: flex; justify-content: space-between;
|
||||
}
|
||||
/* Progress */
|
||||
.progress-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: .4rem; }
|
||||
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; width: 0%; }
|
||||
.progress-text { font-size: .72rem; color: var(--muted); display: flex; justify-content: space-between; }
|
||||
|
||||
/* ── Divider ── */
|
||||
.divider {
|
||||
border: none; border-top: 1px solid var(--border);
|
||||
margin: .5rem 1.5rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ── Next up label ── */
|
||||
.divider { border: none; border-top: 1px solid var(--border); margin: .5rem 1.25rem; flex-shrink: 0; }
|
||||
.next-label {
|
||||
padding: .6rem 1.5rem .4rem;
|
||||
font-size: .7rem; letter-spacing: .15em; text-transform: uppercase;
|
||||
padding: .5rem 1.25rem .3rem;
|
||||
font-size: .65rem; letter-spacing: .15em; text-transform: uppercase;
|
||||
color: var(--muted); font-weight: 600; flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ── Song list ── */
|
||||
#song-list {
|
||||
flex: 1; overflow-y: auto;
|
||||
padding: 0 1rem .5rem;
|
||||
}
|
||||
#song-list { flex: 1; overflow-y: auto; padding: .25rem .75rem .5rem; }
|
||||
#song-list::-webkit-scrollbar { width: 3px; }
|
||||
#song-list::-webkit-scrollbar-thumb { background: var(--border); }
|
||||
|
||||
.song-item {
|
||||
display: flex; align-items: center; gap: .75rem;
|
||||
padding: .55rem .5rem; border-radius: 8px;
|
||||
transition: background .15s;
|
||||
display: flex; align-items: center; gap: .6rem;
|
||||
padding: .45rem .5rem; border-radius: 7px; transition: background .1s;
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
.song-item.playing {
|
||||
background: rgba(232,160,32,.08);
|
||||
border: 1px solid rgba(232,160,32,.2);
|
||||
background: rgba(232,160,32,.09);
|
||||
border: 1px solid rgba(232,160,32,.22);
|
||||
}
|
||||
.song-item.played { opacity: .35; }
|
||||
.song-item.skipped { opacity: .2; }
|
||||
.song-item.played { background: var(--played); opacity: .55; }
|
||||
.song-item.skipped { background: var(--skip); opacity: .35; }
|
||||
|
||||
.song-num { font-size: .7rem; color: var(--muted); width: 1.4rem; text-align: right; flex-shrink: 0; }
|
||||
.song-check { width: 1.1rem; flex-shrink: 0; text-align: center; font-size: .75rem; color: var(--muted); }
|
||||
.song-item.played .song-check { color: var(--green); }
|
||||
|
||||
.song-num {
|
||||
font-size: .72rem; color: var(--muted);
|
||||
width: 1.6rem; text-align: right; flex-shrink: 0;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.song-check {
|
||||
width: 1.2rem; flex-shrink: 0; text-align: center;
|
||||
font-size: .8rem;
|
||||
}
|
||||
.song-info { flex: 1; min-width: 0; }
|
||||
|
||||
/* Dans er primær i listen også */
|
||||
.song-dance-name {
|
||||
font-size: clamp(.82rem, 2vw, 1rem); font-weight: 600;
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
color: var(--text);
|
||||
}
|
||||
.song-dance-name:empty { display: none; }
|
||||
.song-title-sm {
|
||||
font-size: clamp(.82rem, 2vw, .95rem); font-weight: 500;
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.song-artist-sm {
|
||||
font-size: clamp(.7rem, 1.8vw, .8rem); color: var(--muted);
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.song-dance-sm {
|
||||
font-size: .7rem; color: var(--accent); flex-shrink: 0;
|
||||
font-weight: 500; max-width: 100px;
|
||||
font-size: clamp(.7rem, 1.6vw, .82rem); color: var(--muted);
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* ── Empty / loading ── */
|
||||
#empty {
|
||||
display: flex; flex-direction: column; align-items: center;
|
||||
justify-content: center; flex: 1; gap: 1rem;
|
||||
/* ── States ── */
|
||||
#empty, #no-event, #picker {
|
||||
display: none; flex-direction: column; align-items: center;
|
||||
justify-content: center; flex: 1; gap: .75rem;
|
||||
color: var(--muted); text-align: center; padding: 2rem;
|
||||
}
|
||||
.spinner {
|
||||
width: 32px; height: 32px; border: 2px solid var(--border);
|
||||
border-top-color: var(--accent); border-radius: 50%;
|
||||
animation: spin .8s linear infinite;
|
||||
}
|
||||
.spinner { width: 28px; height: 28px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
.no-event-icon { font-size: 2.5rem; opacity: .25; }
|
||||
.big-text { font-size: 1rem; color: var(--text); }
|
||||
.playlist-pick-btn {
|
||||
background: var(--surface); border: 1px solid var(--border);
|
||||
border-radius: 10px; padding: .8rem 1.1rem; width: 100%; max-width: 320px;
|
||||
text-align: left; cursor: pointer; color: var(--text); font-family: inherit;
|
||||
transition: all .15s;
|
||||
}
|
||||
.playlist-pick-btn:hover { border-color: var(--accent); }
|
||||
.playlist-pick-btn strong { display: block; font-size: .9rem; margin-bottom: .15rem; }
|
||||
.playlist-pick-btn span { font-size: .75rem; color: var(--muted); }
|
||||
|
||||
/* ── Footer ── */
|
||||
footer {
|
||||
padding: .6rem 1.5rem; border-top: 1px solid var(--border);
|
||||
font-size: .7rem; color: var(--muted);
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
flex-shrink: 0;
|
||||
padding: .5rem 1.25rem; border-top: 1px solid var(--border);
|
||||
font-size: .68rem; color: var(--muted);
|
||||
display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
|
||||
}
|
||||
#last-updated { font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* ── No event ── */
|
||||
#no-event {
|
||||
display: none; flex-direction: column; align-items: center;
|
||||
justify-content: center; flex: 1; gap: .75rem;
|
||||
color: var(--muted); text-align: center; padding: 3rem;
|
||||
}
|
||||
.no-event-icon { font-size: 2.5rem; opacity: .3; }
|
||||
|
||||
/* Playlist vælger */
|
||||
#picker {
|
||||
display: none; flex-direction: column; align-items: center;
|
||||
justify-content: center; flex: 1; gap: 1rem; padding: 2rem;
|
||||
}
|
||||
#picker h2 { font-size: 1.1rem; color: var(--text); }
|
||||
#picker p { font-size: .85rem; color: var(--muted); text-align: center; max-width: 320px; }
|
||||
.playlist-pick-btn {
|
||||
background: var(--surface); border: 1px solid var(--border);
|
||||
border-radius: 10px; padding: .9rem 1.25rem; width: 100%; max-width: 340px;
|
||||
text-align: left; cursor: pointer; transition: all .15s; color: var(--text);
|
||||
font-family: inherit;
|
||||
}
|
||||
.playlist-pick-btn:hover { border-color: var(--accent); background: rgba(232,160,32,.06); }
|
||||
.playlist-pick-btn strong { display: block; font-size: .95rem; margin-bottom: .2rem; }
|
||||
.playlist-pick-btn span { font-size: .78rem; color: var(--muted); }
|
||||
|
||||
@media (min-width: 600px) {
|
||||
#now-playing { padding: 2.5rem 2.5rem 1.5rem; }
|
||||
.next-label { padding-left: 2.5rem; }
|
||||
#song-list { padding: 0 1.5rem .5rem; }
|
||||
header, footer { padding-left: 2.5rem; padding-right: 2.5rem; }
|
||||
.divider { margin-left: 2.5rem; margin-right: 2.5rem; }
|
||||
#now-playing, .next-label, footer { padding-left: 2rem; padding-right: 2rem; }
|
||||
.divider { margin-left: 2rem; margin-right: 2rem; }
|
||||
#song-list { padding-left: 1.25rem; padding-right: 1.25rem; }
|
||||
header { padding-left: 2rem; padding-right: 2rem; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
@@ -205,38 +189,40 @@
|
||||
|
||||
<header>
|
||||
<div class="logo">LINE<b>DANCE</b></div>
|
||||
<div class="live-dot">
|
||||
<div class="dot" id="live-dot"></div>
|
||||
<span id="live-label">Forbinder...</span>
|
||||
<div class="header-right">
|
||||
<div class="countdown-wrap" title="Opdateres om...">
|
||||
<svg class="countdown-svg" viewBox="0 0 20 20">
|
||||
<circle class="countdown-bg" cx="10" cy="10" r="9"/>
|
||||
<circle class="countdown-arc" id="countdown-arc" cx="10" cy="10" r="9"/>
|
||||
</svg>
|
||||
<span class="countdown-num" id="countdown-num">5</span>
|
||||
</div>
|
||||
<div class="live-dot">
|
||||
<div class="dot" id="live-dot"></div>
|
||||
<span id="live-label">Forbinder...</span>
|
||||
</div>
|
||||
<button class="theme-btn" id="theme-btn" onclick="toggleTheme()">☀ Lyst</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Playlist vælger -->
|
||||
<div id="picker">
|
||||
<h2>Vælg playliste</h2>
|
||||
<p>Ingen aktiv playliste fundet. Vælg en nedenfor eller brug URL-parametret <code>?id=PLAYLIST_ID</code></p>
|
||||
<h2 style="font-size:1.05rem;color:var(--text)">Vælg playliste</h2>
|
||||
<p>Brug URL-parametret <code>?id=PLAYLIST_ID</code> eller vælg herunder</p>
|
||||
<div id="picker-list"></div>
|
||||
</div>
|
||||
|
||||
<!-- Ingen event -->
|
||||
<div id="no-event">
|
||||
<div class="no-event-icon">🎵</div>
|
||||
<div style="font-size:1rem;color:var(--text)">Ingen aktiv playliste</div>
|
||||
<div class="big-text">Ingen aktiv playliste</div>
|
||||
<div>Åbn LineDance Player og start et event</div>
|
||||
</div>
|
||||
|
||||
<!-- Loading -->
|
||||
<div id="empty" style="display:none">
|
||||
<div class="spinner"></div>
|
||||
<span>Henter data...</span>
|
||||
</div>
|
||||
<div id="empty"><div class="spinner"></div></div>
|
||||
|
||||
<!-- Now playing -->
|
||||
<div id="now-playing" style="display:none">
|
||||
<div class="np-label">▶ Spiller nu</div>
|
||||
<div class="np-title" id="np-title">—</div>
|
||||
<div class="np-artist" id="np-artist"></div>
|
||||
<div class="np-label" id="np-label">▶ Spiller nu</div>
|
||||
<div class="np-dance" id="np-dance"></div>
|
||||
<div class="np-song" id="np-song"></div>
|
||||
<div class="progress-bar"><div class="progress-fill" id="np-progress"></div></div>
|
||||
<div class="progress-text">
|
||||
<span id="np-played">0 afspillet</span>
|
||||
@@ -245,7 +231,7 @@
|
||||
</div>
|
||||
|
||||
<hr class="divider" id="divider" style="display:none">
|
||||
<div class="next-label" id="next-label" style="display:none">Kommende</div>
|
||||
<div class="next-label" id="next-label" style="display:none">Kommende dans</div>
|
||||
<div id="song-list"></div>
|
||||
|
||||
<footer>
|
||||
@@ -255,149 +241,180 @@
|
||||
|
||||
<script>
|
||||
const API = '/api';
|
||||
const POLL_SECS = 5;
|
||||
let playlistId = new URLSearchParams(location.search).get('id');
|
||||
let pollTimer = null;
|
||||
let lastData = null;
|
||||
let countdownTimer = null;
|
||||
let countdownVal = POLL_SECS;
|
||||
let dark = localStorage.getItem('ld_live_theme') !== 'light';
|
||||
|
||||
// ── Tema ──────────────────────────────────────────────────────────────────────
|
||||
function applyTheme() {
|
||||
document.body.classList.toggle('light', !dark);
|
||||
document.getElementById('theme-btn').textContent = dark ? '☀ Lyst' : '● Mørkt';
|
||||
}
|
||||
function toggleTheme() {
|
||||
dark = !dark;
|
||||
localStorage.setItem('ld_live_theme', dark ? 'dark' : 'light');
|
||||
applyTheme();
|
||||
}
|
||||
applyTheme();
|
||||
|
||||
// ── Countdown ring ────────────────────────────────────────────────────────────
|
||||
const CIRC = 56.5;
|
||||
function startCountdown() {
|
||||
countdownVal = POLL_SECS;
|
||||
updateCountdown();
|
||||
clearInterval(countdownTimer);
|
||||
countdownTimer = setInterval(() => {
|
||||
countdownVal--;
|
||||
if (countdownVal <= 0) countdownVal = POLL_SECS;
|
||||
updateCountdown();
|
||||
}, 1000);
|
||||
}
|
||||
function updateCountdown() {
|
||||
const frac = countdownVal / POLL_SECS;
|
||||
document.getElementById('countdown-arc').style.strokeDashoffset = CIRC * (1 - frac);
|
||||
document.getElementById('countdown-num').textContent = countdownVal;
|
||||
}
|
||||
|
||||
// ── Fetch & render ────────────────────────────────────────────────────────────
|
||||
function fmt(s) { return (s||'').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); }
|
||||
function fmtTime(d) {
|
||||
if (!d) return '';
|
||||
const now = new Date(d);
|
||||
return now.toLocaleTimeString('da-DK', { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
||||
return new Date(d).toLocaleTimeString('da-DK', { hour:'2-digit', minute:'2-digit', second:'2-digit' });
|
||||
}
|
||||
|
||||
async function loadAndRender() {
|
||||
if (!playlistId) {
|
||||
await showPicker();
|
||||
return;
|
||||
}
|
||||
if (!playlistId) { await showPicker(); return; }
|
||||
try {
|
||||
const r = await fetch(`${API}/live/${playlistId}`);
|
||||
if (!r.ok) { showNoEvent(); return; }
|
||||
const data = await r.json();
|
||||
lastData = data;
|
||||
render(data);
|
||||
} catch(e) {
|
||||
setDot(false, 'Forbindelsesfejl');
|
||||
}
|
||||
render(await r.json());
|
||||
} catch(e) { setDot(false, 'Forbindelsesfejl'); }
|
||||
}
|
||||
|
||||
async function showPicker() {
|
||||
try {
|
||||
const r = await fetch(`${API}/live/`);
|
||||
const lists = await r.json();
|
||||
if (lists.length === 0) { showNoEvent(); return; }
|
||||
if (!lists.length) { showNoEvent(); return; }
|
||||
if (lists.length === 1) { playlistId = lists[0].id; await loadAndRender(); return; }
|
||||
|
||||
document.getElementById('picker').style.display = 'flex';
|
||||
document.getElementById('no-event').style.display = 'none';
|
||||
const container = document.getElementById('picker-list');
|
||||
container.innerHTML = lists.map(p => `
|
||||
show('picker');
|
||||
document.getElementById('picker-list').innerHTML = lists.map(p => `
|
||||
<button class="playlist-pick-btn" onclick="selectPlaylist('${p.id}')">
|
||||
<strong>${fmt(p.name)}</strong>
|
||||
<span>${p.now_playing ? '▶ ' + fmt(p.now_playing) : 'Ingen aktiv sang'}</span>
|
||||
<span>${p.now_playing ? '▶ ' + fmt(p.now_playing) : 'Afventer start'}</span>
|
||||
</button>`).join('');
|
||||
} catch(e) {
|
||||
showNoEvent();
|
||||
}
|
||||
} catch(e) { showNoEvent(); }
|
||||
}
|
||||
|
||||
function selectPlaylist(id) {
|
||||
playlistId = id;
|
||||
history.replaceState(null, '', `?id=${id}`);
|
||||
document.getElementById('picker').style.display = 'none';
|
||||
loadAndRender();
|
||||
}
|
||||
|
||||
function showNoEvent() {
|
||||
document.getElementById('no-event').style.display = 'flex';
|
||||
document.getElementById('picker').style.display = 'none';
|
||||
document.getElementById('now-playing').style.display = 'none';
|
||||
document.getElementById('divider').style.display = 'none';
|
||||
document.getElementById('next-label').style.display = 'none';
|
||||
document.getElementById('song-list').innerHTML = '';
|
||||
show('no-event');
|
||||
setDot(false, 'Ikke aktiv');
|
||||
}
|
||||
|
||||
function show(id) {
|
||||
['picker','no-event','empty','now-playing'].forEach(x => {
|
||||
document.getElementById(x).style.display = x === id ? (x === 'empty' ? 'flex' : '') : 'none';
|
||||
});
|
||||
if (id !== 'now-playing') {
|
||||
document.getElementById('divider').style.display = 'none';
|
||||
document.getElementById('next-label').style.display = 'none';
|
||||
document.getElementById('song-list').innerHTML = '';
|
||||
}
|
||||
}
|
||||
|
||||
function render(data) {
|
||||
const songs = data.songs || [];
|
||||
document.getElementById('picker').style.display = 'none';
|
||||
document.getElementById('picker').style.display = 'none';
|
||||
document.getElementById('no-event').style.display = 'none';
|
||||
document.getElementById('empty').style.display = 'none';
|
||||
document.getElementById('pl-name').textContent = data.name || '';
|
||||
document.getElementById('empty').style.display = 'none';
|
||||
document.getElementById('pl-name').textContent = data.name || '';
|
||||
document.getElementById('last-updated').textContent =
|
||||
data.updated_at ? 'Opdateret ' + fmtTime(data.updated_at) : '';
|
||||
|
||||
const playing = songs.find(s => s.status === 'playing');
|
||||
const pending = songs.filter(s => s.status === 'pending');
|
||||
const played = songs.filter(s => s.status === 'played' || s.status === 'skipped').length;
|
||||
const total = songs.length;
|
||||
const playing = songs.find(s => s.status === 'playing');
|
||||
const pending = songs.filter(s => s.status === 'pending');
|
||||
const playedN = songs.filter(s => s.status === 'played' || s.status === 'skipped').length;
|
||||
const total = songs.length;
|
||||
const hasLive = !!data.updated_at;
|
||||
|
||||
// Now playing
|
||||
// Now playing sektion
|
||||
const npSection = document.getElementById('now-playing');
|
||||
if (playing) {
|
||||
if (songs.length > 0) {
|
||||
npSection.style.display = '';
|
||||
document.getElementById('np-title').textContent = playing.title;
|
||||
document.getElementById('np-artist').textContent = playing.artist;
|
||||
document.getElementById('np-dance').textContent = playing.dance || '';
|
||||
const pct = total > 0 ? Math.round(played / total * 100) : 0;
|
||||
const current = playing || pending[0];
|
||||
const done = !playing && pending.length === 0;
|
||||
|
||||
document.getElementById('np-label').textContent =
|
||||
playing ? '▶ Spiller nu' : done ? '✓ Afsluttet' : '⏸ Pause';
|
||||
|
||||
// Dans er primær
|
||||
document.getElementById('np-dance').textContent =
|
||||
current ? (current.dance || '') : '';
|
||||
|
||||
// Sang + artist sekundær
|
||||
if (current) {
|
||||
const t = current.title || '—';
|
||||
const a = current.artist || '';
|
||||
document.getElementById('np-song').innerHTML =
|
||||
`<span>${fmt(t)}</span>${a ? ' · ' + fmt(a) : ''}`;
|
||||
} else {
|
||||
document.getElementById('np-song').textContent = done ? 'Danselisten er afsluttet' : '';
|
||||
}
|
||||
|
||||
const pct = total > 0 ? Math.round(playedN / total * 100) : 0;
|
||||
document.getElementById('np-progress').style.width = pct + '%';
|
||||
document.getElementById('np-played').textContent = `${played} afspillet`;
|
||||
document.getElementById('np-played').textContent = `${playedN} afspillet`;
|
||||
document.getElementById('np-remaining').textContent = `${pending.length} tilbage`;
|
||||
setDot(true, 'Live');
|
||||
} else if (songs.length > 0) {
|
||||
npSection.style.display = '';
|
||||
const next = pending[0];
|
||||
document.getElementById('np-label') && (npSection.querySelector('.np-label').textContent = next ? '⏸ Pause' : '✓ Afsluttet');
|
||||
document.getElementById('np-title').textContent = next ? next.title : (played > 0 ? 'Danselisten er afsluttet' : songs[0]?.title || '—');
|
||||
document.getElementById('np-artist').textContent = next ? next.artist : '';
|
||||
document.getElementById('np-dance').textContent = next ? (next.dance || '') : '';
|
||||
const pct = total > 0 ? Math.round(played / total * 100) : 0;
|
||||
document.getElementById('np-progress').style.width = pct + '%';
|
||||
document.getElementById('np-played').textContent = `${played} afspillet`;
|
||||
document.getElementById('np-remaining').textContent = `${pending.length} tilbage`;
|
||||
setDot(!!data.updated_at, data.updated_at ? 'Live' : 'Afventer');
|
||||
|
||||
setDot(hasLive, hasLive ? 'Live' : 'Afventer');
|
||||
} else {
|
||||
npSection.style.display = 'none';
|
||||
setDot(false, 'Ingen sange');
|
||||
}
|
||||
|
||||
// Song list — vis pending og aktiv, skip played
|
||||
const listSongs = songs.filter(s => s.status !== 'played' && s.status !== 'skipped' || songs.length <= 10);
|
||||
const hasList = listSongs.length > 0;
|
||||
document.getElementById('divider').style.display = hasList ? '' : 'none';
|
||||
// Liste — vis alle sange, dans primær
|
||||
const hasList = songs.length > 0;
|
||||
document.getElementById('divider').style.display = hasList ? '' : 'none';
|
||||
document.getElementById('next-label').style.display = hasList ? '' : 'none';
|
||||
|
||||
document.getElementById('song-list').innerHTML = songs.map((s, i) => {
|
||||
const icon = s.status === 'played' ? '✓' :
|
||||
s.status === 'skipped' ? '—' :
|
||||
s.status === 'playing' ? '▶' : '';
|
||||
const cls = s.status === 'played' ? 'song-item played' :
|
||||
s.status === 'skipped' ? 'song-item skipped' :
|
||||
s.status === 'playing' ? 'song-item playing' : 'song-item';
|
||||
const cls = 'song-item ' + (s.status || 'pending');
|
||||
const dance = s.dance || '';
|
||||
const song = [s.title, s.artist].filter(Boolean).join(' · ');
|
||||
return `
|
||||
<div class="${cls}">
|
||||
<span class="song-num">${i+1}</span>
|
||||
<span class="song-check">${icon}</span>
|
||||
<div class="song-info">
|
||||
<div class="song-title-sm">${fmt(s.title)}</div>
|
||||
<div class="song-artist-sm">${fmt(s.artist)}</div>
|
||||
<div class="song-dance-name">${fmt(dance)}</div>
|
||||
<div class="song-title-sm">${fmt(song)}</div>
|
||||
</div>
|
||||
${s.dance ? `<span class="song-dance-sm">${fmt(s.dance)}</span>` : ''}
|
||||
</div>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function setDot(active, label) {
|
||||
const dot = document.getElementById('live-dot');
|
||||
const lbl = document.getElementById('live-label');
|
||||
dot.className = 'dot' + (active ? ' active' : '');
|
||||
lbl.textContent = label;
|
||||
document.getElementById('live-dot').className = 'dot' + (active ? ' active' : '');
|
||||
document.getElementById('live-label').textContent = label;
|
||||
}
|
||||
|
||||
// Start polling
|
||||
// ── Init ──────────────────────────────────────────────────────────────────────
|
||||
document.getElementById('empty').style.display = 'flex';
|
||||
loadAndRender();
|
||||
pollTimer = setInterval(loadAndRender, 5000);
|
||||
startCountdown();
|
||||
setInterval(loadAndRender, POLL_SECS * 1000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user