-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
71 lines (63 loc) · 1.42 KB
/
example.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
<!doctype html>
<html>
<head>
<style type="text/css">
html {
overflow: hidden;
}
body {
overflow: hidden;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
background: gray;
}
#ws {
background: white;
margin: 0;
padding: 0.5em 0.5em 0.5em 0.5em;
position: absolute;
top: 5em;
left: 0.5em;
right: 0.5em;
bottom: 3em;
overflow: auto;
}
#form {
padding: 0 0.5em 0 0.5em;
margin: 0;
position: absolute;
bottom: 1em;
left: 0px;
width: 100%;
overflow: hidden;
}
</style>
</head>
<body>
<h1>Websocket Messages:</h1>
<ul id="ws">
</ul>
<form id="form">
<input type="submit" value="Send" />
<input type="text" id="msg" size="64"/>
</form>
</body>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="dist/goatee.js"></script>
<script>
var gt = new goatee("ws://localhost:1235/");
// bind / listen to as many channels as needed.
gt.bind('chan1', function(data) {
$('#ws').append('<p>' + data.data + '</p>');
$('#msg').val('');
});
$('#form').submit(function(e) {
e.preventDefault();
msg = $('#msg').val();
// send data on channels you're bound to
gt.emit('chan1', msg);
});
</script>
</html>