-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
83 lines (77 loc) · 2.36 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
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
// Get elements from the DOM
const menuBtn = document.querySelector('.menu-btn');
const menu = document.querySelector('.menu-container');
const dropdowns = document.querySelectorAll('.dropdown > div');
const subDropdowns = document.querySelectorAll('.sub-dropdown > div');
// Toggle variable
let menuOpen = false;
// Set click event to menu button
menuBtn.addEventListener('click', ()=>{
// Toggle mega menu show class
menu.classList.toggle('mega-menu-show');
// If the menu open variable is false
if(menuOpen===false){
// Set the close icon to the menu button
menuBtn.innerHTML=`
<span class="material-symbols-outlined">
close
</span>
`;
// Set menu open to true
menuOpen = true;
}
else{
// Set the menu icon to the menu button
menuBtn.innerHTML=`
<span class="material-symbols-outlined">
menu
</span>
`;
// Set menu open to false
menuOpen = false;
}
});
// Select all dropdowns
dropdowns.forEach(dropdown=>{
// Add click event
dropdown.addEventListener("click", (e)=>{
// Toggle dropdown menu show class
dropdown.nextElementSibling.classList.toggle('menu-show');
// Toggle icon rotated class
dropdown.lastElementChild.classList.toggle('icon-rotated');
});
});
// Select all sub dropdowns
subDropdowns.forEach(subDropdown=>{
// Add click event
subDropdown.addEventListener('click', (e)=>{
// Toggle sub dropdown menu show class
subDropdown.nextElementSibling.classList.toggle('sub-menu-show');
// Toggle icon rotated class
subDropdown.lastElementChild.classList.toggle('icon-rotated');
});
});
// 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;
}
if(e.ctrlKey && e.keyCode=="S".charCodeAt(0)){
return false;
}
};