-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
79 lines (71 loc) · 2.25 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Rosetta Home</title>
<script src="js/jquery-2.2.3.min.js"></script>
<script src="js/d3.min.js"></script>
<script src="js/cubism.v1.min.js"></script>
<script src="js/horizon.js"></script>
<script src="js/comparison.js"></script>
<script src="js/location.js"></script>
<script src="config.js"></script>
<script src="https://satori-a.akamaihd.net/satori-rtm-sdk/v1.0.2/sdk.min.js"></script>
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<span id="loading">Loading...</span>
<div id="locations"></div>
<script>
var locations = {};
var hvac_discrete = {
"heat": 20,
"cool": 21,
"off": 0,
"on": 22,
"auto": 23,
}
function get_text(value){
for(var k in hvac_discrete){
var v = hvac_discrete[k];
if(v == value) return k;
}
}
var context = cubism.context() // set the cubism context
.serverDelay(0)
.clientDelay(0)
.step(60000)
.size(1800);
d3.select("#locations").call(function (div) {
div.append("div")
.attr("class", "axis")
.call(context.axis().orient("top"));
div.append("div")
.attr("class", "rule")
.call(context.rule());
});
var rtm = new RTM(endpoint, appKey);
rtm.on("enter-connected", function() {
console.log("Connected to RTM.");
});
rtm.on("leave-connected", function() {
console.log("Disconnected from RTM.");
});
var subscription = rtm.subscribe(channel, RTM.SubscriptionMode.SIMPLE);
subscription.on('rtm/subscription/data', function (pdu) {
$("#loading").hide();
pdu.body.messages.forEach(function (msg) {
if(!(msg.tags.node_id in locations)){
locations[msg.tags.node_id] = new Location(msg.tags.node_id, "#locations", msg.tags.node_id, context);
}
for(l in locations){
locations[l].data(msg);
}
});
});
rtm.start();
</script>
</body>
</html>