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

Legend:
Removed from v.21  
changed lines
  Added in v.61

  ViewVC Help
Powered by ViewVC 1.1.26