Spaces:
Running
Running
Download index.html from Fabian-ka/anycoder-dfa97fea: direct link, hf CLI and curl.
- Browser
- Download file 32.8 kB
-
https://huggingface.co/spaces/Fabian-ka/anycoder-dfa97fea/resolve/main/index.html
- Command line
-
hf download hf://spaces/Fabian-ka/anycoder-dfa97fea/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Fabian-ka/anycoder-dfa97fea/resolve/main/index.html
32.8 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Spotify Premium Clone | Ad-free Music</title> | |
| <!-- Import Google Fonts --> | |
| <link rel="preconnect" href="https://fonts.googleapis.com"> | |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet"> | |
| <!-- Import FontAwesome for Icons --> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| :root { | |
| --primary-color: #121212; | |
| --secondary-color: #181818; | |
| --accent-color: #1db954; | |
| --accent-hover: #1ed760; | |
| --text-color: #b3b3b3; | |
| --text-white: #ffffff; | |
| --text-gray: #8e8e8e; | |
| --sidebar-width: 300px; | |
| --player-height: 90px; | |
| --transition: all 0.3s ease; | |
| } | |
| * { | |
| box-sizing: border-box; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| body { | |
| font-family: 'Inter', sans-serif; | |
| background-color: var(--primary-color); | |
| color: var(--text-color); | |
| height: 100vh; | |
| overflow: hidden; | |
| display: flex; | |
| } | |
| /* --- SIDEBAR --- */ | |
| .sidebar { | |
| width: var(--sidebar-width); | |
| background-color: #000; /* Pure black for sidebar */ | |
| height: 100%; | |
| padding: 24px 12px; | |
| display: flex; | |
| flex-direction: column; | |
| gap: 24px; | |
| flex-shrink: 0; | |
| transition: var(--transition); | |
| } | |
| .logo { | |
| color: var(--text-white); | |
| font-size: 24px; | |
| font-weight: 700; | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| margin-bottom: 10px; | |
| } | |
| .logo i { color: var(--accent-color); } | |
| .nav-links { | |
| display: flex; | |
| flex-direction: column; | |
| gap: 16px; | |
| } | |
| .nav-item { | |
| display: flex; | |
| align-items: center; | |
| gap: 16px; | |
| color: var(--text-color); | |
| text-decoration: none; | |
| font-weight: 600; | |
| font-size: 14px; | |
| transition: color 0.2s; | |
| padding: 8px 12px; | |
| border-radius: 4px; | |
| } | |
| .nav-item:hover, .nav-item.active { | |
| color: var(--text-white); | |
| } | |
| .nav-item i { width: 24px; text-align: center; } | |
| .playlist-section { | |
| margin-top: 20px; | |
| flex-grow: 1; | |
| overflow-y: auto; | |
| } | |
| .playlist-header { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| margin-bottom: 16px; | |
| padding-right: 10px; | |
| } | |
| .add-playlist { | |
| color: var(--text-color); | |
| cursor: pointer; | |
| transition: color 0.2s; | |
| } | |
| .add-playlist:hover { color: var(--text-white); } | |
| .playlist-item { | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| color: var(--text-color); | |
| text-decoration: none; | |
| font-size: 14px; | |
| padding: 6px 12px; | |
| border-radius: 4px; | |
| transition: color 0.2s; | |
| } | |
| .playlist-item:hover { color: var(--text-white); } | |
| .playlist-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; } | |
| /* --- MAIN CONTENT --- */ | |
| .main-content { | |
| flex-grow: 1; | |
| background: linear-gradient(180deg, #222 0%, var(--primary-color) 40%); | |
| height: 100%; | |
| display: flex; | |
| flex-direction: column; | |
| overflow-y: auto; | |
| position: relative; | |
| padding-bottom: var(--player-height); /* Space for player */ | |
| } | |
| .top-bar { | |
| position: sticky; | |
| top: 0; | |
| z-index: 100; | |
| background: rgba(18, 18, 18, 0.95); | |
| padding: 16px 32px; | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| backdrop-filter: blur(10px); | |
| } | |
| .nav-arrows { | |
| display: flex; | |
| gap: 16px; | |
| color: var(--text-color); | |
| } | |
| .nav-arrows i { cursor: pointer; font-size: 16px; } | |
| .nav-arrows i:hover { color: var(--text-white); } | |
| .user-profile { | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| background: rgba(0,0,0,0.6); | |
| padding: 6px 12px; | |
| border-radius: 20px; | |
| cursor: pointer; | |
| transition: background 0.2s; | |
| } | |
| .user-profile:hover { background: rgba(255,255,255,0.1); } | |
| .user-avatar { width: 28px; height: 28px; border-radius: 50%; background: #555; display: flex; align-items: center; justify-content: center; font-size: 12px; } | |
| .content-area { | |
| padding: 24px 32px; | |
| animation: fadeIn 0.5s ease; | |
| } | |
| .header-section { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: flex-end; | |
| margin-bottom: 32px; | |
| } | |
| .greeting h1 { | |
| color: var(--text-white); | |
| font-size: 56px; | |
| font-weight: 700; | |
| line-height: 1.1; | |
| } | |
| .greeting p { color: var(--text-white); margin-top: 8px; font-size: 16px; } | |
| .premium-badge { | |
| background: var(--text-white); | |
| color: #000; | |
| padding: 8px 16px; | |
| border-radius: 100px; | |
| font-weight: 700; | |
| font-size: 14px; | |
| display: flex; | |
| align-items: center; | |
| gap: 8px; | |
| } | |
| .section-title { | |
| color: var(--text-white); | |
| font-size: 24px; | |
| font-weight: 700; | |
| margin-bottom: 20px; | |
| line-height: 1.5; | |
| } | |
| .card-grid { | |
| display: grid; | |
| grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); | |
| gap: 24px; | |
| margin-bottom: 40px; | |
| } | |
| .card { | |
| background-color: rgba(255,255,255,0.1); | |
| padding: 16px; | |
| border-radius: 6px; | |
| transition: background 0.3s; | |
| cursor: pointer; | |
| } | |
| .card:hover { | |
| background-color: rgba(255,255,255,0.2); | |
| transform: translateY(-4px); | |
| } | |
| .card img { | |
| width: 100%; | |
| aspect-ratio: 1; | |
| object-fit: cover; | |
| border-radius: 4px; | |
| box-shadow: 0 10px 20px rgba(0,0,0,0.5); | |
| margin-bottom: 16px; | |
| } | |
| .card h3 { color: var(--text-white); font-size: 16px; font-weight: 700; margin-bottom: 8px; } | |
| .card p { font-size: 14px; color: var(--text-gray); line-height: 1.5; } | |
| .quick-links { | |
| display: flex; | |
| gap: 24px; | |
| margin-bottom: 40px; | |
| } | |
| .quick-link { | |
| display: flex; | |
| flex-direction: column; | |
| gap: 8px; | |
| width: 160px; | |
| text-decoration: none; | |
| color: var(--text-color); | |
| } | |
| .quick-link:hover { color: var(--text-white); } | |
| .quick-link i { | |
| width: 80px; | |
| height: 80px; | |
| background: #2a2a2a; | |
| border-radius: 50%; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| font-size: 32px; | |
| color: var(--text-white); | |
| transition: 0.3s; | |
| } | |
| .quick-link:hover i { background: var(--accent-color); transform: scale(1.05); } | |
| /* --- MUSIC PLAYER --- */ | |
| .player-container { | |
| position: fixed; | |
| bottom: 0; | |
| left: 0; | |
| width: 100%; | |
| height: var(--player-height); | |
| background-color: var(--secondary-color); | |
| border-top: 1px solid #282828; | |
| display: flex; | |
| align-items: center; | |
| justify-content: space-between; | |
| padding: 0 24px; | |
| z-index: 1000; | |
| box-shadow: 0 -4px 10px rgba(0,0,0,0.5); | |
| } | |
| .player-left, .player-right { | |
| display: flex; | |
| align-items: center; | |
| gap: 16px; | |
| width: 30%; | |
| } | |
| .track-info { | |
| display: flex; | |
| align-items: center; | |
| gap: 14px; | |
| min-width: 0; /* For text overflow */ | |
| } | |
| .track-art { | |
| width: 56px; | |
| height: 56px; | |
| border-radius: 4px; | |
| object-fit: cover; | |
| box-shadow: 0 4px 10px rgba(0,0,0,0.5); | |
| } | |
| .track-details h4 { color: var(--text-white); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } | |
| .track-details p { font-size: 11px; color: var(--text-gray); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } | |
| .track-options i { color: var(--text-color); font-size: 16px; cursor: pointer; transition: color 0.2s; } | |
| .track-options i:hover { color: var(--text-white); } | |
| .track-options .heart.active { color: var(--accent-color); } | |
| .player-center { | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| flex-grow: 1; | |
| max-width: 600px; | |
| } | |
| .controls { | |
| display: flex; | |
| align-items: center; | |
| gap: 24px; | |
| margin-bottom: 8px; | |
| } | |
| .control-btn { | |
| background: none; | |
| border: none; | |
| color: var(--text-color); | |
| cursor: pointer; | |
| font-size: 18px; | |
| transition: color 0.2s; | |
| padding: 5px; | |
| } | |
| .control-btn:hover { color: var(--text-white); } | |
| .control-btn.play-btn { | |
| color: var(--text-white); | |
| font-size: 28px; | |
| padding: 10px; | |
| } | |
| .control-btn.play-btn:hover { color: var(--accent-color); transform: scale(1.1); } | |
| .progress-container { | |
| width: 100%; | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| font-size: 11px; | |
| color: var(--text-gray); | |
| } | |
| .progress-bar { | |
| flex-grow: 1; | |
| height: 4px; | |
| background-color: #535353; | |
| border-radius: 2px; | |
| cursor: pointer; | |
| position: relative; | |
| transition: background 0.2s; | |
| } | |
| .progress-bar:hover { background-color: #777; } | |
| .progress-fill { | |
| width: 0%; | |
| height: 100%; | |
| background-color: var(--text-white); | |
| border-radius: 2px; | |
| position: relative; | |
| transition: width 0.1s linear; | |
| } | |
| .progress-fill::after { | |
| content: ''; | |
| position: absolute; | |
| right: -6px; | |
| top: -4px; | |
| width: 12px; | |
| height: 12px; | |
| background-color: var(--text-white); | |
| border-radius: 50%; | |
| opacity: 0; | |
| transition: opacity 0.2s; | |
| } | |
| .progress-bar:hover .progress-fill::after { opacity: 1; } | |
| .player-right { | |
| justify-content: flex-end; | |
| gap: 24px; | |
| } | |
| .volume-container { | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| width: 100px; | |
| } | |
| .volume-bar { | |
| flex-grow: 1; | |
| height: 4px; | |
| background-color: #535353; | |
| border-radius: 2px; | |
| cursor: pointer; | |
| } | |
| .volume-fill { | |
| width: 70%; | |
| height: 100%; | |
| background-color: var(--text-white); | |
| border-radius: 2px; | |
| } | |
| /* --- RESPONSIVE DESIGN --- */ | |
| @media (max-width: 768px) { | |
| .sidebar { display: none; } /* Hide sidebar on mobile for simplicity in this demo */ | |
| .player-container { height: 70px; padding: 0 16px; } | |
| .track-art { width: 40px; height: 40px; } | |
| .track-details h4 { font-size: 12px; } | |
| .player-right { gap: 16px; } | |
| .controls { gap: 16px; } | |
| .control-btn { font-size: 16px; } | |
| .control-btn.play-btn { font-size: 24px; } | |
| .greeting h1 { font-size: 32px; } | |
| } | |
| @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } | |
| /* Scrollbar Styling */ | |
| ::-webkit-scrollbar { width: 10px; } | |
| ::-webkit-scrollbar-track { background: transparent; } | |
| ::-webkit-scrollbar-thumb { background: #5a5a5a; border-radius: 5px; } | |
| ::-webkit-scrollbar-thumb:hover { background: #777; } | |
| /* Modal for Premium */ | |
| .modal { | |
| display: none; | |
| position: fixed; | |
| top: 0; left: 0; width: 100%; height: 100%; | |
| background: rgba(0,0,0,0.8); | |
| z-index: 2000; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| .modal-content { | |
| background: #1a1a1a; | |
| padding: 40px; | |
| border-radius: 10px; | |
| text-align: center; | |
| max-width: 500px; | |
| border: 1px solid #333; | |
| animation: popIn 0.3s ease; | |
| } | |
| @keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } } | |
| .btn-premium { | |
| background: var(--accent-color); | |
| color: #000; | |
| border: none; | |
| padding: 12px 30px; | |
| font-size: 16px; | |
| font-weight: 700; | |
| border-radius: 30px; | |
| margin-top: 20px; | |
| cursor: pointer; | |
| transition: transform 0.2s; | |
| } | |
| .btn-premium:hover { transform: scale(1.05); background: #28ae60; } | |
| </style> | |
| </head> | |
| <body> | |
| <!-- SIDEBAR --> | |
| <aside class="sidebar"> | |
| <div class="logo"> | |
| <i class="fab fa-spotify"></i> Spotify | |
| </div> | |
| <div class="nav-links"> | |
| <a href="#" class="nav-item active" onclick="switchTab(this, 'home')"> | |
| <i class="fas fa-home"></i> Home | |
| </a> | |
| <a href="#" class="nav-item" onclick="switchTab(this, 'search')"> | |
| <i class="fas fa-search"></i> Search | |
| </a> | |
| <a href="#" class="nav-item" onclick="switchTab(this, 'library')"> | |
| <i class="fas fa-book"></i> Your Library | |
| </a> | |
| </div> | |
| <div class="playlist-section"> | |
| <div class="playlist-header"> | |
| <span>Playlists</span> | |
| <i class="fas fa-plus-circle add-playlist" title="Create Playlist"></i> | |
| </div> | |
| <div id="playlist-container"> | |
| <!-- Populated by JS --> | |
| </div> | |
| </div> | |
| <div class="nav-links" style="margin-top: auto;"> | |
| <a href="#" class="nav-item" onclick="showPremiumModal()"> | |
| <i class="fas fa-crown" style="color: #ffcc00;"></i> Premium | |
| </a> | |
| <a href="#" class="nav-item"> | |
| <i class="fas fa-download"></i> Offline | |
| </a> | |
| <a href="#" class="nav-item"> | |
| <i class="fas fa-user-cog"></i> Settings | |
| </a> | |
| <a href="#" class="nav-item"> | |
| <i class="fas fa-question-circle"></i> Help | |
| </a> | |
| </div> | |
| </aside> | |
| <!-- MAIN CONTENT --> | |
| <main class="main-content" id="main-content"> | |
| <div class="top-bar"> | |
| <div class="nav-arrows"> | |
| <i class="fas fa-chevron-left"></i> | |
| <i class="fas fa-chevron-right"></i> | |
| </div> | |
| <div class="user-profile" onclick="alert('Profile Settings Clicked')"> | |
| <div class="user-avatar">U</div> | |
| <span style="font-weight: 600; color: white;">User Account</span> | |
| <i class="fas fa-caret-down" style="color: white; font-size: 10px;"></i> | |
| </div> | |
| </div> | |
| <div class="content-area" id="content-view"> | |
| <!-- Content injected via JS --> | |
| </div> | |
| </main> | |
| <!-- PLAYER --> | |
| <div class="player-container"> | |
| <div class="player-left"> | |
| <div class="track-info"> | |
| <img src="https://picsum.photos/id/29/50/50" alt="Track Art" class="track-art" id="current-track-art"> | |
| <div class="track-details"> | |
| <h4 id="current-track-title">Loading...</h4> | |
| <p id="current-track-artist">Unknown Artist</p> | |
| </div> | |
| <i class="far fa-heart track-options" id="like-btn" onclick="toggleLike()"></i> | |
| </div> | |
| </div> | |
| <div class="player-center"> | |
| <div class="controls"> | |
| <i class="fas fa-shuffle control-btn" id="shuffle-btn"></i> | |
| <i class="fas fa-step-backward control-btn" onclick="playPrev()"></i> | |
| <i class="fas fa-play control-btn play-btn" id="play-pause-btn" onclick="togglePlay()"></i> | |
| <i class="fas fa-step-forward control-btn" onclick="playNext()"></i> | |
| <i class="fas fa-redo control-btn" id="repeat-btn"></i> | |
| </div> | |
| <div class="progress-container"> | |
| <span id="current-time">0:00</span> | |
| <div class="progress-bar" id="progress-container" onclick="seekTrack(event)"> | |
| <div class="progress-fill" id="progress-fill"></div> | |
| </div> | |
| <span id="track-duration">0:00</span> | |
| </div> | |
| </div> | |
| <div class="player-right"> | |
| <i class="fas fa-list control-btn" title="Lyrics"></i> | |
| <i class="fas fa-laptop control-btn" title="Device"></i> | |
| <div class="volume-container"> | |
| <i class="fas fa-volume-down control-btn"></i> | |
| <div class="volume-bar" onclick="setVolume(event)"> | |
| <div class="volume-fill" id="volume-fill"></div> | |
| </div> | |
| <i class="fas fa-volume-up control-btn"></i> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- PREMIUM MODAL --> | |
| <div class="modal" id="premium-modal"> | |
| <div class="modal-content"> | |
| <i class="fas fa-crown" style="font-size: 48px; color: #ffcc00; margin-bottom: 16px;"></i> | |
| <h2 style="color: white; margin-bottom: 10px;">Go Premium</h2> | |
| <p style="color: #b3b3b3; margin-bottom: 20px;"> | |
| Ad-free music listening, high audio quality, and offline playback. | |
| Experience music like never before. | |
| </p> | |
| <div style="display: flex; gap: 20px; justify-content: center; margin-bottom: 30px; color: white;"> | |
| <div> | |
| <i class="fas fa-check" style="color: var(--accent-color); margin-right: 8px;"></i> | |
| Ad-free | |
| </div> | |
| <div> | |
| <i class="fas fa-check" style="color: var(--accent-color); margin-right: 8px;"></i> | |
| High Quality | |
| </div> | |
| <div> | |
| <i class="fas fa-check" style="color: var(--accent-color); margin-right: 8px;"></i> | |
| Offline | |
| </div> | |
| </div> | |
| <button class="btn-premium" onclick="subscribePremium()">Start 1 Month Free Trial</button> | |
| <button onclick="closePremiumModal()" style="background: none; border: none; color: var(--text-gray); margin-top: 10px; cursor: pointer;">Cancel</button> | |
| </div> | |
| </div> | |
| <script> | |
| // --- DATA MOCKUP --- | |
| const musicData = { | |
| trending: [ | |
| { id: 1, title: "Midnight City", artist: "M83", cover: "https://picsum.photos/id/29/300/300", duration: "4:03" }, | |
| { id: 2, title: "Starboy", artist: "The Weeknd", cover: "https://picsum.photos/id/54/300/300", duration: "3:50" }, | |
| { id: 3, title: "Do I Wanna Know?", artist: "Arctic Monkeys", cover: "https://picsum.photos/id/238/300/300", duration: "4:22" }, | |
| { id: 4, title: "Levitating", artist: "Dua Lipa", cover: "https://picsum.photos/id/106/300/300", duration: "3:23" }, | |
| { id: 5, title: "Blinding Lights", artist: "The Weeknd", cover: "https://picsum.photos/id/163/300/300", duration: "3:20" }, | |
| { id: 6, title: "Hotel California", artist: "Eagles", cover: "https://picsum.photos/id/183/300/300", duration: "6:30" }, | |
| ], | |
| madeForYou: [ | |
| { id: 7, title: "Discover Weekly", artist: "Your Personalized Mix", cover: "https://picsum.photos/id/10/300/300", description: "Your weekly mixtape of fresh music." }, | |
| { id: 8, title: "On Repeat", artist: "Songs you love right now", cover: "https://picsum.photos/id/20/300/300", description: "Songs you've been playing on repeat." }, | |
| { id: 9, title: "Release Radar", artist: "New music from artists you follow", cover: "https://picsum.photos/id/30/300/300", description: "New releases you might like." }, | |
| { id: 10, title: "Daily Mix 1", artist: "M83, The Weeknd, Arctic Monkeys", cover: "https://picsum.photos/id/40/300/300", description: "M83, The Weeknd, Arctic Monkeys and more." }, | |
| ], | |
| podcasts: [ | |
| { id: 11, title: "The Daily", artist: "The New York Times", cover: "https://picsum.photos/id/50/300/300" }, | |
| { id: 12, title: "Crime Junkie", artist: "Audiochuck", cover: "https://picsum.photos/id/60/300/300" }, | |
| { id: 13, title: "Tech News Today", artist: "The Verge", cover: "https://picsum.photos/id/70/300/300" }, | |
| ] | |
| }; | |
| const playlists = [ | |
| { name: "Chill Vibes", img: "https://picsum.photos/id/11/50/50" }, | |
| { name: "Workout Pump", img: "https://picsum.photos/id/12/50/50" }, | |
| { name: "Late Night Jazz", img: "https://picsum.photos/id/13/50/50" }, | |
| { name: "Coding Focus", img: "https://picsum.photos/id/14/50/50" }, | |
| { name: "Road Trip", img: "https://picsum.photos/id/15/50/50" }, | |
| ]; | |
| // --- STATE MANAGEMENT --- | |
| let currentTrack = null; | |
| let isPlaying = false; | |
| let currentTime = 0; | |
| let duration = 0; | |
| let volume = 0.7; | |
| let currentPlaylist = musicData.trending; | |
| let currentIndex = 0; | |
| // --- DOM ELEMENTS --- | |
| const contentContainer = document.getElementById('content-view'); | |
| const playlistContainer = document.getElementById('playlist-container'); | |
| const playPauseBtn = document.getElementById('play-pause-btn'); | |
| const progressFill = document.getElementById('progress-fill'); | |
| const progressContainer = document.getElementById('progress-container'); | |
| const currentTimeEl = document.getElementById('current-time'); | |
| const durationEl = document.getElementById('track-duration'); | |
| const volumeFill = document.getElementById('volume-fill'); | |
| const trackTitle = document.getElementById('current-track-title'); | |
| const trackArtist = document.getElementById('current-track-artist'); | |
| const trackArt = document.getElementById('current-track-art'); | |
| const likeBtn = document.getElementById('like-btn'); | |
| // --- INITIALIZATION --- | |
| function init() { | |
| renderPlaylists(); | |
| renderHome(); | |
| updatePlayerUI(musicData.trending[0]); | |
| playTrack(0); // Auto play first track | |
| setInterval(updateProgress, 1000); | |
| } | |
| // --- RENDERING --- | |
| function renderPlaylists() { | |
| playlistContainer.innerHTML = ''; | |
| playlists.forEach(pl => { | |
| const div = document.createElement('div'); | |
| div.className = 'playlist-item'; | |
| div.innerHTML = `<img src="${pl.img}" alt="${pl.name}"><span>${pl.name}</span>`; | |
| div.onclick = () => { | |
| // Simulate playing a playlist | |
| currentPlaylist = musicData.trending; // Fallback for demo | |
| currentIndex = 0; | |
| updatePlayerUI(currentPlaylist[0]); | |
| playTrack(0); | |
| }; | |
| playlistContainer.appendChild(div); | |
| }); | |
| } | |
| function renderHome() { | |
| contentContainer.innerHTML = ` | |
| <div class="header-section"> | |
| <div class="greeting"> | |
| <h1>Good afternoon</h1> | |
| <p>Discover playlists and artists just for you.</p> | |
| </div> | |
| <div class="premium-badge"> | |
| <i class="fas fa-crown"></i> Premium | |
| </div> | |
| </div> | |
| <div class="quick-links"> | |
| <a href="#" class="quick-link" onclick="alert('Browse feature coming soon')"> | |
| <i class="fas fa-music"></i> | |
| <span>Browse all</span> | |
| </a> | |
| <a href="#" class="quick-link" onclick="alert('Radio feature coming soon')"> | |
| <i class="fas fa-radio"></i> | |
| <span>Radio</span> | |
| </a> | |
| </div> | |
| <div class="section-title">Made For You</div> | |
| <div class="card-grid" id="card-grid-mixes"> | |
| ${musicData.madeForYou.map(item => createCardHTML(item, 'mix')).join('')} | |
| </div> | |
| <div class="section-title">Trending Now</div> | |
| <div class="card-grid" id="card-grid-trending"> | |
| ${musicData.trending.map(item => createCardHTML(item, 'track')).join('')} | |
| </div> | |
| <div class="section-title">Popular Podcasts</div> | |
| <div class="card-grid"> | |
| ${musicData.podcasts.map(item => createCardHTML(item, 'podcast')).join('')} | |
| </div> | |
| `; | |
| } | |
| function createCardHTML(item, type) { | |
| return ` | |
| <div class="card" onclick="playSpecificTrack(${item.id})"> | |
| <img src="${item.cover}" alt="${item.title}"> | |
| <h3>${item.title}</h3> | |
| <p>${item.artist}</p> | |
| </div> | |
| `; | |
| } | |
| function switchTab(element, section) { | |
| // Update Sidebar UI | |
| document.querySelectorAll('.nav-item').forEach(el => el.classList.remove('active')); | |
| element.classList.add('active'); | |
| // Simulate Content Change | |
| contentContainer.innerHTML = `<div style="padding: 40px; text-align: center; color: white;"> | |
| <h2 style="font-size: 40px; margin-bottom: 20px;">${element.innerText.trim()}</h2> | |
| <p style="font-size: 18px;">This section is currently loading...</p> | |
| <div style="margin-top: 40px; font-size: 48px; color: var(--accent-color);"> | |
| <i class="fas fa-spinner fa-spin"></i> | |
| </div> | |
| </div>`; | |
| } | |
| // --- PLAYER LOGIC --- | |
| function updatePlayerUI(track) { | |
| trackTitle.innerText = track.title; | |
| trackArtist.innerText = track.artist; | |
| trackArt.src = track.cover; | |
| duration = convertToSeconds(track.duration); | |
| durationEl.innerText = track.duration; | |
| currentTime = 0; | |
| currentTimeEl.innerText = "0:00"; | |
| progressFill.style.width = "0%"; | |
| // Reset Play Icon | |
| if (!isPlaying) { | |
| playPauseBtn.classList.remove('fa-pause'); | |
| playPauseBtn.classList.add('fa-play'); | |
| } | |
| } | |
| function togglePlay() { | |
| const icon = isPlaying ? 'fa-play' : 'fa-pause'; | |
| playPauseBtn.classList.remove(icon === 'fa-play' ? 'fa-pause' : 'fa-play'); | |
| playPauseBtn.classList.add(icon); | |
| isPlaying = !isPlaying; | |
| // Simulate Audio Context State | |
| if (isPlaying) { | |
| console.log(`Playing: ${currentPlaylist[currentIndex].title}`); | |
| } else { | |
| console.log(`Paused: ${currentPlaylist[currentIndex].title}`); | |
| } | |
| } | |
| function playTrack(index) { | |
| if (index >= currentPlaylist.length) index = 0; | |
| if (index < 0) index = currentPlaylist.length - 1; | |
| currentIndex = index; | |
| const track = currentPlaylist[index]; | |
| updatePlayerUI(track); | |
| // Simulate loading delay | |
| playPauseBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i>'; | |
| setTimeout(() => { | |
| if (isPlaying) { | |
| playPauseBtn.classList.remove('fa-spinner', 'fa-spin'); | |
| playPauseBtn.classList.add('fa-pause'); | |
| } else { | |
| playPauseBtn.classList.remove('fa-spinner', 'fa-spin'); | |
| playPauseBtn.classList.add('fa-play'); | |
| } | |
| }, 500); | |
| } | |
| function playNext() { | |
| playTrack(currentIndex + 1); | |
| } | |
| function playPrev() { | |
| playTrack(currentIndex - 1); | |
| } | |
| function playSpecificTrack(id) { | |
| // Find track in current playlist | |
| const index = currentPlaylist.findIndex(t => t.id === id); | |
| if (index !== -1) { | |
| playTrack(index); | |
| } | |
| } | |
| function updateProgress() { | |
| if (!isPlaying || !currentTrack) return; | |
| currentTime++; | |
| if (currentTime >= duration) { | |
| playNext(); | |
| return; | |
| } | |
| const percentage = (currentTime / duration) * 100; | |
| progressFill.style.width = `${percentage}%`; | |
| const minutes = Math.floor(currentTime / 60); | |
| const seconds = Math.floor(currentTime % 60); | |
| currentTimeEl.innerText = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`; | |
| } | |
| function seekTrack(e) { | |
| const width = progressContainer.clientWidth; | |
| const clickX = e.offsetX; | |
| const durationInSeconds = duration; // Assuming duration is set in seconds | |
| currentTime = (clickX / width) * durationInSeconds; | |
| const minutes = Math.floor(currentTime / 60); | |
| const seconds = Math.floor(currentTime % 60); | |
| currentTimeEl.innerText = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`; | |
| const percentage = (currentTime / duration) * 100; | |
| progressFill.style.width = `${percentage}%`; | |
| } | |
| function setVolume(e) { | |
| const width = e.currentTarget.clientWidth; | |
| const clickX = e.offsetX; | |
| const newVolume = clickX / width; | |
| volumeFill.style.width = `${newVolume * 100}%`; | |
| volume = newVolume; | |
| console.log(`Volume set to: ${volume}`); | |
| } | |
| function toggleLike() { | |
| likeBtn.classList.toggle('active'); | |
| const isLiked = likeBtn.classList.contains('active'); | |
| console.log(`Track ${currentPlaylist[currentIndex].title} ${isLiked ? 'Liked' : 'Unliked'}`); | |
| } | |
| // --- UTILS --- | |
| function convertToSeconds(timeStr) { | |
| const [min, sec] = timeStr.split(':').map(Number); | |
| return (min * 60) + sec; | |
| } | |
| // --- PREMIUM MODAL LOGIC --- | |
| function showPremiumModal() { | |
| document.getElementById('premium-modal').style.display = 'flex'; | |
| } | |
| function closePremiumModal() { | |
| document.getElementById('premium-modal').style.display = 'none'; | |
| } | |
| function subscribePremium() { | |
| alert("Thank you for subscribing to Spotify Premium! You now have ad-free listening and high-quality audio."); | |
| closePremiumModal(); | |
| } | |
| // Run Init | |
| init(); | |
| </script> | |
| </body> | |
| </html> |