404 lines
14 KiB
HTML
404 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="da">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>LineDance — Live</title>
|
|
<style>
|
|
:root {
|
|
--bg: #0a0b0d;
|
|
--surface: #13151a;
|
|
--border: #252830;
|
|
--accent: #e8a020;
|
|
--text: #eceef4;
|
|
--muted: #60687a;
|
|
--green: #27ae60;
|
|
--gray: #3a3f4b;
|
|
}
|
|
* { 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;
|
|
}
|
|
|
|
/* ── Header ── */
|
|
header {
|
|
padding: .75rem 1.5rem;
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
border-bottom: 1px solid var(--border);
|
|
flex-shrink: 0;
|
|
}
|
|
.logo { font-size: .85rem; 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);
|
|
}
|
|
.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; }
|
|
}
|
|
|
|
/* ── Now playing ── */
|
|
#now-playing {
|
|
padding: 2rem 1.5rem 1.5rem;
|
|
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;
|
|
}
|
|
.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;
|
|
}
|
|
.np-dance:empty { display: none; }
|
|
|
|
/* 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;
|
|
}
|
|
|
|
/* ── Divider ── */
|
|
.divider {
|
|
border: none; border-top: 1px solid var(--border);
|
|
margin: .5rem 1.5rem;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
/* ── Next up label ── */
|
|
.next-label {
|
|
padding: .6rem 1.5rem .4rem;
|
|
font-size: .7rem; 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::-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;
|
|
}
|
|
.song-item.playing {
|
|
background: rgba(232,160,32,.08);
|
|
border: 1px solid rgba(232,160,32,.2);
|
|
}
|
|
.song-item.played { opacity: .35; }
|
|
.song-item.skipped { opacity: .2; }
|
|
|
|
.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; }
|
|
.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;
|
|
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;
|
|
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;
|
|
}
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
|
|
/* ── 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;
|
|
}
|
|
#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; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<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>
|
|
</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>
|
|
<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>Å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>
|
|
|
|
<!-- 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-dance" id="np-dance"></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>
|
|
<span id="np-remaining">0 tilbage</span>
|
|
</div>
|
|
</div>
|
|
|
|
<hr class="divider" id="divider" style="display:none">
|
|
<div class="next-label" id="next-label" style="display:none">Kommende</div>
|
|
<div id="song-list"></div>
|
|
|
|
<footer>
|
|
<span id="pl-name"></span>
|
|
<span id="last-updated"></span>
|
|
</footer>
|
|
|
|
<script>
|
|
const API = '/api';
|
|
let playlistId = new URLSearchParams(location.search).get('id');
|
|
let pollTimer = null;
|
|
let lastData = null;
|
|
|
|
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' });
|
|
}
|
|
|
|
async function loadAndRender() {
|
|
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');
|
|
}
|
|
}
|
|
|
|
async function showPicker() {
|
|
try {
|
|
const r = await fetch(`${API}/live/`);
|
|
const lists = await r.json();
|
|
if (lists.length === 0) { 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 => `
|
|
<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>
|
|
</button>`).join('');
|
|
} 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 = '';
|
|
setDot(false, 'Ikke aktiv');
|
|
}
|
|
|
|
function render(data) {
|
|
const songs = data.songs || [];
|
|
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('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;
|
|
|
|
// Now playing
|
|
const npSection = document.getElementById('now-playing');
|
|
if (playing) {
|
|
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;
|
|
document.getElementById('np-progress').style.width = pct + '%';
|
|
document.getElementById('np-played').textContent = `${played} 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');
|
|
} 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';
|
|
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';
|
|
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>
|
|
${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;
|
|
}
|
|
|
|
// Start polling
|
|
loadAndRender();
|
|
pollTimer = setInterval(loadAndRender, 5000);
|
|
</script>
|
|
</body>
|
|
</html>
|