Font Playlist Script -

// Auto-rotation function startAutoRotate() if (intervalId) clearInterval(intervalId); if (playlist.length === 0) return; isPlaying = true; intervalId = setInterval(() => if (playlist.length > 0) currentIndex = (currentIndex + 1) % playlist.length; updateDisplay(); , 3000);

function updateTextContent() let newText = userMessageTextarea.value; if (newText.trim() === "") newText = " "; // keep visible displayDiv.innerText = newText; font playlist script

function importPlaylist(file) const reader = new FileReader(); reader.onload = (e) => try const json = JSON.parse(e.target.result); if (json.fonts && Array.isArray(json.fonts) && json.fonts.length) playlist = json.fonts; currentIndex = 0; if (json.savedText !== undefined) userMessageTextarea.value = json.savedText; renderPlaylistUI(); updateTextContent(); updateDisplay(); stopAutoRotate(); else alert("Invalid playlist format. Need fonts: [...] "); catch(err) alert("Error parsing file"); ; reader.readAsText(file); if (playlist.length === 0) return

<!-- Playback controls --> <div class="playlist-panel"> <div class="playback-buttons"> <button id="prevBtn" title="Previous Font">⏮️ Prev</button> <button id="playBtn" class="btn-primary">▶️ Play</button> <button id="pauseBtn">⏸️ Pause</button> <button id="nextBtn" title="Next Font">⏭️ Next</button> <button id="darkModeBtn">🌙 Dark/Light</button> </div> <div class="counter" id="fontCounter">Font 1 of 6</div> </div> isPlaying = true

function nextFont() if (!playlist.length) return; currentIndex = (currentIndex + 1) % playlist.length; updateDisplay(); if (isPlaying) stopAutoRotate(); startAutoRotate(); // restart timer to avoid skipping beat else updateDisplay();

// Add font function addFont() let newFont = newFontNameInput.value.trim(); if (newFont === "") return alert("Enter a font name"); // simple check: avoid duplicate (case-insensitive) if (playlist.some(f => f.toLowerCase() === newFont.toLowerCase())) alert("Font already in playlist"); return; playlist.push(newFont); renderPlaylistUI(); if (playlist.length === 1) currentIndex = 0; updateDisplay(); newFontNameInput.value = ""; if (isPlaying) stopAutoRotate(); startAutoRotate();