/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 21 - (hide annotations)
Mon May 14 13:42:45 2007 UTC (16 years, 10 months ago) by andrew.betts
File MIME type: text/html
File size: 2213 byte(s)


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

  ViewVC Help
Powered by ViewVC 1.1.26