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

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

  ViewVC Help
Powered by ViewVC 1.1.26