/[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 62 by andrew.betts, Thu Nov 27 00:33:21 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,  var newdata;
11          temp = function() {  
12                  return method.apply(obj, arguments);  function abort() {
13          };          streamreq.abort();
14          return temp;  }
15  }  
16    function newXmlHttp() {
17  function abort() {          var xhr = null;
18          streamreq.abort();          try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
19  }                  try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
20                            try { xhr = new XMLHttpRequest(); } catch(e) { return false }
21  function newXmlHttp() {                  }
22          var xmlhttp;          }
23          /*@cc_on @*/          return xhr;
24          /*@if (@_jscript_version >= 5)  }
25          try {  
26                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");  function startstream() {
27          } catch (e) {          streamreq = newXmlHttp();
28                  try {          byteoffset = 0;
29                          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");          newdata = "";
30                  } catch (E) {          var url = parent.Meteor.getSubsUrl();
31                          xmlhttp = false;          streamreq.open("GET", url, true);
32                  }          streamreq.onreadystatechange = function() {
33          }                  if (typeof streamreq == "undefined") return;
34          @end @*/                  if (streamreq.readyState == 3) {
35          if (!xmlhttp && typeof XMLHttpRequest!='undefined') {                          extractEvents(streamreq.responseText);
36                  xmlhttp = new XMLHttpRequest();                  } else if (streamreq.readyState == 4) {
37          }                          extractEvents(streamreq.responseText);
38          return xmlhttp;                          delete streamreq;
39  }                          if (typeof(r)=="function") {
40                                    r();
41  var streamreq = newXmlHttp();                          }
42  var byteoffset = 0;                  }
43  var buffer;          }
44  var newdata;          streamreq.send(null);
45  var url = "http://"+location.hostname+"/push?channel="+get("channel")+"&id="+get("MHostId")+"&template=2";          parent.Meteor.lastrequest = parent.Meteor.time();
46  if (get("lastmsgreceived") >= 0) {  }
47          url += "&restartfrom="+(get("lastmsgreceived")+1);  
48  } else if (get("backtrack") > 0) {  function extractEvents(responsestr) {
49          url += "&backtrack="+get("backtrack");          newdata += responsestr.substring(byteoffset);
50  } else if (typeof(get("backtrack")) != "number") {          byteoffset = responsestr.length;
51          url += "&restartfrom=";          while (1) {
52  }                  var x = newdata.indexOf("<s"+"cript>");
53  var now = new Date();                  if (x != -1) {
54  var t = now.getTime();                          y = newdata.indexOf("</"+"script>", x);
55  url += "&nocache="+t;                          if (y != -1) {
56  streamreq.open("GET", url, true);                                  eval(newdata.substring((x+8),y));
57  streamreq.onreadystatechange = handleresponse.bind(streamreq);                                  if (typeof newdata == 'undefined') break;  // If message was eof() then we're now in a freed script
58                                    newdata = newdata.substring(y+9);
59  function handleresponse() {                          } else {
60          if (this.readyState == 3) {  
61                  buffer = this.responseText;                                  // Last message is incomplete.  Ignore it and it will be processed next time
62                  newdata = buffer.substring(byteoffset);                                  break;
63                  byteoffset = buffer.length;                          }
64                  var x = newdata.indexOf("parent.Meteor.setServerTime(");                  } else {
65                  if (x != -1) {  
66                          y = newdata.indexOf(");", x);                          // No more messages
67                          if (y != -1) eval(newdata.substring(x,y+2));                          break;
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) {  startstream();
74                                          eval(newdata.substring((x+8),y));  </script>
75                                          newdata = newdata.substring(y+9);  </body>
                                 } 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>  
76  </html>  </html>

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

  ViewVC Help
Powered by ViewVC 1.1.26