1 |
andrew.betts |
3 |
<html> |
2 |
|
|
<body> |
3 |
|
|
<script type="text/javascript"> |
4 |
|
|
window.onError = null; |
5 |
|
|
var domainparts = document.domain.split("."); |
6 |
|
|
var thisdomain = document.domain; |
7 |
|
|
var topdomain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1]; |
8 |
|
|
document.domain = topdomain; |
9 |
|
|
var lastrequesttime = 0; |
10 |
|
|
var pollreq = false; |
11 |
|
|
var polltimer = false; |
12 |
|
|
parent.Meteor.register(this); |
13 |
|
|
|
14 |
|
|
Function.prototype.bind = function(obj) { |
15 |
|
|
var method = this, |
16 |
|
|
temp = function() { |
17 |
|
|
return method.apply(obj, arguments); |
18 |
|
|
}; |
19 |
|
|
return temp; |
20 |
|
|
} |
21 |
|
|
|
22 |
|
|
function newXmlHttp() { |
23 |
|
|
var xmlhttp; |
24 |
|
|
/*@cc_on @*/ |
25 |
|
|
/*@if (@_jscript_version >= 5) |
26 |
|
|
try { |
27 |
|
|
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); |
28 |
|
|
} catch (e) { |
29 |
|
|
try { |
30 |
|
|
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); |
31 |
|
|
} catch (E) { |
32 |
|
|
xmlhttp = false; |
33 |
|
|
} |
34 |
|
|
} |
35 |
|
|
@end @*/ |
36 |
|
|
if (!xmlhttp && typeof XMLHttpRequest!='undefined') { |
37 |
|
|
xmlhttp = new XMLHttpRequest(); |
38 |
|
|
} |
39 |
|
|
return xmlhttp; |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
function poll() { |
43 |
|
|
if (polltimer) clearTimeout(polltimer); |
44 |
|
|
var byteoffset = 0; |
45 |
|
|
var newdata; |
46 |
|
|
document.domain = topdomain; |
47 |
|
|
var url = "http://"+location.hostname+"/push?channel="+get("channel")+"&id="+get("MHostId")+"&persist="+get("persist")+"&template=2"; |
48 |
|
|
if (get("lastmsgreceived") >= 0) { |
49 |
|
|
url += "&restartfrom="+(get("lastmsgreceived")+1); |
50 |
|
|
} else if (get("backtrack") > 0) { |
51 |
|
|
url += "&backtrack="+get("backtrack"); |
52 |
|
|
} else if (typeof(get("backtrack")) != "number") { |
53 |
|
|
url += "&restartfrom="; |
54 |
|
|
} |
55 |
|
|
if (get("maxmessages") && get("persist")) url += "&maxmessages="+get("maxmessages"); |
56 |
|
|
var now = new Date(); |
57 |
|
|
var t = now.getTime(); |
58 |
|
|
url += "&nocache="+t; |
59 |
|
|
try { |
60 |
|
|
document.domain = thisdomain; |
61 |
|
|
} catch (e) {} |
62 |
|
|
pollreq = newXmlHttp(); |
63 |
|
|
pollreq.open("GET", url, true); |
64 |
|
|
pollreq.onreadystatechange = handleresponse.bind(pollreq); |
65 |
|
|
lastrequesttime = t; |
66 |
|
|
if (get("polltimeout")) polltimer = setTimeout(ptimeout, get("polltimeout")); |
67 |
|
|
pollreq.send(null); |
68 |
|
|
document.domain=topdomain; |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
function handleresponse() { |
72 |
|
|
if (this.readyState == 4) { |
73 |
|
|
if (typeof(topdomain) == "undefined") return false; |
74 |
|
|
document.domain=topdomain; |
75 |
|
|
newdata = this.responseText; |
76 |
|
|
var x = newdata.indexOf("parent.Meteor.setServerTime("); |
77 |
|
|
if (x != -1) { |
78 |
|
|
y = newdata.indexOf(");", x); |
79 |
|
|
if (y != -1) eval(newdata.substring(x,y+2)); |
80 |
|
|
} |
81 |
|
|
while (1) { |
82 |
|
|
var x = newdata.indexOf("<s"+"cript>p("); |
83 |
|
|
if (x != -1) { |
84 |
|
|
y = newdata.indexOf("</"+"script>", x); |
85 |
|
|
if (y != -1) { |
86 |
|
|
eval(newdata.substring((x+8),y)); |
87 |
|
|
newdata = newdata.substring(y+9); |
88 |
|
|
} else { |
89 |
|
|
break; |
90 |
|
|
} |
91 |
|
|
} else { |
92 |
|
|
break; |
93 |
|
|
} |
94 |
|
|
} |
95 |
|
|
var now = new Date(); |
96 |
|
|
var t = now.getTime(); |
97 |
|
|
var x = get("pollfreq") - (t-lastrequesttime); |
98 |
|
|
if (x < 10) x = 10; |
99 |
|
|
setTimeout(poll, x); |
100 |
|
|
} |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
function ptimeout() { |
104 |
|
|
if (typeof(pollreq) == "object") { |
105 |
|
|
pollreq.abort(); |
106 |
|
|
delete pollreq; |
107 |
|
|
} |
108 |
|
|
poll(); |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
poll(); |
112 |
|
|
|
113 |
|
|
</script> |
114 |
|
|
</body> |
115 |
|
|
</html> |