Format HTML, improve performance a bit

This commit is contained in:
Milan Nikolic
2017-10-05 20:40:33 +02:00
parent 04492f988a
commit 24fffe2c3f

View File

@@ -48,29 +48,18 @@ var html = `<html>
<script> <script>
var url = "ws://{BIND}/socket"; var url = "ws://{BIND}/socket";
ws = new WebSocket(url); ws = new WebSocket(url);
var image = new Image();
ws.onopen = function() { ws.onopen = function() {
console.log("onopen");
}
ws.onmessage = function(e) {
var context = document.getElementById("canvas").getContext("2d"); var context = document.getElementById("canvas").getContext("2d");
var image = new Image();
image.onload = function() { image.onload = function() {
context.drawImage(image, 0, 0); context.drawImage(image, 0, 0);
} }
}
ws.onmessage = function(e) {
image.setAttribute("src", "data:image/jpeg;base64," + e.data); image.setAttribute("src", "data:image/jpeg;base64," + e.data);
} }
ws.onclose = function(e) {
console.log("onclose");
}
ws.onerror = function(e) {
console.log("onerror");
}
</script> </script>
</head> </head>
<body style="background-color: #000000"> <body style="background-color: #000000">