basic&ugly FE

This commit is contained in:
2025-04-25 22:49:03 +03:00
parent ae8cd6e1c1
commit 622d540430
3 changed files with 43 additions and 26 deletions

View File

@@ -0,0 +1,21 @@
window.onload = async () => {
let id = (await (await fetch("/api/captcha/new", {method: "POST"})).json()).id
console.log(id);
fetch(`/api/captcha/${id}`).then(response => response.blob())
.then(blob => {
const url = URL.createObjectURL(blob);
document.getElementById("captcha_image").src = url;
}
);
const form = document.getElementById("captchaForm");
const inputField = document.getElementById("captcha");
form.addEventListener('submit', async (e) => {
e.preventDefault();
const response = await fetch(`/api/captcha/${id}`, {method: "PATCH",headers: {'Content-Type': 'application/json'}, body: JSON.stringify({"solution": inputField.value})});
if (response.status == 200) {
inputField.value = "";
window.location.reload();
};
})
};