-
Notifications
You must be signed in to change notification settings - Fork 0
/
Site.js
34 lines (30 loc) · 1.14 KB
/
Site.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
// Smooth scrolling for internal links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Dynamically update the footer with the current year
document.addEventListener("DOMContentLoaded", function() {
const footerYear = new Date().getFullYear();
const footerText = document.querySelector('footer p');
if (footerText) {
footerText.innerHTML = `© ${footerYear} Blood Gang™️, Inc`;
}
});
// Alert and confirm external links (any link that is not to GitHub)
document.querySelectorAll('a').forEach(link => {
const isExternal = link.href && !link.href.includes('github.com');
if (isExternal) {
link.addEventListener('click', (e) => {
e.preventDefault();
const userConfirmed = confirm('You are about to visit an external site. Do you wish to proceed?');
if (userConfirmed) {
window.open(link.href, '_blank');
}
});
}
});