/[meteor]/googlecode.com/svn/trunk/public_html/meteor.js
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/meteor.js

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

revision 32 by andrew.betts, Thu Dec 20 21:24:24 2007 UTC revision 55 by andrew.betts, Thu Feb 28 00:21:39 2008 UTC
# Line 25  Meteor = { Line 25  Meteor = {
25          mode: "stream",          mode: "stream",
26          pingtimeout: 20000,          pingtimeout: 20000,
27          pingtimer: null,          pingtimer: null,
28          pollfreq: 5000,          pollfreq: 3000,
29          port: 80,          port: 80,
30          polltimeout: 30000,          polltimeout: 30000,
31          recvtimes: [],          recvtimes: [],
# Line 36  Meteor = { Line 36  Meteor = {
36                  ifr.p = Meteor.process;                  ifr.p = Meteor.process;
37                  ifr.r = Meteor.reset;                  ifr.r = Meteor.reset;
38                  ifr.eof = Meteor.eof;                  ifr.eof = Meteor.eof;
39                    ifr.ch = Meteor.channelInfo;
40                  clearTimeout(Meteor.frameloadtimer);                  clearTimeout(Meteor.frameloadtimer);
41                  Meteor.setstatus(4);                  Meteor.setstatus(4);
42                  Meteor.log("Frame registered");                  Meteor.log("Frame registered");
# Line 91  Meteor = { Line 92  Meteor = {
92    
93          disconnect: function() {          disconnect: function() {
94                  if (Meteor.status) {                  if (Meteor.status) {
                         if (typeof(Meteor.frameref)=="iframe") Meteor.frameref.setAttribute("src", "about:blank");  
                         Meteor.frameref = null;  
95                          clearTimeout(Meteor.pingtimer);                          clearTimeout(Meteor.pingtimer);
96                          clearTimeout(Meteor.updatepollfreqtimer);                          clearTimeout(Meteor.updatepollfreqtimer);
97                          clearTimeout(Meteor.frameloadtimer);                          clearTimeout(Meteor.frameloadtimer);
98                          if (typeof CollectGarbage == 'function') CollectGarbage();                          if (typeof CollectGarbage == 'function') CollectGarbage();
99                          Meteor.setstatus(0);                          if (Meteor.status != 6) Meteor.setstatus(0);
100                            Meteor.log("Disconnected");
101                  }                  }
102          },          },
103                    
# Line 122  Meteor = { Line 122  Meteor = {
122                                  surl += ".h";                                  surl += ".h";
123                          }                          }
124                  }                  }
125                    var now = new Date();
126                    surl += "?nc="+now.getTime();
127                  return surl;                  return surl;
128          },          },
129    
130          loadFrame: function(url) {          loadFrame: function(url) {
                 Meteor.frameref = null;  
131                  try {                  try {
132                          var transferDoc = new ActiveXObject("htmlfile");                          if (!Meteor.frameref) {
133                          transferDoc.open();                                  var transferDoc = new ActiveXObject("htmlfile");
134                          transferDoc.write("<html><script>");                                  Meteor.frameref = transferDoc;
135                          transferDoc.write("document.domain=\""+(document.domain)+"\";");                          }
136                          transferDoc.write("</"+"script></html>");                          Meteor.frameref.open();
137                          transferDoc.parentWindow.Meteor = Meteor;                          Meteor.frameref.write("<html><script>");
138                          transferDoc.close();                          Meteor.frameref.write("document.domain=\""+(document.domain)+"\";");
139                          var ifrDiv = transferDoc.createElement("div");                          Meteor.frameref.write("</"+"script></html>");
140                          transferDoc.appendChild(ifrDiv);                          Meteor.frameref.parentWindow.Meteor = Meteor;
141                            Meteor.frameref.close();
142                            var ifrDiv = Meteor.frameref.createElement("div");
143                            Meteor.frameref.appendChild(ifrDiv);
144                          ifrDiv.innerHTML = "<iframe src=\""+url+"\"></iframe>";                          ifrDiv.innerHTML = "<iframe src=\""+url+"\"></iframe>";
                         Meteor.frameref = transferDoc;  
145                  } catch (e) {                  } catch (e) {
146                          var ifr = document.createElement("IFRAME");                          if (!Meteor.frameref) {
147                          ifr.style.width = "10px";                                  var ifr = document.createElement("IFRAME");
148                          ifr.style.height = "10px";                                  ifr.style.width = "10px";
149                          ifr.style.border = "none";                                  ifr.style.height = "10px";
150                          ifr.style.position = "absolute";                                  ifr.style.border = "none";
151                          ifr.style.top = "-10px";                                  ifr.style.position = "absolute";
152                          ifr.style.marginTop = "-10px";                                  ifr.style.top = "-10px";
153                          ifr.style.zIndex = "-20";                                  ifr.style.marginTop = "-10px";
154                          ifr.Meteor = Meteor;                                  ifr.style.zIndex = "-20";
155                          ifr.setAttribute("src", url);                                  ifr.Meteor = Meteor;
156                          document.body.appendChild(ifr);                                  document.body.appendChild(ifr);
157                          Meteor.frameref = ifr;                                  Meteor.frameref = ifr;
158                            }
159                            Meteor.frameref.setAttribute("src", url);
160                  }                  }
161                  Meteor.log("Loading URL '"+url+"' into frame...");                  Meteor.log("Loading URL '"+url+"' into frame...");
162                  Meteor.frameloadtimer = setTimeout(Meteor.frameloadtimeout, 5000);                  Meteor.frameloadtimer = setTimeout(Meteor.frameloadtimeout, 5000);
# Line 161  Meteor = { Line 166  Meteor = {
166                  Meteor.log("Ping timeout");                  Meteor.log("Ping timeout");
167                  Meteor.mode="smartpoll";                  Meteor.mode="smartpoll";
168                  clearTimeout(Meteor.pingtimer);                  clearTimeout(Meteor.pingtimer);
                 Meteor.connect();  
169                  Meteor.callbacks["changemode"]("poll");                  Meteor.callbacks["changemode"]("poll");
170                  Meteor.lastpingtime = false;                  Meteor.lastpingtime = false;
171                    Meteor.connect();
172          },          },
173    
174          process: function(id, channel, data) {          process: function(id, channel, data) {
175                  if (id == -1) {                  if (id == -1) {
176                          Meteor.log("Ping");                          Meteor.log("Ping");
177                          Meteor.ping();                          Meteor.ping();
178                  } else if (typeof(Meteor.channels[channel]) != "undefined" && id > Meteor.channels[channel].lastmsgreceived) {                  } else if (typeof(Meteor.channels[channel]) != "undefined") {
179                          Meteor.log("Message "+id+" received on channel "+channel+" (last id on channel: "+Meteor.channels[channel].lastmsgreceived+")\n"+data);                          Meteor.log("Message "+id+" received on channel "+channel+" (last id on channel: "+Meteor.channels[channel].lastmsgreceived+")\n"+data);
180                          Meteor.callbacks["process"](data);                          Meteor.callbacks["process"](data);
181                          Meteor.channels[channel].lastmsgreceived = id;                          Meteor.channels[channel].lastmsgreceived = id;
# Line 194  Meteor = { Line 199  Meteor = {
199          },          },
200    
201          reset: function() {          reset: function() {
202                  Meteor.log("Stream reset");                  if (Meteor.status != 6) {
203                  Meteor.ping();                          Meteor.log("Stream reset");
204                  Meteor.callbacks["reset"]();                          Meteor.ping();
205                  var now = new Date();                          Meteor.callbacks["reset"]();
206                  var t = now.getTime();                          var now = new Date();
207                  var x = Meteor.pollfreq - (t-Meteor.lastrequest);                          var t = now.getTime();
208                  if (x < 10) x = 10;                          var x = Meteor.pollfreq - (t-Meteor.lastrequest);
209                  setTimeout(Meteor.connect, x);                          if (x < 10) x = 10;
210                            setTimeout(Meteor.connect, x);
211                    }
212          },          },
213    
214          eof: function() {          eof: function() {
215                    Meteor.log("Received end of stream, will not reconnect");
216                  Meteor.callbacks["eof"]();                  Meteor.callbacks["eof"]();
217                    Meteor.setstatus(6);
218                    Meteor.disconnect();
219            },
220    
221            channelInfo: function(channel, id) {
222                    Meteor.channels[channel].lastmsgreceived = id;
223                    Meteor.log("Received channel info for channel "+channel+": resume from "+id);
224          },          },
225    
226          updatepollfreq: function() {          updatepollfreq: function() {
# Line 241  Meteor = { Line 256  Meteor = {
256                  Meteor.log("Frame load timeout");                  Meteor.log("Frame load timeout");
257                  if (Meteor.frameloadtimer) clearTimeout(Meteor.frameloadtimer);                  if (Meteor.frameloadtimer) clearTimeout(Meteor.frameloadtimer);
258                  Meteor.setstatus(3);                  Meteor.setstatus(3);
259                  setTimeout(Meteor.connect, 5000);                  Meteor.pollmode();
260          },          },
261    
262          extract_xss_domain: function(old_domain) {          extract_xss_domain: function(old_domain) {
# Line 257  Meteor = { Line 272  Meteor = {
272                  //                              3 = Controller frame timeout, retrying.                  //                              3 = Controller frame timeout, retrying.
273                  //                              4 = Controller frame loaded and ready                  //                              4 = Controller frame loaded and ready
274                  //                              5 = Receiving data                  //                              5 = Receiving data
275                    //                              6 = End of stream, will not reconnect
276    
277                  if (Meteor.status != newstatus) {                  if (Meteor.status != newstatus) {
278                          Meteor.status = newstatus;                          Meteor.status = newstatus;

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

  ViewVC Help
Powered by ViewVC 1.1.26