-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
57 lines (50 loc) · 1.8 KB
/
main.js
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
// Get elements from DOM
const modalBtn=document.querySelector('.yt-modal-btn');
const modal=document.querySelector('.modal-bg');
// Add click event to the button
modalBtn.addEventListener('click', ()=>{
// Add youtube embed to the HTML
// You can get the embed code by right clcicking any youtube video and selecting 'ember code'
modal.innerHTML=`<div class="modal">
<iframe width="892" height="502" src="https://www.youtube.com/embed/hrRvFS1qIAQ" title="Jibaro | Love, Death and Robots" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>`;
// Show the modal
modal.style.display="flex";
// Smooth opacity transition
setTimeout(()=>{
modal.style.opacity="1";
},50);
});
// Add click event to the modal bg
modal.addEventListener('click', ()=>{
// Remove youtube ember to the HTML
// This is a simple way to stop the video from playing from playing when you close the modal
modal.innerHTML='';
// smooth opacity transition
modal.style.opacity="0";
setTimeout(()=>{
// Hide the modal when the transition is done
modal.style.display="none";
},450);
});
// disabling inspect element
document.addEventListener("contextmenu", function(e){
e.preventDefault(); //this prevents right click
});
document.onkeydown=function(e){
if(event.keycode==123){
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode=="I".charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode=="C".charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode=="J".charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode=="U".charCodeAt(0)){
return false;
}
};