File size: 4,047 Bytes
0d0d7d2
 
0b5b1d5
0d0d7d2
 
 
0b5b1d5
0d0d7d2
 
 
 
 
 
 
0b5b1d5
0d0d7d2
0b5b1d5
aaeaeb6
 
 
0d0d7d2
0b5b1d5
 
0d0d7d2
0b5b1d5
aaeaeb6
 
 
0d0d7d2
0b5b1d5
 
 
aaeaeb6
ae8f9a8
0b5b1d5
 
ae8f9a8
 
2fc2053
 
701a252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fad9455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Get all love icons and add event listeners
const loveIcons = document.querySelectorAll('.love-icon');

loveIcons.forEach(loveIcon => {
    loveIcon.addEventListener('click', togglePlaylist);
});

function togglePlaylist(event) {
    const clickedIcon = event.target;
    const songCard = clickedIcon.closest('.movie');
    const audioSource = songCard.querySelector('.song-audio source').getAttribute('src');
    const loveIcon = songCard.querySelector('.love-icon');

    if (!songCard.classList.contains('song-added')) {
        // Add the song to the playlist
        addToPlaylist(songCard, audioSource);

        // Change the love icon to solid
        loveIcon.classList.remove('far');
        loveIcon.classList.add('fas');
        songCard.classList.add('song-added');
    } else {
        // Remove the song from the playlist
        removeFromPlaylist(songCard);

        // Change the love icon to hollow
        loveIcon.classList.remove('fas');
        loveIcon.classList.add('far');
        songCard.classList.remove('song-added');
    }
}

// Rest of the addToPlaylist and removeFromPlaylist functions remain the same







function validateSignup() {
    var username = document.forms["signupForm"]["username"].value;
    var password = document.forms["signupForm"]["password"].value;
    var email = document.forms["signupForm"]["email"].value;

    if (username === "" || password === "" || email === "") {
      alert("Please enter all the required fields");
      return false;
    }

    var existingUsernames = ['user1', 'user2', 'user3'];
    if (existingUsernames.includes(username)) {
      alert("Username already exists. Please choose a different username");
      return false;
    }

    var existingEmails = ['user1@example.com', 'user2@example.com', 'user3@example.com'];
    if (existingEmails.includes(email)) {
      alert("Email already exists. Please enter a different email address");
      return false;
    }

    // If all validations pass, you can proceed with submitting the form
    return true;
}


function validateLogin() {
    var username = document.forms["loginForm"]["username"].value;
    var password = document.forms["loginForm"]["password"].value;

    if (username === "" || password === "") {
      alert("Please enter both username and password");
      return false;
    }
    
    // Your login validation logic goes here
    // For example:
    if (username !== "admin" || password !== "password") {
      alert("Incorrect username or password");
      return false;
    }

    return true;
}



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');
        });
    });
});