510 lines
19 KiB
HTML
510 lines
19 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;
|
|
}
|
|
.light {
|
|
--bg: #f5f4ef;
|
|
--surface: #ffffff;
|
|
--border: #dddbd3;
|
|
--accent: #c47a10;
|
|
--text: #1a1c22;
|
|
--muted: #7a7a6a;
|
|
--green: #1e8449;
|
|
}
|
|
* { 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: .55rem 1.25rem;
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
border-bottom: 1px solid var(--border); flex-shrink: 0;
|
|
}
|
|
.logo { font-size: .75rem; 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: .35rem; }
|
|
.countdown-svg { width: 22px; height: 22px; 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: .68rem; color: var(--muted); min-width: 1rem; }
|
|
.live-dot { display: flex; align-items: center; gap: .35rem; font-size: .7rem; color: var(--muted); }
|
|
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
|
|
.dot.active { background: var(--green); animation: pulse 2s infinite; }
|
|
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }
|
|
.theme-btn {
|
|
background: none; border: 1px solid var(--border); border-radius: 5px;
|
|
padding: .2rem .5rem; cursor: pointer; color: var(--muted); font-size: .72rem;
|
|
transition: all .15s;
|
|
}
|
|
.theme-btn:hover { border-color: var(--accent); color: var(--text); }
|
|
|
|
/* ── Now playing ── */
|
|
#now-playing { padding: 1.5rem 1.25rem 1rem; flex-shrink: 0; }
|
|
|
|
.np-label {
|
|
font-size: .62rem; letter-spacing: .18em; text-transform: uppercase;
|
|
color: var(--accent); font-weight: 700; margin-bottom: .4rem;
|
|
}
|
|
/* Dans primær — stor */
|
|
.np-dance {
|
|
font-size: clamp(2.2rem, 8vw, 5rem);
|
|
font-weight: 800; line-height: 1; color: var(--text);
|
|
letter-spacing: -.02em; margin-bottom: .3rem;
|
|
}
|
|
.np-dance:empty::before { content: '—'; color: var(--muted); }
|
|
|
|
/* Nummer under dans */
|
|
.np-number {
|
|
font-size: clamp(.75rem, 2vw, 1rem);
|
|
color: var(--muted); margin-bottom: .2rem;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
.np-number b { color: var(--text); }
|
|
|
|
/* Sang + artist sekundær */
|
|
.np-song {
|
|
font-size: clamp(.85rem, 2.2vw, 1.2rem);
|
|
color: var(--muted); margin-bottom: .9rem;
|
|
}
|
|
.np-song span { color: var(--text); }
|
|
|
|
/* Estimeret tid til næste */
|
|
.np-eta {
|
|
font-size: clamp(.72rem, 1.8vw, .9rem);
|
|
color: var(--muted); margin-bottom: .5rem;
|
|
display: flex; align-items: center; gap: .4rem;
|
|
}
|
|
.np-eta b { color: var(--accent); }
|
|
|
|
/* ── Fremgangsbar — NEDERST på now-playing ── */
|
|
.progress-section { margin-top: .5rem; }
|
|
.progress-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: .35rem; }
|
|
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .4s; width: 0%; }
|
|
.progress-text {
|
|
font-size: .7rem; color: var(--muted);
|
|
display: flex; justify-content: space-between;
|
|
}
|
|
|
|
/* ── Divider ── */
|
|
.divider { border: none; border-top: 1px solid var(--border); margin: .4rem 1.25rem; flex-shrink: 0; }
|
|
.next-label {
|
|
padding: .4rem 1.25rem .2rem;
|
|
font-size: .62rem; 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: .2rem .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: .4rem .5rem; border-radius: 7px; margin-bottom: 1px;
|
|
}
|
|
.song-item.playing {
|
|
background: rgba(232,160,32,.09);
|
|
border: 1px solid rgba(232,160,32,.22);
|
|
}
|
|
.song-item.played { opacity: .4; }
|
|
.song-item.skipped { opacity: .25; }
|
|
|
|
.song-num { font-size: .68rem; color: var(--muted); width: 1.4rem; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
|
|
.song-check { width: 1rem; flex-shrink: 0; text-align: center; font-size: .72rem; color: var(--muted); }
|
|
.song-item.played .song-check { color: var(--green); }
|
|
|
|
.song-info { flex: 1; min-width: 0; }
|
|
.song-dance-name {
|
|
font-size: clamp(.8rem, 2vw, .95rem); font-weight: 600;
|
|
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
}
|
|
.song-title-sm {
|
|
font-size: clamp(.68rem, 1.6vw, .8rem); color: var(--muted);
|
|
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
}
|
|
.song-eta-sm {
|
|
font-size: .65rem; color: var(--muted); flex-shrink: 0;
|
|
font-variant-numeric: tabular-nums; text-align: right; min-width: 2.5rem;
|
|
}
|
|
|
|
/* ── 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: 26px; height: 26px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
.big-text { font-size: 1rem; color: var(--text); }
|
|
.playlist-pick-btn {
|
|
background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
|
|
padding: .75rem 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: .88rem; margin-bottom: .15rem; }
|
|
.playlist-pick-btn span { font-size: .74rem; color: var(--muted); }
|
|
|
|
/* ── Footer ── */
|
|
footer {
|
|
padding: .45rem 1.25rem; border-top: 1px solid var(--border);
|
|
font-size: .67rem; 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:1rem;color:var(--text)">Vælg playliste</h2>
|
|
<p style="max-width:300px">Brug <code>?id=PLAYLIST_ID</code> i URL eller vælg herunder</p>
|
|
<div id="picker-list"></div>
|
|
</div>
|
|
|
|
<div id="no-event">
|
|
<div style="font-size:2.5rem;opacity:.2">🎵</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-number" id="np-number"></div>
|
|
<div class="np-song" id="np-song"></div>
|
|
<div class="np-eta" id="np-eta" style="display:none">
|
|
⏱ Næste dans starter om ca. <b id="np-eta-val"></b>
|
|
</div>
|
|
<!-- Fremgangsbar NEDERST -->
|
|
<div class="progress-section">
|
|
<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>
|
|
</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';
|
|
const POLL_SECS = 5;
|
|
const BETWEEN_DANCE_SEC = 30; // pause mellem danse (bruges i estimat)
|
|
const WORKSHOP_MIN_SEC = 20 * 60; // default workshoptid hvis ingen varighed
|
|
|
|
let playlistId = new URLSearchParams(location.search).get('id');
|
|
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;
|
|
}
|
|
|
|
// ── Hjælpefunktioner ─────────────────────────────────────────────────────────
|
|
function fmt(s) { return (s||'').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); }
|
|
|
|
function fmtDur(secs) {
|
|
if (!secs || secs <= 0) return '';
|
|
const m = Math.floor(secs / 60);
|
|
const s = Math.round(secs % 60);
|
|
if (m === 0) return `${s}s`;
|
|
return s === 0 ? `${m} min` : `${m}:${String(s).padStart(2,'0')}`;
|
|
}
|
|
|
|
function fmtTime(d) {
|
|
if (!d) return '';
|
|
return new Date(d).toLocaleTimeString('da-DK', { hour:'2-digit', minute:'2-digit', second:'2-digit' });
|
|
}
|
|
|
|
// Dansenavn — workshop vises som "Workshop"
|
|
function getDanceName(song) {
|
|
if (song.is_workshop) return 'Workshop';
|
|
return song.dance || '';
|
|
}
|
|
|
|
// Estimeret varighed for en sang (bruges til tidsestimat)
|
|
function songDuration(song) {
|
|
if (song.is_workshop) {
|
|
return song.duration > 0 ? song.duration : WORKSHOP_MIN_SEC;
|
|
}
|
|
return song.duration > 0 ? song.duration : 210; // default 3:30
|
|
}
|
|
|
|
// Beregn estimeret sekunder til en bestemt index
|
|
function estimateSecsTo(songs, fromIdx) {
|
|
let secs = 0;
|
|
for (let i = 0; i < fromIdx; i++) {
|
|
const s = songs[i];
|
|
if (s.status === 'played' || s.status === 'skipped') continue;
|
|
secs += songDuration(s);
|
|
secs += BETWEEN_DANCE_SEC; // pause mellem danse
|
|
}
|
|
return secs;
|
|
}
|
|
|
|
// ── Fetch & render ────────────────────────────────────────────────────────────
|
|
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 ? '' : '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 || [];
|
|
const hasLive = !!data.updated_at;
|
|
|
|
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;
|
|
|
|
// ── Now playing ────────────────────────────────────────────────────────────
|
|
if (songs.length > 0) {
|
|
document.getElementById('now-playing').style.display = '';
|
|
const current = playing || pending[0];
|
|
const done = !playing && pending.length === 0;
|
|
const currentIdx = current ? songs.indexOf(current) : -1;
|
|
|
|
document.getElementById('np-label').textContent =
|
|
playing ? '▶ Spiller nu' : done ? '✓ Afsluttet' : '⏸ Pause';
|
|
|
|
// Dans primær
|
|
document.getElementById('np-dance').textContent =
|
|
current ? getDanceName(current) : '';
|
|
|
|
// Nummer under dansen
|
|
if (current && currentIdx >= 0) {
|
|
document.getElementById('np-number').innerHTML =
|
|
`Nr. <b>${currentIdx + 1}</b> af ${total}`;
|
|
} else {
|
|
document.getElementById('np-number').textContent = '';
|
|
}
|
|
|
|
// Sang sekundær (ikke ved workshop)
|
|
if (current && !current.is_workshop) {
|
|
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 = '';
|
|
}
|
|
|
|
// ETA til næste dans
|
|
const etaEl = document.getElementById('np-eta');
|
|
const etaValEl = document.getElementById('np-eta-val');
|
|
if (playing && currentIdx >= 0) {
|
|
// Find næste pending sang
|
|
const nextIdx = songs.findIndex((s, i) => i > currentIdx && s.status === 'pending');
|
|
if (nextIdx >= 0) {
|
|
// Varighed af nuværende sang + pause
|
|
const remainSecs = songDuration(playing) + BETWEEN_DANCE_SEC;
|
|
etaEl.style.display = '';
|
|
etaValEl.textContent = fmtDur(remainSecs);
|
|
} else {
|
|
etaEl.style.display = 'none';
|
|
}
|
|
} else {
|
|
etaEl.style.display = 'none';
|
|
}
|
|
|
|
// Fremgangsbar
|
|
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 {
|
|
document.getElementById('now-playing').style.display = 'none';
|
|
setDot(false, 'Ingen sange');
|
|
}
|
|
|
|
// ── Songliste ──────────────────────────────────────────────────────────────
|
|
const hasList = songs.length > 0;
|
|
document.getElementById('divider').style.display = hasList ? '' : 'none';
|
|
document.getElementById('next-label').style.display = hasList ? '' : 'none';
|
|
|
|
// Beregn kumulative tidsestimater fra nuværende position
|
|
const playingIdx = songs.findIndex(s => s.status === 'playing');
|
|
let cumSecs = 0;
|
|
|
|
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 name = getDanceName(s);
|
|
const sub = (!s.is_workshop && s.title) ? s.title + (s.artist ? ' · ' + s.artist : '') : '';
|
|
|
|
// ETA for pending sange efter den der spiller
|
|
let etaTxt = '';
|
|
if (s.status === 'pending' && playingIdx >= 0 && i > playingIdx) {
|
|
cumSecs += songDuration(songs[i-1] || s) + BETWEEN_DANCE_SEC;
|
|
if (cumSecs > 0) etaTxt = `~${fmtDur(cumSecs)}`;
|
|
} else if (s.status === 'playing') {
|
|
cumSecs = 0;
|
|
}
|
|
|
|
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(name)}</div>
|
|
${sub ? `<div class="song-title-sm">${fmt(sub)}</div>` : ''}
|
|
</div>
|
|
${etaTxt ? `<span class="song-eta-sm">${etaTxt}</span>` : ''}
|
|
</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>
|