trimill.xyz/flaskr/templates/projects/number/index.html
2022-06-30 23:47:46 -04:00

36 lines
1 KiB
HTML

{% set meta={"title": "Number", "desc": "make go up"} %}
{% extends "/_base.html"%}
{% block head%}
<script>
const url = "wss://api.trimill.xyz/number";
let ws = undefined;
window.onload = () => {
try {
ws = new WebSocket(url);
ws.addEventListener("message", msg => {
document.getElementById("error").textContent = "";
document.getElementById("number").textContent = msg.data;
console.log(msg);
});
} catch(e) {
document.getElementById("error").textContent = "Error connecting to server: " + e.toString();
}
}
function makegoup() {
try {
ws.send("inc");
} catch(e) {
document.getElementById("error").textContent = "Error connecting to server: " + e.toString();
}
}
</script>
{% endblock %}
{% block content%}
<div id="number">?</div>
<div>
<input type="button" value="Make go up" id="button" onclick="makegoup();" />
</div>
<div class="error" id="error"></div>
{% endblock %}