Use nalgebra

This commit is contained in:
2020-06-01 21:25:40 +02:00
parent b0bb187f75
commit 7c4a6a885e
5 changed files with 136 additions and 36 deletions

View File

@@ -6,10 +6,10 @@
<body>
<h1>Hello, world!</h1>
<p id="iteration">Iteration: {{ iteration }}<p>
<p id="iteration">Iteration: {{ iteration }} messages 0.<p>
<ul id="objects">
{% for object in objects %}
<li>{{ object.name }} @ {{ object.x }}, {{ object.y }}</li>
<li id="object-{{ object.id }}">{{ object.name }} @ {{ object.x }}, {{ object.y }}</li>
{% endfor %}
</ul>
@@ -21,18 +21,17 @@
console.log("Connected");
ws.send("MOAR");
}
let messages = 0;
ws.onmessage = function(e) {
const data = JSON.parse(e.data);
messages += 1;
document.getElementById("iteration").innerText = `Iteration: ${data.iteration}`;
const ul = document.getElementById("objects");
while(ul.firstChild) { ul.removeChild(ul.lastChild) }
document.getElementById("iteration").innerText = `Iteration: ${data.iteration} messages ${messages}.`;
for (n in data.objects) {
const ob = data.objects[n];
const li = document.createElement("li");
const li = document.getElementById(`object-${ob.id}`);
li.innerText = `${ob.name} @ ${ob.x}, ${ob.y}`;
ul.append(li);
}
ws.send("MOAR");
};