/* COOKIE BANNER */
const cookieBanner = () => {
if (localStorage.getItem('cookies-accepted')) return;
const banner = document.createElement('div');
banner.className = 'fixed bottom-0 inset-x-0 bg-slate-900 text-white px-6 py-4 z-50 shadow-2xl';
banner.innerHTML = `
Esta página web utiliza cookies. Al seguir utilizando esta página, aceptas nuestro uso de cookies.
`;
document.body.appendChild(banner);
document.getElementById('accept-cookies').onclick = () => {
localStorage.setItem('cookies-accepted', 'true');
banner.remove();
};
document.getElementById('reject-cookies').onclick = () => banner.remove();
};
/* SMOOTH SCROLL ANCHOR LINKS */
const smoothScroll = () => {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
});
};
/* INIT */
document.addEventListener('DOMContentLoaded', () => {
cookieBanner();
smoothScroll();
// Initialize feather icons
if (window.feather) {
feather.replace();
}
});