File size: 1,486 Bytes
2f8c35e
deacdff
 
568ef55
deacdff
 
568ef55
deacdff
 
 
2f8c35e
deacdff
 
 
 
 
 
0648934
3d661b3
deacdff
 
 
3d661b3
deacdff
 
 
 
 
 
 
3d661b3
deacdff
 
3d661b3
deacdff
3d661b3
deacdff
 
3d661b3
 
0648934
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
document.addEventListener('DOMContentLoaded', function () {
    const searchBar = document.getElementById('searchBar');
    const movieContainers = document.querySelectorAll('.movie');

    searchBar.addEventListener('input', function () {
        const searchText = searchBar.value.toLowerCase().trim();

        movieContainers.forEach(function (container) {
            const title = container.querySelector('.title').textContent.toLowerCase();
            const description = container.querySelector('.description').textContent.toLowerCase();

            if (title.includes(searchText) || description.includes(searchText)) {
                container.style.display = 'block';
            } else {
                container.style.display = 'none';
            }
        });
    });

    movieContainers.forEach(function (container) {
        container.addEventListener('click', function () {
            const audio = this.querySelector('audio');

            movieContainers.forEach(function (otherContainer) {
                const otherAudio = otherContainer.querySelector('audio');
                if (otherAudio !== audio && !otherAudio.paused) {
                    otherAudio.pause();
                    otherAudio.classList.add('d-none');
                }
            });

            if (audio.paused) {
                audio.play();
            } else {
                audio.pause();
            }

            audio.classList.toggle('d-none');
        });
    });
});