1 |
<html> |
2 |
<body> |
3 |
<script type="text/javascript"> |
4 |
window.onError = null; |
5 |
var domainparts = document.domain.split("."); |
6 |
document.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1]; |
7 |
parent.Meteor.register(this); |
8 |
var streamreq; |
9 |
var byteoffset; |
10 |
|
11 |
function abort() { |
12 |
streamreq.abort(); |
13 |
} |
14 |
|
15 |
function newXmlHttp() { |
16 |
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {} |
17 |
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} |
18 |
try { return new XMLHttpRequest(); } catch(e) {} |
19 |
return null; |
20 |
} |
21 |
|
22 |
function startstream() { |
23 |
streamreq = newXmlHttp(); |
24 |
byteoffset = 0; |
25 |
var url = parent.Meteor.getSubsUrl(); |
26 |
streamreq.open("GET", url, true); |
27 |
streamreq.onreadystatechange = function() { |
28 |
if (typeof streamreq == "undefined") return; |
29 |
if (streamreq.readyState == 3) { |
30 |
var buffer = streamreq.responseText; |
31 |
var newdata = buffer.substring(byteoffset); |
32 |
byteoffset = buffer.length; |
33 |
while (1) { |
34 |
var x = newdata.indexOf("<s"+"cript>"); |
35 |
if (x != -1) { |
36 |
y = newdata.indexOf("</"+"script>", x); |
37 |
if (y != -1) { |
38 |
eval(newdata.substring((x+8),y)); |
39 |
newdata = newdata.substring(y+9); |
40 |
} else { |
41 |
|
42 |
// Last message is incomplete. Ignore it and it will be fetched again |
43 |
break; |
44 |
} |
45 |
} else { |
46 |
|
47 |
// No more messages |
48 |
break; |
49 |
} |
50 |
} |
51 |
byteoffset = buffer.length-newdata.length; |
52 |
} else if (streamreq.readyState == 4) { |
53 |
delete streamreq; |
54 |
if (typeof(r)=="function") { |
55 |
r(); |
56 |
} |
57 |
} |
58 |
} |
59 |
streamreq.send(null); |
60 |
} |
61 |
|
62 |
|
63 |
|
64 |
startstream(); |
65 |
</script> |
66 |
</body> |
67 |
</html> |