45 lines
1.1 KiB
HTML
45 lines
1.1 KiB
HTML
<!-- vim: set ts=2 sw=2 et tw=80: -->
|
|
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
</head>
|
|
<body>
|
|
<div id="malusa">
|
|
<h1>Waiting for authentication...</h1>
|
|
</div>
|
|
<script>
|
|
|
|
let malusa = document.getElementById("malusa");
|
|
let token = localStorage.getItem("token");
|
|
if (!token) {
|
|
token = prompt("insert authentication token");
|
|
localStorage.setItem("token", token);
|
|
}
|
|
|
|
let connection = new WebSocket("ws://localhost:8080/sensor-socket?token=" + token);
|
|
console.log("***CREATED WEBSOCKET");
|
|
|
|
let authentica
|
|
connection.onopen = function(evt) {
|
|
malusa.innerHTML = "<h1>Socket is now authenticated!</h1>" +
|
|
"<img src='https://maggioni.xyz/astley.gif'>";
|
|
};
|
|
|
|
connection.onmessage = function(evt) {
|
|
console.log("***ONMESSAGE", evt);
|
|
let data = JSON.parse(evt.data);
|
|
let a = document.getElementById("giovanni");
|
|
if (a) a.remove();
|
|
|
|
malusa.innerHTML += "<pre id=\"giovanni\">" + JSON.stringify(JSON.parse(evt.data), null, 2) + "</pre>";
|
|
};
|
|
|
|
connection.onerror = function(evt) {
|
|
console.error("***ONERROR", evt);
|
|
};
|
|
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|