fix/Footer scripts moved to a dedicated file
This commit is contained in:
1 parent
34c6dd2c66
commit
4a02b75a4d
2 files changed
+28
-29
No files matched your search
@@ -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');
|
||||
});
|
||||
});
|
||||
@@ -21,34 +21,6 @@
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script>
|
||||
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');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="/static/scripts/footer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user