Skip to content

Commit 276cda8

Browse files
Update script.js
1 parent f7b586f commit 276cda8

File tree

1 file changed

+69
-1
lines changed

1 file changed

+69
-1
lines changed

script.js

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,69 @@
1-
console.log("Política de Privacidade carregada com sucesso!");
1+
// Configurações iniciais
2+
document.addEventListener('DOMContentLoaded', () => {
3+
// 1. Scroll suave para seções
4+
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
5+
anchor.addEventListener('click', function(e) {
6+
e.preventDefault();
7+
const target = document.querySelector(this.getAttribute('href'));
8+
if (target) {
9+
target.scrollIntoView({
10+
behavior: 'smooth',
11+
block: 'start'
12+
});
13+
}
14+
});
15+
});
16+
17+
// 2. Destaque dinâmico de seções
18+
const observerOptions = {
19+
threshold: 0.1,
20+
rootMargin: '0px'
21+
};
22+
23+
const observer = new IntersectionObserver((entries) => {
24+
entries.forEach(entry => {
25+
if (entry.isIntersecting) {
26+
entry.target.classList.add('secao-ativa');
27+
}
28+
});
29+
}, observerOptions);
30+
31+
document.querySelectorAll('section').forEach(section => {
32+
observer.observe(section);
33+
});
34+
35+
// 3. Botão "Voltar ao Topo"
36+
const backToTop = document.createElement('button');
37+
backToTop.innerHTML = '↑';
38+
backToTop.className = 'back-to-top';
39+
backToTop.ariaLabel = 'Voltar ao topo da página';
40+
document.body.appendChild(backToTop);
41+
42+
backToTop.addEventListener('click', () => {
43+
window.scrollTo({
44+
top: 0,
45+
behavior: 'smooth'
46+
});
47+
});
48+
49+
window.addEventListener('scroll', () => {
50+
backToTop.style.display = (window.scrollY > 500) ? 'block' : 'none';
51+
});
52+
53+
// 4. Data da última atualização
54+
const lastUpdated = document.createElement('p');
55+
lastUpdated.className = 'ultima-atualizacao';
56+
lastUpdated.innerHTML = `Última atualização: ${new Date(document.lastModified).toLocaleDateString('pt-BR')}`;
57+
document.querySelector('section[aria-labelledby="atualizacoes"]').appendChild(lastUpdated);
58+
59+
// 5. Interação com links de contato
60+
document.querySelectorAll('address a').forEach(link => {
61+
link.addEventListener('click', (e) => {
62+
if (!confirm('Você está sendo redirecionado para um recurso externo. Continuar?')) {
63+
e.preventDefault();
64+
}
65+
});
66+
});
67+
68+
console.log('Política de Privacidade - Funcionalidades carregadas com sucesso!');
69+
});

0 commit comments

Comments
 (0)