File size: 1,686 Bytes
872a351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d2e03e
 
 
 
 
f191e6c
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
37
38
39
40
41
42
43
44
45
46

/* 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();
    }
});