fix/Footer scripts moved to a dedicated file

This commit is contained in:
nicoagostini committed 2025-05-14 12:53:58 -07:00
1 parent 34c6dd2c66
commit 4a02b75a4d
2 files changed
+28 -29

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
const factButton = document.getElementById("factButton");
const factMenu = document.getElementById("factMenu");
const factInput = document.getElementById("factInput");
const factSubmitButton = document.getElementById("factSubmitButton");
factButton.addEventListener("click", () => {
factMenu.classList.toggle("hidden");
});
factSubmitButton.addEventListener("click", () => {
fetch("/fact", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
fact: factInput.value,
}),
})
.then(response => response.json())
.then(data => {
Swal.fire('Here is a fact!', data.fact, 'success');
})
.catch(error => {
console.error("Error fetching fact:", error);
Swal.fire('Error fetching fact', 'Please try again later', 'error');
});
});