basic&ugly FE
This commit is contained in:
@@ -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();
|
||||
};
|
||||
})
|
||||
};
|
||||
Reference in New Issue
Block a user