mirror of
https://github.com/Noratrieb/viewstrap.git
synced 2026-01-14 16:45:10 +01:00
133 lines
3.3 KiB
HTML
133 lines
3.3 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;
|
|
}
|
|
|
|
#compilers-wrapper {
|
|
display: flex;
|
|
height: 100px;
|
|
}
|
|
|
|
.compiler {
|
|
height: 70px;
|
|
width: 150px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border: 1px black solid;
|
|
background: rgb(185, 210, 181);
|
|
}
|
|
</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>
|
|
|
|
<div id="compilers-wrapper"></div>
|
|
|
|
<button class="compile-action" disabled onclick="compile()">
|
|
build me a compiler
|
|
</button>
|
|
<button class="compile-action" disabled onclick="updateCompilers()">
|
|
update compilers
|
|
</button>
|
|
|
|
<br />
|
|
<br />
|
|
|
|
<textarea id="stdout" rows="30" cols="80"></textarea>
|
|
<textarea id="stderr" rows="30" cols="80"></textarea>
|
|
|
|
<script>
|
|
const stdout = document.getElementById("stdout");
|
|
const stderr = document.getElementById("stderr");
|
|
|
|
const compilersWrapper = document.getElementById("compilers-wrapper");
|
|
|
|
const compileActions = document.querySelectorAll(".compile-action");
|
|
|
|
const ws = new WebSocket("ws://localhost:3000/ws");
|
|
|
|
ws.addEventListener("open", () => {
|
|
for (elem of compileActions) {
|
|
elem.disabled = false;
|
|
}
|
|
|
|
ws.send(JSON.stringify("ListCompilers"));
|
|
});
|
|
|
|
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;
|
|
}
|
|
if ("AvailableCompilers" in msg) {
|
|
console.log("compilers");
|
|
const compilers = msg.AvailableCompilers;
|
|
|
|
compilersWrapper.innerHTML = "";
|
|
|
|
for (const compiler of compilers) {
|
|
const inner = document.createElement("div");
|
|
inner.innerText = compiler;
|
|
inner.classList.add("source-box-text");
|
|
const elem = document.createElement("div");
|
|
elem.classList.add("compiler");
|
|
elem.appendChild(inner);
|
|
compilersWrapper.appendChild(elem);
|
|
}
|
|
}
|
|
});
|
|
|
|
function compile() {
|
|
console.log("compiling");
|
|
|
|
ws.send(JSON.stringify("Compile"));
|
|
|
|
stdout.value = "";
|
|
stderr.value = "";
|
|
}
|
|
|
|
function updateCompilers() {
|
|
console.log("list compilers");
|
|
|
|
ws.send(JSON.stringify("ListCompilers"));
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|