-
Notifications
You must be signed in to change notification settings - Fork 7
/
client.html
87 lines (68 loc) · 2.61 KB
/
client.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
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Emoncms</title>
<!--<link href="static/style.css" rel="stylesheet">-->
<link href="static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="static/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">
<script type="text/javascript" src="static/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="static/socket.io.min.js"></script>
<script type="text/javascript" src="static/app.js"></script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="#nodes">Nodes</a></li>
<li><a href="#console">Console</a></li>
<li><a href="#config">Config</a></li>
</ul>
</div>
</div>
</div>
</div>
<br><br><br>
<div class="container">
<div id="content"></div>
</div>
<script src="static/bootstrap/js/bootstrap.js"></script>
</body>
</html>
<script>
var path = "http://"+window.location.host+"/";
var nodes = {};
app.load("console");
app.load("nodes");
app.load("config");
app.load("graph");
var appname = "nodes";
req = (window.location.hash).substring(1).split("/");
appname = req[0];
if (appname=="") appname = "nodes";
app.show(appname);
$(window).on('hashchange', function() {
app.hide(appname);
req = (window.location.hash).substring(1).split("/");
appname = req[0];
app.load(appname);
app.show(appname);
});
$(document).ready(function(){
namespace = '/test'; // change to an empty string to use the global namespace
// the socket.io documentation recommends sending an explicit package upon connection
// this is specially important when using the global namespace
var socket = io.connect('http://' + document.domain + ':' + location.port + namespace);
socket.on('connect', function() {
socket.emit('my event', {data: 'I\'m connected!'});
});
// event handler for server sent data
// the data is displayed in the "Received" section of the page
socket.on('mqttrelay', function(msg) {
$(document).trigger("socketio_msg",[msg]);
});
});
</script>