mirror of
https://github.com/gen2brain/cam2ip.git
synced 2026-01-09 08:08:33 +00:00
Format HTML, improve performance a bit
This commit is contained in:
@@ -48,28 +48,17 @@ 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");
|
var context = document.getElementById("canvas").getContext("2d");
|
||||||
}
|
image.onload = function() {
|
||||||
|
context.drawImage(image, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ws.onmessage = function(e) {
|
ws.onmessage = function(e) {
|
||||||
var context = document.getElementById("canvas").getContext("2d");
|
image.setAttribute("src", "data:image/jpeg;base64," + e.data);
|
||||||
|
|
||||||
var image = new Image();
|
|
||||||
image.onload = function() {
|
|
||||||
context.drawImage(image, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
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>
|
||||||
@@ -81,5 +70,5 @@ var html = `<html>
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>`
|
</html>`
|
||||||
|
|||||||
Reference in New Issue
Block a user