33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
// DauphinCraft — main.js (vanilla, no deps)
|
|
|
|
// Intersection Observer — fade-in sections
|
|
const observer = new IntersectionObserver(
|
|
(entries) => entries.forEach(e => {
|
|
if (e.isIntersecting) { e.target.classList.add('visible'); observer.unobserve(e.target); }
|
|
}),
|
|
{ threshold: 0.12 }
|
|
);
|
|
document.querySelectorAll('.fade-in').forEach(el => observer.observe(el));
|
|
|
|
// Copy server IP to clipboard
|
|
function copyServerIP() {
|
|
const ip = document.getElementById('server-ip').textContent;
|
|
const btn = document.getElementById('btn-copy');
|
|
if (!navigator.clipboard) { return; }
|
|
navigator.clipboard.writeText(ip).then(() => {
|
|
btn.classList.add('copied');
|
|
btn.querySelector('svg').style.display = 'none';
|
|
const original = btn.innerHTML;
|
|
btn.textContent = 'Copié !';
|
|
setTimeout(() => { btn.innerHTML = original; btn.classList.remove('copied'); }, 2000);
|
|
});
|
|
}
|
|
|
|
// Close mobile menu when a nav link is clicked
|
|
document.querySelectorAll('.nav-links a').forEach(a => {
|
|
a.addEventListener('click', () => {
|
|
const toggle = document.getElementById('nav-toggle');
|
|
if (toggle) toggle.checked = false;
|
|
});
|
|
});
|