blob: 8cffc8d284a1facd35164438e82ace37d0f4437d (
plain)
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
|
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
Start = new Date().getTime();
Timestamp = new Date().getTime();
function refresh() {
var onSuccess = function(json) {
Timestamp = json.timestamp;
$('body').prepend('<div>' + (Timestamp - Start) + ": " + json.messages.length + " messages</div>");
setTimeout(refresh, 1000);
};
var onError = function(resp, textStatus, errorThrown) {
$('body').prepend('<div style="color: red">' + textStatus + ', ' + errorThrown + '</div>');
setTimeout(refresh, 1000);
};
$.ajax({
type: 'GET',
timeout: 5000,
url: "/refresh",
data: { 'room': "RoomA", 'since': Timestamp },
cache: false,
dataType: 'json',
success: onSuccess,
error: onError
});
}
$(document).ready(refresh);
</script>
</head>
<body>
</body>
</html>
|