Project

General

Profile

Download (3.14 KB) Statistics
| Branch: | Revision:
1
/*
2
	Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
3
	Available via Academic Free License >= 2.1 OR the modified BSD license.
4
	see: http://dojotoolkit.org/license for details
5
*/
6

    
7

    
8
if(!window["OpenAjax"]){
9
OpenAjax=new function(){
10
var t=true;
11
var f=false;
12
var g=window;
13
var _4;
14
var _5="org.openajax.hub.";
15
var h={};
16
this.hub=h;
17
h.implementer="http://openajax.org";
18
h.implVersion="0.6";
19
h.specVersion="0.6";
20
h.implExtraData={};
21
var _4={};
22
h.libraries=_4;
23
h.registerLibrary=function(_7,_8,_9,_a){
24
_4[_7]={prefix:_7,namespaceURI:_8,version:_9,extraData:_a};
25
this.publish(_5+"registerLibrary",_4[_7]);
26
};
27
h.unregisterLibrary=function(_b){
28
this.publish(_5+"unregisterLibrary",_4[_b]);
29
delete _4[_b];
30
};
31
h._subscriptions={c:{},s:[]};
32
h._cleanup=[];
33
h._subIndex=0;
34
h._pubDepth=0;
35
h.subscribe=function(_c,_d,_e,_f,_10){
36
if(!_e){
37
_e=window;
38
}
39
var _11=_c+"."+this._subIndex;
40
var sub={scope:_e,cb:_d,fcb:_10,data:_f,sid:this._subIndex++,hdl:_11};
41
var _13=_c.split(".");
42
this._subscribe(this._subscriptions,_13,0,sub);
43
return _11;
44
};
45
h.publish=function(_14,_15){
46
var _16=_14.split(".");
47
this._pubDepth++;
48
this._publish(this._subscriptions,_16,0,_14,_15);
49
this._pubDepth--;
50
if((this._cleanup.length>0)&&(this._pubDepth==0)){
51
for(var i=0;i<this._cleanup.length;i++){
52
this.unsubscribe(this._cleanup[i].hdl);
53
}
54
delete (this._cleanup);
55
this._cleanup=[];
56
}
57
};
58
h.unsubscribe=function(sub){
59
var _19=sub.split(".");
60
var sid=_19.pop();
61
this._unsubscribe(this._subscriptions,_19,0,sid);
62
};
63
h._subscribe=function(_1b,_1c,_1d,sub){
64
var _1f=_1c[_1d];
65
if(_1d==_1c.length){
66
_1b.s.push(sub);
67
}else{
68
if(typeof _1b.c=="undefined"){
69
_1b.c={};
70
}
71
if(typeof _1b.c[_1f]=="undefined"){
72
_1b.c[_1f]={c:{},s:[]};
73
this._subscribe(_1b.c[_1f],_1c,_1d+1,sub);
74
}else{
75
this._subscribe(_1b.c[_1f],_1c,_1d+1,sub);
76
}
77
}
78
};
79
h._publish=function(_20,_21,_22,_23,msg){
80
if(typeof _20!="undefined"){
81
var _25;
82
if(_22==_21.length){
83
_25=_20;
84
}else{
85
this._publish(_20.c[_21[_22]],_21,_22+1,_23,msg);
86
this._publish(_20.c["*"],_21,_22+1,_23,msg);
87
_25=_20.c["**"];
88
}
89
if(typeof _25!="undefined"){
90
var _26=_25.s;
91
var max=_26.length;
92
for(var i=0;i<max;i++){
93
if(_26[i].cb){
94
var sc=_26[i].scope;
95
var cb=_26[i].cb;
96
var fcb=_26[i].fcb;
97
var d=_26[i].data;
98
if(typeof cb=="string"){
99
cb=sc[cb];
100
}
101
if(typeof fcb=="string"){
102
fcb=sc[fcb];
103
}
104
if((!fcb)||(fcb.call(sc,_23,msg,d))){
105
cb.call(sc,_23,msg,d);
106
}
107
}
108
}
109
}
110
}
111
};
112
h._unsubscribe=function(_2d,_2e,_2f,sid){
113
if(typeof _2d!="undefined"){
114
if(_2f<_2e.length){
115
var _31=_2d.c[_2e[_2f]];
116
this._unsubscribe(_31,_2e,_2f+1,sid);
117
if(_31.s.length==0){
118
for(var x in _31.c){
119
return;
120
}
121
delete _2d.c[_2e[_2f]];
122
}
123
return;
124
}else{
125
var _33=_2d.s;
126
var max=_33.length;
127
for(var i=0;i<max;i++){
128
if(sid==_33[i].sid){
129
if(this._pubDepth>0){
130
_33[i].cb=null;
131
this._cleanup.push(_33[i]);
132
}else{
133
_33.splice(i,1);
134
}
135
return;
136
}
137
}
138
}
139
}
140
};
141
h.reinit=function(){
142
for(var lib in OpenAjax.hub.libraries){
143
delete OpenAjax.hub.libraries[lib];
144
}
145
OpenAjax.hub.registerLibrary("OpenAjax","http://openajax.org/hub","0.6",{});
146
delete OpenAjax._subscriptions;
147
OpenAjax._subscriptions={c:{},s:[]};
148
delete OpenAjax._cleanup;
149
OpenAjax._cleanup=[];
150
OpenAjax._subIndex=0;
151
OpenAjax._pubDepth=0;
152
};
153
};
154
OpenAjax.hub.registerLibrary("OpenAjax","http://openajax.org/hub","0.6",{});
155
}
(6-6/26)