-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (33 loc) · 1.15 KB
/
script.js
File metadata and controls
40 lines (33 loc) · 1.15 KB
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
const menu = document.getElementById('menu');
const menuToggle = document.getElementById('menuToggle');
const body = document.body;
menuToggle.addEventListener('click', (e) => {
e.stopPropagation();
menu.classList.toggle('active');
});
body.addEventListener('click', (e) => {
if (menu.classList.contains('active') && !menu.contains(e.target) && e.target !== menuToggle) {
menu.classList.remove('active');
}
});
menu.addEventListener('click', (e) => {
e.stopPropagation();
});
document.addEventListener('DOMContentLoaded', function() {
const links = document.querySelectorAll('a');
const currentDomain = window.location.hostname;
links.forEach(link => {
const linkHost = new URL(link.href).hostname;
if (linkHost !== currentDomain) {
link.addEventListener('click', function(event) {
event.preventDefault();
const redirectUrl = link.href;
window.open(`redirect.html?url=${encodeURIComponent(redirectUrl)}`, '_blank');
});
}
});
});
const footer = document.getElementsByTagName('footer')[0];
if (footer) {
footer.textContent = footer.textContent.replace('!!FULL_YEAR!!', `${new Date().getFullYear()}`);
};