-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
64 lines (60 loc) · 1.86 KB
/
index.html
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
<!doctype html>
<html lang="en">
<head>
<title>ArtnetSlideServer</title>
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
var curr = {};
curr.img = '';
curr.alpha = 0;
// preload images
for (let i = 0; i < 25; i++) {
let img = new Image();
if (i < 10) { n = '0'+i } else { n = i; }
img.src = '/images/image_'+n+'.png';
}
var mediaImg = document.getElementById("media");
socket.on("update_0", function(data) {
console.log(data);
if (data.i != undefined) {
if (curr.img != data.i) {
document.getElementById("media").style.backgroundImage = 'url(/images/'+data.i+')';
}
curr.img = data.i;
}
if (data.a != undefined) {
if (curr.alpha != data.a) {
document.getElementById("media").style.opacity = data.a;
}
curr.alpha = parseFloat(data.a);
}
if (data.cmd != undefined) {
if (data.cmd == "reload") {
window.location = window.location.href.split('?')[0]+'?its='+Math.floor(Date.now);
}
}
console.log(curr);
});
</script>
<style>
body { background-color: #000; }
#media {
position: fixed;
top: 0;
left: 0;
background-position: center;
background-size: cover;
background-image: url("/images/image_00.png");
height: 100%;
width: 100%;
transition: opacity 0.05s linear; /* used for basic smoothing */
}
.hidden { display: none; }
</style>
</head>
<body>
<div id="media"></div>
<div class="hidden"><img id="buf" src="#"></div>
</body>
</html>