-
Notifications
You must be signed in to change notification settings - Fork 0
/
html-configmap.yaml
70 lines (63 loc) · 2.58 KB
/
html-configmap.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
apiVersion: v1
kind: ConfigMap
metadata:
name: index-html-configmap
namespace: minifigures
data:
index.html: |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#025928">
<title>IoTrain</title>
<script>
var url_params = new URLSearchParams(window.location.search);
var refresh_interval = url_params.get('refresh_ms');
if (refresh_interval == null) {
insertUrlParam("refresh_ms", 1000)
refresh_interval = 1000
}
var img;
var img2;
var firstTimeDraw = true
var context;
function init() {
var canvas = document.getElementById("canvas");
context = canvas.getContext("2d");
img = new Image();
img2 = new Image();
img.onload = function () {
drawImages();
}
refresh();
setInterval("refresh()", refresh_interval)
}
function refresh() {
img.src = "images/original.jpg" + "?" + new Date() //We need to add this so the canvas thinks its a new image, otherwise it does not load it again
img2.src = "images/masked.jpg" + "?" + new Date() //We need to add this so the canvas thinks its a new image, otherwise it does not load it again
}
function drawImages() {
if (firstTimeDraw) {
canvas.setAttribute("width", img.width * 2);
canvas.setAttribute("height", img.height);
firstTimeDraw = false;
}
context.drawImage(img, 0, 0);
context.drawImage(img2, canvas.width / 2, 0);
}
function insertUrlParam(key, value) {
if (history.pushState) {
let searchParams = new URLSearchParams(window.location.search);
searchParams.set(key, value);
let newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?' + searchParams.toString();
window.history.pushState({ path: newurl }, '', newurl);
}
}
</script>
</head>
<body onload="javascript:init();" style="text-align: center;">
<canvas id="canvas" style="max-width: 100%;"></canvas>
</body>
</html>