Spaces:
Running
Running
Commit
·
2fc2053
1
Parent(s):
27f221a
Update audio.js
Browse files
audio.js
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
function validateSignup() {
|
| 2 |
var username = document.forms["signupForm"]["username"].value;
|
| 3 |
var password = document.forms["signupForm"]["password"].value;
|
|
|
|
| 1 |
+
// Get all the add-to-playlist buttons
|
| 2 |
+
const addToPlaylistButtons = document.querySelectorAll('.add-to-playlist');
|
| 3 |
+
|
| 4 |
+
// Add event listener to each button
|
| 5 |
+
addToPlaylistButtons.forEach(button => {
|
| 6 |
+
button.addEventListener('click', function() {
|
| 7 |
+
// Get the song details
|
| 8 |
+
const songCard = this.closest('.movie');
|
| 9 |
+
const songTitle = songCard.querySelector('.title').textContent;
|
| 10 |
+
const songDescription = songCard.querySelector('.description').textContent;
|
| 11 |
+
const songSrc = songCard.querySelector('source').getAttribute('src');
|
| 12 |
+
|
| 13 |
+
// Create a new list item element
|
| 14 |
+
const newSongItem = document.createElement('li');
|
| 15 |
+
newSongItem.classList.add('song-item', 'row');
|
| 16 |
+
|
| 17 |
+
// Create the song item content
|
| 18 |
+
const songItemContent = `
|
| 19 |
+
<div class="song-details col-10 col-md-11">
|
| 20 |
+
<p class="song-title">${songTitle}</p>
|
| 21 |
+
<p class="song-artist">${songDescription}</p>
|
| 22 |
+
</div>
|
| 23 |
+
`;
|
| 24 |
+
|
| 25 |
+
// Set the content of the new list item
|
| 26 |
+
newSongItem.innerHTML = songItemContent;
|
| 27 |
+
|
| 28 |
+
// Append the new song item to the playlist
|
| 29 |
+
const playlist = document.querySelector('.song-list');
|
| 30 |
+
playlist.appendChild(newSongItem);
|
| 31 |
+
|
| 32 |
+
// Update the audio source and display the audio player
|
| 33 |
+
const audioPlayer = document.querySelector('#audio');
|
| 34 |
+
audioPlayer.querySelector('source').setAttribute('src', songSrc);
|
| 35 |
+
audioPlayer.classList.remove('d-none');
|
| 36 |
+
});
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
|
| 40 |
function validateSignup() {
|
| 41 |
var username = document.forms["signupForm"]["username"].value;
|
| 42 |
var password = document.forms["signupForm"]["password"].value;
|