-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
42 lines (40 loc) · 1.08 KB
/
Copy pathindex.html
File metadata and controls
42 lines (40 loc) · 1.08 KB
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
<!doctype html>
<html lang="en">
<head>
<title>Socket IO example</title>
<style>
ul.percentage { width: 100% }
ul.percentage li { display: block; width: 0; }
ul.percentage li span { float: right; display: block }
ul.percentage li.google { background: #0E70A5; color: #fff }
</style>
</head>
<body>
<h1 style="color:#3facf9">Google Pulse</h1>
<ul class="percentage">
<li class="google">
google<span></span>
</li>
</ul>
<ul class="tweets"></ul>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://127.0.0.1:3000/socket.io/socket.io.js"></script>
<script>
try{
var socket = io.connect('http://localhost:3000');
}catch(e){
console.log('exception',e)
}
jQuery(function ($){
var tweetList = $('ul.tweets'),
count = $('li.google')
if(socket !== undefined){
socket.on('tweet',function(data){
count.css("width",data.google );
tweetList.prepend('<li>'+data.user+': '+data.text + '</li>');
});
}
});
</script>
</body>
</html>