energrid-cr / script.js
spwotton's picture
fix this mess but use htis : <!DOCTYPE html>
2d2e03e verified
/* 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 = `
<div class="container mx-auto flex flex-col sm:flex-row items-center gap-4">
<p class="text-sm">Esta página web utiliza cookies. Al seguir utilizando esta página, aceptas nuestro uso de cookies.</p>
<div class="flex gap-3">
<button id="reject-cookies" class="text-sm underline">Rechazar</button>
<button id="accept-cookies" class="btn-primary text-sm">Aceptar y cerrar</button>
</div>
</div>
`;
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();
}
});