421 lines
15 KiB
HTML
421 lines
15 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;
|
|
--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: .6rem 1.25rem;
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
border-bottom: 1px solid var(--border); flex-shrink: 0;
|
|
}
|
|
.logo { font-size: .8rem; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
|
|
.logo b { color: var(--accent); }
|
|
|
|
.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;
|
|
}
|
|
.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:.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: 1.75rem 1.25rem 1.25rem; flex-shrink: 0;
|
|
}
|
|
.np-label {
|
|
font-size: .65rem; letter-spacing: .18em; text-transform: uppercase;
|
|
color: var(--accent); font-weight: 700; margin-bottom: .5rem;
|
|
}
|
|
/* Dans er primær */
|
|
.np-dance {
|
|
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::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 */
|
|
.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.25rem; flex-shrink: 0; }
|
|
.next-label {
|
|
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: .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: .6rem;
|
|
padding: .45rem .5rem; border-radius: 7px; transition: background .1s;
|
|
margin-bottom: 1px;
|
|
}
|
|
.song-item.playing {
|
|
background: rgba(232,160,32,.09);
|
|
border: 1px solid rgba(232,160,32,.22);
|
|
}
|
|
.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-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(.7rem, 1.6vw, .82rem); color: var(--muted);
|
|
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
}
|
|
|
|
/* ── 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: 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: .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;
|
|
}
|
|
|
|
@media (min-width: 600px) {
|
|
#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>
|
|
<body>
|
|
|
|
<header>
|
|
<div class="logo">LINE<b>DANCE</b></div>
|
|
<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>
|
|
|
|
<div id="picker">
|
|
<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>
|
|
|
|
<div id="no-event">
|
|
<div class="no-event-icon">🎵</div>
|
|
<div class="big-text">Ingen aktiv playliste</div>
|
|
<div>Åbn LineDance Player og start et event</div>
|
|
</div>
|
|
|
|
<div id="empty"><div class="spinner"></div></div>
|
|
|
|
<div id="now-playing" style="display:none">
|
|
<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>
|
|
<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 dans</div>
|
|
<div id="song-list"></div>
|
|
|
|
<footer>
|
|
<span id="pl-name"></span>
|
|
<span id="last-updated"></span>
|
|
</footer>
|
|
|
|
<script>
|
|
const API = '/api';
|
|
const POLL_SECS = 5;
|
|
let playlistId = new URLSearchParams(location.search).get('id');
|
|
let pollTimer = 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 '';
|
|
return new Date(d).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; }
|
|
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) { showNoEvent(); return; }
|
|
if (lists.length === 1) { playlistId = lists[0].id; await loadAndRender(); return; }
|
|
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) : 'Afventer start'}</span>
|
|
</button>`).join('');
|
|
} catch(e) { showNoEvent(); }
|
|
}
|
|
|
|
function selectPlaylist(id) {
|
|
playlistId = id;
|
|
history.replaceState(null, '', `?id=${id}`);
|
|
loadAndRender();
|
|
}
|
|
|
|
function showNoEvent() {
|
|
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('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 playedN = songs.filter(s => s.status === 'played' || s.status === 'skipped').length;
|
|
const total = songs.length;
|
|
const hasLive = !!data.updated_at;
|
|
|
|
// Now playing sektion
|
|
const npSection = document.getElementById('now-playing');
|
|
if (songs.length > 0) {
|
|
npSection.style.display = '';
|
|
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 = `${playedN} afspillet`;
|
|
document.getElementById('np-remaining').textContent = `${pending.length} tilbage`;
|
|
|
|
setDot(hasLive, hasLive ? 'Live' : 'Afventer');
|
|
} else {
|
|
npSection.style.display = 'none';
|
|
setDot(false, 'Ingen sange');
|
|
}
|
|
|
|
// 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 = '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-dance-name">${fmt(dance)}</div>
|
|
<div class="song-title-sm">${fmt(song)}</div>
|
|
</div>
|
|
</div>`;
|
|
}).join('');
|
|
}
|
|
|
|
function setDot(active, label) {
|
|
document.getElementById('live-dot').className = 'dot' + (active ? ' active' : '');
|
|
document.getElementById('live-label').textContent = label;
|
|
}
|
|
|
|
// ── Init ──────────────────────────────────────────────────────────────────────
|
|
document.getElementById('empty').style.display = 'flex';
|
|
loadAndRender();
|
|
startCountdown();
|
|
setInterval(loadAndRender, POLL_SECS * 1000);
|
|
</script>
|
|
</body>
|
|
</html>
|