]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/xdomain.js
1 qwebirc
.xdomain
.Poller
= new Class({
2 initialize: function(callback
) {
3 this._callback
= callback
;
4 this._poll
.periodical(100, this);
5 this._lastValue
= null;
9 var value
= window
.location
.href
;
10 if(value
=== null || value
=== undefined || value
== this._lastValue
)
12 this._lastValue
= value
;
13 var fragment
= value
.splitMax("#", 2)[1];
15 if(fragment
=== undefined || fragment
.substr(0, 6) != "qwmsg:")
18 var components
= fragment
.substr(6).split(":", 3);
19 var counter
= parseInt(components
[0]);
20 if(counter
<= this._counter
)
23 this._counter
= counter
;
25 var len
= parseInt(components
[1]);
26 var message
= decodeURIComponent(components
[2]);
27 if(len
!= message
.length
)
30 message
= message
.replaceAll("\000", "").replaceAll("\n", "").replaceAll("\r", "");
31 this._callback(message
);