1 |
// Set domain at highest level |
// Set domain at highest level |
2 |
var domainparts = document.domain.split("."); |
var domainparts = document.domain.split("."); |
3 |
document.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1]; |
document.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1]; |
4 |
|
|
5 |
Function.prototype.bind = function(obj) { |
Function.prototype.bind = function(obj) { |
6 |
var method = this, |
var method = this, |
7 |
temp = function() { |
temp = function() { |
8 |
return method.apply(obj, arguments); |
return method.apply(obj, arguments); |
9 |
}; |
}; |
10 |
return temp; |
return temp; |
11 |
} |
} |
12 |
Function.prototype.andThen=function(g) { |
Function.prototype.andThen=function(g) { |
13 |
var f=this; |
var f=this; |
14 |
var a=this.arguments |
var a=this.arguments |
15 |
return function(args) { |
return function(args) { |
16 |
f(a);g(args); |
f(a);g(args); |
17 |
} |
} |
18 |
}; |
}; |
19 |
|
function addUnLoadEvent(func) { |
20 |
function Meteor(instID) { |
var oldonunload = window.onunload; |
21 |
|
if (typeof window.onunload != 'function') { |
22 |
this.lastmsgreceived = -1; |
window.onunload = func; |
23 |
this.transferDoc = false; |
} else { |
24 |
this.pingtimer = false; |
window.onunload = function() { |
25 |
this.updatepollfreqtimer = false; |
if (oldonunload) { |
26 |
this.lastrequest = 0; |
oldonunload(); |
27 |
this.recvtimes = new Array(); |
} |
28 |
this.MHostId = false; |
func(); |
29 |
this.callback_process = function() {}; |
} |
30 |
this.callback_reset = function() {}; |
} |
31 |
this.callback_eof = function() {}; |
} |
32 |
this.callback_changemode = function() {}; |
//addUnLoadEvent(meteordestroy); |
33 |
this.persist = true; |
function meteordestroy() { |
34 |
|
var x = Meteor.instances.length; |
35 |
// Documented public properties |
for(var i=0; i<x; i++) { |
36 |
this.channel = false; |
Meteor.instances[i].stop(); |
37 |
this.subdomain = "data"; |
delete Meteor.instances[i]; |
38 |
this.dynamicpageaddress = "push"; |
} |
39 |
this.backtrack = 0; |
} |
40 |
this.smartpoll = true; |
|
41 |
this.pollfreq = 2000; |
function Meteor(instID) { |
42 |
this.minpollfreq = 2000; |
|
43 |
this.mode = "stream"; |
this.lastmsgreceived = -1; |
44 |
this.polltimeout=30000; |
this.transferDoc = false; |
45 |
this.maxmessages=0; |
this.pingtimer = false; |
46 |
this.pingtimeout = 10000; |
this.updatepollfreqtimer = false; |
47 |
|
this.lastrequest = 0; |
48 |
// Set or retrieve host id. Cookie takes this form: |
this.recvtimes = new Array(); |
49 |
// MeteorID=123:6356353/124:098320454; |
this.MHostId = false; |
50 |
var MeteIds = Meteor.readCookie("MeteorID"); |
this.callback_process = function() {}; |
51 |
var regex1 = new RegExp("^([0-9\:\/M]+\/)*"+instID+"\:([^\/]+)(\/[0-9\:\/M]+)*$"); |
this.callback_reset = function() {}; |
52 |
var regex2 = new RegExp("^([0-9\:\/M]+\/)*M\:([^\/]+)(\/[0-9\:\/M]+)*$"); |
this.callback_eof = function() {}; |
53 |
if (typeof(instID) == "Number" && regex1.exec(MeteIds)) { |
this.callback_changemode = function() {}; |
54 |
this.MHostId = ma[2]; |
this.callback_statuschanged = function() {}; |
55 |
} else if (typeof(instID) == "Number") { |
this.persist = true; |
56 |
this.MHostId = Math.floor(Math.random()*1000000); |
this.frameloadtimer = false; |
57 |
var newcookie = (MeteIds)?MeteIds+"/":""; |
this.frameurl = false; |
58 |
newcookie += instID+":"+this.MHostId; |
|
59 |
Meteor.createCookie("MeteorID", newcookie); |
// Documented public properties |
60 |
} else if (ma = regex2.exec(MeteIds)) { |
this.channel = false; |
61 |
this.MHostId = ma[2]; |
this.subdomain = "data"; |
62 |
} else { |
this.dynamicpageaddress = "push"; |
63 |
this.MHostId = Math.floor(Math.random()*1000000); |
this.backtrack = 0; |
64 |
var newcookie = (MeteIds)?MeteIds+"/":""; |
this.smartpoll = true; |
65 |
newcookie += "M:"+this.MHostId; |
this.pollfreq = 2000; |
66 |
Meteor.createCookie("MeteorID", newcookie); |
this.minpollfreq = 2000; |
67 |
} |
this.mode = "stream"; |
68 |
this.instID = (typeof(instID) != "undefined") ? instID : 0; |
this.polltimeout=30000; |
69 |
} |
this.maxmessages=0; |
70 |
|
this.pingtimeout = 10000; |
71 |
Meteor.instances = new Array(); |
this.status = 0; |
72 |
Meteor.servertimeoffset = 0; |
|
73 |
|
/* Statuses: 0 = Uninitialised, |
74 |
Meteor.create = function(instID) { |
1 = Loading stream, |
75 |
if (!instID) instID = 0; |
2 = Loading controller frame, |
76 |
Meteor.instances[instID] = new Meteor(instID); |
3 = Controller frame timeout, retrying every 5 seconds |
77 |
return Meteor.instances[instID]; |
4 = Controller frame loaded and ready |
78 |
} |
5 = Receiving data |
79 |
|
*/ |
80 |
Meteor.register = function(ifr) { |
|
81 |
instid = new String(ifr.window.frameElement.id); |
this.instID = (typeof(instID) != "undefined") ? instID : 0; |
82 |
instid = instid.replace("meteorframe_", ""); |
this.MHostId = Math.floor(Math.random()*100000000)+this.instID; |
83 |
ifr.p = this.instances[instid].process.bind(this.instances[instid]); |
} |
84 |
ifr.r = this.instances[instid].reset.bind(this.instances[instid]); |
|
85 |
ifr.eof = this.instances[instid].eof.bind(this.instances[instid]); |
Meteor.instances = new Array(); |
86 |
ifr.get = this.instances[instid].get.bind(this.instances[instid]); |
Meteor.servertimeoffset = 0; |
87 |
ifr.increasepolldelay = this.instances[instid].increasepolldelay.bind(this.instances[instid]); |
|
88 |
} |
Meteor.create = function(instID) { |
89 |
|
if (!instID) instID = Meteor.instances.length; |
90 |
Meteor.setServerTime = function(timestamp) { |
Meteor.instances[instID] = new Meteor(instID); |
91 |
var now = new Date(); |
return Meteor.instances[instID]; |
92 |
var clienttime = (now.getTime() / 1000); |
} |
93 |
Meteor.servertimeoffset = timestamp - clienttime; |
|
94 |
} |
Meteor.register = function(ifr) { |
95 |
|
instid = new String(ifr.window.frameElement.id); |
96 |
Meteor.prototype.start = function() { |
instid = instid.replace("meteorframe_", ""); |
97 |
this.persist = (this.maxmessages)?1:0; |
ifr.p = this.instances[instid].process.bind(this.instances[instid]); |
98 |
this.smartpoll = (this.smartpoll)?1:0; |
ifr.r = this.instances[instid].reset.bind(this.instances[instid]); |
99 |
this.mode = (this.mode=="stream")?"stream":"poll"; |
ifr.eof = this.instances[instid].eof.bind(this.instances[instid]); |
100 |
if (!this.subdomain || !this.channel) throw "Channel or Meteor subdomain host not specified"; |
ifr.get = this.instances[instid].get.bind(this.instances[instid]); |
101 |
var now = new Date(); |
ifr.increasepolldelay = this.instances[instid].increasepolldelay.bind(this.instances[instid]); |
102 |
var t = now.getTime(); |
clearTimeout(this.instances[instid].frameloadtimer); |
103 |
if (typeof(this.transferDoc)=="object") { |
this.instances[instid].setstatus(4); |
104 |
this.transferDoc.open(); |
} |
105 |
this.transferDoc.close(); |
|
106 |
delete this.transferDoc; |
Meteor.setServerTime = function(timestamp) { |
107 |
} |
var now = new Date(); |
108 |
if (document.getElementById("meteorframe_"+this.instID)) { |
var clienttime = (now.getTime() / 1000); |
109 |
document.body.removeChild(document.getElementById("meteorframe_"+this.instID)); |
Meteor.servertimeoffset = timestamp - clienttime; |
110 |
} |
} |
111 |
if (this.mode=="stream") { |
|
112 |
if (document.all) { |
Meteor.prototype.start = function() { |
113 |
this.transferDoc = new ActiveXObject("htmlfile"); |
this.persist = (this.maxmessages)?1:0; |
114 |
this.transferDoc.open(); |
this.smartpoll = (this.smartpoll)?1:0; |
115 |
this.transferDoc.write("<html>"); |
this.mode = (this.mode=="stream")?"stream":"poll"; |
116 |
this.transferDoc.write("<script>document.domain=\""+(document.domain)+"\";</"+"script>"); |
if (!this.subdomain || !this.channel) throw "Channel or Meteor subdomain host not specified"; |
117 |
this.transferDoc.write("</html>"); |
var now = new Date(); |
118 |
var selfref = this; |
var t = now.getTime(); |
119 |
this.transferDoc.parentWindow.Meteor = Meteor; |
if (typeof(this.transferDoc)=="object") { |
120 |
this.transferDoc.close(); |
this.transferDoc.open(); |
121 |
var ifrDiv = this.transferDoc.createElement("div"); |
this.transferDoc.close(); |
122 |
this.transferDoc.appendChild(ifrDiv); |
delete this.transferDoc; |
123 |
var url = "http://"+this.subdomain+"."+location.hostname+"/"+this.dynamicpageaddress+"?channel="+this.channel+"&id="+this.MHostId; |
} |
124 |
if (this.lastmsgreceived >= 0) { |
if (document.getElementById("meteorframe_"+this.instID)) { |
125 |
url += "&restartfrom="+this.lastmsgreceived; |
document.body.removeChild(document.getElementById("meteorframe_"+this.instID)); |
126 |
} else if (this.backtrack > 0) { |
} |
127 |
url += "&backtrack="+this.backtrack; |
if (this.mode=="stream") { |
128 |
} else if (this.backtrack < 0 || isNaN(this.backtrack)) { |
if (document.all) { |
129 |
url += "&restartfrom="; |
this.setstatus(1); |
130 |
} |
this.transferDoc = new ActiveXObject("htmlfile"); |
131 |
ifrDiv.innerHTML = "<iframe id=\"meteorframe_"+this.instID+"\" src=\""+url+"&nocache="+t+"\" style=\"display: none;\"></iframe>"; |
this.transferDoc.open(); |
132 |
} else { |
this.transferDoc.write("<html>"); |
133 |
var ifr = document.createElement("IFRAME"); |
this.transferDoc.write("<script>document.domain=\""+(document.domain)+"\";</"+"script>"); |
134 |
ifr.style.width = "10px"; |
this.transferDoc.write("</html>"); |
135 |
ifr.style.height = "10px"; |
var selfref = this; |
136 |
ifr.style.border = "none"; |
this.transferDoc.parentWindow.Meteor = Meteor; |
137 |
ifr.style.position = "absolute"; |
this.transferDoc.close(); |
138 |
ifr.style.top = "-10px"; |
var ifrDiv = this.transferDoc.createElement("div"); |
139 |
ifr.style.marginTop = "-10px"; |
this.transferDoc.appendChild(ifrDiv); |
140 |
ifr.style.zIndex = "-20"; |
var url = "http://"+this.subdomain+"."+location.hostname+"/"+this.dynamicpageaddress+"?channel="+this.channel+"&id="+this.MHostId; |
141 |
ifr.id = "meteorframe_"+this.instID; |
if (this.lastmsgreceived >= 0) { |
142 |
document.body.appendChild(ifr); |
url += "&restartfrom="+this.lastmsgreceived; |
143 |
ifr.src = "http://"+this.subdomain+"."+location.hostname+"/stream.html?nocache="+t; |
} else if (this.backtrack > 0) { |
144 |
} |
url += "&backtrack="+this.backtrack; |
145 |
var f = this.pollmode.bind(this); |
} else if (this.backtrack < 0 || isNaN(this.backtrack)) { |
146 |
clearTimeout(this.pingtimer); |
url += "&restartfrom="; |
147 |
this.pingtimer = setTimeout(f, this.pingtimeout); |
} |
148 |
|
ifrDiv.innerHTML = "<iframe id=\"meteorframe_"+this.instID+"\" src=\""+url+"&nocache="+t+"\" style=\"display: none;\"></iframe>"; |
149 |
} else { |
} else { |
150 |
var ifr = document.createElement("IFRAME"); |
var ifr = document.createElement("IFRAME"); |
151 |
ifr.style.width = "10px"; |
ifr.style.width = "10px"; |
152 |
ifr.style.height = "10px"; |
ifr.style.height = "10px"; |
153 |
ifr.style.border = "none"; |
ifr.style.border = "none"; |
154 |
if (document.all) { |
ifr.style.position = "absolute"; |
155 |
ifr.style.display = "none"; |
ifr.style.top = "-10px"; |
156 |
} else { |
ifr.style.marginTop = "-10px"; |
157 |
ifr.style.position = "absolute"; |
ifr.style.zIndex = "-20"; |
158 |
ifr.style.marginTop = "-10px"; |
ifr.id = "meteorframe_"+this.instID; |
159 |
ifr.style.zIndex = "-20"; |
document.body.appendChild(ifr); |
160 |
} |
this.frameurl = "http://"+this.subdomain+"."+location.hostname+"/stream.html"; |
161 |
ifr.id = "meteorframe_"+this.instID; |
this.frameload(); |
162 |
document.body.appendChild(ifr); |
} |
163 |
ifr.src = "http://"+this.subdomain+"."+location.hostname+"/poll.html?nocache="+t; |
var f = this.pollmode.bind(this); |
164 |
this.recvtimes[0] = t; |
clearTimeout(this.pingtimer); |
165 |
if (this.updatepollfreqtimer) clearTimeout(this.updatepollfreqtimer); |
this.pingtimer = setTimeout(f, this.pingtimeout); |
166 |
this.updatepollfreqtimer = setInterval(this.updatepollfreq.bind(this), 2500); |
|
167 |
} |
} else { |
168 |
this.lastrequest = t; |
var ifr = document.createElement("IFRAME"); |
169 |
} |
ifr.style.width = "10px"; |
170 |
|
ifr.style.height = "10px"; |
171 |
Meteor.prototype.pollmode = function() { |
ifr.style.border = "none"; |
172 |
this.mode="poll"; |
if (document.all) { |
173 |
this.start(); |
ifr.style.display = "none"; |
174 |
this.callback_changemode("poll"); |
} else { |
175 |
} |
ifr.style.position = "absolute"; |
176 |
|
ifr.style.marginTop = "-10px"; |
177 |
Meteor.prototype.process = function(id, data) { |
ifr.style.zIndex = "-20"; |
178 |
if (id > this.lastmsgreceived) { |
} |
179 |
this.callback_process(data); |
ifr.id = "meteorframe_"+this.instID; |
180 |
if (id != -1) this.lastmsgreceived = id; |
document.body.appendChild(ifr); |
181 |
if (this.mode=="poll") { |
this.frameurl = "http://"+this.subdomain+"."+location.hostname+"/poll.html"; |
182 |
var now = new Date(); |
this.frameload(); |
183 |
var t = now.getTime(); |
this.recvtimes[0] = t; |
184 |
this.recvtimes[this.recvtimes.length] = t; |
if (this.updatepollfreqtimer) clearTimeout(this.updatepollfreqtimer); |
185 |
while (this.recvtimes.length > 5) this.recvtimes.shift(); |
this.updatepollfreqtimer = setInterval(this.updatepollfreq.bind(this), 2500); |
186 |
} |
} |
187 |
} else if (id == -1) { |
this.lastrequest = t; |
188 |
this.ping(); |
} |
189 |
} |
|
190 |
} |
Meteor.prototype.stop = function() { |
191 |
|
if (typeof(this.transferDoc)=="object") { |
192 |
Meteor.prototype.ping = function() { |
this.transferDoc.open(); |
193 |
if (this.mode=="stream" && this.pingtimer) { |
this.transferDoc.close(); |
194 |
clearTimeout(this.pingtimer); |
delete this.transferDoc; |
195 |
var f = this.pollmode.bind(this); |
} |
196 |
this.pingtimer = setTimeout(f, this.pingtimeout); |
if (document.getElementById("meteorframe_"+this.instID)) { |
197 |
var now = new Date(); |
document.getElementById("meteorframe_"+this.instID).src="about:blank"; |
198 |
this.lastpingtime = now.getTime(); |
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 |
Meteor.prototype.reset = function() { |
if (!isNaN(this.frameloadtimer)) clearTimeout(this.frameloadtimer); |
203 |
var now = new Date(); |
this.setstatus(0); |
204 |
var t = now.getTime(); |
} |
205 |
var x = this.pollfreq - (t-this.lastrequest); |
|
206 |
if (x < 10) x = 10; |
Meteor.prototype.pollmode = function() { |
207 |
this.ping(); |
this.mode="poll"; |
208 |
this.callback_reset(); |
this.start(); |
209 |
setTimeout(this.start.bind(this), x); |
this.callback_changemode("poll"); |
210 |
} |
this.lastpingtime = false; |
211 |
|
} |
212 |
Meteor.prototype.eof = function() { |
|
213 |
this.callback_eof(); |
Meteor.prototype.process = function(id, data, timestamp) { |
214 |
} |
if (id > this.lastmsgreceived) { |
215 |
|
this.callback_process(data); |
216 |
Meteor.prototype.get = function(varname) { |
if (id != -1) this.lastmsgreceived = id; |
217 |
eval("var a = this."+varname+";"); |
if (this.mode=="poll") { |
218 |
if (typeof(a) == "undefined") throw "Cannot get value of "+varname; |
var now = new Date(); |
219 |
return a; |
var t = now.getTime(); |
220 |
} |
this.recvtimes[this.recvtimes.length] = t; |
221 |
|
while (this.recvtimes.length > 5) this.recvtimes.shift(); |
222 |
Meteor.prototype.increasepolldelay = function() { |
} |
223 |
this.pollfreq *= 2; |
} else if (id == -1) { |
224 |
} |
this.ping(); |
225 |
|
} |
226 |
Meteor.prototype.updatepollfreq = function() { |
this.setstatus(5); |
227 |
if (this.smartpoll) { |
if (!isNaN(timestamp)) { |
228 |
var now = new Date(); |
Meteor.setServerTime(timestamp); |
229 |
var t = now.getTime(); |
} |
230 |
var avg = 0; |
} |
231 |
for (var i=1; i<this.recvtimes.length; i++) { |
|
232 |
var x = (this.recvtimes[i]-this.recvtimes[i-1]); |
Meteor.prototype.ping = function() { |
233 |
avg += (x>60000)? 60000 : x; |
if (this.mode=="stream" && this.pingtimer) { |
234 |
} |
clearTimeout(this.pingtimer); |
235 |
x = (t-this.recvtimes[this.recvtimes.length-1]); |
var f = this.pollmode.bind(this); |
236 |
avg += (x>180000)? 180000 : x; |
this.pingtimer = setTimeout(f, this.pingtimeout); |
237 |
avg /= this.recvtimes.length; |
var now = new Date(); |
238 |
if ((avg/3) < this.pollfreq && (avg/3) >= this.minpollfreq) this.pollfreq = Math.ceil(this.pollfreq*0.9); |
this.lastpingtime = now.getTime(); |
239 |
if ((avg/3) > this.pollfreq) this.pollfreq = Math.floor(this.pollfreq*1.05); |
} |
240 |
} |
this.setstatus(5); |
241 |
} |
} |
242 |
|
|
243 |
Meteor.prototype.registerEventCallback = function(evt, funcRef) { |
Meteor.prototype.reset = function() { |
244 |
if (evt=="process") { |
var now = new Date(); |
245 |
this.callback_process = (this.callback_process).andThen(funcRef); |
var t = now.getTime(); |
246 |
} else if (evt=="reset") { |
var x = this.pollfreq - (t-this.lastrequest); |
247 |
this.callback_reset = (this.callback_reset).andThen(funcRef); |
if (x < 10) x = 10; |
248 |
} else if (evt=="eof") { |
this.ping(); |
249 |
this.callback_eof = (this.callback_eof).andThen(funcRef); |
this.callback_reset(); |
250 |
} else if (evt=="changemode") { |
setTimeout(this.start.bind(this), x); |
251 |
this.callback_changemode = (this.callback_changemode).andThen(funcRef); |
} |
252 |
} |
|
253 |
} |
Meteor.prototype.eof = function() { |
254 |
|
this.callback_eof(); |
255 |
|
} |
256 |
Meteor.createCookie = function(name,value,days) { |
|
257 |
if (days) { |
Meteor.prototype.get = function(varname) { |
258 |
var date = new Date(); |
eval("var a = this."+varname+";"); |
259 |
date.setTime(date.getTime()+(days*24*60*60*1000)); |
if (typeof(a) == "undefined") throw "Cannot get value of "+varname; |
260 |
var expires = "; expires="+date.toGMTString(); |
return a; |
261 |
} |
} |
262 |
else var expires = ""; |
|
263 |
document.cookie = name+"="+value+expires+"; path=/"; |
Meteor.prototype.increasepolldelay = function() { |
264 |
} |
this.pollfreq *= 2; |
265 |
|
} |
266 |
Meteor.readCookie = function(name) { |
|
267 |
var nameEQ = name + "="; |
Meteor.prototype.updatepollfreq = function() { |
268 |
var ca = document.cookie.split(';'); |
if (this.smartpoll) { |
269 |
for(var i=0;i < ca.length;i++) { |
var now = new Date(); |
270 |
var c = ca[i]; |
var t = now.getTime(); |
271 |
while (c.charAt(0)==' ') c = c.substring(1,c.length); |
var avg = 0; |
272 |
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); |
for (var i=1; i<this.recvtimes.length; i++) { |
273 |
} |
var x = (this.recvtimes[i]-this.recvtimes[i-1]); |
274 |
return null; |
avg += (x>60000)? 60000 : x; |
275 |
} |
} |
276 |
|
x = (t-this.recvtimes[this.recvtimes.length-1]); |
277 |
Meteor.eraseCookie = function(name) { |
avg += (x>180000)? 180000 : x; |
278 |
createCookie(name,"",-1); |
avg /= this.recvtimes.length; |
279 |
|
if ((avg/3) < this.pollfreq && (avg/3) >= this.minpollfreq) this.pollfreq = Math.ceil(this.pollfreq*0.9); |
280 |
|
if ((avg/3) > this.pollfreq) this.pollfreq = Math.floor(this.pollfreq*1.05); |
281 |
|
} |
282 |
|
} |
283 |
|
|
284 |
|
Meteor.prototype.registerEventCallback = function(evt, funcRef) { |
285 |
|
if (evt=="process") { |
286 |
|
this.callback_process = (this.callback_process).andThen(funcRef); |
287 |
|
} else if (evt=="reset") { |
288 |
|
this.callback_reset = (this.callback_reset).andThen(funcRef); |
289 |
|
} else if (evt=="eof") { |
290 |
|
this.callback_eof = (this.callback_eof).andThen(funcRef); |
291 |
|
} else if (evt=="changemode") { |
292 |
|
this.callback_changemode = (this.callback_changemode).andThen(funcRef); |
293 |
|
} else if (evt=="changestatus") { |
294 |
|
this.callback_statuschanged = (this.callback_statuschanged).andThen(funcRef); |
295 |
|
} |
296 |
|
} |
297 |
|
|
298 |
|
Meteor.prototype.frameload = function() { |
299 |
|
this.setstatus(2); |
300 |
|
if (document.getElementById("meteorframe_"+this.instID)) { |
301 |
|
var f = this.frameloadtimeout.bind(this); |
302 |
|
this.frameloadtimer = setTimeout(f, 5000); |
303 |
|
document.getElementById("meteorframe_"+this.instID).src = "about:blank"; |
304 |
|
setTimeout(this.doloadurl.bind(this), 100); |
305 |
|
} |
306 |
|
} |
307 |
|
Meteor.prototype.doloadurl = function() { |
308 |
|
var now = new Date(); |
309 |
|
var t = now.getTime(); |
310 |
|
document.getElementById("meteorframe_"+this.instID).src = this.frameurl+"?nocache="+t; |
311 |
|
} |
312 |
|
Meteor.prototype.frameloadtimeout = function() { |
313 |
|
if (this.frameloadtimer) clearTimeout(this.frameloadtimer); |
314 |
|
this.setstatus(3); |
315 |
|
this.frameload(); |
316 |
|
} |
317 |
|
Meteor.prototype.setstatus = function(newstatus) { |
318 |
|
if (this.status != newstatus) { |
319 |
|
this.status = newstatus; |
320 |
|
this.callback_statuschanged(newstatus); |
321 |
|
} |
322 |
|
} |
323 |
|
|
324 |
|
Meteor.createCookie = function(name,value,days) { |
325 |
|
if (days) { |
326 |
|
var date = new Date(); |
327 |
|
date.setTime(date.getTime()+(days*24*60*60*1000)); |
328 |
|
var expires = "; expires="+date.toGMTString(); |
329 |
|
} |
330 |
|
else var expires = ""; |
331 |
|
document.cookie = name+"="+value+expires+"; path=/"; |
332 |
|
} |
333 |
|
|
334 |
|
Meteor.readCookie = function(name) { |
335 |
|
var nameEQ = name + "="; |
336 |
|
var ca = document.cookie.split(';'); |
337 |
|
for(var i=0;i < ca.length;i++) { |
338 |
|
var c = ca[i]; |
339 |
|
while (c.charAt(0)==' ') c = c.substring(1,c.length); |
340 |
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); |
341 |
|
} |
342 |
|
return null; |
343 |
|
} |
344 |
|
|
345 |
|
Meteor.eraseCookie = function(name) { |
346 |
|
createCookie(name,"",-1); |
347 |
} |
} |