JAYASWAROOP commited on
Commit
aaeaeb6
1 Parent(s): 001a8bb

Update audio.js

Browse files
Files changed (1) hide show
  1. audio.js +7 -33
audio.js CHANGED
@@ -15,49 +15,23 @@ function togglePlaylist(event) {
15
  // Add the song to the playlist
16
  addToPlaylist(songCard, audioSource);
17
 
18
- // Change the color of the love icon to indicate it's selected
19
- loveIcon.classList.add('selected');
 
20
  songCard.classList.add('song-added');
21
  } else {
22
  // Remove the song from the playlist
23
  removeFromPlaylist(songCard);
24
 
25
- // Change the color of the love icon back to its original color
26
- loveIcon.classList.remove('selected');
 
27
  songCard.classList.remove('song-added');
28
  }
29
  }
30
 
31
- function addToPlaylist(songCard, audioSource) {
32
- // Create elements for the new song in the playlist
33
- const playlist = document.querySelector('.playlist');
34
 
35
- const newSongDiv = document.createElement('div');
36
- newSongDiv.classList.add('song1');
37
-
38
- const newAudio = document.createElement('audio');
39
- newAudio.setAttribute('controls', '');
40
-
41
- const audioSourceElem = document.createElement('source');
42
- audioSourceElem.setAttribute('src', audioSource);
43
- audioSourceElem.setAttribute('type', 'audio/mpeg');
44
-
45
- newAudio.appendChild(audioSourceElem);
46
- newSongDiv.appendChild(newAudio);
47
-
48
- // Add the new song to the playlist
49
- playlist.appendChild(newSongDiv);
50
- }
51
-
52
- function removeFromPlaylist(songCard) {
53
- const playlist = document.querySelector('.playlist');
54
- const songEntry = playlist.querySelector('.song1');
55
-
56
- // Remove the song from the playlist
57
- if (songEntry) {
58
- playlist.removeChild(songEntry);
59
- }
60
- }
61
 
62
 
63
 
 
15
  // Add the song to the playlist
16
  addToPlaylist(songCard, audioSource);
17
 
18
+ // Change the love icon to solid
19
+ loveIcon.classList.remove('far');
20
+ loveIcon.classList.add('fas');
21
  songCard.classList.add('song-added');
22
  } else {
23
  // Remove the song from the playlist
24
  removeFromPlaylist(songCard);
25
 
26
+ // Change the love icon to hollow
27
+ loveIcon.classList.remove('fas');
28
+ loveIcon.classList.add('far');
29
  songCard.classList.remove('song-added');
30
  }
31
  }
32
 
33
+ // Rest of the addToPlaylist and removeFromPlaylist functions remain the same
 
 
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
 
37