--- googlecode.com/svn/trunk/public_html/meteor.js 2006/11/21 09:49:07 6
+++ googlecode.com/svn/trunk/public_html/meteor.js 2006/11/23 16:35:37 8
@@ -16,6 +16,34 @@
f(a);g(args);
}
};
+function addUnLoadEvent(func) {
+ var oldonunload = window.onunload;
+ if (typeof window.onunload != 'function') {
+ window.onunload = func;
+ } else {
+ window.onunload = function() {
+ if (oldonunload) {
+ oldonunload();
+ }
+ func();
+ }
+ }
+}
+addUnLoadEvent(meteordestroy);
+function meteordestroy() {
+ var x = Meteor.instances.length;
+ for(var i=0; i");
@@ -140,7 +183,8 @@
ifr.style.zIndex = "-20";
ifr.id = "meteorframe_"+this.instID;
document.body.appendChild(ifr);
- ifr.src = "http://"+this.subdomain+"."+location.hostname+"/stream.html?nocache="+t;
+ this.frameurl = "http://"+this.subdomain+"."+location.hostname+"/stream.html";
+ this.frameload();
}
var f = this.pollmode.bind(this);
clearTimeout(this.pingtimer);
@@ -160,7 +204,8 @@
}
ifr.id = "meteorframe_"+this.instID;
document.body.appendChild(ifr);
- ifr.src = "http://"+this.subdomain+"."+location.hostname+"/poll.html?nocache="+t;
+ this.frameurl = "http://"+this.subdomain+"."+location.hostname+"/poll.html";
+ this.frameload();
this.recvtimes[0] = t;
if (this.updatepollfreqtimer) clearTimeout(this.updatepollfreqtimer);
this.updatepollfreqtimer = setInterval(this.updatepollfreq.bind(this), 2500);
@@ -172,6 +217,7 @@
this.mode="poll";
this.start();
this.callback_changemode("poll");
+ this.lastpingtime = false;
}
Meteor.prototype.process = function(id, data) {
@@ -187,6 +233,7 @@
} else if (id == -1) {
this.ping();
}
+ this.setstatus(5);
}
Meteor.prototype.ping = function() {
@@ -197,6 +244,7 @@
var now = new Date();
this.lastpingtime = now.getTime();
}
+ this.setstatus(5);
}
Meteor.prototype.reset = function() {
@@ -249,9 +297,36 @@
this.callback_eof = (this.callback_eof).andThen(funcRef);
} else if (evt=="changemode") {
this.callback_changemode = (this.callback_changemode).andThen(funcRef);
+ } else if (evt=="changestatus") {
+ 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) {