/[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 32 - (hide annotations)
Thu Dec 20 21:24:24 2007 UTC (13 years, 4 months ago) by andrew.betts
File MIME type: text/html
File size: 1631 byte(s)
Complete rewrite of the JS web client
Opera and Safari compatibility
Saner request format

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 abort() {
12     streamreq.abort();
13     }
14    
15     function newXmlHttp() {
16 andrew.betts 32 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 andrew.betts 9 }
21    
22     function startstream() {
23     streamreq = newXmlHttp();
24     byteoffset = 0;
25 andrew.betts 32 var url = parent.Meteor.getSubsUrl();
26 andrew.betts 9 streamreq.open("GET", url, true);
27 andrew.betts 32 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>p(");
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 andrew.betts 9
42 andrew.betts 32 // Last message is incomplete. Ignore it and it will be fetched again
43     break;
44     }
45 andrew.betts 9 } else {
46    
47 andrew.betts 32 // No more messages
48 andrew.betts 9 break;
49     }
50     }
51 andrew.betts 32 byteoffset = buffer.length-newdata.length;
52     } else if (streamreq.readyState == 4) {
53     delete streamreq;
54     if (typeof(r)=="function") {
55     r();
56     }
57 andrew.betts 9 }
58     }
59 andrew.betts 32 streamreq.send(null);
60 andrew.betts 9 }
61    
62 andrew.betts 32
63    
64 andrew.betts 9 startstream();
65     </script>
66     </body>
67 andrew.betts 3 </html>

  ViewVC Help
Powered by ViewVC 1.1.26