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

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

  ViewVC Help
Powered by ViewVC 1.1.26