🐳 13/04 - 09:52 - genres should also include custom genre selection where a user can type in the genre and the typed genre saves to memory so that it adds auto complete suggestions for the next user
8058687 verified Download index.html from Onttraders/deepsite-project-eo5bp: direct link, hf CLI and curl.
- Browser
- Download file 23.5 kB
-
https://huggingface.co/spaces/Onttraders/deepsite-project-eo5bp/resolve/main/index.html
- Command line
-
hf download hf://spaces/Onttraders/deepsite-project-eo5bp/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Onttraders/deepsite-project-eo5bp/resolve/main/index.html
23.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Beatfridge - Every Track Gets Heard</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/lucide@latest"></script> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap'); | |
| body { | |
| font-family: 'Inter', sans-serif; | |
| background-color: #0B0F1A; | |
| color: white; | |
| } | |
| .accent-blue { color: #2D9CFF; } | |
| .bg-accent-blue { background-color: #2D9CFF; } | |
| .border-accent-blue { border-color: #2D9CFF; } | |
| .cta-orange { background-color: #FF8A00; } | |
| .text-orange { color: #FF8A00; } | |
| .glass { | |
| background: rgba(255, 255, 255, 0.05); | |
| backdrop-filter: blur(10px); | |
| border: 1px solid rgba(255, 255, 255, 0.1); | |
| } | |
| .track-card:hover { | |
| transform: translateY(-4px); | |
| box-shadow: 0 20px 40px rgba(45, 156, 255, 0.1); | |
| } | |
| .play-btn { | |
| opacity: 0; | |
| transition: all 0.3s ease; | |
| } | |
| .track-card:hover .play-btn { | |
| opacity: 1; | |
| } | |
| .now-playing { | |
| box-shadow: 0 0 30px rgba(255, 138, 0, 0.3); | |
| } | |
| input[type="file"] { | |
| display: none; | |
| } | |
| .upload-zone { | |
| border: 2px dashed rgba(45, 156, 255, 0.3); | |
| transition: all 0.3s ease; | |
| } | |
| .upload-zone:hover, .upload-zone.dragover { | |
| border-color: #2D9CFF; | |
| background: rgba(45, 156, 255, 0.05); | |
| } | |
| .liked { | |
| color: #FF6B6B; | |
| fill: #FF6B6B; | |
| } | |
| </style> | |
| </head> | |
| <body class="min-h-screen"> | |
| <!-- Hero Section --> | |
| <section class="py-20 px-6 text-center"> | |
| <div class="max-w-3xl mx-auto"> | |
| <h1 class="text-5xl md:text-6xl font-bold mb-6 leading-tight"> | |
| Stop uploading music<br> | |
| <span class="accent-blue">to get ignored.</span> | |
| </h1> | |
| <p class="text-xl text-gray-400 mb-8">Every track here gets heard.</p> | |
| <button onclick="scrollToUpload()" class="cta-orange px-8 py-4 rounded-full font-semibold text-white text-lg hover:scale-105 transition-transform"> | |
| Upload Your Track | |
| </button> | |
| </div> | |
| </section> | |
| <!-- Upload Section --> | |
| <section id="uploadSection" class="py-12 px-6"> | |
| <div class="max-w-xl mx-auto"> | |
| <div class="glass rounded-2xl p-8"> | |
| <h2 class="text-2xl font-bold mb-6 accent-blue">Drop a Beat</h2> | |
| <form id="uploadForm" class="space-y-4"> | |
| <div> | |
| <label class="block text-sm text-gray-400 mb-2">Artist Name</label> | |
| <input type="text" id="artistName" required | |
| class="w-full px-4 py-3 rounded-xl bg-white/5 border border-gray-700 focus:border-accent-blue focus:outline-none transition-colors" | |
| placeholder="Your Artist Name"> | |
| </div> | |
| <div> | |
| <label class="block text-sm text-gray-400 mb-2">Track Title</label> | |
| <input type="text" id="trackTitle" required | |
| class="w-full px-4 py-3 rounded-xl bg-white/5 border border-gray-700 focus:border-accent-blue focus:outline-none transition-colors" | |
| placeholder="Track Title"> | |
| </div> | |
| <div class="grid grid-cols-2 gap-4"> | |
| <div class="relative"> | |
| <label class="block text-sm text-gray-400 mb-2">Genre</label> | |
| <div class="relative"> | |
| <input type="text" id="genre" list="genreSuggestions" | |
| class="w-full px-4 py-3 rounded-xl bg-white/5 border border-gray-700 focus:border-accent-blue focus:outline-none transition-colors text-white placeholder-gray-500" | |
| placeholder="Type or select..." | |
| autocomplete="off"> | |
| <i data-lucide="chevron-down" class="w-5 h-5 absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 pointer-events-none"></i> | |
| </div> | |
| <datalist id="genreSuggestions"> | |
| </datalist> | |
| <span class="text-xs text-gray-500 mt-1 block">Type custom or pick from suggestions</span> | |
| </div> | |
| <div> | |
| <label class="block text-sm text-gray-400 mb-2">BPM</label> | |
| <input type="number" id="bpm" min="1" max="999" | |
| class="w-full px-4 py-3 rounded-xl bg-white/5 border border-gray-700 focus:border-accent-blue focus:outline-none transition-colors" | |
| placeholder="120"> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-2 gap-4"> | |
| <div> | |
| <label class="block text-sm text-gray-400 mb-2">Key</label> | |
| <select id="key" class="w-full px-4 py-3 rounded-xl bg-white/5 border border-gray-700 focus:border-accent-blue focus:outline-none transition-colors text-white"> | |
| <option value="" class="bg-gray-900">--</option> | |
| <option value="C Major" class="bg-gray-900">C Major</option> | |
| <option value="C Minor" class="bg-gray-900">C Minor</option> | |
| <option value="C# Major" class="bg-gray-900">C# Major</option> | |
| <option value="C# Minor" class="bg-gray-900">C# Minor</option> | |
| <option value="D Major" class="bg-gray-900">D Major</option> | |
| <option value="D Minor" class="bg-gray-900">D Minor</option> | |
| <option value="D# Major" class="bg-gray-900">D# Major</option> | |
| <option value="D# Minor" class="bg-gray-900">D# Minor</option> | |
| <option value="E Major" class="bg-gray-900">E Major</option> | |
| <option value="E Minor" class="bg-gray-900">E Minor</option> | |
| <option value="F Major" class="bg-gray-900">F Major</option> | |
| <option value="F Minor" class="bg-gray-900">F Minor</option> | |
| <option value="F# Major" class="bg-gray-900">F# Major</option> | |
| <option value="F# Minor" class="bg-gray-900">F# Minor</option> | |
| <option value="G Major" class="bg-gray-900">G Major</option> | |
| <option value="G Minor" class="bg-gray-900">G Minor</option> | |
| <option value="G# Major" class="bg-gray-900">G# Major</option> | |
| <option value="G# Minor" class="bg-gray-900">G# Minor</option> | |
| <option value="A Major" class="bg-gray-900">A Major</option> | |
| <option value="A Minor" class="bg-gray-900">A Minor</option> | |
| <option value="A# Major" class="bg-gray-900">A# Major</option> | |
| <option value="A# Minor" class="bg-gray-900">A# Minor</option> | |
| <option value="B Major" class="bg-gray-900">B Major</option> | |
| <option value="B Minor" class="bg-gray-900">B Minor</option> | |
| </select> | |
| </div> | |
| <div> | |
| <label class="block text-sm text-gray-400 mb-2">Mood/Tags</label> | |
| <input type="text" id="tags" | |
| class="w-full px-4 py-3 rounded-xl bg-white/5 border border-gray-700 focus:border-accent-blue focus:outline-none transition-colors" | |
| placeholder="e.g. Dark, Energetic, Chill"> | |
| </div> | |
| </div> | |
| <div> | |
| <label class="block text-sm text-gray-400 mb-2">Description</label> | |
| <textarea id="description" rows="3" | |
| class="w-full px-4 py-3 rounded-xl bg-white/5 border border-gray-700 focus:border-accent-blue focus:outline-none transition-colors resize-none" | |
| placeholder="Tell us about this track..."></textarea> | |
| </div> | |
| <div> | |
| <label class="block text-sm text-gray-400 mb-2">Audio File (MP3)</label> | |
| <div class="upload-zone rounded-xl p-8 text-center cursor-pointer" id="audioDropZone"> | |
| <i data-lucide="music" class="w-10 h-10 mx-auto mb-2 text-gray-500"></i> | |
| <p class="text-gray-400">Click to upload MP3 or drag & drop</p> | |
| <p id="audioFileName" class="text-sm accent-blue mt-2 hidden"></p> | |
| </div> | |
| <input type="file" id="audioFile" accept=".mp3,audio/mpeg" required> | |
| </div> | |
| <div> | |
| <label class="block text-sm text-gray-400 mb-2">Cover Image (Optional)</label> | |
| <div class="upload-zone rounded-xl p-6 text-center cursor-pointer" id="coverDropZone"> | |
| <i data-lucide="image" class="w-8 h-8 mx-auto mb-2 text-gray-500"></i> | |
| <p class="text-gray-400 text-sm">Click to add cover art</p> | |
| <img id="coverPreview" class="mt-2 mx-auto max-h-32 rounded-lg hidden"> | |
| </div> | |
| <input type="file" id="coverFile" accept="image/*"> | |
| </div> | |
| <button type="submit" | |
| class="w-full cta-orange py-4 rounded-xl font-semibold text-white hover:opacity-90 transition-opacity flex items-center justify-center gap-2"> | |
| <i data-lucide="upload" class="w-5 h-5"></i> | |
| Upload Track | |
| </button> | |
| </form> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Live Feed --> | |
| <section class="py-12 px-6 max-w-6xl mx-auto"> | |
| <div class="flex items-center justify-between mb-8"> | |
| <div> | |
| <h2 class="text-3xl font-bold">Fresh Drops</h2> | |
| <p class="text-gray-400 mt-1">Newest first</p> | |
| </div> | |
| <button onclick="shuffleFeed()" class="px-4 py-2 rounded-lg glass hover:border-accent-blue transition-colors flex items-center gap-2"> | |
| <i data-lucide="shuffle" class="w-4 h-4"></i> | |
| Shuffle | |
| </button> | |
| </div> | |
| <div id="trackFeed" class="grid md:grid-cols-2 lg:grid-cols-3 gap-6"> | |
| <!-- Tracks injected here --> | |
| </div> | |
| <div id="emptyState" class="text-center py-20 hidden"> | |
| <i data-lucide="disc" class="w-16 h-16 mx-auto text-gray-600 mb-4"></i> | |
| <p class="text-gray-400 text-lg">No beats in the fridge yet.</p> | |
| <p class="text-gray-500 text-sm mt-2">Be the first to drop a track!</p> | |
| </div> | |
| </section> | |
| <!-- Audio Player Bar --> | |
| <div id="playerBar" class="fixed bottom-0 left-0 right-0 glass border-t border-gray-800 transform translate-y-full transition-transform duration-300 z-50"> | |
| <div class="max-w-6xl mx-auto px-6 py-4 flex items-center gap-4"> | |
| <img id="playerCover" src="" class="w-12 h-12 rounded-lg object-cover bg-gray-800"> | |
| <div class="flex-1 min-w-0"> | |
| <p id="playerTitle" class="font-semibold truncate">Track Title</p> | |
| <p id="playerArtist" class="text-sm text-gray-400 truncate">Artist</p> | |
| </div> | |
| <button id="playPauseBtn" class="w-10 h-10 rounded-full bg-accent-blue flex items-center justify-center hover:scale-105 transition-transform"> | |
| <i data-lucide="pause" class="w-5 h-5 text-white fill-white"></i> | |
| </button> | |
| <button onclick="closePlayer()" class="p-2 hover:text-red-400 transition-colors"> | |
| <i data-lucide="x" class="w-5 h-5"></i> | |
| </button> | |
| </div> | |
| <audio id="audioElement"></audio> | |
| </div> | |
| <script> | |
| // State | |
| let tracks = JSON.parse(localStorage.getItem('beatfridge_tracks')) || []; | |
| let customGenres = JSON.parse(localStorage.getItem('beatfridge_genres')) || []; | |
| let currentTrack = null; | |
| let isPlaying = false; | |
| // Default/predefined genres | |
| const defaultGenres = ['Hip Hop', 'Trap', 'R&B', 'Electronic', 'Lo-Fi', 'Pop', 'Rock', 'Jazz', 'Drill', 'Afrobeat', 'Dancehall', 'House', 'Techno', 'Salsa', 'Reggaeton', 'Country', 'Classical', 'Metal', 'Punk', 'Soul', 'Funk', 'Disco', 'Blues', 'Folk', 'Indie', 'Alternative', 'Ambient', 'Synthwave', 'Phonk', 'Jersey Club', 'Baile Funk', 'Amapiano']; | |
| // Initialize | |
| document.addEventListener('DOMContentLoaded', () => { | |
| lucide.createIcons(); | |
| renderFeed(); | |
| initPlayer(); | |
| setupUpload(); | |
| setupGenreAutocomplete(); | |
| checkSharedTrack(); | |
| }); | |
| // Setup Upload Interactions | |
| function setupUpload() { | |
| const audioDrop = document.getElementById('audioDropZone'); | |
| const audioInput = document.getElementById('audioFile'); | |
| const coverDrop = document.getElementById('coverDropZone'); | |
| const coverInput = document.getElementById('coverFile'); | |
| // Audio upload | |
| audioDrop.addEventListener('click', () => audioInput.click()); | |
| audioDrop.addEventListener('dragover', (e) => { | |
| e.preventDefault(); | |
| audioDrop.classList.add('dragover'); | |
| }); | |
| audioDrop.addEventListener('dragleave', () => audioDrop.classList.remove('dragover')); | |
| audioDrop.addEventListener('drop', (e) => { | |
| e.preventDefault(); | |
| audioDrop.classList.remove('dragover'); | |
| if (e.dataTransfer.files[0]) { | |
| audioInput.files = e.dataTransfer.files; | |
| showAudioName(e.dataTransfer.files[0].name); | |
| } | |
| }); | |
| audioInput.addEventListener('change', (e) => { | |
| if (e.target.files[0]) showAudioName(e.target.files[0].name); | |
| }); | |
| // Cover upload | |
| coverDrop.addEventListener('click', () => coverInput.click()); | |
| coverInput.addEventListener('change', (e) => { | |
| if (e.target.files[0]) { | |
| const preview = document.getElementById('coverPreview'); | |
| preview.src = URL.createObjectURL(e.target.files[0]); | |
| preview.classList.remove('hidden'); | |
| } | |
| }); | |
| // Form submit | |
| document.getElementById('uploadForm').addEventListener('submit', handleUpload); | |
| } | |
| function showAudioName(name) { | |
| const el = document.getElementById('audioFileName'); | |
| el.textContent = name; | |
| el.classList.remove('hidden'); | |
| } | |
| function handleUpload(e) { | |
| e.preventDefault(); | |
| const artist = document.getElementById('artistName').value.trim(); | |
| const title = document.getElementById('trackTitle').value.trim(); | |
| const audioFile = document.getElementById('audioFile').files[0]; | |
| const coverFile = document.getElementById('coverFile').files[0]; | |
| if (!audioFile) { | |
| alert('Please select an audio file'); | |
| return; | |
| } | |
| // Get metadata values | |
| const genre = document.getElementById('genre').value; | |
| const bpm = document.getElementById('bpm').value; | |
| const key = document.getElementById('key').value; | |
| const tags = document.getElementById('tags').value.trim(); | |
| const description = document.getElementById('description').value.trim(); | |
| // Create track object | |
| const newTrack = { | |
| id: Date.now(), | |
| artist: artist, | |
| title: title, | |
| audioUrl: URL.createObjectURL(audioFile), | |
| coverUrl: coverFile ? URL.createObjectURL(coverFile) : `http://static.photos/abstract/400x400/${Math.floor(Math.random() * 100)}`, | |
| timestamp: Date.now(), | |
| plays: 0, | |
| likes: 0, | |
| liked: false, | |
| genre: genre, | |
| bpm: bpm || null, | |
| key: key || null, | |
| tags: tags, | |
| description: description | |
| }; | |
| tracks.unshift(newTrack); | |
| saveTracks(); | |
| // Reset form | |
| document.getElementById('uploadForm').reset(); | |
| document.getElementById('audioFileName').classList.add('hidden'); | |
| document.getElementById('coverPreview').classList.add('hidden'); | |
| renderFeed(); | |
| scrollToFeed(); | |
| } | |
| function saveTracks() { | |
| localStorage.setItem('beatfridge_tracks', JSON.stringify(tracks)); | |
| } | |
| function renderFeed() { | |
| const feed = document.getElementById('trackFeed'); | |
| const emptyState = document.getElementById('emptyState'); | |
| if (tracks.length === 0) { | |
| feed.innerHTML = ''; | |
| emptyState.classList.remove('hidden'); | |
| return; | |
| } | |
| emptyState.classList.add('hidden'); | |
| feed.innerHTML = tracks.map(track => ` | |
| <div class="track-card glass rounded-2xl overflow-hidden transition-all duration-300 ${currentTrack?.id === track.id ? 'now-playing border-2 border-orange-500' : ''}"> | |
| <div class="relative aspect-square group cursor-pointer" onclick="playTrack(${track.id})"> | |
| <img src="${track.coverUrl}" class="w-full h-full object-cover"> | |
| <div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent"></div> | |
| <div class="play-btn absolute inset-0 flex items-center justify-center"> | |
| <div class="w-16 h-16 rounded-full bg-accent-blue flex items-center justify-center shadow-2xl"> | |
| <i data-lucide="${currentTrack?.id === track.id && isPlaying ? 'pause' : 'play'}" | |
| class="w-6 h-6 text-white ${currentTrack?.id === track.id && isPlaying ? '' : 'fill-white'}"></i> | |
| </div> | |
| </div> | |
| <div class="absolute bottom-3 left-3 right-3"> | |
| <h3 class="font-bold text-lg truncate">${track.title}</h3> | |
| <p class="text-sm text-gray-300">${track.artist}</p> | |
| </div> | |
| </div> | |
| <div class="p-4"> | |
| <div class="flex flex-wrap gap-2 mb-3"> | |
| ${track.genre ? `<span class="text-xs px-2 py-1 rounded-full bg-accent-blue/20 text-accent-blue border border-accent-blue/30">${track.genre}</span>` : ''} | |
| ${track.bpm ? `<span class="text-xs px-2 py-1 rounded-full bg-white/10 text-gray-300 border border-white/20">${track.bpm} BPM</span>` : ''} | |
| ${track.key ? `<span class="text-xs px-2 py-1 rounded-full bg-white/10 text-gray-300 border border-white/20">${track.key}</span>` : ''} | |
| ${track.tags ? track.tags.split(',').map(tag => tag.trim() ? `<span class="text-xs px-2 py-1 rounded-full bg-orange-500/20 text-orange border border-orange-500/30">#${tag.trim()}</span>` : '').join('') : ''} | |
| </div> | |
| ${track.description ? `<p class="text-sm text-gray-400 mb-3 line-clamp-2">${track.description}</p>` : ''} | |
| <div class="flex items-center justify-between"> | |
| <div class="flex items-center gap-4 text-sm text-gray-400"> | |
| <span class="flex items-center gap-1"> | |
| <i data-lucide="play" class="w-4 h-4"></i> | |
| ${track.plays} | |
| </span> | |
| <button onclick="toggleLike(${track.id})" class="flex items-center gap-1 hover:text-red-400 transition-colors ${track.liked ? 'liked' : ''}"> | |
| <i data-lucide="heart" class="w-4 h-4 ${track.liked ? 'fill-current' : ''}"></i> | |
| ${track.likes} | |
| </button> | |
| </div> | |
| <button onclick="shareTrack(${track.id})" class="flex items-center gap-1 text-sm text-gray-400 hover:text-accent-blue transition-colors" title="Share track"> | |
| <i data-lucide="share-2" class="w-4 h-4"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| `).join(''); | |
| lucide.createIcons(); | |
| } | |
| function initPlayer() { | |
| const audio = document.getElementById('audioElement'); | |
| document.getElementById('playPauseBtn').addEventListener('click', togglePlay); | |
| audio.addEventListener('ended', () => { | |
| isPlaying = false; | |
| playerBar.classList.add('translate-y-full'); | |
| renderFeed(); | |
| }); | |
| audio.addEventListener('pause', () => { | |
| isPlaying = false; | |
| updatePlayButton(); | |
| renderFeed(); | |
| }); | |
| audio.addEventListener('play', () => { | |
| isPlaying = true; | |
| updatePlayButton(); | |
| renderFeed(); | |
| }); | |
| } | |
| function playTrack(id) { | |
| const audio = document.getElementById('audioElement'); | |
| const playerBar = document.getElementById('playerBar'); | |
| const track = tracks.find(t => t.id === id); | |
| if (!track) return; | |
| // If clicking same track, toggle play/pause | |
| if (currentTrack?.id === id) { | |
| if (isPlaying) { | |
| audio.pause(); | |
| } else { | |
| audio.play(); | |
| } | |
| return; | |
| } | |
| // New track | |
| currentTrack = track; | |
| audio.src = track.audioUrl; | |
| audio.play(); | |
| // Increment plays | |
| track.plays++; | |
| saveTracks(); | |
| // Update player bar | |
| document.getElementById('playerTitle').textContent = track.title; | |
| document.getElementById('playerArtist').textContent = track.artist; | |
| document.getElementById('playerCover').src = track.coverUrl; | |
| playerBar.classList.remove('translate-y-full'); | |
| isPlaying = true; | |
| updatePlayButton(); | |
| renderFeed(); | |
| } | |
| function togglePlay() { | |
| const audio = document.getElementById('audioElement'); | |
| if (!currentTrack) return; | |
| if (isPlaying) { | |
| audio.pause(); | |
| } else { | |
| audio.play(); | |
| } | |
| } | |
| function updatePlayButton() { | |
| const btn = document.getElementById('playPauseBtn'); | |
| const icon = btn.querySelector('i'); | |
| icon.setAttribute('data-lucide', isPlaying ? 'pause' : 'play'); | |
| lucide.createIcons(); | |
| } | |
| function closePlayer() { | |
| const audio = document.getElementById('audioElement'); | |
| audio.pause(); | |
| document.getElementById('playerBar').classList.add('translate-y-full'); | |
| isPlaying = false; | |
| renderFeed(); | |
| } | |
| function toggleLike(id) { | |
| const track = tracks.find(t => t.id === id); | |
| if (!track) return; | |
| track.liked = !track.liked; | |
| track.likes += track.liked ? 1 : -1; | |
| saveTracks(); | |
| renderFeed(); | |
| } | |
| function shuffleFeed() { | |
| tracks.sort(() => Math.random() - 0.5); | |
| renderFeed(); | |
| } | |
| function timeAgo(timestamp) { | |
| const seconds = Math.floor((Date.now() - timestamp) / 1000); | |
| if (seconds < 60) return 'just now'; | |
| const minutes = Math.floor(seconds / 60); | |
| if (minutes < 60) return `${minutes}m ago`; | |
| const hours = Math.floor(minutes / 60); | |
| if (hours < 24) return `${hours}h ago`; | |
| const days = Math.floor(hours / 24); | |
| return `${days}d ago`; | |
| } | |
| function scrollToUpload() { | |
| document.getElementById('uploadSection').scrollIntoView({ behavior: 'smooth' }); | |
| } | |
| function scrollToFeed() { | |
| document.getElementById('trackFeed').scrollIntoView({ behavior: 'smooth' }); | |
| } | |
| // Genre autocomplete with custom genre persistence | |
| function setupGenreAutocomplete() { | |
| updateGenreDatalist(); | |
| const genreInput = document.getElementById('genre'); | |
| // Save custom genres when user types a new one | |
| genreInput.addEventListener('blur', () => { | |
| saveCustomGenre(); | |
| }); | |
| genreInput.addEventListener('keypress', (e) => { | |
| if (e.key === 'Enter') { | |
| saveCustomGenre(); | |
| } | |
| }); | |
| } | |
| function updateGenreDatalist() { | |
| const datalist = document.getElementById('genreSuggestions'); | |
| const allGenres = [...defaultGenres, ...customGenres]; | |
| // Remove duplicates and sort alphabetically | |
| const uniqueGenres = [...new Set(allGenres)].sort((a, b) => a.localeCompare(b)); | |
| datalist.innerHTML = uniqueGenres.map(g => `<option value="${g}">`).join(''); | |
| } | |
| function saveCustomGenre() { | |
| const genreInput = document.getElementById('genre'); | |
| const value = genreInput.value.trim(); | |
| if (value && !defaultGenres.includes(value) && !customGenres.includes(value)) { | |
| customGenres.push(value); | |
| localStorage.setItem('beatfridge_genres', JSON.stringify(customGenres)); | |
| updateGenreDatalist(); | |
| } | |
| } | |
| function shareTrack(id) { | |
| const track = tracks.find(t => t.id === id); | |
| if (!track) return; | |
| const shareUrl = `${window.location.origin}${window.location.pathname}?track=${id}`; | |
| if (navigator.share) { | |
| navigator.share({ | |
| title: `${track.title} by ${track.artist} on Beatfridge`, | |
| text: `Check out "${track.title}" by ${track.artist} on Beatfridge!`, | |
| url: shareUrl | |
| }).catch(() => { | |
| // Fallback to clipboard if share dialog dismissed | |
| copyToClipboard(shareUrl); | |
| }); | |
| } else { | |
| copyToClipboard(shareUrl); | |
| } | |
| } | |
| function copyToClipboard(text) { | |
| const input = document.createElement('input'); | |
| input.value = text; | |
| document.body.appendChild(input); | |
| input.select(); | |
| document.execCommand('copy'); | |
| document.body.removeChild(input); | |
| // Show feedback | |
| const feedback = document.createElement('div'); | |
| feedback.className = 'fixed top-4 left-1/2 transform -translate-x-1/2 bg-accent-blue text-white px-6 py-3 rounded-full font-semibold shadow-2xl z-50'; | |
| feedback.textContent = 'Link copied to clipboard!'; | |
| document.body.appendChild(feedback); | |
| setTimeout(() => { | |
| feedback.remove(); | |
| }, 2000); | |
| } | |
| function checkSharedTrack() { | |
| const params = new URLSearchParams(window.location.search); | |
| const trackId = params.get('track'); | |
| if (trackId) { | |
| const id = parseInt(trackId); | |
| const track = tracks.find(t => t.id === id); | |
| if (track) { | |
| // Scroll to feed first | |
| setTimeout(() => { | |
| renderFeed(); // Ensure DOM is updated | |
| const trackElement = document.querySelector(`[onclick="playTrack(${id})"]`); | |
| if (trackElement) { | |
| trackElement.scrollIntoView({ behavior: 'smooth', block: 'center' }); | |
| } | |
| // Auto-play the track | |
| setTimeout(() => playTrack(id), 500); | |
| }, 100); | |
| } | |
| } | |
| } | |
| // Check for shared track on load | |
| window.addEventListener('load', checkSharedTrack); | |
| </script> | |
| </body> | |
| </html> |