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

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

  ViewVC Help
Powered by ViewVC 1.1.26