63 lines
2.6 KiB
HTML
63 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>lđa testing</title>
|
|
</head>
|
|
|
|
<body>
|
|
<form action="/endp" method="post" id="only_form">
|
|
<style>
|
|
@scope {
|
|
*:not(style, script) {
|
|
display: block;
|
|
}
|
|
|
|
p {
|
|
font-size: larger;
|
|
}
|
|
}
|
|
</style>
|
|
<label for="oneid">url (anything after the first /):<input type="text" name="one" id="oneid"
|
|
placeholder="url" /></label>
|
|
<label for="twoid">content (as html cuz mime my ass):<textarea rows="7" cols="40" name="two" id="twoid"
|
|
placeholder="content"></textarea>
|
|
</label>
|
|
<label for="threeid">response code if path visited. Default 200<input type="number" name="three" id="threeid"
|
|
placeholder="http res code" min="0" /></label>
|
|
<label for="fourid">expiration time for anything (todo idk how to do )<input type="number" name="four"
|
|
id="fourid" placeholder="expiration in days" min="0" /></label>
|
|
<p>if bugs tell me how to solve cuz im bad</p>
|
|
<input type="submit" value="Sumit rn" />
|
|
<script>
|
|
const form = document.getElementById("only_form");
|
|
// const what = form.querySelector("input[type=submit]");
|
|
console.log(form);
|
|
form.addEventListener("submit", (e) => {
|
|
// somewhere there has been code
|
|
e.preventDefault();
|
|
const data = new FormData(form);
|
|
const jsData = Object.fromEntries(data);
|
|
Object.entries(jsData).forEach(
|
|
([k, v]) => (jsData[k] = v ? v : undefined)
|
|
); // important here as we are dealing with Strings true/false kinda works how it is.
|
|
const jsonified_data = JSON.stringify(jsData);
|
|
const jsonified_custom_data = `{"from":"ldlda","data":${jsonified_data}}`; // haxxor
|
|
const xhr = new XMLHttpRequest(); // this is going to be used. a lot.
|
|
xhr.open("POST", form.getAttribute("action"));
|
|
xhr.setRequestHeader("Content-type", "application/json");
|
|
xhr.send(jsonified_custom_data);
|
|
xhr.addEventListener(
|
|
"load",
|
|
(_) => (document.getElementById("what").innerText = xhr.response)
|
|
);
|
|
return false;
|
|
});
|
|
</script>
|
|
</form>
|
|
<div id="what"></div>
|
|
</body>
|
|
|
|
</html> |