Font Playlist Script |work| (Linux)
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);
function prevFont() if (!playlist.length) return; currentIndex = (currentIndex - 1 + playlist.length) % playlist.length; updateDisplay(); if (isPlaying) stopAutoRotate(); startAutoRotate(); else updateDisplay(); font playlist script
function updateTextContent() let newText = userMessageTextarea.value; if (newText.trim() === "") newText = " "; // keep visible displayDiv.innerText = newText; reader.onload = (e) =>
<!-- Custom text input --> <label>✏️ Your message:</label> <textarea id="userMessage" rows="2" placeholder="Type any text...">The quick brown fox jumps over the lazy dog</textarea> try const json = JSON.parse(e.target.result)
<!-- Playlist editor --> <h3>📋 Font Playlist</h3> <div class="add-font-area"> <input type="text" id="newFontName" placeholder="Font name (e.g., 'Poppins', 'Courier New')"> <button id="addFontBtn">➕ Add</button> </div> <div class="font-list" id="fontListContainer"> <!-- dynamic font list --> </div> <div class="toolbar"> <button id="exportBtn">💾 Export Playlist</button> <button id="importBtn">📂 Import Playlist</button> <input type="file" id="importFile" style="display:none" accept=".json"> </div> <p style="font-size: 0.75rem; margin-top: 20px; opacity:0.6;">💡 Tip: Add any Google Font or system font. Playlist rotates every 3 sec.</p> </div>
<!-- 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>
// Helper: update preview font + text function updateDisplay() if (!playlist.length) displayDiv.style.fontFamily = "sans-serif"; currentFontLabel.innerText = "Font: none"; fontCounterSpan.innerText = `Font 0 of 0`; return; const currentFont = playlist[currentIndex]; displayDiv.style.fontFamily = `'$currentFont', system-ui, sans-serif`; currentFontLabel.innerText = `Font: $currentFont`; fontCounterSpan.innerText = `Font $currentIndex+1 of $playlist.length`;