mirror of
https://github.com/Noratrieb/viewstrap.git
synced 2026-01-14 08:35:11 +01:00
47 lines
1.2 KiB
HTML
47 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
<button onclick="startWs()">build me a compiler</button>
|
|
|
|
<br />
|
|
<br />
|
|
|
|
<textarea id="stdout" rows="30" cols="80"></textarea>
|
|
<textarea id="stderr" rows="30" cols="80"></textarea>
|
|
|
|
<script>
|
|
function startWs() {
|
|
console.log("starting ws");
|
|
|
|
const stdout = document.getElementById("stdout");
|
|
const stderr = document.getElementById("stderr");
|
|
|
|
const ws = new WebSocket("ws://localhost:3000/ws");
|
|
|
|
ws.addEventListener("open", () => {
|
|
ws.send("bootstrap me");
|
|
});
|
|
|
|
ws.addEventListener("message", (event) => {
|
|
console.log(event.data);
|
|
|
|
const msg = JSON.parse(event.data);
|
|
console.log(msg);
|
|
|
|
if ("Stdout" in msg) {
|
|
stdout.value += msg.Stdout;
|
|
}
|
|
if ("Stderr" in msg) {
|
|
stdout.value += msg.Stderr;
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|