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

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

revision 18 by andrew.betts, Wed May 2 10:55:26 2007 UTC revision 64 by andrew.betts, Mon Jan 19 11:19:41 2009 UTC
# Line 1  Line 1 
1  // Set domain at highest level  /*
2  var domainparts = document.domain.split(".");  stream: xhrinteractive, iframe, serversent
3  document.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];  longpoll
4    smartpoll
5  Function.prototype.bind = function(obj) {  simplepoll
6          var method = this,  */
7          temp = function() {  
8                  return method.apply(obj, arguments);  Meteor = {
9          };  
10          return temp;          callbacks: {
11  }                  process: function() {},
12  Function.prototype.andThen=function(g) {                  reset: function() {},
13          var f=this;                  eof: function() {},
14          var a=this.arguments                  statuschanged: function() {},
15          return function(args) {                  changemode: function() {}
16                  f(a);g(args);          },
17          }          channelcount: 0,
18  };          channels: {},
19            debugmode: false,
20  function Meteor(instID) {          frameref: null,
21            host: null,
22          this.transferDoc = false;          hostid: null,
23          this.pingtimer = false;          maxpollfreq: 60000,
24          this.updatepollfreqtimer = false;          minpollfreq: 2000,
25          this.lastrequest = 0;          mode: "stream",
26          this.recvtimes = new Array();          pingtimeout: 20000,
27          this.MHostId = false;          pingtimer: null,
28          this.callback_process = function() {};          pollfreq: 3000,
29          this.callback_reset = function() {};          port: 80,
30          this.callback_eof = function() {};          pollaborted: false,
31          this.callback_changemode = function() {};          pollhost: null,
32          this.callback_statuschanged = function() {};          pollnum: 0,
33          this.persist = true;          polltimeout: 30000,
34          this.frameloadtimer = false;          polltimer: null,
35          this.debugmode = false;          recvtimes: [],
36          this.subsurl = false;          lastrequest: null,
37            status: 0,
38          // Documented public properties          updatepollfreqtimer: null,
39          this.channels = new Array();  
40          this.subdomain = "data";          isSupportedBrowser: function() {
41          this.dynamicpageaddress = "push";                  var v;
42          this.smartpoll = true;                  if (v = navigator.userAgent.match(/compatible\; MSIE\ ([0-9\.]+)\;/i)) {
43          this.pollfreq = 2000;                          if (parseFloat(v[1]) <= 5.5) return false;
44          this.minpollfreq = 2000;                  } else if (v = navigator.userAgent.match(/Gecko\/([0-9]+)/i)) {
45          this.mode = "poll";                          if (parseInt(v[1]) <= 20051015) return false;
46          this.polltimeout=30000;                  } else if (v = navigator.userAgent.match(/WebKit\/([0-9\.]+)/i)) {
47          this.pingtimeout = 10000;                          if (parseFloat(v[1]) < 400) return false;
48          this.maxmessages = 0;                  }
49          this.status = 0;                  return true;
50            },
51          /* Statuses:    0 = Uninitialised,  
52                                          1 = Loading stream,          register: function(ifr) {
53                                          2 = Loading controller frame,                  ifr.p = Meteor.process;
54                                          3 = Controller frame timeout, retrying.                  ifr.r = Meteor.reset;
55                                          4 = Controller frame loaded and ready                  ifr.eof = Meteor.eof;
56                                          5 = Receiving data                  ifr.ch = Meteor.channelInfo;
57          */                  clearTimeout(Meteor.frameloadtimer);
58                    Meteor.setstatus(4);
59          this.instID = (typeof(instID) != "undefined") ? instID : 0;                  Meteor.log("Frame registered");
60          this.MHostId = Math.floor(Math.random()*100000000)+""+this.instID;          },
61  }  
62            joinChannel: function(channelname, backtrack) {
63  Meteor.instances = new Array();                  if (typeof(Meteor.channels[channelname]) != "undefined") throw "Cannot join channel "+channelname+": already subscribed";
64                    Meteor.channels[channelname] = {backtrack:backtrack};
65  Meteor.create = function(instID) {                  Meteor.log("Joined channel "+channelname);
66          if (!instID) instID = Meteor.instances.length;                  Meteor.channelcount++;
67          Meteor.instances[instID] = new Meteor(instID);                  if (Meteor.status != 0 && Meteor.status != 6) Meteor.connect();
68          return Meteor.instances[instID];          },
69  }  
70            leaveChannel: function(channelname) {
71  Meteor.register = function(ifr) {                  if (typeof(Meteor.channels[channelname]) == "undefined") throw "Cannot leave channel "+channelname+": not subscribed";
72          instid = new String(ifr.window.frameElement.id);                  delete Meteor.channels[channelname];
73          instid = instid.replace(/.*_([0-9]*)$/, "$1");                  Meteor.log("Left channel "+channelname);
74          ifr.p = this.instances[instid].process.bind(this.instances[instid]);                  Meteor.channelcount--;
75          ifr.r = this.instances[instid].reset.bind(this.instances[instid]);                  if (Meteor.channelcount && Meteor.status != 0 && Meteor.status != 6) Meteor.connect();
76          ifr.eof = this.instances[instid].eof.bind(this.instances[instid]);                  else Meteor.disconnect();
77          ifr.get = this.instances[instid].get.bind(this.instances[instid]);          },
78          ifr.increasepolldelay = this.instances[instid].increasepolldelay.bind(this.instances[instid]);  
79          clearTimeout(this.instances[instid].frameloadtimer);          connect: function() {
80          this.instances[instid].setstatus(4);                  if (!Meteor.host) throw "Meteor host not specified";
81          if (this.debugmode) console.log("Frame registered");                  if (isNaN(Meteor.port)) throw "Meteor port not specified";
82  }                  if (!Meteor.channelcount) throw "No channels specified";
83                    if (Meteor.status) Meteor.disconnect();
84  Meteor.reset = function(ifr) {                  Meteor.log("Connecting");
85          instid = new String(ifr.window.frameElement.id);                  Meteor.setstatus(1);
86          instid = instid.replace(/.*_([0-9]*)$/, "$1");                  if (!Meteor.hostid) Meteor.hostid = Meteor.time()+""+Math.floor(Math.random()*1000000)
87          this.instances[instid].reset();                  document.domain = Meteor.extract_xss_domain(document.domain);
88  }                  if (Meteor.mode=="stream") Meteor.mode = Meteor.selectStreamTransport();
89                    Meteor.log("Selected "+Meteor.mode+" transport");
90  Meteor.prototype.joinChannel = function(channelname, backtrack) {                  if (Meteor.mode=="xhrinteractive" || Meteor.mode=="iframe" || Meteor.mode=="serversent") {
91          if (typeof(this.channels[channelname]) != "undefined") throw "Cannot join channel "+channelname+": already subscribed";                          if (Meteor.mode == "iframe") {
92          this.channels[channelname] = {backtrack:backtrack, lastmsgreceived:0};                                  Meteor.loadFrame(Meteor.getSubsUrl());
93          if (this.status != 0) this.start();                          } else {
94  }                                  Meteor.loadFrame("http://"+Meteor.host+((Meteor.port==80)?"":":"+Meteor.port)+"/stream.html");
95                            }
96  Meteor.prototype.leaveChannel = function(channelname) {                          clearTimeout(Meteor.pingtimer);
97          if (typeof(this.channels[channelname]) == "undefined") throw "Cannot leave channel "+channelname+": not subscribed";                          Meteor.pingtimer = setTimeout(Meteor.pollmode, Meteor.pingtimeout);
98          delete this.channels[channelname];  
99          if (this.status != 0) this.start();                  } else {
100  }                          Meteor.recvtimes[0] = Meteor.time();
101                            if (Meteor.updatepollfreqtimer) clearTimeout(Meteor.updatepollfreqtimer);
102  Meteor.prototype.start = function() {                          if (Meteor.mode=='smartpoll') Meteor.updatepollfreqtimer = setInterval(Meteor.updatepollfreq, 10000);
103          this.persist = (this.maxmessages)?1:0;                          if (Meteor.mode=='longpoll') Meteor.pollfreq = Meteor.minpollfreq;
104          this.smartpoll = (this.smartpoll)?1:0;                          Meteor.poll();
105          this.mode = (this.mode=="stream")?"stream":"poll";                  }
106          if (!this.subdomain || this.channels.length) throw "Channel or Meteor subdomain host not specified";          },
107          this.stop();  
108          var now = new Date();          disconnect: function() {
109          var t = now.getTime();                  if (Meteor.status) {
110          this.setstatus(1);                          if (Meteor.status != 6) Meteor.setstatus(0);
111          var surl = "http://" + this.subdomain + "." + location.hostname + "/" + this.dynamicpageaddress + "?id=" + this.MHostId;                          Meteor.clearpoll();
112          if (this.maxmessages && !this.persist) surl += "&maxmessages=" + this.maxmessages;                          clearTimeout(Meteor.pingtimer);
113          for (var c in this.channels) {                          clearTimeout(Meteor.updatepollfreqtimer);
114                  surl += "&channel="+c;                          clearTimeout(Meteor.frameloadtimer);
115                  if (this.channels[c].lastmsgreceived >= 0) {                          if (typeof CollectGarbage == 'function') CollectGarbage();
116                          surl += "&restartfrom="+this.channels[c].lastmsgreceived;                          Meteor.log("Disconnected");
117                  } else if (this.channels[c].backtrack > 0) {                          try { Meteor.frameref.parentNode.removeChild(Meteor.frameref); delete Meteor.frameref; return true; } catch(e) { }
118                          surl += "&backtrack="+this.channels[c].backtrack;                          try { Meteor.frameref.open(); Meteor.frameref.close(); return true; } catch(e) {}                      
119                  } else if (this.channels[c].backtrack < 0 || isNaN(this.channels[c].backtrack)) {                  }
120                          surl += "&restartfrom=";          },
121                  }          
122          }          selectStreamTransport: function() {
123          this.subsurl = surl;                  try {
124          if (this.mode=="stream") {                          var test = ActiveXObject;
125                  this.createIframe(this.subsurl);                          return "iframe";
126                  var f = this.pollmode.bind(this);                  } catch (e) {}
127                  clearTimeout(this.pingtimer);                  if ((typeof window.addEventStream) == "function") return "iframe";
128                  this.pingtimer = setTimeout(f, this.pingtimeout);                  return "xhrinteractive";
129            },
130          } else {  
131                  this.createIframe("http://"+this.subdomain+"."+location.hostname+"/poll.html");          getSubsUrl: function() {
132                  this.recvtimes[0] = t;                  var host = ((Meteor.mode=='simplepoll' || Meteor.mode=='smartpoll' || Meteor.mode=='longpoll') && Meteor.pollhost) ? Meteor.pollhost : Meteor.host;
133                  if (this.updatepollfreqtimer) clearTimeout(this.updatepollfreqtimer);                  var surl = "http://" + host + ((Meteor.port==80)?"":":"+Meteor.port) + "/push/" + Meteor.hostid + "/" + Meteor.mode;
134                  this.updatepollfreqtimer = setInterval(this.updatepollfreq.bind(this), 2500);                  for (var c in Meteor.channels) {
135          }                          surl += "/"+c;
136          this.lastrequest = t;                          if (typeof Meteor.channels[c].lastmsgreceived != 'undefined') {
137  }                                  surl += ".r"+(Meteor.channels[c].lastmsgreceived+1);
138                            } else if (Meteor.channels[c].backtrack > 0) {
139  Meteor.prototype.createIframe = function(url) {                                  surl += ".b"+Meteor.channels[c].backtrack;
140          if (document.all) {                          } else if (Meteor.channels[c].backtrack != undefined) {
141                  this.transferDoc = new ActiveXObject("htmlfile");                                  surl += ".h";
142                  this.transferDoc.open();                          }
143                  this.transferDoc.write("<html>");                  }
144                  this.transferDoc.write("<script>document.domain=\""+(document.domain)+"\";</"+"script>");                  surl += "?nc="+Meteor.time();
145                  this.transferDoc.write("</html>");                  return surl;
146                  var selfref = this;          },
147                  this.transferDoc.parentWindow.Meteor = Meteor;  
148                  this.transferDoc.close();          loadFrame: function(url) {
149                  var ifrDiv = this.transferDoc.createElement("div");                  try {
150                  this.transferDoc.appendChild(ifrDiv);                          if (!Meteor.frameref) {
151                  ifrDiv.innerHTML = "<iframe id=\"meteorframe_"+this.instID+"\" src=\""+url+"\" style=\"display: none;\"></iframe>";                                  var transferDoc = new ActiveXObject("htmlfile");
152          } else {                                  Meteor.frameref = transferDoc;
153                  var ifr = document.createElement("IFRAME");                          }
154                  ifr.style.width = "10px";                          Meteor.frameref.open();
155                  ifr.style.height = "10px";                          Meteor.frameref.write("<html><script>");
156                  ifr.style.border = "none";                          Meteor.frameref.write("document.domain=\""+(document.domain)+"\";");
157                  ifr.style.position = "absolute";                          Meteor.frameref.write("</"+"script></html>");
158                  ifr.style.top = "-10px";                          Meteor.frameref.parentWindow.Meteor = Meteor;
159                  ifr.style.marginTop = "-10px";                          Meteor.frameref.close();
160                  ifr.style.zIndex = "-20";                          var ifrDiv = Meteor.frameref.createElement("div");
161                  ifr.setAttribute("id", "meteorframe_"+this.instID);                          Meteor.frameref.appendChild(ifrDiv);
162                  ifr.Meteor = Meteor;                          ifrDiv.innerHTML = "<iframe src=\""+url+"\"></iframe>";
163                  var innerifr = document.createElement("IFRAME");                  } catch (e) {
164                  innerifr.setAttribute("src", url);                          if (!Meteor.frameref) {
165                  innerifr.setAttribute("id", "meteorinnerframe_"+this.instID);                                  var ifr = document.createElement("IFRAME");
166                  ifr.appendChild(innerifr);                                  ifr.style.width = "10px";
167                  document.body.appendChild(ifr);                                  ifr.style.height = "10px";
168          }                                  ifr.style.border = "none";
169          if (this.debugmode) console.log("Loading URL '"+url+"' into frame...");                                  ifr.style.position = "absolute";
170          var f = this.frameloadtimeout.bind(this);                                  ifr.style.top = "-10px";
171          this.frameloadtimer = setTimeout(f, 5000);                                  ifr.style.marginTop = "-10px";
172  }                                  ifr.style.zIndex = "-20";
173                                    ifr.Meteor = Meteor;
174  Meteor.prototype.stop = function() {                                  document.body.appendChild(ifr);
175          if (typeof(this.transferDoc)=="object") {                                  Meteor.frameref = ifr;
176                  this.transferDoc = false;                          }
177          }                          Meteor.frameref.setAttribute("src", url);
178          if (document.getElementById("meteorframe_"+this.instID)) {                  }
179                  document.getElementById("meteorframe_"+this.instID).src="about:blank";                  Meteor.log("Loading URL '"+url+"' into frame...");
180                  document.body.removeChild(document.getElementById("meteorframe_"+this.instID));                  Meteor.frameloadtimer = setTimeout(Meteor.frameloadtimeout, 5000);
181          }          },
182          if (!isNaN(this.pingtimer)) clearTimeout(this.pingtimer);  
183          if (!isNaN(this.updatepollfreqtimer)) clearTimeout(this.updatepollfreqtimer);          pollmode: function() {
184          if (!isNaN(this.frameloadtimer)) clearTimeout(this.frameloadtimer);                  Meteor.log("Ping timeout");
185          this.setstatus(0);                  if (Meteor.mode != "smartpoll") {
186  }                          Meteor.mode="smartpoll";
187                            Meteor.callbacks["changemode"]("poll");
188  Meteor.prototype.pollmode = function() {                          clearTimeout(Meteor.pingtimer);
189          if (this.debugmode) console.log("Ping timeout");                          Meteor.lastpingtime = false;
190          this.mode="poll";                  }
191          this.start();                  Meteor.connect();
192          this.callback_changemode("poll");          },
193          this.lastpingtime = false;  
194  }          process: function(id, channel, data) {
195                    if (id == -1) {
196  Meteor.prototype.process = function(id, channel, data) {                          Meteor.log("Ping");
197          if (id > this.channels[channel].lastmsgreceived) {                          Meteor.ping();
198                  if (this.debugmode) console.log("Message "+id+" received on channel "+channel+": "+data);                  } else if (typeof(Meteor.channels[channel]) != "undefined") {
199                  this.callback_process(data);                          Meteor.log("Message "+id+" received on channel "+channel+" (last id on channel: "+Meteor.channels[channel].lastmsgreceived+")\n"+data);
200                  this.channels[channel].lastmsgreceived = id;                          Meteor.callbacks["process"](data);
201                  if (this.mode=="poll") {                          Meteor.channels[channel].lastmsgreceived = id;
202                          var now = new Date();                          if (Meteor.mode=="smartpoll") {
203                          var t = now.getTime();                                  Meteor.recvtimes[Meteor.recvtimes.length] = Meteor.time();
204                          this.recvtimes[this.recvtimes.length] = t;                                  while (Meteor.recvtimes.length > 5) Meteor.recvtimes.shift();
205                          while (this.recvtimes.length > 5) this.recvtimes.shift();                          }
206                  }                  }
207          } else if (id == -1) {                  Meteor.setstatus(5);
208                  if (this.debugmode) console.log("Ping");          },
209                  this.ping();  
210          }          ping: function() {
211          this.setstatus(5);                  if (Meteor.pingtimer) {
212  }                          clearTimeout(Meteor.pingtimer);
213                            Meteor.pingtimer = setTimeout(Meteor.pollmode, Meteor.pingtimeout);
214  Meteor.prototype.ping = function() {                          Meteor.lastpingtime = Meteor.time();
215          if (this.mode=="stream" && this.pingtimer) {                  }
216                  clearTimeout(this.pingtimer);                  Meteor.setstatus(5);
217                  var f = this.pollmode.bind(this);          },
218                  this.pingtimer = setTimeout(f, this.pingtimeout);  
219                  var now = new Date();          reset: function() {
220                  this.lastpingtime = now.getTime();                  if (Meteor.status != 6 && Meteor.status != 0) {
221          }                          Meteor.log("Stream reset");
222          this.setstatus(5);                          Meteor.ping();
223  }                          Meteor.callbacks["reset"]();
224                            var x = Meteor.pollfreq - (Meteor.time()-Meteor.lastrequest);
225  Meteor.prototype.reset = function() {                          if (x < 10) x = 10;
226          if (this.debugmode) console.log("Stream reset");                          setTimeout(Meteor.connect, x);
227          var now = new Date();                  }
228          var t = now.getTime();          },
229          var x = this.pollfreq - (t-this.lastrequest);  
230          if (x < 10) x = 10;          eof: function() {
231          this.ping();                  Meteor.log("Received end of stream, will not reconnect");
232          this.callback_reset();                  Meteor.callbacks["eof"]();
233          setTimeout(this.start.bind(this), x);                  Meteor.setstatus(6);
234  }                  Meteor.disconnect();
235            },
236  Meteor.prototype.eof = function() {  
237          this.callback_eof();          channelInfo: function(channel, id) {
238  }                  Meteor.channels[channel].lastmsgreceived = id;
239                    Meteor.log("Received channel info for channel "+channel+": resume from "+id);
240  Meteor.prototype.get = function(varname) {          },
241          eval("var a = this."+varname+";");  
242          if (typeof(a) == "undefined") throw "Cannot get value of "+varname;          updatepollfreq: function() {
243          return a;                  var avg = 0;
244  }                  for (var i=1; i<Meteor.recvtimes.length; i++) {
245                            avg += (Meteor.recvtimes[i]-Meteor.recvtimes[i-1]);
246  Meteor.prototype.increasepolldelay = function() {                  }
247          this.pollfreq *= 2;                  avg += (Meteor.time()-Meteor.recvtimes[Meteor.recvtimes.length-1]);
248  }                  avg /= Meteor.recvtimes.length;
249                    var target = avg/2;
250  Meteor.prototype.updatepollfreq = function() {                  if (target < Meteor.pollfreq && Meteor.pollfreq > Meteor.minpollfreq) Meteor.pollfreq = Math.ceil(Meteor.pollfreq*0.9);
251          if (this.smartpoll) {                  if (target > Meteor.pollfreq && Meteor.pollfreq < Meteor.maxpollfreq) Meteor.pollfreq = Math.floor(Meteor.pollfreq*1.05);
252                  var now = new Date();          },
253                  var t = now.getTime();  
254                  var avg = 0;          registerEventCallback: function(evt, funcRef) {
255                  for (var i=1; i<this.recvtimes.length; i++) {                  Function.prototype.andThen=function(g) {
256                          var x = (this.recvtimes[i]-this.recvtimes[i-1]);                          var f=this;
257                          avg += (x>60000)? 60000 : x;                          var a=Meteor.arguments
258                  }                          return function(args) {
259                  x = (t-this.recvtimes[this.recvtimes.length-1]);                                  f(a);g(args);
260                  avg += (x>180000)? 180000 : x;                          }
261                  avg /= this.recvtimes.length;                  };
262                  if ((avg/3) < this.pollfreq && (avg/3) >= this.minpollfreq) this.pollfreq = Math.ceil(this.pollfreq*0.9);                  if (typeof Meteor.callbacks[evt] == "function") {
263                  if ((avg/3) > this.pollfreq) this.pollfreq = Math.floor(this.pollfreq*1.05);                          Meteor.callbacks[evt] = (Meteor.callbacks[evt]).andThen(funcRef);
264          }                  } else {
265  }                          Meteor.callbacks[evt] = funcRef;
266                    }
267  Meteor.prototype.registerEventCallback = function(evt, funcRef) {          },
268          if (evt=="process") {  
269                  this.callback_process = (this.callback_process).andThen(funcRef);          frameloadtimeout: function() {
270          } else if (evt=="reset") {                  Meteor.log("Frame load timeout");
271                  this.callback_reset = (this.callback_reset).andThen(funcRef);                  if (Meteor.frameloadtimer) clearTimeout(Meteor.frameloadtimer);
272          } else if (evt=="eof") {                  Meteor.setstatus(3);
273                  this.callback_eof = (this.callback_eof).andThen(funcRef);                  Meteor.pollmode();
274          } else if (evt=="changemode") {          },
275                  this.callback_changemode = (this.callback_changemode).andThen(funcRef);  
276          } else if (evt=="changestatus") {          extract_xss_domain: function(old_domain) {
277                  this.callback_statuschanged = (this.callback_statuschanged).andThen(funcRef);                  if (old_domain.match(/^(\d{1,3}\.){3}\d{1,3}$/)) return old_domain;
278          }                  domain_pieces = old_domain.split('.');
279  }                  return domain_pieces.slice(-2, domain_pieces.length).join(".");
280            },
281  Meteor.prototype.frameloadtimeout = function() {  
282          if (this.debugmode) console.log("Frame load timeout");          setstatus: function(newstatus) {
283          if (this.frameloadtimer) clearTimeout(this.frameloadtimer);                  // Statuses:    0 = Uninitialised,
284          this.setstatus(3);                  //                              1 = Loading stream,
285          setTimeout(this.start.bind(this), 5000);                  //                              2 = Loading controller frame,
286  }                  //                              3 = Controller frame timeout, retrying.
287  Meteor.prototype.setstatus = function(newstatus) {                  //                              4 = Controller frame loaded and ready
288          if (this.status != newstatus) {                  //                              5 = Receiving data
289                  this.status = newstatus;                  //                              6 = End of stream, will not reconnect
290                  this.callback_statuschanged(newstatus);  
291          }                  if (Meteor.status != newstatus) {
292  }                          Meteor.status = newstatus;
293                            Meteor.callbacks["statuschanged"](newstatus);
294  Meteor.createCookie = function(name,value,days) {                  }
295          if (days) {          },
296                  var date = new Date();  
297                  date.setTime(date.getTime()+(days*24*60*60*1000));          log: function(logstr) {
298                  var expires = "; expires="+date.toGMTString();                  if (Meteor.debugmode) {
299          }                          if (window.console) {
300          else var expires = "";                                  window.console.log(logstr);
301          document.cookie = name+"="+value+expires+"; path=/";                          } else if (document.getElementById("meteorlogoutput")) {
302  }                                  document.getElementById("meteorlogoutput").innerHTML += logstr+"<br/>";
303                            }
304  Meteor.readCookie = function(name) {                  }
305          var nameEQ = name + "=";          },
306          var ca = document.cookie.split(';');  
307          for(var i=0;i < ca.length;i++) {          poll: function() {
308                  var c = ca[i];                  Meteor.pollaborted = 0;
309                  while (c.charAt(0)==' ') c = c.substring(1,c.length);                  try {
310                  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);                          clearTimeout(Meteor.polltimer);
311          }                  } catch (e) {};
312          return null;                  Meteor.lastrequest = Meteor.time();
313  }                  if (Meteor.polltimeout) Meteor.polltimer = setTimeout(Meteor.clearpoll, Meteor.polltimeout);
314                    var scripttag = document.createElement("SCRIPT");
315  Meteor.eraseCookie = function(name) {                  scripttag.type = "text/javascript";
316          createCookie(name,"",-1);                  scripttag.src = Meteor.getSubsUrl();
317                    scripttag.id = "meteorpoll"+(++Meteor.pollnum);
318                    scripttag.className = "meteorpoll";
319                    document.getElementsByTagName("HEAD")[0].appendChild(scripttag);
320            },
321    
322            clearpoll: function() {
323                    if (document.getElementById('meteorpoll'+Meteor.pollnum)) {
324                            var s = document.getElementById('meteorpoll'+Meteor.pollnum);
325                            s.parentNode.removeChild(s);
326                    }
327                    if (Meteor.status == 5) {
328                            var x = parent.Meteor.pollfreq - (Meteor.time()-Meteor.lastrequest);
329                            if (x < 10) x = 10;
330                            setTimeout(Meteor.poll, x);
331                    }
332            },
333    
334            time: function() {
335                    var now = new Date();
336                    return now.getTime();
337            }
338    }
339    
340    var oldonunload = window.onunload;
341    if (typeof window.onunload != 'function') {
342            window.onunload = Meteor.disconnect;
343    } else {
344            window.onunload = function() {
345                    if (oldonunload) oldonunload();
346                    Meteor.disconnect();
347            }
348  }  }

Legend:
Removed from v.18  
changed lines
  Added in v.64

  ViewVC Help
Powered by ViewVC 1.1.26