mirror of
https://github.com/gen2brain/cam2ip.git
synced 2026-01-09 16:18:31 +00:00
Format HTML
This commit is contained in:
@@ -44,31 +44,31 @@ func (h *HTML) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
var html = `<html>
|
var html = `<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
<title>cam2ip</title>
|
<title>cam2ip</title>
|
||||||
<script>
|
<script>
|
||||||
var url = "ws://{BIND}/socket";
|
ws = new WebSocket("ws://{BIND}/socket");
|
||||||
ws = new WebSocket(url);
|
var image = new Image();
|
||||||
var image = new Image();
|
|
||||||
|
|
||||||
ws.onopen = function() {
|
ws.onopen = function() {
|
||||||
var context = document.getElementById("canvas").getContext("2d");
|
var context = document.getElementById("canvas").getContext("2d");
|
||||||
image.onload = function() {
|
image.onload = function() {
|
||||||
context.drawImage(image, 0, 0);
|
context.drawImage(image, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.onmessage = function(e) {
|
ws.onmessage = function(e) {
|
||||||
image.setAttribute("src", "data:image/jpeg;base64," + e.data);
|
image.setAttribute("src", "data:image/jpeg;base64," + e.data);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body style="background-color: #000000">
|
<body style="background-color: #000000">
|
||||||
<table style="width:100%; height:100%">
|
<table style="width:100%; height:100%">
|
||||||
<tr style="height:100%">
|
<tr style="height:100%">
|
||||||
<td style="height:100%; text-align:center">
|
<td style="height:100%; text-align:center">
|
||||||
<canvas id="canvas" width="{WIDTH}" height="{HEIGHT}"></canvas>
|
<canvas id="canvas" width="{WIDTH}" height="{HEIGHT}"></canvas>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>`
|
</html>`
|
||||||
|
|||||||
Reference in New Issue
Block a user