Spaces:
Running
Running
File size: 1,057 Bytes
466372a 0c6b869 466372a | 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 | // Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Dynamic server stats counter (example)
const counters = document.querySelectorAll('.text-5xl');
const speed = 200;
counters.forEach(counter => {
const target = +counter.getAttribute('data-target');
const count = +counter.innerText;
const increment = target / speed;
if(count < target) {
counter.innerText = Math.ceil(count + increment);
setTimeout(updateCount, 1);
} else {
counter.innerText = target;
}
function updateCount() {
const current = +counter.innerText;
if(current < target) {
counter.innerText = Math.ceil(current + increment);
setTimeout(updateCount, 1);
} else {
counter.innerText = target;
}
}
}); |