diff --git a/apps/furnace-fjsc/furnace-fjsc.factor b/apps/furnace-fjsc/furnace-fjsc.factor index 4cd5ad6e57..a065bb5623 100644 --- a/apps/furnace-fjsc/furnace-fjsc.factor +++ b/apps/furnace-fjsc/furnace-fjsc.factor @@ -31,9 +31,7 @@ USING: kernel html furnace xml io httpd sequences #! Render the fjsc page importing the required #! scripts. serving-html { - "/responder/fjsc-resources/yahoo/yahoo.js" - "/responder/fjsc-resources/yahoo/event.js" - "/responder/fjsc-resources/yahoo/connection.js" + "/responder/fjsc-resources/jquery.js" "/responder/fjsc-resources/bootstrap.js" } swap [ [ diff --git a/apps/furnace-fjsc/repl.fhtml b/apps/furnace-fjsc/repl.fhtml index 057ba5154a..b7a6d7d6df 100644 --- a/apps/furnace-fjsc/repl.fhtml +++ b/apps/furnace-fjsc/repl.fhtml @@ -1,4 +1,4 @@ -
+ diff --git a/apps/furnace-fjsc/resources/bootstrap.js b/apps/furnace-fjsc/resources/bootstrap.js index bab1e361b3..eea93ff3b2 100644 --- a/apps/furnace-fjsc/resources/bootstrap.js +++ b/apps/furnace-fjsc/resources/bootstrap.js @@ -42,7 +42,6 @@ function Factor() { this.in_vocab = "scratchpad"; this.using_vocabs = [ "scratchpad", "kernel","math","sequences","parser","alien","browser-dom", "words" ]; this.cont = new Continuation(); - this.form = false ; } var factor = new Factor(); @@ -111,26 +110,15 @@ Factor.prototype.make_quotation = function(source, func) { Factor.prototype.server_eval = function(text, next) { var self = this; - var callback = { - success: function(o) { - var v = o.responseText; - document.getElementById('compiled').innerHTML="
" + v + "
"; - document.getElementById('code').value=""; - var func = eval(v); - factor.cont.next = function() { self.display_datastack(); } - func(factor); - if(next) - factor.call_next(next); - } - }; - this.form.code.value=text; - YAHOO.util.Connect.setForm(this.form); - YAHOO.util.Connect.asyncRequest('POST', "/responder/fjsc/compile", callback); -} - -Factor.prototype.fjsc_eval = function(form) { - this.form = form; - this.server_eval(form.code.value); + $.post("/responder/fjsc/compile", { code: text }, function(result) { + document.getElementById('compiled').innerHTML="
" + result + "
"; + document.getElementById('code').value=""; + var func = eval(result); + factor.cont.next = function() { self.display_datastack(); } + func(factor); + if(next) + factor.call_next(next); + }); } Factor.prototype.display_datastack = function() { @@ -353,17 +341,9 @@ factor.add_word("prettyprint", ".", "primitive", function(next) { factor.add_word("parser", "run-file", "primitive", function(next) { var stack = factor.cont.data_stack; var url = stack.pop(); - var callback = { - success: function(o) { - var result = o.responseText; - factor.server_eval(result, next); - }, - failure: function(o) { - alert('run-file failed'); - factor.call_next(next); - } - }; - YAHOO.util.Connect.asyncRequest('GET', url, callback, null); + $.get(url, function(result) { + factor.server_eval(result, next); + }); }); diff --git a/apps/furnace-fjsc/resources/jquery.js b/apps/furnace-fjsc/resources/jquery.js new file mode 100644 index 0000000000..2531342aef --- /dev/null +++ b/apps/furnace-fjsc/resources/jquery.js @@ -0,0 +1 @@ +eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('l(1T 1z.6=="Q"){1z.Q=1z.Q;u 6=q(a,c){l(a&&1T a=="q"&&6.C.1W)v 6(17).1W(a);a=a||6.1o||17;l(a.3E)v 6(6.1X(a,[]));l(c&&c.3E)v 6(c).1V(a);l(1z==7)v 1h 6(a,c);l(a.O==1C){u m=/^[^<]*(<.+>)[^>]*$/.3d(a);l(m)a=6.3D([m[1]])}7.1n(a.O==2z||a.D&&!a.1R&&a[0]!=Q&&a[0].1R?6.1X(a,[]):6.1V(a,c));u C=19[19.D-1];l(C&&1T C=="q")7.W(C);v 7};l(1T $!="Q")6.44$=$;u $=6;6.C=6.8b={3E:"1.0.3",5J:q(){v 7.D},1n:q(23){l(23&&23.O==2z){7.D=0;[].1k.16(7,23);v 7}G v 23==Q?6.1X(7,[]):7[23]},W:q(C,1g){v 6.W(7,C,1g)},8g:q(15){u 2j=-1;7.W(q(i){l(7==15)2j=i});v 2j},1t:q(1L,Y,B){v 1L.O!=1C||Y!=Q?7.W(q(){l(Y==Q)I(u E 1r 1L)6.1t(B?7.1a:7,E,1L[E]);G 6.1t(B?7.1a:7,1L,Y)}):6[B||"1t"](7[0],1L)},1f:q(1L,Y){v 7.1t(1L,Y,"26")},2B:q(e){e=e||7;u t="";I(u j=0;j0:U},2T:q(1g,22,2X,C){u 4f=7.5J()>1;u a=6.3D(1g);v 7.W(q(){u 15=7;l(22&&7.2p.2b()=="8m"&&a[0].2p.2b()!="62"){u 29=7.4S("29");l(!29.D){15=17.5N("29");7.4e(15)}G 15=29[0]}I(u i=(2X<0?a.D-1:0);i!=(2X<0?2X:a.D);i+=2X){C.16(15,[4f?a[i].3f(T):a[i]])}})},2n:q(a,1g){u C=1g&&1g[1g.D-1];u 2d=1g&&1g[1g.D-2];l(C&&C.O!=1v)C=M;l(2d&&2d.O!=1v)2d=M;l(!C){l(!7.33)7.33=[];7.33.1k(7.1n());7.1n(a)}G{u 1Z=7.1n();7.1n(a);l(2d&&a.D||!2d)7.W(2d||C).1n(1Z);G 7.1n(1Z).W(C)}v 7}};6.1y=6.C.1y=q(15,E){l(19.D>1&&(E===M||E==Q))v 15;l(!E){E=15;15=7}I(u i 1r E)15[i]=E[i];v 15};6.1y({5C:q(){6.65=T;6.W(6.2e.5r,q(i,n){6.C[i]=q(a){u L=6.2r(7,n);l(a&&a.O==1C)L=6.1c(a,L).r;v 7.2n(L,19)}});6.W(6.2e.2o,q(i,n){6.C[i]=q(){u a=19;v 7.W(q(){I(u j=0;j",""];G l(!s.1b("<6w")||!s.1b("<29"))1Y=[1,"<22>",""];G l(!s.1b("<4t"))1Y=[2,"<22>",""];G l(!s.1b("<6x")||!s.1b("<6z"))1Y=[3,"<22><29><4t>",""];21.2V=1Y[1]+s+1Y[2];24(1Y[0]--)21=21.2a;I(u j=0;j<21.2f.D;j++)r.1k(21.2f[j])}G l(1M.D!=Q&&!1M.1R)I(u n=0;n<1M.D;n++)r.1k(1M[n]);G r.1k(1M.1R?1M:17.6A(1M.6C()))}v r},2u:{"":"m[2]== \'*\'||a.2p.2b()==m[2].2b()","#":"a.3a(\'3H\')&&a.3a(\'3H\')==m[2]",":":{5o:"im[3]-0",5L:"m[3]-0==i",5n:"m[3]-0==i",2h:"i==0",1N:"i==r.D-1",52:"i%2==0",53:"i%2","5L-3x":"6.1x(a,m[3]).1l","2h-3x":"6.1x(a,0).1l","1N-3x":"6.1x(a,0).1N","6D-3x":"6.1x(a).D==1",5s:"a.2f.D",5B:"!a.2f.D",5p:"6.C.2B.16([a]).1b(m[3])>=0",6E:"a.B!=\'1S\'&&6.1f(a,\'1u\')!=\'20\'&&6.1f(a,\'3U\')!=\'1S\'",1S:"a.B==\'1S\'||6.1f(a,\'1u\')==\'20\'||6.1f(a,\'3U\')==\'1S\'",6F:"!a.2P",2P:"a.2P",2J:"a.2J",3V:"a.3V || 6.1t(a, \'3V\')",2B:"a.B==\'2B\'",3W:"a.B==\'3W\'",5y:"a.B==\'5y\'",3Q:"a.B==\'3Q\'",5v:"a.B==\'5v\'",4x:"a.B==\'4x\'",5w:"a.B==\'5w\'",4w:"a.B==\'4w\'",4s:"a.B==\'4s\'",5z:"a.2p.4d().4T(/5z|3c|6L|4s/)"},".":"6.1j.3t(a,m[2])","@":{"=":"z==m[4]","!=":"z!=m[4]","^=":"z && !z.1b(m[4])","$=":"z && z.32(z.D - m[4].D,m[4].D)==m[4]","*=":"z && z.1b(m[4])>=0","":"z"},"[":"6.1V(m[2],a).D"},3B:["\\\\.\\\\.|/\\\\.\\\\.","a.1i",">|/","6.1x(a.2a)","\\\\+","6.1x(a).3z","~",q(a){u r=[];u s=6.1x(a);l(s.n>0)I(u i=s.n;i=1)t=t.32(t.1b("/"),t.D)}u L=[1o];u 1K=[];u 1N=M;24(t.D>0&&1N!=t){u r=[];1N=t;t=6.2K(t).1B(/^\\/\\//i,"");u 36=U;I(u i=0;i<6.3B.D;i+=2){l(36)51;u 2v=1h 43("^("+6.3B[i]+")");u m=2v.3d(t);l(m){r=L=6.2r(L,6.3B[i+1]);t=6.2K(t.1B(2v,""));36=T}}l(!36){l(!t.1b(",")||!t.1b("|")){l(L[0]==1o)L.4h();1K=6.1X(1K,L);r=L=[1o];t=" "+t.32(1,t.D)}G{u 3Z=/^([#.]?)([a-4Y-9\\\\*44-]*)/i;u m=3Z.3d(t);l(m[1]=="#"){u 4l=17.5V(m[2]);r=L=4l?[4l]:[];t=t.1B(3Z,"")}G{l(!m[2]||m[1]==".")m[2]="*";I(u i=0;i<\\/27>");u 27=17.5V("5W");27.2w=q(){l(7.3n!="1I")v;7.1i.3s(7);6.1W()};27=M}G l(6.11.2M){6.3N=42(q(){l(17.3n=="63"||17.3n=="1I"){56(6.3N);6.3N=M;6.1W()}},10)}6.J.2g(1z,"2S",6.1W)};l(6.11.1p)6(1z).4z(q(){u J=6.J,1e=J.1e;I(u B 1r 1e){u 3P=1e[B],i=3P.D;l(i>0)6a l(B!=\'4z\')J.25(3P[i-1],B);24(--i)}});6.C.1y({60:6.C.1A,1A:q(12,H){v 12?7.1U({1G:"1A",2c:"1A",1m:"1A"},12,H):7.60()},5U:6.C.1s,1s:q(12,H){v 12?7.1U({1G:"1s",2c:"1s",1m:"1s"},12,H):7.5U()},6n:q(12,H){v 7.1U({1G:"1A"},12,H)},6o:q(12,H){v 7.1U({1G:"1s"},12,H)},6p:q(12,H){v 7.W(q(){u 4J=6(7).4E(":1S")?"1A":"1s";6(7).1U({1G:4J},12,H)})},6r:q(12,H){v 7.1U({1m:"1A"},12,H)},6s:q(12,H){v 7.1U({1m:"1s"},12,H)},6t:q(12,2o,H){v 7.1U({1m:2o},12,H)},1U:q(E,12,H){v 7.1w(q(){7.2U=6.1y({},E);I(u p 1r E){u e=1h 6.2R(7,6.12(12,H),p);l(E[p].O==4O)e.3e(e.1l(),E[p]);G e[E[p]](E)}})},1w:q(B,C){l(!C){C=B;B="2R"}v 7.W(q(){l(!7.1w)7.1w={};l(!7.1w[B])7.1w[B]=[];7.1w[B].1k(C);l(7.1w[B].D==1)C.16(7)})}});6.1y({5f:q(e,p){l(e.5F)v;l(p=="1G"&&e.4L!=3l(6.26(e,p)))v;l(p=="2c"&&e.4M!=3l(6.26(e,p)))v;u a=e.1a[p];u o=6.26(e,p,1);l(p=="1G"&&e.4L!=o||p=="2c"&&e.4M!=o)v;e.1a[p]=e.34?"":"5H";u n=6.26(e,p,1);l(o!=n&&n!="5H"){e.1a[p]=a;e.5F=T}},12:q(s,o){o=o||{};l(o.O==1v)o={1I:o};u 5D={6G:6H,6J:4K};o.2E=(s&&s.O==4O?s:5D[s])||5k;o.3J=o.1I;o.1I=q(){6.4R(7,"2R");l(o.3J&&o.3J.O==1v)o.3J.16(7)};v o},1w:{},4R:q(F,B){B=B||"2R";l(F.1w&&F.1w[B]){F.1w[B].4h();u f=F.1w[B][0];l(f)f.16(F)}},2R:q(F,2x,E){u z=7;z.o={2E:2x.2E||5k,1I:2x.1I,2s:2x.2s};z.V=F;u y=z.V.1a;z.a=q(){l(2x.2s)2x.2s.16(F,[z.2i]);l(E=="1m")6.1t(y,"1m",z.2i);G l(3l(z.2i))y[E]=3l(z.2i)+"5d";y.1u="2F"};z.61=q(){v 4c(6.1f(z.V,E))};z.1l=q(){u r=4c(6.26(z.V,E));v r&&r>-6Z?r:z.61()};z.3e=q(41,2o){z.3M=(1h 54()).55();z.2i=41;z.a();z.49=42(q(){z.2s(41,2o)},13)};z.1A=q(){l(!z.V.1Q)z.V.1Q={};z.V.1Q[E]=7.1l();z.3e(0,z.V.1Q[E]);l(E!="1m")y[E]="77"};z.1s=q(){l(!z.V.1Q)z.V.1Q={};z.V.1Q[E]=7.1l();z.o.1s=T;z.3e(z.V.1Q[E],0)};l(!z.V.4b)z.V.4b=6.1f(z.V,"3h");y.3h="1S";z.2s=q(4B,4g){u t=(1h 54()).55();l(t>z.o.2E+z.3M){56(z.49);z.49=M;z.2i=4g;z.a();z.V.2U[E]=T;u 1K=T;I(u i 1r z.V.2U)l(z.V.2U[i]!==T)1K=U;l(1K){y.3h=z.V.4b;l(z.o.1s)y.1u=\'20\';l(z.o.1s){I(u p 1r z.V.2U){l(p=="1m")6.1t(y,p,z.V.1Q[p]);G y[p]=z.V.1Q[p]+"5d";l(p==\'1G\'||p==\'2c\')6.5f(z.V,p)}}}l(1K&&z.o.1I&&z.o.1I.O==1v)z.o.1I.16(z.V)}G{u p=(t-7.3M)/z.o.2E;z.2i=((-5q.7w(p*5q.7y)/2)+0.5)*(4g-4B)+4B;z.a()}}}});6.C.1y({7D:q(N,1O,H){7.2S(N,1O,H,1)},2S:q(N,1O,H,1F){l(N.O==1v)v 7.2Z("2S",N);H=H||q(){};u B="3T";l(1O){l(1O.O==1v){H=1O;1O=M}G{1O=6.2Q(1O);B="4W"}}u 4m=7;6.3I(B,N,1O,q(3v,18){l(18=="2D"||!1F&&18=="5m"){4m.38(3v.3G).3X().W(H,[3v.3G,18])}G H.16(4m,[3v.3G,18])},1F);v 7},7J:q(){v 6.2Q(7)},3X:q(){v 7.1V(\'27\').W(q(){l(7.3w)6.5Y(7.3w,q(){});G 3A.3O(1z,7.2B||7.7L||7.2V||"")}).4q()}});l(6.11.1p&&1T 3i=="Q")3i=q(){v 1h 7Q(5I.5K.1b("7W 5")>=0?"82.5R":"84.5R")};1h q(){u e="5O,5G,5A,5x,5t".3b(",");I(u i=0;i-1)?"&":"?")+6.2Q(K);6.3I("3T",N,M,q(r,18){l(H)H(6.3r(r,B),18)},1F)},8h:q(N,K,H,B){6.1n(N,K,H,B,1)},5Y:q(N,H){l(H)6.1n(N,M,H,"27");G{6.1n(N,M,M,"27")}},64:q(N,K,H){l(H)6.1n(N,K,H,"3S");G{6.1n(N,K,"3S")}},8o:q(N,K,H,B){6.3I("4W",N,6.2Q(K),q(r,18){l(H)H(6.3r(r,B),18)})},1q:0,6h:q(1q){6.1q=1q},39:{},3I:q(B,N,K,L,1F){u 1e=T;u 1q=6.1q;l(!N){L=B.1I;u 2D=B.2D;u 2l=B.2l;u 4k=B.4k;u 1e=1T B.1e=="6q"?B.1e:T;u 1q=1T B.1q=="6u"?B.1q:6.1q;1F=B.1F||U;K=B.K;N=B.N;B=B.B}l(1e&&!6.4v++)6.J.1P("5O");u 4y=U;u R=1h 3i();R.6B(B||"3T",N,T);l(K)R.3j("6I-6K","6M/x-6N-6Q-6T");l(1F)R.3j("6V-3Y-6Y",6.39[N]||"71, 74 75 78 46:46:46 79");R.3j("X-7a-7d","3i");l(R.7g)R.3j("7j","7k");u 2w=q(4F){l(R&&(R.3n==4||4F=="1q")){4y=T;u 18=6.4G(R)&&4F!="1q"?1F&&6.4N(R,N)?"5m":"2D":"2l";l(18!="2l"){u 3q;3u{3q=R.4i("4P-3Y")}3o(e){}l(1F&&3q)6.39[N]=3q;l(2D)2D(6.3r(R,4k),18);l(1e)6.J.1P("5t")}G{l(2l)2l(R,18);l(1e)6.J.1P("5x")}l(1e)6.J.1P("5A");l(1e&&!--6.4v)6.J.1P("5G");l(L)L(R,18);R.2w=q(){};R=M}};R.2w=2w;l(1q>0)7Z(q(){l(R){R.85();l(!4y)2w("1q");R=M}},1q);R.8i(K)},4v:0,4G:q(r){3u{v!r.18&&66.6d=="3Q:"||(r.18>=4K&&r.18<6y)||r.18==5b||6.11.2M&&r.18==Q}3o(e){}v U},4N:q(R,N){3u{u 4V=R.4i("4P-3Y");v R.18==5b||4V==6.39[N]||6.11.2M&&R.18==Q}3o(e){}v U},3r:q(r,B){u 4n=r.4i("7I-B");u K=!B&&4n&&4n.1b("R")>=0;K=B=="R"||K?r.80:r.3G;l(B=="27")3A.3O(1z,K);l(B=="3S")3A("K = "+K);l(B=="38")$("<21>").38(K).3X();v K},2Q:q(a){u s=[];l(a.O==2z||a.3E){I(u i=0;i= 200 && httpStatus < 300){ - responseObject = this.createResponseObject(o, callback.argument); - if(callback.success){ - if(!callback.scope){ - callback.success(responseObject); - } - else{ - // If a scope property is defined, the callback will be fired from - // the context of the object. - callback.success.apply(callback.scope, [responseObject]); - } - } - } - else{ - switch(httpStatus){ - // The following case labels are wininet.dll error codes that may be encountered. - // Server timeout - case 12002: - // 12029 to 12031 correspond to dropped connections. - case 12029: - case 12030: - case 12031: - // Connection closed by server. - case 12152: - // See above comments for variable status. - case 13030: - responseObject = this.createExceptionObject(o, callback.argument); - if(callback.failure){ - if(!callback.scope){ - callback.failure(responseObject); - } - else{ - callback.failure.apply(callback.scope,[responseObject]); - } - } - break; - default: - responseObject = this.createResponseObject(o, callback.argument); - if(callback.failure){ - if(!callback.scope){ - callback.failure(responseObject); - } - else{ - callback.failure.apply(callback.scope,[responseObject]); - } - } - } - } - - this.releaseObject(o); - }, - - /** - * This method evaluates the server response, creates and returns the results via - * its properties. Success and failure cases will differ in the response - * object's property values. - * @private - * @param {object} o The connection object - * @param {} callbackArg User-defined argument or arguments to be passed to the callback - * @return object - */ - createResponseObject:function(o, callbackArg) - { - var obj = {}; - var headerObj = {}; - - try - { - var headerStr = o.conn.getAllResponseHeaders(); - var header = headerStr.split("\n"); - for(var i=0; i < header.length; i++){ - var delimitPos = header[i].indexOf(':'); - if(delimitPos != -1){ - headerObj[header[i].substring(0,delimitPos)] = header[i].substring(delimitPos+1); - } - } - - obj.tId = o.tId; - obj.status = o.conn.status; - obj.statusText = o.conn.statusText; - obj.getResponseHeader = headerObj; - obj.getAllResponseHeaders = headerStr; - obj.responseText = o.conn.responseText; - obj.responseXML = o.conn.responseXML; - if(typeof callbackArg !== undefined){ - obj.argument = callbackArg; - } - } - catch(e){} - finally - { - return obj; - } - }, - - /** - * If a transaction cannot be completed due to dropped or closed connections, - * there may be not be enough information to build a full response object. - * The failure callback will be fired and this specific condition can be identified - * by a status property value of 0. - * @private - * @param {int} tId Transaction Id - * @param callbackArg The user-defined arguments - * @return object - */ - createExceptionObject:function(tId, callbackArg) - { - var COMM_CODE = 0; - var COMM_ERROR = 'communication failure'; - - var obj = {}; - - obj.tId = tId; - obj.status = COMM_CODE; - obj.statusText = COMM_ERROR; - if(callbackArg){ - obj.argument = callbackArg; - } - - return obj; - }, - - /** - * Public method that stores the custom HTTP headers for each transaction. - * @public - * @param {string} label The HTTP header label - * @param {string} value The HTTP header value - * @return void - */ - initHeader:function(label,value) - { - if(this._http_header[label] === undefined){ - this._http_header[label] = value; - } - else{ - this._http_header[label] = value + "," + this._http_header[label]; - } - - this._has_http_headers = true; - }, - - /** - * Accessor that sets the HTTP headers for each transaction. - * @private - * @param {object} o The connection object for the transaction. - * @return void - */ - setHeader:function(o) - { - for(var prop in this._http_header){ - o.conn.setRequestHeader(prop, this._http_header[prop]); - } - delete this._http_header; - - this._http_header = {}; - this._has_http_headers = false; - }, - - /** - * This method assembles the form label and value pairs and - * constructs an encoded string. - * asyncRequest() will automatically initialize the - * transaction with a HTTP header Content-Type of - * application/x-www-form-urlencoded. - * @public - * @param {string || object} form id or name attribute, or form object. - * @return void - */ - setForm:function(formId) - { - this._sFormData = ''; - if(typeof formId == 'string'){ - // Determine if the argument is a form id or a form name. - // Note form name usage is deprecated by supported - // here for legacy reasons. - var oForm = (document.getElementById(formId) || document.forms[formId] ); - } - else if(typeof formId == 'object'){ - var oForm = formId; - } - else{ - return; - } - var oElement, oName, oValue, oDisabled; - var hasSubmit = false; - - // Iterate over the form elements collection to construct the - // label-value pairs. - for (var i=0; i - * - The type of event - * - All of the arguments fire() was executed with as an array - * - The custom object (if any) that was passed into the subscribe() method - * - * - * @param {Array} an arbitrary set of parameters to pass to the handler - */ - fire: function() { - for (var i=0, len=this.subscribers.length; i= 0) { - cacheItem = listeners[index]; - } - - if (!el || !cacheItem) { - return false; - } - - - if (el.removeEventListener) { - el.removeEventListener(sType, cacheItem[this.WFN], false); - } else if (el.detachEvent) { - el.detachEvent("on" + sType, cacheItem[this.WFN]); - } - - // removed the wrapped handler - delete listeners[index][this.WFN]; - delete listeners[index][this.FN]; - delete listeners[index]; - - return true; - - }, - - /** - * Returns the event's target element - * @param {Event} ev the event - * @param {boolean} resolveTextNode when set to true the target's - * parent will be returned if the target is a - * text node - * @return {HTMLElement} the event's target - */ - getTarget: function(ev, resolveTextNode) { - var t = ev.target || ev.srcElement; - - if (resolveTextNode && t && "#text" == t.nodeName) { - return t.parentNode; - } else { - return t; - } - }, - - /** - * Returns the event's pageX - * @param {Event} ev the event - * @return {int} the event's pageX - */ - getPageX: function(ev) { - var x = ev.pageX; - if (!x && 0 !== x) { - x = ev.clientX || 0; - - if ( this.isIE ) { - x += this._getScrollLeft(); - } - } - - return x; - }, - - /** - * Returns the event's pageY - * @param {Event} ev the event - * @return {int} the event's pageY - */ - getPageY: function(ev) { - var y = ev.pageY; - if (!y && 0 !== y) { - y = ev.clientY || 0; - - if ( this.isIE ) { - y += this._getScrollTop(); - } - } - - return y; - }, - - /** - * Returns the pageX and pageY properties as an indexed array. - * @type int[] - */ - getXY: function(ev) { - return [this.getPageX(ev), this.getPageY(ev)]; - }, - - /** - * Returns the event's related target - * @param {Event} ev the event - * @return {HTMLElement} the event's relatedTarget - */ - getRelatedTarget: function(ev) { - var t = ev.relatedTarget; - if (!t) { - if (ev.type == "mouseout") { - t = ev.toElement; - } else if (ev.type == "mouseover") { - t = ev.fromElement; - } - } - - return t; - }, - - /** - * Returns the time of the event. If the time is not included, the - * event is modified using the current time. - * @param {Event} ev the event - * @return {Date} the time of the event - */ - getTime: function(ev) { - if (!ev.time) { - var t = new Date().getTime(); - try { - ev.time = t; - } catch(e) { - // can't set the time property - return t; - } - } - - return ev.time; - }, - - /** - * Convenience method for stopPropagation + preventDefault - * @param {Event} ev the event - */ - stopEvent: function(ev) { - this.stopPropagation(ev); - this.preventDefault(ev); - }, - - /** - * Stops event propagation - * @param {Event} ev the event - */ - stopPropagation: function(ev) { - if (ev.stopPropagation) { - ev.stopPropagation(); - } else { - ev.cancelBubble = true; - } - }, - - /** - * Prevents the default behavior of the event - * @param {Event} ev the event - */ - preventDefault: function(ev) { - if (ev.preventDefault) { - ev.preventDefault(); - } else { - ev.returnValue = false; - } - }, - - /** - * Finds the event in the window object, the caller's arguments, or - * in the arguments of another method in the callstack. This is - * executed automatically for events registered through the event - * manager, so the implementer should not normally need to execute - * this function at all. - * @param {Event} the event parameter from the handler - * @return {Event} the event - */ - getEvent: function(e) { - var ev = e || window.event; - - if (!ev) { - var c = this.getEvent.caller; - while (c) { - ev = c.arguments[0]; - if (ev && Event == ev.constructor) { - break; - } - c = c.caller; - } - } - - return ev; - }, - - /** - * Returns the charcode for an event - * @param {Event} ev the event - * @return {int} the event's charCode - */ - getCharCode: function(ev) { - return ev.charCode || ((ev.type == "keypress") ? ev.keyCode : 0); - }, - - /** - * @private - * Locating the saved event handler data by function ref - */ - _getCacheIndex: function(el, sType, fn) { - for (var i=0,len=listeners.length; i 0); - } - - // Delayed listeners - var stillDelayed = []; - - for (var i=0,len=delayedListeners.length; i 0) { - for (i=0,len=listeners.length; i