File size: 816 Bytes
036b3a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(function () {
    const videoLink = document.getElementById('videoLink');
    const videoPopup = document.getElementById('videoPopup');
    const closePopup = document.getElementById('closePopup');
    const youtubeVideo = document.getElementById('youtubeVideo');

    videoLink.addEventListener('click', (e) => {
        e.preventDefault();
        youtubeVideo.src = 'https://www.youtube.com/embed/' + videoLink.getAttribute('video-id');
        videoPopup.classList.remove('hidden');
    });

    closePopup.addEventListener('click', () => {
        youtubeVideo.src = '';
        videoPopup.classList.add('hidden');
    });

    videoPopup.addEventListener('click', (e) => {
        if (e.target === videoPopup) {
        youtubeVideo.src = '';
        videoPopup.classList.add('hidden');
        }
    })
})();