cargo-bisect-rustc-service/index.html
2022-09-28 20:44:42 +02:00

85 lines
1.9 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bisect rustc</title>
<style>
html {
font-family: Arial, Helvetica, sans-serif;
}
.hidden {
display: none;
}
#code {
columns: 100;
}
.bisect-btn {
width: 200px;
height: 50px;
}
</style>
</head>
<body>
<h1>Bisect rustc</h1>
<textarea
id="code"
rows="30"
cols="80"
placeholder="// Rust code goes here..."
>
fn uwu() {}
</textarea>
<br />
<button class="bisect-btn" onclick="bisect()">Bisect!</button>
<div id="status" class="hidden" />
<div id="result" class="hidden" />
<script>
let bisecting = false;
async function bisect() {
if (bisecting) {
return;
}
bisecting = true;
const code = document.getElementById("code");
const status = document.getElementById("status");
const result = document.getElementById("result");
status.classList.remove("hidden");
status.innerText = "Sending request...";
const fetched = await fetch(
"https://bisect-rustc.nilstrieb.dev/bisect",
{
method: "POST",
body: code.value,
}
);
const { id } = await fetched.json();
async function tryFetch() {
const fetched = await fetch(
`https://bisect-rustc.nilstrieb.dev/bisect/${id}`
);
const { done, output, time } = await fetched.json();
if (done) {
bisecting = false;
result.innerText = output;
status.innerText = `Bisected job ${id} successfully in ${time}ms`;
}
setTimeout(tryFetch, 3000);
}
tryFetch();
status.innerHTML = `Waiting for bisection, job id=${id}`;
}
</script>
</body>
</html>