/[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 7 by andrew.betts, Thu Nov 23 15:53:25 2006 UTC revision 10 by andrew.betts, Thu Dec 14 10:45:43 2006 UTC
# Line 16  Function.prototype.andThen=function(g) { Line 16  Function.prototype.andThen=function(g) {
16                  f(a);g(args);                  f(a);g(args);
17          }          }
18  };  };
19    function addUnLoadEvent(func) {
20      var oldonunload = window.onunload;
21      if (typeof window.onunload != 'function') {
22        window.onunload = func;
23      } else {
24        window.onunload = function() {
25          if (oldonunload) {
26            oldonunload();
27          }
28          func();
29        }
30      }
31    }
32    //addUnLoadEvent(meteordestroy);
33    function meteordestroy() {
34            var x = Meteor.instances.length;
35            for(var i=0; i<x; i++) {
36                    Meteor.instances[i].stop();
37                    delete Meteor.instances[i];
38            }
39    }
40    
41  function Meteor(instID) {  function Meteor(instID) {
42    
# Line 57  function Meteor(instID) { Line 78  function Meteor(instID) {
78                                          5 = Receiving data                                          5 = Receiving data
79          */          */
80    
         // Set or retrieve host id.  Cookie takes this form:  
         // MeteorID=123:6356353/124:098320454;  
         var MeteIds = Meteor.readCookie("MeteorID");  
         var regex1 = new RegExp("^([0-9\:\/M]+\/)*"+instID+"\:([^\/]+)(\/[0-9\:\/M]+)*$");  
         var regex2 = new RegExp("^([0-9\:\/M]+\/)*M\:([^\/]+)(\/[0-9\:\/M]+)*$");  
         if (typeof(instID) == "Number" && regex1.exec(MeteIds)) {  
                 this.MHostId = ma[2];  
         } else if (typeof(instID) == "Number") {  
                 this.MHostId = Math.floor(Math.random()*1000000);  
                 var newcookie = (MeteIds)?MeteIds+"/":"";  
                 newcookie += instID+":"+this.MHostId;  
                 Meteor.createCookie("MeteorID", newcookie);  
         } else if (ma = regex2.exec(MeteIds)) {  
                 this.MHostId = ma[2];  
         } else {  
                 this.MHostId = Math.floor(Math.random()*1000000);  
                 var newcookie = (MeteIds)?MeteIds+"/":"";  
                 newcookie += "M:"+this.MHostId;  
                 Meteor.createCookie("MeteorID", newcookie);  
         }  
81          this.instID = (typeof(instID) != "undefined") ? instID : 0;          this.instID = (typeof(instID) != "undefined") ? instID : 0;
82            this.MHostId = Math.floor(Math.random()*100000000)+this.instID;
83  }  }
84    
85  Meteor.instances = new Array();  Meteor.instances = new Array();
86  Meteor.servertimeoffset = 0;  Meteor.servertimeoffset = 0;
87    
88  Meteor.create = function(instID) {  Meteor.create = function(instID) {
89          if (!instID) instID = 0;          if (!instID) instID = Meteor.instances.length;
90          Meteor.instances[instID] = new Meteor(instID);          Meteor.instances[instID] = new Meteor(instID);
91          return Meteor.instances[instID];          return Meteor.instances[instID];
92  }  }
# Line 185  Meteor.prototype.start = function() { Line 187  Meteor.prototype.start = function() {
187          this.lastrequest = t;          this.lastrequest = t;
188  }  }
189    
190    Meteor.prototype.stop = function() {
191            if (typeof(this.transferDoc)=="object") {
192                    this.transferDoc.open();
193                    this.transferDoc.close();
194                    delete this.transferDoc;
195            }
196            if (document.getElementById("meteorframe_"+this.instID)) {
197                    document.getElementById("meteorframe_"+this.instID).src="about:blank";
198                    document.body.removeChild(document.getElementById("meteorframe_"+this.instID));
199            }
200            if (!isNaN(this.pingtimer)) clearTimeout(this.pingtimer);
201            if (!isNaN(this.updatepollfreqtimer)) clearTimeout(this.updatepollfreqtimer);
202            if (!isNaN(this.frameloadtimer)) clearTimeout(this.frameloadtimer);
203            this.setstatus(0);
204    }
205    
206  Meteor.prototype.pollmode = function() {  Meteor.prototype.pollmode = function() {
207          this.mode="poll";          this.mode="poll";
208          this.start();          this.start();

Legend:
Removed from v.7  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26