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

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

  ViewVC Help
Powered by ViewVC 1.1.26