Spaces:
Running
Running
Download js/script.js from EricAdams3d188/undefined: direct link, hf CLI and curl.
- Browser
- Download file 2.31 kB
-
https://huggingface.co/spaces/EricAdams3d188/undefined/resolve/main/js/script.js
- Command line
-
hf download hf://spaces/EricAdams3d188/undefined/js/script.js
-
curl -L -o script.js https://huggingface.co/spaces/EricAdams3d188/undefined/resolve/main/js/script.js
2.31 kB
| ```javascript | |
| document.addEventListener('DOMContentLoaded', function() { | |
| feather.replace(); | |
| // Upload functionality | |
| const uploadBtn = document.getElementById('uploadBtn'); | |
| if (uploadBtn) { | |
| uploadBtn.addEventListener('click', function() { | |
| document.getElementById('musicUpload').click(); | |
| }); | |
| } | |
| const musicUpload = document.getElementById('musicUpload'); | |
| if (musicUpload) { | |
| musicUpload.addEventListener('change', function(e) { | |
| const files = e.target.files; | |
| if (files.length > 0) { | |
| console.log('Files selected for upload:', files); | |
| simulateUpload(files); | |
| } | |
| }); | |
| } | |
| }); | |
| function simulateUpload(files) { | |
| const tracksList = document.getElementById('tracksList'); | |
| const uploadedCount = document.getElementById('uploadedCount'); | |
| Array.from(files).forEach((file, index) => { | |
| const trackItem = document.createElement('div'); | |
| trackItem.className = 'grid grid-cols-12 p-4 items-center hover:bg-gray-700 track-item'; | |
| trackItem.innerHTML = ` | |
| <div class="col-span-6 flex items-center"> | |
| <div class="relative w-10 h-10 mr-4"> | |
| <img src="http://static.photos/music/80x80/${10 + index}" alt="Track cover" class="rounded-md w-full h-full object-cover"> | |
| <button class="play-button absolute inset-0 m-auto bg-green-500 bg-opacity-80 rounded-full w-6 h-6 flex items-center justify-center opacity-0 group-hover:opacity-100"> | |
| <i data-feather="play" class="h-3 w-3 text-white"></i> | |
| </button> | |
| </div> | |
| <div> | |
| <h3 class="font-medium text-white">${file.name.replace(/\.[^/.]+$/, "")}</h3> | |
| <p class="text-sm text-gray-400">Uploaded now</p> | |
| </div> | |
| </div> | |
| <div class="col-span-2 text-gray-400 text-sm">Just now</div> | |
| <div class="col-span-2 text-gray-400 text-sm">0</div> | |
| <div class="col-span-2 text-gray-400 text-sm">--:--</div> | |
| `; | |
| tracksList.prepend(trackItem); | |
| uploadedCount.textContent = parseInt(uploadedCount.textContent) + 1; | |
| }); | |
| feather.replace(); | |
| } | |
| ``` |