-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
98 lines (84 loc) · 2.39 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
function json(url, func)
{
return $.ajax({
dataType: "json",
url: url,
success: func,
timeout: 50000
})
.done(function() {
$("#diagnostic").hide()
})
.fail(function() {
$("#diagnostic").show()
console.log("fail")
})
}
function requestUpdate()
{
json("refresh.json", renderUpdate)
//$.getJSON("refresh.json", renderUpdate)
}
function renderUpdate(packet)
{
var c = document.getElementById("display")
var ctx = c.getContext("2d")
var xrange = packet.data.length
var yrange = packet.data[0].length
for(var x=0; x<xrange; ++x) {
for(var y=0; y<yrange; ++y) {
ctx.fillStyle = "#" + packet.data[x][y]
ctx.fillRect(x, y, 1.01, 1.01)
}
}
}
function initialize(info)
{
var c = document.getElementById("display")
var ctx = c.getContext("2d")
ctx.scale(c.width/info.xrange, c.height/info.yrange)
}
$(document).ready(function(){
json("initialize.json", initialize)
setInterval(requestUpdate, 300);
});
</script>
<style>
.stdsize {
width: 600px;
height: 600px;
padding: 5px;
position: absolute;
left: 0;
top: 0;
}
#display {
border: 1px solid #ccc;
background: #333;
}
#diagnostic {
font-family: Helvetica, Arial, sans-serif;
border: 1px solid red;
color: #eee;
display: none;
}
p {
padding: 0 15px;
}
</style>
</head>
<body>
<canvas id="display" class="stdsize" width="600" height="600">
Your browser does not support the HTML5 canvas tag.
</canvas>
<div id="diagnostic" class="stdsize">
<p>The server is offline.</p>
<p>+++ Out of Cheese Error. Redo From Start. +++</p>
</div>
</body>
</html>