-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
63 lines (54 loc) · 1.66 KB
/
script.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
document.addEventListener("DOMContentLoaded", function () {
const ancoras = document.querySelectorAll(".navegador_ancoras a");
const sections = document.querySelectorAll("section");
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
const id = entry.target.getAttribute("id");
const navItem = document.querySelector(
`.navegador_ancoras a[href="#${id}"]`
);
if (entry.isIntersecting) {
ancoras.forEach((a) => a.classList.remove("ativa"));
navItem.classList.add("ativa");
}
});
},
{ threshold: 0.7 }
);
sections.forEach((section) => {
observer.observe(section);
});
ancoras.forEach((ancora) => {
ancora.addEventListener("click", function (event) {
ancoras.forEach((a) => a.classList.remove("ativa"));
this.classList.add("ativa");
});
});
});
function showAlert(message) {
document.getElementById("alertMessage").innerText = message;
document.getElementById("customAlert").style.display = "flex";
}
function closeAlert() {
document.getElementById("customAlert").style.display = "none";
}
function handleSubmit(event) {
event.preventDefault();
showAlert("Processando o envio do formulário...");
var formData = new FormData(event.target);
fetch("https://formsubmit.co/lais301m@gmail.com", {
method: "POST",
body: formData,
})
.then((response) => {
if (response.ok) {
showAlert("Formulário enviado com sucesso!");
} else {
throw new Error("Falha ao enviar o formulário");
}
})
.catch((error) => {
showAlert("Erro: " + error.message);
});
}