let concerts = []; let viewMode = 'timeline'; function formatDate(dateStr) { const d = new Date(dateStr); return d.toLocaleDateString('fr-FR', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }); } function formatDateShort(dateStr) { const d = new Date(dateStr); return d.toLocaleDateString('fr-FR', { year: 'numeric', month: 'long', day: 'numeric' }); } function timelineSongCard(song) { const embed = youtubeEmbedUrl(song.youtube_url); return `
Pas de lien YouTube
`} ${song.spotify_url ? `` : ''} ${song.note ? `${escapeHtml(song.note)}
` : ''}Aucun morceau enregistré.
'}Aucun concert passé enregistré.
'; return; } container.innerHTML = concerts.map(timelineConcertBlock).join(''); } function renderCompact() { const container = document.getElementById('compact-view'); renderList(container, concerts, concertCardTemplate, 'Aucun concert passé enregistré.'); } function applyViewMode() { const timelineEl = document.getElementById('timeline-view'); const compactEl = document.getElementById('compact-view'); const btn = document.getElementById('toggle-view-btn'); if (viewMode === 'timeline') { timelineEl.style.display = 'block'; compactEl.style.display = 'none'; btn.textContent = 'Vue réduite'; } else { timelineEl.style.display = 'none'; compactEl.style.display = 'grid'; btn.textContent = 'Vue chronologique'; } } function showError(message) { document.getElementById('error').innerHTML = ``; } (async function init() { await initNav('history'); document.getElementById('toggle-view-btn').addEventListener('click', () => { viewMode = viewMode === 'timeline' ? 'compact' : 'timeline'; applyViewMode(); }); try { concerts = await api.get('/api/setlists/history?full=1'); renderTimeline(); renderCompact(); applyViewMode(); } catch (err) { showError(err.message); } })();