mirror of
https://github.com/Noratrieb/viewstrap.git
synced 2026-03-14 21:26:07 +01:00
78 lines
1.9 KiB
HTML
78 lines
1.9 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>Viewstrap</title>
|
|
<style>
|
|
html {
|
|
font-family: sans-serif;
|
|
}
|
|
|
|
.source-box {
|
|
border: 1px black solid;
|
|
background: rgb(188, 188, 188);
|
|
width: 500px;
|
|
height: 150px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.source-box-text {
|
|
font-size: 18pt;
|
|
}
|
|
|
|
.source-wrapper {
|
|
display: flex;
|
|
margin-bottom: 10px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="source-wrapper">
|
|
<div class="source-box"><div class="source-box-text">COMPILER</div></div>
|
|
<div class="source-box"><div class="source-box-text">LIBRARY</div></div>
|
|
</div>
|
|
|
|
<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");
|
|
|
|
stdout.value = "";
|
|
stderr.value = "";
|
|
|
|
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>
|