-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
94 lines (68 loc) · 2.49 KB
/
script.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
84
85
86
87
88
89
90
91
92
93
94
var topNav = document.querySelector('#topnav');
var hotdog = document.querySelector('#hotdog');
var rightSidebar = document.querySelector('#right-socials');
var menuButton = document.querySelector('#dropdown');
var closeMenu = document.querySelector('#closeMenu');
var openMenu = document.querySelector('#openMenu');
window.addEventListener('resize', function() {
// if (window.innerWidth <= window.innerHeight) {
if (topNav.clientWidth < 662) {
hotdog.style.display = 'none';
menuButton.style.display = 'flex';
} else {
hotdog.style.display = 'flex';
rightSidebar.style.display = 'none';
menuButton.style.display = 'none';
openMenu.style.display = 'block';
closeMenu.style.display = 'none';
}
});
function toggleMenu() {
if (rightSidebar.style.display == 'flex') {
rightSidebar.style.display = 'none'
openMenu.style.display = 'block';
closeMenu.style.display = 'none';
} else {
rightSidebar.style.display = 'flex'
openMenu.style.display = 'none';
closeMenu.style.display = 'block';
}
}
// const container = document.querySelector('#topnav');
// const drop = document.querySelector('#dropdown');
// const navWidth = container.scrollWidth
// window.addEventListener('resize', function() {
// if (container.scrollWidth > container.clientWidth) {
// topNav.style.display = 'none';
// menuButton.style.display = 'flex';
// } else {
// topNav.style.display = 'flex';
// rightSidebar.style.display = 'none';
// menuButton.style.display = 'none';
// }
// });
// // Create a ResizeObserver to monitor for size changes
// const resizeObserver = new ResizeObserver(checkOverflow);
// // Start observing the container
// resizeObserver.observe(container);
// // You may want to check for overflow initially
// checkOverflow();
// Initial check on page load
document.addEventListener('DOMContentLoaded', function() {
var event = new Event('resize');
window.dispatchEvent(event);
});
function activateLink(element) {
document.querySelectorAll('a').forEach(function(a) {
a.classList.remove('selected');
});
element.classList.add('selected');
}
function copyToClipboard(text) {
// Use the Clipboard API to copy the text
navigator.clipboard.writeText(text).then(function() {
alert(`"`+ text + `"` + " copied to clipboard!");
}).catch(function(error) {
alert("Failed to copy text: " + error);
});
}