JAYASWAROOP commited on
Commit
3ee9d8c
·
1 Parent(s): 5970ef1

Update audio.js

Browse files
Files changed (1) hide show
  1. audio.js +22 -20
audio.js CHANGED
@@ -1,7 +1,7 @@
1
  document.addEventListener('DOMContentLoaded', function () {
2
- const searchBar = document.getElementById('searchBar');
3
- const songNames = document.querySelectorAll('h1[style="font-size: 28px;"]');
4
- const descriptions = document.querySelectorAll('p[style="font-size: 20px;"]');
5
  const songContainers = document.querySelectorAll('.movie');
6
 
7
  songContainers.forEach(function (container) {
@@ -13,33 +13,35 @@ document.addEventListener('DOMContentLoaded', function () {
13
  const otherAudio = otherContainer.querySelector('audio');
14
  if (otherAudio !== audio && !otherAudio.paused) {
15
  otherAudio.pause();
16
- otherAudio.classList.add('d-none'); // Hide other audio elements
17
  }
18
  });
19
 
20
- // Toggle the display class of the audio element
21
- audio.classList.toggle('d-none');
22
- if (audio.paused) {
23
  audio.play();
24
  } else {
 
25
  audio.pause();
26
  }
27
  });
28
  });
29
 
 
 
30
 
31
- searchBar.addEventListener('input', function() {
32
- const searchText = searchBar.value.toLowerCase();
 
 
33
 
34
- songNames.forEach((song, index) => {
35
- const songName = song.textContent.toLowerCase();
36
- const description = descriptions[index].textContent.toLowerCase();
37
-
38
- if (songName.includes(searchText) || description.includes(searchText)) {
39
- song.parentElement.parentElement.style.display = 'block';
40
- } else {
41
- song.parentElement.parentElement.style.display = 'none';
42
- }
43
- });
44
  });
45
- });
 
 
1
  document.addEventListener('DOMContentLoaded', function () {
2
+ const searchBar = document.getElementById('searchBar');
3
+ const songNames = document.querySelectorAll('h1[style="font-size: 28px;"]');
4
+ const descriptions = document.querySelectorAll('p[style="font-size: 20px;"]');
5
  const songContainers = document.querySelectorAll('.movie');
6
 
7
  songContainers.forEach(function (container) {
 
13
  const otherAudio = otherContainer.querySelector('audio');
14
  if (otherAudio !== audio && !otherAudio.paused) {
15
  otherAudio.pause();
16
+ otherAudio.style.display = 'none'; // Hide other audio elements
17
  }
18
  });
19
 
20
+ // Toggle the display of the audio element
21
+ if (getComputedStyle(audio).display === 'none') {
22
+ audio.style.display = 'block';
23
  audio.play();
24
  } else {
25
+ audio.style.display = 'none';
26
  audio.pause();
27
  }
28
  });
29
  });
30
 
31
+ searchBar.addEventListener('input', function() {
32
+ const searchText = searchBar.value.toLowerCase();
33
 
34
+ songNames.forEach((song, index) => {
35
+ const songName = song.textContent.toLowerCase();
36
+ const description = descriptions[index].textContent.toLowerCase();
37
+ const container = song.parentElement.parentElement;
38
 
39
+ if (songName.includes(searchText) || description.includes(searchText)) {
40
+ container.style.display = 'block';
41
+ } else {
42
+ container.style.display = 'none';
43
+ }
44
+ });
 
 
 
 
45
  });
46
+ });
47
+