JAYASWAROOP commited on
Commit
deacdff
1 Parent(s): b22feca

Update audio.js

Browse files
Files changed (1) hide show
  1. audio.js +28 -33
audio.js CHANGED
@@ -1,46 +1,41 @@
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 movieContainers = document.querySelectorAll('.movie');
6
 
7
- movieContainers.forEach(function (container) {
8
- container.addEventListener('click', function () {
9
- const audio = this.querySelector('audio');
10
 
11
- // Pause all other audio elements except the one clicked
12
- movieContainers.forEach(function (otherContainer) {
13
- const otherAudio = otherContainer.querySelector('audio');
14
- if (otherAudio !== audio && !otherAudio.paused) {
15
- otherAudio.pause();
16
- otherAudio.classList.add('d-none');
17
- }
18
- });
19
 
20
- // Play or pause the audio based on its current state
21
- if (audio.paused) {
22
- audio.play();
23
- } else {
24
- audio.pause();
25
- }
26
-
27
- // Toggle the display of the audio element
28
- audio.classList.toggle('d-none');
29
  });
30
- });
31
 
32
- searchBar.addEventListener('input', function() {
33
- const searchText = searchBar.value.toLowerCase();
 
34
 
35
- songNames.forEach((song, index) => {
36
- const songName = song.textContent.toLowerCase();
37
- const description = descriptions[index].textContent.toLowerCase();
 
 
 
 
38
 
39
- if (songName.includes(searchText) || description.includes(searchText)) {
40
- song.parentElement.parentElement.style.display = 'block';
41
  } else {
42
- song.parentElement.parentElement.style.display = 'none';
43
  }
 
 
44
  });
45
  });
46
  });
 
1
  document.addEventListener('DOMContentLoaded', function () {
2
+ const searchBar = document.getElementById('searchBar');
3
+ const movieContainers = document.querySelectorAll('.movie');
 
 
4
 
5
+ searchBar.addEventListener('input', function () {
6
+ const searchText = searchBar.value.toLowerCase().trim();
 
7
 
8
+ movieContainers.forEach(function (container) {
9
+ const title = container.querySelector('.title').textContent.toLowerCase();
10
+ const description = container.querySelector('.description').textContent.toLowerCase();
 
 
 
 
 
11
 
12
+ if (title.includes(searchText) || description.includes(searchText)) {
13
+ container.style.display = 'block';
14
+ } else {
15
+ container.style.display = 'none';
16
+ }
17
+ });
 
 
 
18
  });
 
19
 
20
+ movieContainers.forEach(function (container) {
21
+ container.addEventListener('click', function () {
22
+ const audio = this.querySelector('audio');
23
 
24
+ movieContainers.forEach(function (otherContainer) {
25
+ const otherAudio = otherContainer.querySelector('audio');
26
+ if (otherAudio !== audio && !otherAudio.paused) {
27
+ otherAudio.pause();
28
+ otherAudio.classList.add('d-none');
29
+ }
30
+ });
31
 
32
+ if (audio.paused) {
33
+ audio.play();
34
  } else {
35
+ audio.pause();
36
  }
37
+
38
+ audio.classList.toggle('d-none');
39
  });
40
  });
41
  });