/[meteor]/googlecode.com/svn/trunk/public_html/stream.html
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /googlecode.com/svn/trunk/public_html/stream.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations)
Mon Nov 20 17:59:30 2006 UTC (13 years, 4 months ago) by andrew.betts
File MIME type: text/html
File size: 2274 byte(s)
Initial import
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
9 Function.prototype.bind = function(obj) {
10 var method = this,
11 temp = function() {
12 return method.apply(obj, arguments);
13 };
14 return temp;
15 }
16
17 function abort() {
18 streamreq.abort();
19 }
20
21 function newXmlHttp() {
22 var xmlhttp;
23 /*@cc_on @*/
24 /*@if (@_jscript_version >= 5)
25 try {
26 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
27 } catch (e) {
28 try {
29 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
30 } catch (E) {
31 xmlhttp = false;
32 }
33 }
34 @end @*/
35 if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
36 xmlhttp = new XMLHttpRequest();
37 }
38 return xmlhttp;
39 }
40
41 var streamreq = newXmlHttp();
42 var byteoffset = 0;
43 var buffer;
44 var newdata;
45 var url = "http://"+location.hostname+"/push?channel="+get("channel")+"&id="+get("MHostId")+"&template=2";
46 if (get("lastmsgreceived") >= 0) {
47 url += "&restartfrom="+(get("lastmsgreceived")+1);
48 } else if (get("backtrack") > 0) {
49 url += "&backtrack="+get("backtrack");
50 } else if (typeof(get("backtrack")) != "number") {
51 url += "&restartfrom=";
52 }
53 var now = new Date();
54 var t = now.getTime();
55 url += "&nocache="+t;
56 streamreq.open("GET", url, true);
57 streamreq.onreadystatechange = handleresponse.bind(streamreq);
58
59 function handleresponse() {
60 if (this.readyState == 3) {
61 buffer = this.responseText;
62 newdata = buffer.substring(byteoffset);
63 byteoffset = buffer.length;
64 var x = newdata.indexOf("parent.Meteor.setServerTime(");
65 if (x != -1) {
66 y = newdata.indexOf(");", x);
67 if (y != -1) eval(newdata.substring(x,y+2));
68 }
69 while (1) {
70 var x = newdata.indexOf("<s"+"cript>p(");
71 if (x != -1) {
72 y = newdata.indexOf("</"+"script>", x);
73 if (y != -1) {
74 eval(newdata.substring((x+8),y));
75 newdata = newdata.substring(y+9);
76 } else {
77
78 // Last message is corrupt or incomplete. Ignore it and it will be fetched again
79 break;
80 }
81 } else {
82
83 // No more messages
84 break;
85 }
86 }
87 byteoffset = buffer.length-newdata.length;
88 } else if (this.readyState == 4) {
89 if (typeof(r)== "function") r();
90 }
91 }
92 streamreq.send(null);
93
94
95 </script>
96 </body>
97 </html>

  ViewVC Help
Powered by ViewVC 1.1.26