/[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

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

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

  ViewVC Help
Powered by ViewVC 1.1.26