2022-06-23 05:58:54 +00:00
|
|
|
{% set meta={"title": "Number", "desc": "make go up"} %}
|
|
|
|
{% extends "/_base.html"%}
|
|
|
|
{% block head%}
|
|
|
|
<script>
|
2022-07-01 03:47:46 +00:00
|
|
|
const url = "wss://api.trimill.xyz/number";
|
|
|
|
let ws = undefined;
|
|
|
|
|
2022-06-23 05:58:54 +00:00
|
|
|
window.onload = () => {
|
2022-07-01 03:47:46 +00:00
|
|
|
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();
|
2022-06-23 05:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function makegoup() {
|
2022-07-01 03:47:46 +00:00
|
|
|
try {
|
|
|
|
ws.send("inc");
|
|
|
|
} catch(e) {
|
|
|
|
document.getElementById("error").textContent = "Error connecting to server: " + e.toString();
|
2022-06-23 05:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|
|
|
|
{% block content%}
|
|
|
|
<div id="number">?</div>
|
|
|
|
<div>
|
|
|
|
<input type="button" value="Make go up" id="button" onclick="makegoup();" />
|
|
|
|
</div>
|
2022-07-01 03:47:46 +00:00
|
|
|
<div class="error" id="error"></div>
|
2022-06-23 05:58:54 +00:00
|
|
|
{% endblock %}
|