/[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 8 by andrew.betts, Mon Nov 20 17:59:30 2006 UTC revision 9 by andrew.betts, Fri Dec 8 16:52:58 2006 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 = "http://"+location.hostname+"/push?channel="+get("channel")+"&id="+get("MHostId")+"&template=2";
47          url += "&restartfrom="+(get("lastmsgreceived")+1);          if (get("lastmsgreceived") >= 0) {
48  } else if (get("backtrack") > 0) {                  url += "&restartfrom="+(get("lastmsgreceived")+1);
49          url += "&backtrack="+get("backtrack");          } else if (get("backtrack") > 0) {
50  } else if (typeof(get("backtrack")) != "number") {                  url += "&backtrack="+get("backtrack");
51          url += "&restartfrom=";          } else if (typeof(get("backtrack")) != "number") {
52  }                  url += "&restartfrom=";
53  var now = new Date();          }
54  var t = now.getTime();          var now = new Date();
55  url += "&nocache="+t;          var t = now.getTime();
56  streamreq.open("GET", url, true);          url += "&nocache="+t;
57  streamreq.onreadystatechange = handleresponse.bind(streamreq);          streamreq.open("GET", url, true);
58            streamreq.onreadystatechange = handleresponse.bind(streamreq);
59  function handleresponse() {          streamreq.send(null);
60          if (this.readyState == 3) {  }
61                  buffer = this.responseText;  
62                  newdata = buffer.substring(byteoffset);  function handleresponse() {
63                  byteoffset = buffer.length;          if (this.readyState == 3) {
64                  var x = newdata.indexOf("parent.Meteor.setServerTime(");                  var buffer = this.responseText;
65                  if (x != -1) {                  var newdata = buffer.substring(byteoffset);
66                          y = newdata.indexOf(");", x);                  byteoffset = buffer.length;
67                          if (y != -1) eval(newdata.substring(x,y+2));                  var x = newdata.indexOf("parent.Meteor.setServerTime(");
68                  }                  if (x != -1) {
69                  while (1) {                          y = newdata.indexOf(");", x);
70                          var x = newdata.indexOf("<s"+"cript>p(");                          if (y != -1) eval(newdata.substring(x,y+2));
71                          if (x != -1) {                  }
72                                  y = newdata.indexOf("</"+"script>", x);                  while (1) {
73                                  if (y != -1) {                          var x = newdata.indexOf("<s"+"cript>p(");
74                                          eval(newdata.substring((x+8),y));                          if (x != -1) {
75                                          newdata = newdata.substring(y+9);                                  y = newdata.indexOf("</"+"script>", x);
76                                  } else {                                  if (y != -1) {
77                                            eval(newdata.substring((x+8),y));
78                                          // Last message is corrupt or incomplete.  Ignore it and it will be fetched again                                          newdata = newdata.substring(y+9);
79                                          break;                                  } else {
80                                  }  
81                          } else {                                          // Last message is corrupt or incomplete.  Ignore it and it will be fetched again
82                                            break;
83                                  // No more messages                                  }
84                                  break;                          } else {
85                          }  
86                  }                                  // No more messages
87                  byteoffset = buffer.length-newdata.length;                                  break;
88          } else if (this.readyState == 4) {                          }
89                  if (typeof(r)== "function") r();                  }
90          }                  byteoffset = buffer.length-newdata.length;
91  }          } else if (this.readyState == 4) {
92  streamreq.send(null);                  delete streamreq;
93                    if (typeof(startstream)=="function") {
94                            startstream();
95  </script>                  } else if (typeof(r)=="function") {
96  </body>                          r();
97                    }
98            }
99    }
100    
101    startstream();
102    </script>
103    </body>
104  </html>  </html>

Legend:
Removed from v.8  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26