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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3 by andrew.betts, Mon Nov 20 17:59:30 2006 UTC revision 53 by andrew.betts, Wed Feb 27 21:58:56 2008 UTC
# Line 1  Line 1 
1  <html>  <html>
2  <body>  <body>
3  <script type="text/javascript">  <script type="text/javascript">
4  window.onError = null;  window.onError = null;
5  var domainparts = document.domain.split(".");  var domainparts = document.domain.split(".");
6  document.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];  document.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];
7  parent.Meteor.register(this);  parent.Meteor.register(this);
8    var streamreq;
9  Function.prototype.bind = function(obj) {  var byteoffset;
10          var method = this,  
11          temp = function() {  function abort() {
12                  return method.apply(obj, arguments);          streamreq.abort();
13          };  }
14          return temp;  
15  }  function newXmlHttp() {
16        try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
17  function abort() {      try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
18          streamreq.abort();      try { return new XMLHttpRequest(); } catch(e) {}
19  }      return null;
20    }
21  function newXmlHttp() {  
22          var xmlhttp;  function startstream() {
23          /*@cc_on @*/          streamreq = newXmlHttp();
24          /*@if (@_jscript_version >= 5)          byteoffset = 0;
25          try {          var url = parent.Meteor.getSubsUrl();
26                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");          streamreq.open("GET", url, true);
27          } catch (e) {          streamreq.onreadystatechange = function() {
28                  try {                  if (typeof streamreq == "undefined") return;
29                          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");                  if (streamreq.readyState == 3) {
30                  } catch (E) {                          var buffer = streamreq.responseText;
31                          xmlhttp = false;                          var newdata = buffer.substring(byteoffset);
32                  }                          byteoffset = buffer.length;
33          }                          while (1) {
34          @end @*/                                  var x = newdata.indexOf("<s"+"cript>");
35          if (!xmlhttp && typeof XMLHttpRequest!='undefined') {                                  if (x != -1) {
36                  xmlhttp = new XMLHttpRequest();                                          y = newdata.indexOf("</"+"script>", x);
37          }                                          if (y != -1) {
38          return xmlhttp;                                                  eval(newdata.substring((x+8),y));
39  }                                                  newdata = newdata.substring(y+9);
40                                            } else {
41  var streamreq = newXmlHttp();  
42  var byteoffset = 0;                                                  // Last message is incomplete.  Ignore it and it will be fetched again
43  var buffer;                                                  break;
44  var newdata;                                          }
45  var url = "http://"+location.hostname+"/push?channel="+get("channel")+"&id="+get("MHostId")+"&template=2";                                  } else {
46  if (get("lastmsgreceived") >= 0) {  
47          url += "&restartfrom="+(get("lastmsgreceived")+1);                                          // No more messages
48  } else if (get("backtrack") > 0) {                                          break;
49          url += "&backtrack="+get("backtrack");                                  }
50  } else if (typeof(get("backtrack")) != "number") {                          }
51          url += "&restartfrom=";                          byteoffset = buffer.length-newdata.length;
52  }                  } else if (streamreq.readyState == 4) {
53  var now = new Date();                          delete streamreq;
54  var t = now.getTime();                          if (typeof(r)=="function") {
55  url += "&nocache="+t;                                  r();
56  streamreq.open("GET", url, true);                          }
57  streamreq.onreadystatechange = handleresponse.bind(streamreq);                  }
58            }
59  function handleresponse() {          streamreq.send(null);
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(");  startstream();
65                  if (x != -1) {  </script>
66                          y = newdata.indexOf(");", x);  </body>
                         if (y != -1) eval(newdata.substring(x,y+2));  
                 }  
                 while (1) {  
                         var x = newdata.indexOf("<s"+"cript>p(");  
                         if (x != -1) {  
                                 y = newdata.indexOf("</"+"script>", x);  
                                 if (y != -1) {  
                                         eval(newdata.substring((x+8),y));  
                                         newdata = newdata.substring(y+9);  
                                 } else {  
   
                                         // Last message is corrupt or incomplete.  Ignore it and it will be fetched again  
                                         break;  
                                 }  
                         } else {  
   
                                 // No more messages  
                                 break;  
                         }  
                 }  
                 byteoffset = buffer.length-newdata.length;  
         } else if (this.readyState == 4) {  
                 if (typeof(r)== "function") r();  
         }  
 }  
 streamreq.send(null);  
   
   
 </script>  
 </body>  
67  </html>  </html>

Legend:
Removed from v.3  
changed lines
  Added in v.53

  ViewVC Help
Powered by ViewVC 1.1.26