dt(hl))};fn7x2568x=9z(gT,hl){3y 2y bO(gT7x298x6whl7x298x3wex(gT)6wex(hl)3wdt(gT)6wdt(hl))};fn7x2588x=9z(gT,hl){3y _b(gT,hl,'eq')};fn7x1568x=9z(gT,hl){3y _b(gT,hl,'lt')};fn7x1518x=9z(gT,hl){3y _b(gT,hl,'gt')};fn7x2558x=9z(gT,hl){3y dp(gT,hl,'eq')};fn7x1508x=9z(gT,hl){3y dp(gT,hl,'lt')};fn7x1458x=9z(gT,hl){3y dp(gT,hl,'gt')};fn7x2508x=9z(gT,hl){3y dq(gT,hl,'eq')};fn7x1448x=9z(gT,hl){3y dq(gT,hl,'lt')};fn7x1488x=9z(gT,hl){3y dq(gT,hl,'gt')};fn7x2528x=9z(gT,hl){3y _b(2y cS(gT7x118x,gT7x68x,e5(gT7x118x,gT7x68x),0,0,0,gT7x48x6w2x?5x7x48x:gT7x48x),2y cS(hl7x118x,hl7x68x,e5(hl7x118x,hl7x68x),0,0,0,hl7x48x6w2x?5x7x48x:hl7x48x),'eq')};fn7x2538x=9z(gT,hl){3y _b(2y cS(gT7x118x,1,1,0,0,0,gT7x48x6w2x?5x7x48x:gT7x48x),2y cS(hl7x118x,1,1,0,0,0,hl7x48x6w2x?5x7x48x:hl7x48x),'eq')};fn7x2608x=9z(gT,hl){3y _b(2y cS(1972,gT7x68x,gT7x158x,0,0,0,gT7x48x6w2x?5x7x48x:gT7x48x),2y cS(1972,hl7x68x,hl7x158x,0,0,0,hl7x48x6w2x?5x7x48x:hl7x48x),'eq')};fn7x2618x=9z(gT,hl){3y _b(2y cS(1972,gT7x68x,e5(1972,hl7x68x),0,0,0,gT7x48x6w2x?5x7x48x:gT7x48x),2y cS(1972,hl7x68x,e5(1972,hl7x68x),0,0,0,hl7x48x6w2x?5x7x48x:hl7x48x),'eq')};fn7x2688x=9z(gT,hl){3y _b(2y cS(1972,12,gT7x158x,0,0,0,gT7x48x6w2x?5x7x48x:gT7x48x),2y cS(1972,12,hl7x158x,0,0,0,hl7x48x6w2x?5x7x48x:hl7x48x),'eq')};fn7x2698x=9z(gT,hl){3y ew(ex(gT)+ex(hl))};fn7x2708x=9z(gT,hl){3y ew(ex(gT)-ex(hl))};fn7x1588x=9z(gT,hl){3y ew(ex(gT)*hl)};fn7x2678x=9z(gT,hl){3y ew(ex(gT)/hl)};fn7x2668x=9z(gT,hl){3y 2y cU(ex(gT)/ex(hl))};fn7x2628x=9z(gT,hl){3y ds(dt(gT)+dt(hl))};fn7x2638x=9z(gT,hl){3y ds(dt(gT)-dt(hl))};fn7x1698x=9z(gT,hl){3y ds(dt(gT)*hl)};fn7x2658x=9z(gT,hl){3y ds(dt(gT)/hl)};fn7x2498x=9z(gT,hl){3y 2y cU(dt(gT)/dt(hl))};fn7x2488x=9z(gT,hl){3y ds(dr(gT)-dr(hl))};fn7x2328x=9z(gT,hl){3y ds(dr(gT)-dr(hl))};fn7x2338x=9z(gT,hl){3y ds(dv(gT)-dv(hl))};fn7x1708x=9z(gT,hl){3y dn(gT,hl,'+')};fn7x1658x=9z(gT,hl){3y dm(gT,hl,'+')};fn7x2348x=9z(gT,hl){3y dn(gT,hl,'-')};fn7x2358x=9z(gT,hl){3y dm(gT,hl,'-')};fn7x1618x=9z(gT,hl){3y dn(gT,hl,'+')};fn7x1628x=9z(gT,hl){3y dm(gT,hl,'+')};fn7x2268x=9z(gT,hl){3y dn(gT,hl,'-')};fn7x2278x=9z(gT,hl){3y dm(gT,hl,'-')};fn7x1348x=9z(gT,hl){8y hG=2y cm(gT7x188x,gT7x198x,gT7x228x,gT7x48x);hG7x188x0vhl7x188x;hG7x198x0vhl7x198x;hG7x228x0vhl7x228x;3y eb(hG)};fn7x2288x=9z(gT,hl){8y hG=2y cm(gT7x188x,gT7x198x,gT7x228x,gT7x48x);hG7x188x1vhl7x188x;hG7x198x1vhl7x198x;hG7x228x1vhl7x228x;3y eb(hG)};9z dq(gT,hl,il){8y fG=dv(gT),f1=dv(hl);3y 2y bO(il6w'lt'?fGf1:fG6wf1)};9z dp(gT,hl,il){3y _b(cS7x38x(gT),cS7x38x(hl),il)};9z _b(gT,hl,il){8y hB=2y cT(0,0,0,0),_e=d0(gT,hB)7x318x2w,jI=d0(hl,hB)7x318x2w;3y 2y bO(il6w'lt'?_ejI:_e6wjI)};9z dn(gT,hl,iC){8y hG;0y(gT 1y cR)hG=2y cR(gT7x118x,gT7x68x,gT7x158x,gT7x48x,gT7x298x);7z 0y(gT 1y cS)hG=2y cS(gT7x118x,gT7x68x,gT7x158x,gT7x188x,gT7x198x,gT7x228x,gT7x48x,gT7x298x);hG7x118x=hG7x118x+hl7x118x*(iC6w'-'?-1:1);hG7x68x=hG7x68x+hl7x68x*(iC6w'-'?-1:1);e6(hG,3x);8y fw=e5(hG7x118x,hG7x68x);0y(hG7x158x>fw)hG7x158x=fw;3y hG};9z dm(gT,hl,iC){8y hG;0y(gT 1y cR){8y fb=(hl7x188x*60+hl7x198x)*60+hl7x228x;hG=2y cR(gT7x118x,gT7x68x,gT7x158x,gT7x48x,gT7x298x);hG7x158x=hG7x158x+hl7x158x*(iC6w'-'?-1:1)-1*(fb3wiC6w'-');e6(hG)}7z 0y(gT 1y cS){hG=2y cS(gT7x118x,gT7x68x,gT7x158x,gT7x188x,gT7x198x,gT7x228x,gT7x48x,gT7x298x);hG7x228x=hG7x228x+hl7x228x*(iC6w'-'?-1:1);hG7x198x=hG7x198x+hl7x198x*(iC6w'-'?-1:1);hG7x188x=hG7x188x+hl7x188x*(iC6w'-'?-1:1);hG7x158x=hG7x158x+hl7x158x*(iC6w'-'?-1:1);e3(hG)}3y hG};9z dt(gA){3y(((gA7x158x*24+gA7x188x)*60+gA7x198x)*60+gA7x228x)*(gA7x298x?-1:1)};9z ds(fb){8y B=(fb=bd7x438x(fb))<0,fx=~~((fb=bd7x408x(fb))/86400),fB=~~((fb1vfx*3600*24)/3600),fM=~~((fb1vfB*3600)/60),f5=fb1vfM*60;3y 2y cT(fx,fB,fM,f5,B)};9z ex(gA){3y(gA7x118x*12+gA7x68x)*(gA7x298x?-1:1)};9z ew(fb){8y fQ=(fb=bd7x438x(fb))<0,gd=~~((fb=bd7x408x(fb))/12),fO=fb1vgd*12;3y 2y ct(gd,fO,fQ)};9z dv(hA){3y hA7x228x+(hA7x198x-(hA7x48x9w2x?hA7x48x%60:0)+(hA7x188x-(hA7x48x9w2x?~~(hA7x48x/60):0))*60)*60};9z dr(hG){8y gw=2y U((hG7x298x?-1:1)*hG7x118x,hG7x68x,hG7x158x,0,0,0,0);0y(hG 1y cS){gw7x4708x(hG7x188x);gw7x1958x(hG7x198x);gw7x4588x(hG7x228x)}0y(hG7x48x9w2x)gw7x1958x(gw7x1948x2w-hG7x48x);3y gw7x4578x2w/1000};fn7x2878x=9z(gT,hl){3y 2y bO(5x7x248x7x1178x(gT,hl))};fn7x2418x=9z(gT,hl){3y 2y bO(7w(5x7x248x7x628x(gT,hl)&4))};fn7x2408x=9z(gT,hl){3y 2y bO(7w(5x7x248x7x628x(gT,hl)&2))};9z dX(gT,hl){0y(dc(gT)4w(bd7x408x(gT)6wfD)4wdc(hl)4w(bd7x408x(hl)6wfD))3y 0;8y h=by(gT)7x258x(hN),m=by(hl)7x258x(hN),fW=bd7x1918x(1,(h[2]4wh[3]4w'')7x18x+(h[5]4w0)*(h[4]6w'+'?-1:1),(m[2]4wm[3]4w'')7x18x+(m[5]4w0)*(m[4]6w'+'?-1:1));3y fW+(fW%2?0:1)};fn7x1158x=9z(gT,hl){8y fG=gT7x28x2w,f1=hl7x28x2w,fW=bd7x728x(10,dX(fG,f1));3y du(gT,hl,((fG*fW)+(f1*fW))/fW)};fn7x1208x=9z(gT,hl){8y fG=gT7x28x2w,f1=hl7x28x2w,fW=bd7x728x(10,dX(fG,f1));3y du(gT,hl,((fG*fW)-(f1*fW))/fW)};fn7x898x=9z(gT,hl){8y fG=gT7x28x2w,f1=hl7x28x2w,fW=bd7x728x(10,dX(fG,f1));3y du(gT,hl,((fG*fW)*(f1*fW))/(fW*fW))};fn7x908x=9z(gT,hl){8y fG=gT7x28x2w,f1=hl7x28x2w,fW=bd7x728x(10,dX(fG,f1));3y du(gT,hl,(gT*fW)/(hl*fW))};fn7x2398x=9z(gT,hl){3y 2y c7(~~(gT/hl))};fn7x2388x=9z(gT,hl){8y fG=gT7x28x2w,f1=hl7x28x2w,fW=bd7x728x(10,dX(fG,f1));3y du(gT,hl,((fG*fW)%(f1*fW))/fW)};fn7x2428x=9z(hl){3y hl};fn7x2438x=9z(hl){hl7x78x*=-1;3y hl};fn7x1308x=9z(gT,hl){3y 2y bO(gT7x28x2w6whl7x28x2w)};fn7x998x=9z(gT,hl){3y 2y bO(gT7x28x2whl7x28x2w)};9z du(gT,hl,f0){3y 2y(gT 1y c73whl 1y c73wf06wbd7x438x(f0)?c7:cU)(f0)};fn7x2468x=9z(gT,hl){3y 2y bO(gT7x208x6whl7x208x3wgT7x178x6whl7x178x)};fn7x2458x=9z(hr,hs){3y hr7x968x(hs)};fn7x1198x=9z(hr,hs){8y hq=0w;8z(8y fC=0,fJ=hr7x18x,gN;fCfr)c7x1778x2w;7z{c7x108x(q[fC]);fr2v}}7z 0y(q[fC]9w'.')c7x108x(q[fC])}0y(q[3vfC]6w'..'4wq[fC]6w'.')c7x108x('');hF7x588x=c7x418x('/')}}3y hF});eL(_[230],0w,9z2w{3y 2y bO(3x)});eL(_[499],0w,9z2w{3y 2y bO(1x)});eL(_[496],[[cy,'*'8x,9z(hr){3y 2y bO(!d5(hr,5x))});eL(_[76],0w,9z2w{3y 2y c7(5x7x768x)});eL(_[497],0w,9z2w{3y 2y c7(5x7x948x)});eL(_[498],0w,9z2w{3y 5x7x708x});eL(_[503],0w,9z2w{3y cR7x38x(5x7x708x)});eL(_[504],0w,9z2w{3y cm7x38x(5x7x708x)});eL(_[510],0w,9z2w{3y 5x7x48x});eL(_[511],0w,9z2w{3y 2y cl(5x7x538x7x1748x)});eL(_[509],0w,9z2w{3y bM7x38x(2y cl(5x7x538x7x838x4w''))});eL(_[508],[[cW,'?'8x,9z(gA){3y d2(gA,_[11])});eL(_[505],[[cW,'?'8x,9z(gA){3y d2(gA,_[6])});eL(_[506],[[cW,'?'8x,9z(gA){3y d2(gA,_[15])});eL(_[507],[[cW,'?'8x,9z(gA){3y d2(gA,_[18])});eL(_[495],[[cW,'?'8x,9z(gA){3y d2(gA,_[19])});eL(_[494],[[cW,'?'8x,9z(gA){3y d2(gA,_[22])});eL(_[482],[[cS,'?'8x,9z(gx){3y d1(gx,_[11])});eL(_[483],[[cS,'?'8x,9z(gx){3y d1(gx,_[6])});eL(_[484],[[cS,'?'8x,9z(gx){3y d1(gx,_[15])});eL(_[481],[[cS,'?'8x,9z(gx){3y d1(gx,_[18])});eL(_[480],[[cS,'?'8x,9z(gx){3y d1(gx,_[19])});eL(_[477],[[cS,'?'8x,9z(gx){3y d1(gx,_[22])});eL(_[478],[[cS,'?'8x,9z(gx){3y d1(gx,_[4])});eL(_[479],[[cR,'?'8x,9z(gw){3y d1(gw,_[11])});eL(_[485],[[cR,'?'8x,9z(gw){3y d1(gw,_[6])});eL(_[486],[[cR,'?'8x,9z(gw){3y d1(gw,_[15])});eL(_[492],[[cR,'?'8x,9z(gw){3y d1(gw,_[4])});eL(_[493],[[cm,'?'8x,9z(hA){3y d1(hA,_[18])});eL(_[491],[[cm,'?'8x,9z(hA){3y d1(hA,_[19])});eL(_[490],[[cm,'?'8x,9z(hA){3y d1(hA,_[22])});eL(_[487],[[cm,'?'8x,9z(hA){3y d1(hA,_[4])});eL(_[488],[[cS,'?'],[cT,'?',3x8x,9z(gx,gy){3y d0(gx,4x7x18x>13wgy9w2x?4x7x18x>1?gy:5x7x48x:2x)});eL(_[489],[[cR,'?'],[cT,'?',3x8x,9z(gw,gy){3y d0(gw,4x7x18x>13wgy9w2x?4x7x18x>1?gy:5x7x48x:2x)});eL(_[512],[[cm,'?'],[cT,'?',3x8x,9z(hA,gy){3y d0(hA,4x7x18x>13wgy9w2x?4x7x18x>1?gy:5x7x48x:2x)});9z d2(gA,iz){0y(gA6w2x)3y 2x;8y fb=gA[iz]*(gA7x298x?-1:1);3y iz6w_[22]?2y cU(fb):2y c7(fb)};9z d1(gx,iz){0y(gx6w2x)3y 2x;0y(iz6w_[4]){8y f8=gx7x48x;0y(f86w2x)3y 2x;3y 2y cT(0,bd7x408x(~~(f8/60)),bd7x408x(f8%60),0,f8<0)}7z{8y fb=gx[iz];0y(!(gx 1y cR)){0y(iz6w_[18])0y(fb6w24)fb=0}0y(!(gx 1y cm))fb*=gx7x298x?-1:1;3y iz6w_[22]?2y cU(fb):2y c7(fb)}};9z d0(gx,hB){0y(gx6w2x)3y 2x;8y hG;0y(gx 1y cR)hG=2y cR(gx7x118x,gx7x68x,gx7x158x,gx7x48x,gx7x298x);7z 0y(gx 1y cm)hG=2y cm(gx7x188x,gx7x198x,gx7x228x,gx7x48x,gx7x298x);7z hG=2y cS(gx7x118x,gx7x68x,gx7x158x,gx7x188x,gx7x198x,gx7x228x,gx7x48x,gx7x298x);0y(hB6w2x)hG7x48x=2x;7z{8y f8=dt(hB)/60;0y(gx7x48x9w2x){8y fz=f8-gx7x48x;0y(gx 1y cR){0y(fz<0)hG7x158x3v}7z{hG7x198x0vfz%60;hG7x188x0v~~(fz/60)}e3(hG)}hG7x48x=f8}3y hG};eL(_[47],[[cz,'?',3x8x,9z(g0){0y(!4x7x18x){0y(!5x7x248x7x368x(5x7x268x))4y 2y X(_[9]);g0=5x7x268x}7z 0y(g06w2x)3y 2y cl('');8y j2=fm7x2258x7x218x(5x,g0);3y 2y cl(j26w2x?'':j27x318x2w)});eL(_[513],[[cz,'?',3x8x,9z(g0){0y(!4x7x18x){0y(!5x7x248x7x368x(5x7x268x))4y 2y X(_[9]);g0=5x7x268x}7z 0y(g06w2x)3y 2y cl('');3y 2y cl(5x7x248x7x288x(g0,_[20])4w'')});eL(_[537],[[cz,'?',3x8x,9z(g0){0y(!4x7x18x){0y(!5x7x248x7x368x(5x7x268x))4y 2y X(_[9]);g0=5x7x268x}7z 0y(g06w2x)3y bM7x38x(2y cl(''));3y bM7x38x(2y cl(5x7x248x7x288x(g0,_[17])4w''))});eL(_[271],[[bJ,'?',3x8x,9z(gN){0y(!4x7x18x){0y(!5x7x268x)4y 2y X(_[75]);gN=d3([5x7x268x],5x)[0]}8y j2=2y cV(fP);0y(gN9w2x){7y{j2=cV7x38x(gN)}3z(e)1w}3y j2});eL(_[538],[[cl,'?'],[cz,'',3x8x,9z(ir,g0){0y(4x7x18x<2){0y(!5x7x248x7x368x(5x7x268x))4y 2y X(_[9]);g0=5x7x268x}8y d7=5x7x248x7x288x;0y(d7(g0,_[27])6w2)g0=d7(g0,_[56]);8z(8y b;g0;g0=d7(g0,_[42]))0y(b=d7(g0,_[57]))8z(8y fC=0,fJ=b7x18x;fC1?hc7x28x2w:0;0y(fX<0){8y hb=2y c7(bd7x728x(10,-fX)),f4=bd7x438x(fn7x908x7x218x(5x,hG,hb)),hm=2y c7(f4);fy=bd7x408x(fn7x1208x7x218x(5x,hm,fn7x908x7x218x(5x,hG,hb)));3y fn7x898x7x218x(5x,fn7x1158x7x218x(5x,hm,2y cU(fy6w0.53wf4%2?-1:0)),hb)}7z{8y hb=2y c7(bd7x728x(10,fX)),f4=bd7x438x(fn7x898x7x218x(5x,hG,hb)),hm=2y c7(f4);fy=bd7x408x(fn7x1208x7x218x(5x,hm,fn7x898x7x218x(5x,hG,hb)));3y fn7x908x7x218x(5x,fn7x1158x7x218x(5x,hm,2y cU(fy6w0.53wf4%2?-1:0)),hb)}});eL(_[533],[[cl,'?'],[cx8x,9z(hf,gB){0y(hf6w2x)3y 2x;8y iF=hf7x28x2w,j=iF7x258x(i9);0y(!j)4y 2y X(_[95]);8y iE=j[1]4w2x,iu=j[2],iA=5x7x248x7x558x(gB,iE);0y(iE9w2x3w!iA)4y 2y X(_[198]);3y 2y cj(iE,iu,iA4w2x)});eL(_[147],[[cl,'?'],[cl8x,9z(hF,hf){8y iF=hf7x28x2w,j=iF7x258x(i9);0y(!j)4y 2y X(_[95]);3y 2y cj(j[1]4w2x,j[2]4w2x,hF6w2x?'':hF7x28x2w)});eL(_[534],[[cj,'?'8x,9z(hf){0y(hf9w2x){0y(hf7x308x)3y 2y ca(hf7x308x)}3y 2x});eL(_[539],[[cj,'?'8x,9z(hf){0y(hf6w2x)3y 2x;3y 2y ca(hf7x208x)});eL(_[540],[[cj,'?'8x,9z(hf){0y(hf6w2x)3y 2x;3y bM7x38x(2y cl(hf7x178x4w''))});eL(_[546],[[cl,'?'],[cx8x,9z(hd,gB){8y iE=hd6w2x?'':hd7x28x2w,iA=5x7x248x7x558x(gB,iE4w2x);3y iA6w2x?2x:bM7x38x(2y cl(iA))});eL(_[181],[[cx8x,9z(gB){4y \"Function '\"+_[181]+\"' not implemented\"});eL(_[118],[[cy,'*'8x,9z(hr){3y 2y bO(d5(hr,5x))});eL(_[547],[[bJ,'*'],[bJ],[cl,'',3x8x,9z(hr,ho,gr){0y(!hr7x18x4who6w2x)3y 0w;8y jZ=ho;0y(jZ 1y cs)jZ=cl7x38x(jZ);8y hq=0w;8z(8y fC=0,fJ=hr7x18x,j1;fCfJ)fV=fJ+1;8y hq=0w;8z(8y fC=0;fCfJ)3y hr;8y hq=0w;8z(8y fC=0;fC2?bd7x438x(gU):hr7x18x-fV+1;3y hr7x4468x(fV-1,fV-1+fJ)});eL(_[530],[[cy,'*'8x,9z(hr){3y hr});eL(_[519],[[cy,'*'8x,9z(hr){0y(hr7x18x>1)4y 2y X(_[188]);3y hr});eL(_[520],[[cy,'*'8x,9z(hr){0y(!hr7x18x)4y 2y X(_[187]);3y hr});eL(_[518],[[cy,'*'8x,9z(hr){0y(hr7x18x9w1)4y 2y X(_[184]);3y hr});eL(_[185],[[cy,'*'],[cy,'*'],[cl,'',3x8x,9z(hr,hs,gr){4y \"Function '\"+_[185]+\"' not implemented\"});eL(_[517],[[cy,'*'8x,9z(hr){3y 2y c7(hr7x18x)});eL(_[514],[[bJ,'*'8x,9z(hr){0y(!hr7x18x)3y 2x;7y{8y j2=hr[0];0y(j2 1y cs)j2=cV7x38x(j2);8z(8y fC=1,fJ=hr7x18x,j1;fC1)3y hL;7z 3y 2y cV(0);3y 2x}7y{8y j2=hr[0];0y(j2 1y cs)j2=cV7x38x(j2);8z(8y fC=1,fJ=hr7x18x,j1;fC2)ik=gr7x28x2w;jW=ik6wix+_[223]?gq:5x7x538x7x2518x(ik);0y(!jW)4y 2y X(_[222]);3y 2y c7(jW7x508x(hH7x28x2w,hI7x28x2w))});eL(_[528],[[cl,'?'],[cl,'?'8x,9z(hH,hI){0y(hH6w2x4whI6w2x)3y 2x;3y 2y bO(hH7x28x2w6whI7x28x2w)});eL(_[96],2x,9z2w{0y(4x7x18x<2)4y 2y X(_[46]);8y r=0w;8z(8y fC=0,fJ=4x7x18x,hq;fC2?f7+bd7x438x(gU):jO7x18x;3y 2y cl(fA>f7?jO7x1018x(f7,fA):'')});eL(_[527],[[cl,'?',3x8x,9z(hG){0y(!4x7x18x){0y(!5x7x268x)4y 2y X(_[75]);hG=cl7x38x(d3([5x7x268x],5x)[0])}3y 2y c7(hG6w2x?0:hG7x28x2w7x18x)});eL(_[526],[[cl,'?',3x8x,9z(hG){0y(!4x7x18x){0y(!5x7x268x)4y 2y X(_[75]);hG=cl7x38x(d3([5x7x268x],5x)[0])}3y 2y cl(hG6w2x?'':eP(hG)7x388x(/\\s\\s+/g,' '))});eL(_[272],[[cl,'?'],[cl,'',3x8x,9z(hG,h3){4y \"Function '\"+_[272]+\"' not implemented\"});eL(_[523],[[cl,'?'8x,9z(hG){3y 2y cl(hG6w2x?'':hG7x28x2w7x2648x2w)});eL(_[524],[[cl,'?'8x,9z(hG){3y 2y cl(hG6w2x?'':hG7x28x2w7x778x2w)});eL(_[525],[[cl,'?'],[cl],[cl8x,9z(hG,gY,hC){0y(hG6w2x)3y 2y cl('');8y r=hG7x28x2w7x488x(''),i=gY7x28x2w7x488x(''),p=hC7x28x2w7x488x(''),f9=p7x18x,l=0w;8z(8y fC=0,fJ=r7x18x,fV;fC126)r[fC]=6x7x2318x(r[fC]);3y 2y cl(r7x418x(''))});eL(_[428],[[cl,'?'],[cl,'?'],[cl,'',3x8x,9z(hG,ho,gr){3y 2y bO((hG6w2x?'':hG7x28x2w)7x458x(ho6w2x?'':ho7x28x2w)5v0)});eL(_[426],[[cl,'?'],[cl,'?'],[cl,'',3x8x,9z(hG,ho,gr){3y 2y bO((hG6w2x?'':hG7x28x2w)7x458x(ho6w2x?'':ho7x28x2w)6w0)});eL(_[425],[[cl,'?'],[cl,'?'],[cl,'',3x8x,9z(hG,ho,gr){8y jO=hG6w2x?'':hG7x28x2w,jK=ho6w2x?'':ho7x28x2w;3y 2y bO(jO7x458x(jK)6wjO7x18x-jK7x18x)});eL(_[422],[[cl,'?'],[cl,'?'],[cl,'',3x8x,9z(hG,ho,gr){8y jO=hG6w2x?'':hG7x28x2w,jK=ho6w2x?'':ho7x28x2w,fV;3y 2y cl((fV=jO7x458x(jK))5v0?jO7x1018x(0,fV):'')});eL(_[423],[[cl,'?'],[cl,'?'],[cl,'',3x8x,9z(hG,ho,gr){8y jO=hG6w2x?'':hG7x28x2w,jK=ho6w2x?'':ho7x28x2w,fV;3y 2y cl((fV=jO7x458x(jK))5v0?jO7x1018x(fV+jK7x18x):'')});9z d6(jO,io){8y d1='\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF',d2='\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D',d3='\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\jR\\jS-\\jT\\jU-\\jV',c='A-Z_a-z\\\\-.0-9\\u00B7'+d1+'\\u0300-\\u036F'+d2+'\\u203F-\\u2040'+d3,i='A-Z_a-z'+d1+d2+d3;jO=jO 7x388x(/\\[\\\\i-\\[:\\]\\]/g,'['+i+']')7x388x(/\\[\\\\c-\\[:\\]\\]/g,'['+c+']')7x388x(/\\\\i/g,'[:'+i+']')7x388x(/\\\\I/g,'[^:'+i+']')7x388x(/\\\\c/g,'[:'+c+']')7x388x(/\\\\C/g,'[^:'+c+']');0y(io3w!io7x258x(/^[smix]+$/))4y 2y X(_[210]);8y v=io7x458x('s')5v0,w=io7x458x('x')5v0;0y(v4ww){io=io7x388x(/[sx]/g,'');8y r=0w,hR=/\\s/;8z(8y fC=0,fJ=jO7x18x,H=1x,ih,ii='';fC2?gH7x28x2w:'');3y 2y bO(hO7x378x(jO))});eL(_[38],[[cl,'?'],[cl],[cl],[cl,'',3x8x,9z(hG,h9,hi,gH){8y jO=hG6w2x?'':hG7x28x2w,hO=d6(h97x28x2w,4x7x18x>3?gH7x28x2w:'');3y 2y bO(jO7x388x(hO,hi7x28x2w))});eL(_[424],[[cl,'?'],[cl],[cl,'',3x8x,9z(hG,h9,gH){8y jO=hG6w2x?'':hG7x28x2w,hO=d6(h97x28x2w,4x7x18x>2?gH7x28x2w:'');8y hq=0w;8z(8y fC=0,r=jO7x488x(hO),fJ=r7x18x;fCjQ?1:-1};8y M=9z2w1w;M9x7x278x=2;M9x7x618x=M9x7x868x=M9x7x608x=M9x7x208x=M9x7x178x=M9x7x308x=M9x7x578x=M9x7x1768x=M9x7x858x=M9x7x2478x=M9x7x798x=M9x7x748x=M9x7x428x=M9x7x478x=M9x7x928x=M9x7x78x=M9x7x568x=2x;9z ba2w1w;ba9x=2y T;8y gR=2y bw;ba9x7x288x=9z(g0,iz){0y(iz 0z g0)3y g0[iz];0y(iz6w_[83]){8y ie='',eE=gR7x1788x('{'+_[361]+'}'+_[281]),cl=gR7x1068x('{'+_[362]+'}'+_[104]);8z(8y h7=g0,jN;h7;h7=h77x428x)0y(h77x278x6w13w(jN=h77x4418x(_[430])))ie=eE(2y cl(jN),2y cl(ie))7x318x2w;3y ie}7z 0y(iz6w_[91]){8y o=0w;(9z(g0){8z(8y fC=0,gp;gp=g07x1768x[fC];fC2v)0y(gp7x278x6w34wgp7x278x6w4)o7x108x(gp7x1168x);7z 0y(gp7x278x6w13wgp7x858x)4x7x1038x(gp)})(g0);3y o7x418x('')}};ba9x7x628x=9z(g0,gp){0y(_[62] 0z g0)3y g07x628x(gp);0y(gp6wg0)3y 0;8y gj=2x,gk=2x,b,gi,gB,fC,fJ;0y(g07x278x6w2){gj=g0;g0=5x7x288x(gj,_[56])}0y(gp7x278x6w2){gk=gp;gp=5x7x288x(gk,_[56])}0y(gj3wgk3wg03wg06wgp){8z(fC=0,b=5x7x288x(g0,_[57]),fJ=b7x18x;fC?!>=!..!,,!>.!>,!>\"!>>\"!\"\"!>>!>>>!}}!\'\'!*)!~|!^\\!^%\\!^^!\\`\\!xpeojx!tjiu!tuofnvhsb!fvsu!mmvo!ftmbg!iujx!fmjix!sbw!zsu!idujxt!gpfqzu!xpsiu!osvufs!xfo!gpfdobutoj!gj!opjudovg!spg!ftmf!fufmfe!umvbgfe!fvojuopd!idubd!ftbd!lbfsc!oj",'',0,this,'prototype length valueOf cast timezone peek month value evaluate XPTY0004 push year XPST0003 next eof day items namespaceURI hours minutes localName call seconds builtInKind DOMAdapter match item nodeType getProperty negative prefix toString left FORG0001 primitiveKind expression isNode test replace type abs join parentNode round bindings indexOf XPST0017 name split stack compare scope operator staticContext predicates lookupNamespaceURI ownerElement attributes path occurence ownerDocument nodeName compareDocumentPosition right itemType attribute scheme code authority FORG0006 dateTime args pow getURIForPrefix nextSibling XPDY0002 position toLowerCase index previousSibling inExpr node xmlns baseURI substr firstChild nodeValue defaultFunctionNamespace schema-attribute numeric-multiply numeric-divide textContent specified schema-element size FOCA0002 concat numeric-greater-than getElementsByTagNameNS numeric-less-than XPST0051 substring satisfiesExpr callee string XPDY0050 getDataType collations parent functions descendant-or-self dataTypes axis returnExpr namespaceResolver numeric-add data isSameNode boolean union numeric-subtract getElementById query fragment child intersect ancestor ancestor-or-self thenExpr internalExpression numeric-equal quantifier applyPredicates collections add-dayTimeDuration-to-time to popVariable except condExpr pushVariable defaultElementNamespace hasOwnProperty elseExpr document-node time-less-than date-greater-than boolean-less-than QName time-greater-than root date-less-than dateTime-greater-than boolean-greater-than yearMonthDuration-greater-than dayTimeDuration-less-than dayTimeDuration-greater-than dateTime-less-than NOTATION multiply-yearMonthDuration yearMonthDuration-less-than element add-yearMonthDuration-to-date add-dayTimeDuration-to-date preceding-sibling processing-instruction add-dayTimeDuration-to-dateTime as undefined Infinity multiply-dayTimeDuration add-yearMonthDuration-to-dateTime preceding documents charAt defaultCollationName charCodeAt childNodes pop getFunction reverse text in-scope-prefixes hexBinary-equal base64Binary-equal FORG0005 deep-equal NMTOKEN_DT FORG0004 FORG0003 and or max baseName in getMinutes setMinutes XPTY0020 extend FONS0004 boolean-equal doc gYearMonth gYear hexBinary ENTITY_DT time gMonthDay gMonth float NCNAME_DT FORX0001 gDay BOOLEAN_DT ID_DT collection doc-available floor idref element-with-id LANGUAGE_DT xs2js xpath FOCH0002 /collation/codepoint FODC0001 node-name subtract-yearMonthDuration-from-date subtract-dayTimeDuration-from-date subtract-dayTimeDuration-from-time target true encodeURIComponent subtract-dates subtract-times subtract-yearMonthDuration-from-dateTime subtract-dayTimeDuration-from-dateTime min log numeric-mod numeric-integer-divide node-after node-before numeric-unary-plus numeric-unary-minus equals concatenate QName-equal lastChild subtract-dateTimes divide-dayTimeDuration-by-dayTimeDuration time-equal getCollation gYearMonth-equal gYear-equal fromCharCode date-equal duration-equal INF dateTime-equal every gMonthDay-equal gMonth-equal add-dayTimeDurations subtract-dayTimeDurations toUpperCase divide-dayTimeDuration divide-yearMonthDuration-by-yearMonthDuration divide-yearMonthDuration gDay-equal add-yearMonthDurations subtract-yearMonthDurations number normalize-unicode INT_DT comment SHORT_DT BYTE_DT LONG_DT NEGATIVEINTEGER_DT DAYTIMEDURATION_DT INTEGER_DT resolve-uri NONPOSITIVEINTEGER_DT NONNEGATIVEINTEGER_DT GMONTHDAY_DT GDAY_DT PRIMITIVE_FLOAT is-same-node FLOAT_DT PRIMITIVE_GDAY GMONTH_DT xml XPST0008 PRIMITIVE_GMONTH XPTY0019 XT_YEARMONTHDURATION_DT following following-sibling self NOTATION_DT descendant PRIMITIVE_HEXBINARY GYEARMONTH_DT PRIMITIVE_GYEARMONTH HEXBINARY_DT GYEAR_DT PRIMITIVE_NOTATION TIME_DT XPST0081 PRIMITIVE_TIME XT_UNTYPEDATOMIC_DT PRIMITIVE_STRING STRING_DT PRIMITIVE_GMONTHDAY QNAME_DT PRIMITIVE_QNAME PRIMITIVE_DURATION DURATION_DT DATE_DT anyAtomicType PRIMITIVE_BOOLEAN BASE64BINARY_DT PRIMITIVE_ANYURI ANYURI_DT ANYSIMPLETYPE_DT UNSIGNEDSHORT_DT ANYATOMICTYPE_DT PRIMITIVE_BASE64BINARY anyURI NORMALIZEDSTRING_DT TOKEN_DT duration NAME_DT UNSIGNEDBYTE_DT double base64Binary date decimal UNSIGNEDINT_DT ANYTYPE_DT PRIMITIVE_DECIMAL DECIMAL_DT documentElement apply DOUBLE_DT trim PRIMITIVE_DOUBLE POSITIVEINTEGER_DT PRIMITIVE_DATETIME PRIMITIVE_GYEAR DATETIME_DT PRIMITIVE_DATE UNSIGNEDLONG_DT XPTY0018 else some XPST0010 http://www.w3.org/XML/1998/namespace if then http://www.w3.org/2000/xmlns/ http://www.w3.org/2005/xpath-functions http://www.w3.org/2001/XMLSchema treat castable int of instance fourth for fifth long XPST0080 dayTimeDuration yearMonthDuration untypedAtomic http://www.w3.org/1999/xhtml empty-sequence negativeInteger nonPositiveInteger integer short byte NCName Name token ENTITY ID satisfies NMTOKEN language normalizedString unsignedByte third positiveInteger nonNegativeInteger second unsignedLong unsignedShort first unsignedInt return matches isNaN isFinite NaN TypeError SyntaxError Function Math Error btoa atob getTimezoneOffset getFullYear getMonth back reset parseInt message Date RegExp substring-before substring-after tokenize ends-with starts-with escape-html-uri contains trace xml:base Number Object Array Boolean String div DIV getDate getHours console getAttribute innerText decodeURI encodeURI ceil slice sort nodeFromID jQuery href createElement tagName location createElementNS document namespaces getTime setSeconds setFunction setCollation setCollection setDocument setDataType getSeconds getMilliseconds js2xs IDREF_DT DAYMONTHDURATION_DT PRECISIONDECIMAL_DT setHours DATETIMESTAMP_DT UNAVAILABLE_DT LISTOFUNION_DT LIST_DT iri-to-uri encode-for-uri seconds-from-dateTime timezone-from-dateTime year-from-date minutes-from-dateTime hours-from-dateTime year-from-dateTime month-from-dateTime day-from-dateTime month-from-date day-from-date timezone-from-time adjust-dateTime-to-timezone adjust-date-to-timezone seconds-from-time minutes-from-time timezone-from-date hours-from-time seconds-from-duration minutes-from-duration not last current-dateTime false documentURI base-uri document-uri current-date current-time months-from-duration days-from-duration hours-from-duration years-from-duration static-base-uri implicit-timezone default-collation adjust-time-to-timezone local-name avg sum id count exactly-one zero-or-one one-or-more codepoints-to-string string-to-codepoints upper-case lower-case translate normalize-space string-length codepoint-equal string-join unordered subsequence round-half-to-even resolve-QName prefix-from-QName ceiling xml:lang namespace-uri lang local-name-from-QName namespace-uri-from-QName distinct-values insert-before remove exists empty namespace-uri-for-prefix index-of nilled'.split(' '));
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-xpath",
3 | "title": "jQuery XPath plugin",
4 | "description": "jQuery plugin for querying XML and HTML documents with XPath 2.0",
5 | "version": "0.3.1",
6 | "main": "jquery.xpath.js",
7 | "homepage": "https://github.com/ilinsky/jquery-xpath",
8 | "author": {
9 | "name": "Sergey Ilinsky",
10 | "email": "sergey@ilinsky.com",
11 | "url": "http://www.ilinsky.com"
12 | },
13 | "licenses": [
14 | {
15 | "type": "MIT",
16 | "url": "https://github.com/ilinsky/jquery-xpath/blob/master/res/license/MIT-LICENSE.txt"
17 | }
18 | ],
19 | "repository": {
20 | "type": "git",
21 | "url": "https://github.com/ilinsky/jquery-xpath.git"
22 | },
23 | "bugs": {
24 | "url": "https://github.com/ilinsky/jquery-xpath/issues"
25 | },
26 | "keywords": [
27 | "jquery",
28 | "xpath",
29 | "xpath2",
30 | "jquery-plugin"
31 | ],
32 | "dependencies": {
33 | "jquery": ">=1.0.0"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/res/assemble.js:
--------------------------------------------------------------------------------
1 | (function() {
2 |
3 | var cXMLHttpRequest = window.XMLHttpRequest || function() {
4 | return new ActiveXObject("Microsoft.XMLHTTP");
5 | };
6 |
7 | // Uri utilities
8 | var hUriCache = {};
9 | function fGetUriComponents(sUri) {
10 | var aResult = hUriCache[sUri] ||(hUriCache[sUri] = sUri.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/));
11 | return [aResult[1], aResult[3], aResult[5], aResult[6], aResult[8]];
12 | };
13 |
14 | function fResolveUri(sUri, sBaseUri) {
15 | if (sUri == '' || sUri.charAt(0) == '#')
16 | return sBaseUri;
17 |
18 | var aUri = fGetUriComponents(sUri);
19 | if (aUri[0]) // scheme
20 | return sUri;
21 |
22 | var aBaseUri = fGetUriComponents(sBaseUri);
23 | aUri[0] = aBaseUri[0]; // scheme
24 |
25 | if (!aUri[1]) {
26 | // authority
27 | aUri[1] = aBaseUri[1];
28 |
29 | // path
30 | if (aUri[2].charAt(0) != '/') {
31 | var aUriSegments = aUri[2].split('/'),
32 | aBaseUriSegments = aBaseUri[2].split('/');
33 | aBaseUriSegments.pop();
34 |
35 | var nBaseUriStart = aBaseUriSegments[0] == '' ? 1 : 0;
36 | for (var nIndex = 0, nLength = aUriSegments.length; nIndex < nLength; nIndex++) {
37 | if (aUriSegments[nIndex] == '..') {
38 | if (aBaseUriSegments.length > nBaseUriStart)
39 | aBaseUriSegments.pop();
40 | else {
41 | aBaseUriSegments.push(aUriSegments[nIndex]);
42 | nBaseUriStart++;
43 | }
44 | }
45 | else
46 | if (aUriSegments[nIndex] != '.')
47 | aBaseUriSegments.push(aUriSegments[nIndex]);
48 | }
49 | if (aUriSegments[--nIndex] == '..' || aUriSegments[nIndex] == '.')
50 | aBaseUriSegments.push('');
51 | aUri[2] = aBaseUriSegments.join('/');
52 | }
53 | }
54 |
55 | var aResult = [];
56 | if (aUri[0])
57 | aResult.push(aUri[0]);
58 | if (aUri[1]) // '//'
59 | aResult.push(aUri[1]);
60 | if (aUri[2])
61 | aResult.push(aUri[2]);
62 | if (aUri[3]) // '?'
63 | aResult.push(aUri[3]);
64 | if (aUri[4]) // '#'
65 | aResult.push(aUri[4]);
66 |
67 | return aResult.join('');
68 | };
69 |
70 | function fAssemble(descriptor) {
71 | // get files list
72 | var oRequest = new cXMLHttpRequest;
73 | oRequest.open("GET", descriptor, false);
74 | oRequest.send(null);
75 |
76 | // read files
77 | var source = [];
78 | for (var n = 0, files = oRequest.responseText.split(/\n/g), file; n < files.length; n++) {
79 | if ((file = files[n].replace(/^\s+/, "").replace(/\s+$/, "")) != '' && file.substr(0, 1) != "#") {
80 | file = fResolveUri(file, descriptor);
81 | if (file.match(/.files$/))
82 | source[source.length] = fAssemble(file);
83 | else {
84 | oRequest.open("GET", file, false);
85 | oRequest.send(null);
86 | source[source.length] = oRequest.responseText;
87 | }
88 | }
89 | }
90 | return source.join("\n");
91 | };
92 |
93 | // Get baseUri
94 | var scripts = document.getElementsByTagName("script"),
95 | self = scripts[scripts.length-1],
96 | match = self.src.match(/\?path=(.+)$/);
97 |
98 | //
99 | self.parentNode.removeChild(self);
100 |
101 | // Remove self
102 | var code = fAssemble(match[1] + ".files");
103 |
104 | // Evaluate
105 | var oScript = document.getElementsByTagName("head")[0].appendChild(document.createElement("script"));
106 | oScript.type = "text/javascript";
107 | oScript.text = "" +
108 | "(function(){" +
109 | code +
110 | "})();" +
111 | "";
112 | })();
--------------------------------------------------------------------------------
/res/assemble.php:
--------------------------------------------------------------------------------
1 | ' . $sTagName . '.+\/\/<\-' . $sTagName . '/Us', "", $sInput);
32 | }
33 |
34 | function fAssemble($descriptor) {
35 | $files = file($descriptor);
36 |
37 | $output = "";
38 | for ($n = 0; $n < count($files); $n++)
39 | if (($file = trim($files[$n])) != "" && substr($file, 0, 1) != "#") {
40 | $file = fResolveUri($file, $descriptor);
41 | if (preg_match("/\.files$/", $file, $match))
42 | $source .= fAssemble($file);
43 | else
44 | $source .= join('', file($file)) . "\n";
45 | }
46 | return $source;
47 | };
48 |
49 | // Uri utilities
50 | $hUriCache = array();
51 | function fGetUriComponents($sUri) {
52 | if (!isset($hUriCache[$sUri])) {
53 | preg_match("/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/", $sUri, $match);
54 | $hUriCache[$sUri] = array($match[1], $match[3], $match[5], $match[6], $match[8]);
55 | }
56 | return $hUriCache[$sUri];
57 | };
58 |
59 | function fResolveUri($sUri, $sBaseUri) {
60 | if ($sUri == '' || substr($sUri, 0, 1) == '#')
61 | return $sBaseUri;
62 |
63 | $aUri = fGetUriComponents($sUri);
64 | if ($aUri[0]) // scheme
65 | return $sUri;
66 |
67 | $aBaseUri = fGetUriComponents($sBaseUri);
68 | $aUri[0] = $aBaseUri[0]; // scheme
69 |
70 | if (!$aUri[1]) {
71 | // authority
72 | $aUri[1] = $aBaseUri[1];
73 |
74 | // path
75 | if (substr($aUri[2], 0, 1) != '/') {
76 | $aUriSegments = explode("/", $aUri[2]);
77 | $aBaseUriSegments = explode("/", $aBaseUri[2]);
78 | array_pop($aBaseUriSegments);
79 |
80 | $nBaseUriStart = $aBaseUriSegments[0] == '' ? 1 : 0;
81 | for ($nIndex = 0, $nLength = count($aUriSegments); $nIndex < $nLength; $nIndex++) {
82 | if ($aUriSegments[$nIndex] == '..') {
83 | if ($aBaseUriSegments.length > $nBaseUriStart)
84 | array_pop($aBaseUriSegments);
85 | else {
86 | array_push($aBaseUriSegments, $aUriSegments[$nIndex]);
87 | $nBaseUriStart++;
88 | }
89 | }
90 | else
91 | if ($aUriSegments[$nIndex] != '.')
92 | array_push($aBaseUriSegments, $aUriSegments[$nIndex]);
93 | }
94 | if ($aUriSegments[--$nIndex] == '..' || $aUriSegments[$nIndex] == '.')
95 | array_push($aBaseUriSegments, '');
96 | $aUri[2] = implode($aBaseUriSegments, '/');
97 | }
98 | }
99 |
100 | $result = "";
101 | if ($aUri[0])
102 | $result .= $aUri[0];
103 | if ($aUri[1]) // '//'
104 | $result .= $aUri[1];
105 | if ($aUri[2])
106 | $result .= $aUri[2];
107 | if ($aUri[3]) // '?'
108 | $result .= $aUri[3];
109 | if ($aUri[4]) // '#'
110 | $result .= $aUri[4];
111 |
112 | return $result;
113 | };
114 | ?>
--------------------------------------------------------------------------------
/res/build/COPYING.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @project.name@ v@project.version@
3 | * https://github.com/ilinsky/jquery-xpath
4 | * Copyright 2015, Sergey Ilinsky
5 | * Dual licensed under the MIT and GPL licenses.
6 | *
7 | * Includes xpath.js - XPath 2.0 implementation in JavaScript
8 | * https://github.com/ilinsky/xpath.js
9 | * Copyright 2015, Sergey Ilinsky
10 | * Dual licensed under the MIT and GPL licenses.
11 | *
12 | */
13 |
--------------------------------------------------------------------------------
/res/build/compiler/cJSCompiler.php:
--------------------------------------------------------------------------------
1 | output = $sString;
16 | }
17 |
18 | function readFromFile($sFileName) {
19 | $this->output = $this->output . join("", file($sFileName));
20 | }
21 |
22 | function getOutput() {
23 | return $this->output;
24 | }
25 |
26 | function addOmmitArray($aOmmit) {
27 | for ($nIndex = 0; $nIndex < count($aOmmit); $nIndex++)
28 | $this->addOmmitString($aOmmit[$nIndex]);
29 | }
30 |
31 | function addOmmitString($sString) {
32 | if (!in_array($sString, $this->aStrings))
33 | array_push($this->aStrings, $sString);
34 | }
35 |
36 | function stripComments() {
37 | $sData = $this->output;
38 |
39 | // Strip '//' comments
40 | $sData = str_replace('://', '?????', $sData);
41 | $sData = preg_replace('/\/\/.*(\r?\n)/', "", $sData);
42 | $sData = str_replace('?????', '://', $sData);
43 |
44 | // Strip '/* comment */' comments
45 | $sData = preg_replace('/\/\*.+\*\//Us', "", $sData);
46 |
47 | $this->output = $sData;
48 | }
49 |
50 | function stripSpaces() {
51 | $sData = $this->output;
52 |
53 | // replace tabs with spaces
54 | $sData = str_replace(" ", " ", $sData);
55 |
56 | // Strip ' : ' spaces around
57 | $sData = preg_replace('/\s*([=\+\-\*\/\?\:\|\&\^\!<>\{\},%;\(\)])\s*/', '\\1', $sData);
58 | //
59 | $sData = preg_replace('/\s*(if|for|with|do|while|try|catch)\s+/', '\\1', $sData);
60 |
61 | // strip carriage returns
62 | $sData = preg_replace("/\r\n|\r|\n/", "", $sData);
63 | // strip all more than one spaces
64 | $sData = preg_replace("/\s\s+/", " ", $sData);
65 |
66 | // Additional tweaks
67 | $sData = str_replace(";}", "}", $sData);
68 |
69 | $this->output = $sData;
70 | }
71 |
72 | /*
73 | * Obfuscates variables (starting with any known variable prefix)
74 | *
75 | */
76 | function obfuscateVariables() {
77 | $sData = $this->output;
78 |
79 | preg_match_all('/[^a-zA-Z]([a-z][A-Z][a-zA-Z0-9_]+)/', $sData, $aTemp);
80 |
81 | $aValues = array_unique($aTemp[1]);
82 | sort($aValues);
83 | reset($aValues);
84 |
85 | // $aValues = $this->_normalizeArray($aTemp[1]);
86 |
87 | // Debug
88 | if ($this->debug)
89 | echo "Processing local variables:\n";
90 |
91 | for ($nIndex = count($aValues)-1; $nIndex >= 0; $nIndex--) {
92 | $sReplace = /*$nIndex < 26 ? chr(97 + $nIndex) :*/ $this->createToken($nIndex);
93 |
94 | $sData = str_replace($aValues[$nIndex], $sReplace, $sData);
95 | // $sData = preg_replace('/(\W)' . $aValues[$nIndex] . '(\W)/', '$1' . $sReplace . '$2', $sData);
96 |
97 | // Debug
98 | if ($this->debug)
99 | echo $aValues[$nIndex] . " [" . count(array_intersect($aTemp[1], array($aValues[$nIndex]))). "] -> " . $sReplace . "\n";
100 | }
101 | // Debug
102 | if ($this->debug)
103 | echo "\n";
104 |
105 | $this->output = $sData;
106 | }
107 |
108 | /*
109 | * Obfuscates private properties (starting with "_" prefix)
110 | *
111 | */
112 | function obfuscatePrivates() {
113 | $sData = $this->output;
114 |
115 | preg_match_all('/(\._[a-z_]+)/i', $sData, $aTemp);
116 | $aValues = array_unique($aTemp[1]);
117 | sort($aValues);
118 | reset($aValues);
119 |
120 | // Debug
121 | if ($this->debug)
122 | echo "Processing private members:\n";
123 |
124 | for ($nIndex = count($aValues)-1; $nIndex >= 0; $nIndex--) {
125 | $sReplace = "." . $this->createToken($nIndex);
126 | $sData = str_replace($aValues[$nIndex], $sReplace, $sData);
127 |
128 | // Debug
129 | if ($this->debug)
130 | echo $aValues[$nIndex] . " [" . count(array_intersect($aTemp[1], array($aValues[$nIndex]))). "] -> " . $sReplace . "\n";
131 | }
132 | // Debug
133 | if ($this->debug)
134 | echo "\n";
135 |
136 | $this->output = $sData;
137 | }
138 |
139 | function obfuscateStrings() {
140 | $sData = $this->output;
141 | $sDataTemp = $sData;
142 | if (count($this->aStrings))
143 | $sDataTemp = str_replace($this->aStrings, array_fill(0, count($this->aStrings), ""), $sDataTemp);
144 |
145 | // find "values"
146 | preg_match_all('/\"([a-z0-9_\-+\#\:\;\/\.]{2,})\"/i', $sDataTemp, $aTempValues);
147 |
148 | // find .properties
149 | preg_match_all('/\.(\$?[a-z][a-z0-9_]{2,})/i', $sDataTemp, $aTempProperties);
150 | /*
151 | $this->aStrings = array_unique(array_merge($this->aStrings, $aTempValues[1], $aTempProperties[1]));
152 | sort($this->aStrings);
153 | reset($this->aStrings);
154 | */
155 | $this->aStrings = $this->_normalizeArray(array_merge($this->aStrings, $aTempValues[1], $aTempProperties[1]));
156 |
157 | // Debug
158 | if ($this->debug)
159 | echo "Processing public properties and string values:\n";
160 |
161 | // manually replace most used property "prototype"
162 | $sData = str_replace(".prototype", "[$]", $sData);
163 |
164 | // Strings
165 | for ($nIndex = count($this->aStrings)-1; $nIndex >= 0; $nIndex--)
166 | $sData = str_replace( '"' . $this->aStrings[$nIndex] . '"', "_[" . $nIndex . ']', $sData);
167 |
168 | // Properties
169 | for ($nIndex = count($this->aStrings)-1; $nIndex >= 0; $nIndex--) {
170 | /*
171 | $sData = str_replace( '.' . $this->aStrings[$nIndex], "[_[" . $nIndex . ']]', $sData);
172 | */
173 | $sData = preg_replace( '/\.' .
174 | str_replace(
175 | array('/', '.', '$'),
176 | array('\/', '\.', '\$'),
177 | $this->aStrings[$nIndex]
178 | ). '(?!\w)/', "[_[" . $nIndex . ']]', $sData);
179 |
180 | // Debug
181 | if ($this->debug)
182 | echo $this->aStrings[$nIndex] . " [" . count(array_intersect(array_merge($aTempValues[1], $aTempProperties[1]), array($this->aStrings[$nIndex]))). "]\n";
183 | }
184 |
185 | // Debug
186 | if ($this->debug)
187 | echo "\n";
188 |
189 | $this->output = $sData;
190 | }
191 |
192 | function obfuscate() {
193 | // get or create obfuscated properties
194 | $nWString = array_search("String", $this->aStrings);
195 | if (!$nWString)
196 | $nWString = array_push($this->aStrings, "String") - 1;
197 | $nWMath = array_search("Math", $this->aStrings);
198 | if (!$nWMath)
199 | $nWMath = array_push($this->aStrings, "Math") - 1;
200 | $nWRegExp = array_search("RegExp", $this->aStrings);
201 | if (!$nWRegExp)
202 | $nWRegExp = array_push($this->aStrings, "RegExp") - 1;
203 | $nWFunction = array_search("Function", $this->aStrings);
204 | if (!$nWFunction)
205 | $nWFunction = array_push($this->aStrings, "Function") - 1;
206 | $nWlength = array_search("length", $this->aStrings);
207 | if (!$nWlength)
208 | $nWlength = array_push($this->aStrings, "length") - 1;
209 | $nWreplace = array_search("replace", $this->aStrings);
210 | if (!$nWreplace)
211 | $nWreplace = array_push($this->aStrings, "replace") - 1;
212 | $nWsplit = array_search("split", $this->aStrings);
213 | if (!$nWsplit)
214 | $nWsplit = array_push($this->aStrings, "split") - 1;
215 | $nWfromCharCode = array_search("fromCharCode", $this->aStrings);
216 | if (!$nWfromCharCode)
217 | $nWfromCharCode = array_push($this->aStrings, "fromCharCode") - 1;
218 | $nWcharCodeAt = array_search("charCodeAt", $this->aStrings);
219 | if (!$nWcharCodeAt)
220 | $nWcharCodeAt = array_push($this->aStrings, "charCodeAt") - 1;
221 | $nWfloor = array_search("floor", $this->aStrings);
222 | if (!$nWfloor)
223 | $nWfloor = array_push($this->aStrings, "floor") - 1;
224 |
225 | $output = $this->output;
226 | $sKeyWords = "";
227 | $nShift = 1;
228 |
229 | if (true) {
230 | $aKeyWords = array();
231 | $aKeyWords = array_merge($aKeyWords, array("in", "break", "case", "catch", "continue", "default", "delete", "else", "for", "function", "if", "instanceof", "new", "return", "throw", "typeof", "switch", "try", "var", "while", "with"));
232 | $aKeyWords = array_merge($aKeyWords, array("false", "null", "true"));
233 | $aKeyWords = array_merge($aKeyWords, array("arguments", "this", "window"));
234 | $aKeyWords = array_merge($aKeyWords, array("[_[", "]]", "[$]"));
235 | $aKeyWords = array_merge($aKeyWords, array("[]", "{}", "()", "&&", "||", "===", "==", "!!", "!==", "!=", "+=", "-=", "++", "--", "<=", ">="));
236 |
237 | // replace js keywords
238 | for ($nIndex = count($aKeyWords) - 1; $nIndex >= 0; $nIndex--)
239 | $output = str_replace($aKeyWords[$nIndex], ($nIndex % 10) . chr(122 - floor($nIndex/10)), $output);
240 |
241 | // encode keywords
242 | $sKeyWords = join(" ", $aKeyWords);
243 | $sKeyWords2 = "";
244 | for ($nIndex = strlen($sKeyWords) - 1; $nIndex >= 0; $nIndex--)
245 | $sKeyWords2 .= chr(ord(substr($sKeyWords, $nIndex, 1)) + $nShift);
246 | $sKeyWords = $sKeyWords2;
247 | }
248 |
249 | $m = $this->keyword[0];
250 | $u = $this->keyword[1];
251 | $n = $this->keyword[2];
252 | $g = $this->keyword[3];
253 | $e = $this->keyword[4];
254 | $d = $this->keyword[5];
255 |
256 | // create JS wrapper
257 | $sData = "(function({$m},{$u},{$n},{$g},{$e},{$d}){";
258 | if (true) {
259 | // decode js keywords
260 | $sData.= "for({$g}={$u}[{$d}[$nWlength]]-1;{$g}>=0;{$g}--)".
261 | "{$n}+={$e}[{$d}[$nWString]][{$d}[$nWfromCharCode]]({$u}[{$d}[$nWcharCodeAt]]({$g})-$nShift);";
262 | // restore js source
263 | $sData.= "{$u}={$n}[{$d}[$nWsplit]](' ');".
264 | "for({$g}={$u}[{$d}[$nWlength]]-1;{$g}>=0;{$g}--)".
265 | "{$m}={$m}[{$d}[$nWreplace]]({$e}[{$d}[$nWRegExp]]({$g}%10+({$e}[{$d}[$nWString]][{$d}[$nWfromCharCode]](122-{$e}[{$d}[$nWMath]][{$d}[$nWfloor]]({$g}/10))),'g'),{$u}[{$g}]);";
266 | }
267 |
268 | // execute source
269 | $sData .= "{$e}[{$d}[$nWFunction]]('_','$',{$m})({$d},{$d}[" . array_search("prototype", $this->aStrings) . "])";
270 |
271 | $sData .= "})(".
272 | "\"" . str_replace("\'", "'", addslashes($output)) . "\"," .
273 | "\"" . addslashes($sKeyWords) ."\",".
274 | "''," .
275 | "0," .
276 | "this,".
277 | "'" . join(" ", $this->aStrings) . "'.split(' ')".
278 | ");";
279 |
280 | $this->output = $sData;
281 | }
282 |
283 | function obfuscate2() {
284 | $output = $this->output;
285 |
286 | // Restore prototype to proper reference
287 | // $output = str_replace("[$]", "[_[0]]", $output);
288 |
289 | $sData = "(function($,_,_\$){"
290 | . str_replace("window", "_\$", $output)
291 | . "})('prototype','" . join(" ", $this->aStrings) . "'.split(' '),window)";
292 |
293 | $this->output = $sData;
294 | }
295 |
296 | function _normalizeArray($aTemp) {
297 | $aValuesTemp = array();
298 | for ($nIndex = count($aTemp) - 1; $nIndex >= 0; $nIndex--) {
299 | if (array_key_exists($aTemp[$nIndex], $aValuesTemp))
300 | $aValuesTemp[$aTemp[$nIndex]]++;
301 | else
302 | $aValuesTemp[$aTemp[$nIndex]] = 1;
303 | }
304 | arsort($aValuesTemp);
305 | // print_r($aValuesTemp);
306 | $aValues = array_keys($aValuesTemp);
307 | return $aValues;
308 | }
309 |
310 | var $reservedTokens = array("as", "do", "if", "in", "is", "for"/*, "let"*/, "var");
311 | var $alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
312 |
313 | function createToken($nIndex) {
314 | $sToken = $nIndex < 52
315 | ? substr($this->alphabet, $nIndex, 1)
316 | : substr($this->alphabet, (int) ($nIndex / 52), 1) . substr($this->alphabet, $nIndex % 62, 1);
317 | $nPosition = array_search($sToken, $this->reservedTokens);
318 |
319 | return $nPosition ? "_" . chr(97 + $nPosition % 62) : $sToken;
320 | }
321 | }
322 | ?>
--------------------------------------------------------------------------------
/res/build/compiler/js.php:
--------------------------------------------------------------------------------
1 | ' . $sTagName . '.+\/\/<\-' . $sTagName . '/Us', "", $sInput);
8 | }
9 |
10 | $sInputFile = $_SERVER["argv"][1];
11 | $sOutputFile = $_SERVER["argv"][2];
12 |
13 | $sInput = join('', file($sInputFile));
14 | $sOutput = $sInput;
15 |
16 | echo "Reading: " . $sInputFile . "\n";
17 |
18 | // Strip "Source" version tags
19 | if (in_array("--strip-Source", $_SERVER["argv"])) {
20 | echo "Stripping 'Source' code\n";
21 | $sOutput = fStripTags($sOutput, "Source");
22 | }
23 | // Strip "Debug" version tags
24 | if (in_array("--strip-Debug", $_SERVER["argv"])) {
25 | echo "Stripping 'Debug' code\n";
26 | $sOutput = fStripTags($sOutput, "Debug");
27 | }
28 | // Strip "Guard" version tags
29 | if (in_array("--strip-Guard", $_SERVER["argv"])) {
30 | echo "Stripping 'Guard' code\n";
31 | $sOutput = fStripTags($sOutput, "Guard");
32 | }
33 |
34 | if (in_array("--obfuscate", $_SERVER["argv"])) {
35 |
36 | $oCompiler = new cJSCompiler;
37 | $oCompiler->keyword = "packed";
38 | $oCompiler->readFromString($sOutput);
39 |
40 | echo "Obfuscating contents\n";
41 |
42 | $oCompiler->addOmmitArray(array(
43 | "http://www.w3.org/1999/xhtml",
44 | "http://www.w3.org/2001/XMLSchema",
45 | "http://www.w3.org/2005/xpath-functions",
46 | "http://www.w3.org/2000/xmlns/",
47 | "http://www.w3.org/XML/1998/namespace"
48 | ));
49 |
50 | //
51 | $oCompiler->stripComments();
52 | $oCompiler->stripSpaces();
53 |
54 | $oCompiler->obfuscateStrings();
55 | $oCompiler->obfuscateVariables();
56 | $oCompiler->obfuscatePrivates();
57 | $oCompiler->obfuscate();
58 |
59 | $sOutput = $oCompiler->getOutput();
60 | }
61 | else {
62 | echo "Wrapping contents\n";
63 |
64 | $oCompiler = new cJSCompiler;
65 | $oCompiler->readFromString($sOutput);
66 | $oCompiler->stripComments();
67 | $sOutput = $oCompiler->output;
68 |
69 | $sOutput = "".
70 | "(function () {\n" .
71 | $sOutput . "\n" .
72 | "})();" .
73 | "";
74 | }
75 |
76 | echo "Writing: " . $sOutputFile ."\n";
77 |
78 | $fOutputFile = fopen($sOutputFile, "w+");
79 | fwrite($fOutputFile, $sOutput);
80 | fclose($fOutputFile);
81 | ?>
--------------------------------------------------------------------------------
/res/license/GPL-LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/res/license/MIT-LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Sergey Ilinsky
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the "Software"), to deal in the Software without
6 | restriction, including without limitation the rights to use,
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following
10 | conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/src/.files:
--------------------------------------------------------------------------------
1 | # XPath 2 engine
2 | ../../xpath.js/src/.files
3 | # Browser adapters
4 | adapters/classes/Attr.js
5 | adapters/classes/LXDOMAdapter.js
6 | adapters/L2DOMAdapter.js
7 | adapters/L2HTMLDOMAdapter.js
8 | adapters/MSHTMLDOMAdapter.js
9 | adapters/MSXMLDOMAdapter.js
10 | # API implementation
11 | jquery-xpath.js
--------------------------------------------------------------------------------
/src/.htaccess:
--------------------------------------------------------------------------------
1 | ## Rewrite engine
2 | RewriteEngine on
3 |
4 | ##
5 | RewriteRule jquery.xpath.js ../res/assemble.php?path=../src/
--------------------------------------------------------------------------------
/src/adapters/L2DOMAdapter.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery XPath plugin (with full XPath 2.0 language support)
3 | *
4 | * Copyright (c) 2013 Sergey Ilinsky
5 | * Dual licensed under the MIT and GPL licenses.
6 | *
7 | *
8 | */
9 |
10 | var oL2DOMAdapter = new cLXDOMAdapter;
11 |
12 |
--------------------------------------------------------------------------------
/src/adapters/L2HTMLDOMAdapter.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery XPath plugin (with full XPath 2.0 language support)
3 | *
4 | * Copyright (c) 2013 Sergey Ilinsky
5 | * Dual licensed under the MIT and GPL licenses.
6 | *
7 | *
8 | */
9 |
10 | var oL2HTMLDOMAdapter = new cLXDOMAdapter;
11 |
12 | //
13 | oL2HTMLDOMAdapter.getProperty = function(oNode, sName) {
14 | if (sName == "localName") {
15 | if (oNode.nodeType == 1)
16 | return oNode.localName.toLowerCase();
17 | }
18 | if (sName == "namespaceURI")
19 | return oNode.nodeType == 1 ? "http://www.w3.org/1999/xhtml" : null;
20 | //
21 | return cLXDOMAdapter.prototype.getProperty.call(this, oNode, sName);
22 | };
--------------------------------------------------------------------------------
/src/adapters/MSHTMLDOMAdapter.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery XPath plugin (with full XPath 2.0 language support)
3 | *
4 | * Copyright (c) 2013 Sergey Ilinsky
5 | * Dual licensed under the MIT and GPL licenses.
6 | *
7 | *
8 | */
9 |
10 | var oMSHTMLDOMAdapter = new cLXDOMAdapter;
11 |
12 | //
13 | oMSHTMLDOMAdapter.getProperty = function(oNode, sName) {
14 | if (sName == "localName") {
15 | if (oNode.nodeType == 1)
16 | return oNode.nodeName.toLowerCase();
17 | }
18 | if (sName == "prefix")
19 | return null;
20 | if (sName == "namespaceURI")
21 | return oNode.nodeType == 1 ? "http://www.w3.org/1999/xhtml" : null;
22 | if (sName == "textContent")
23 | return oNode.innerText;
24 | if (sName == "attributes" && oNode.nodeType == 1) {
25 | var aAttributes = [];
26 | for (var nIndex = 0, oAttributes = oNode.attributes, nLength = oAttributes.length, oNode2, oAttribute; nIndex < nLength; nIndex++) {
27 | oNode2 = oAttributes[nIndex];
28 | if (oNode2.specified) {
29 | oAttribute = new cAttr;
30 | oAttribute.ownerElement = oNode;
31 | oAttribute.ownerDocument= oNode.ownerDocument;
32 | oAttribute.specified = true;
33 | oAttribute.value =
34 | oAttribute.nodeValue = oNode2.nodeValue;
35 | oAttribute.name =
36 | oAttribute.nodeName =
37 | //
38 | oAttribute.localName = oNode2.nodeName.toLowerCase();
39 | //
40 | aAttributes[aAttributes.length] = oAttribute;
41 | }
42 | }
43 | return aAttributes;
44 | }
45 | //
46 | return cLXDOMAdapter.prototype.getProperty.call(this, oNode, sName);
47 | };
48 |
--------------------------------------------------------------------------------
/src/adapters/MSXMLDOMAdapter.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery XPath plugin (with full XPath 2.0 language support)
3 | *
4 | * Copyright (c) 2013 Sergey Ilinsky
5 | * Dual licensed under the MIT and GPL licenses.
6 | *
7 | *
8 | */
9 |
10 | var oMSXMLDOMAdapter = new cLXDOMAdapter;
11 |
12 | //
13 | oMSXMLDOMAdapter.getProperty = function(oNode, sName) {
14 | if (sName == "localName") {
15 | if (oNode.nodeType == 7)
16 | return null;
17 | if (oNode.nodeType == 1)
18 | return oNode.baseName;
19 | }
20 | if (sName == "prefix" || sName == "namespaceURI")
21 | return oNode[sName] || null;
22 | if (sName == "textContent")
23 | return oNode.text;
24 | if (sName == "attributes" && oNode.nodeType == 1) {
25 | var aAttributes = [];
26 | for (var nIndex = 0, oAttributes = oNode.attributes, nLength = oAttributes.length, oNode2, oAttribute; nIndex < nLength; nIndex++) {
27 | oNode2 = oAttributes[nIndex];
28 | if (oNode2.specified) {
29 | oAttribute = new cAttr;
30 | oAttribute.nodeType = 2;
31 | oAttribute.ownerElement = oNode;
32 | oAttribute.ownerDocument= oNode.ownerDocument;
33 | oAttribute.specified = true;
34 | oAttribute.value =
35 | oAttribute.nodeValue = oNode2.nodeValue;
36 | oAttribute.name =
37 | oAttribute.nodeName = oNode2.nodeName;
38 | //
39 | oAttribute.localName = oNode2.baseName;
40 | oAttribute.prefix = oNode2.prefix || null;
41 | oAttribute.namespaceURI = oNode2.namespaceURI || null;
42 | //
43 | aAttributes[aAttributes.length] = oAttribute;
44 | }
45 | }
46 | return aAttributes;
47 | }
48 | //
49 | return cLXDOMAdapter.prototype.getProperty.call(this, oNode, sName);
50 | };
51 |
52 | // Document object members
53 | oMSXMLDOMAdapter.getElementById = function(oDocument, sId) {
54 | return oDocument.nodeFromID(sId);
55 | };
56 |
57 | /*oMSXMLDOMAdapter.getElementById = function(oNode, sId) {
58 | return oNode.selectSingleNode('/' + '/' + '*[@id="' + sId + '"]');
59 | };*/
60 |
--------------------------------------------------------------------------------
/src/adapters/classes/Attr.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery XPath plugin (with full XPath 2.0 language support)
3 | *
4 | * Copyright (c) 2013 Sergey Ilinsky
5 | * Dual licensed under the MIT and GPL licenses.
6 | *
7 | *
8 | */
9 |
10 | var cAttr = function() {
11 |
12 | };
13 |
14 | // Node
15 | cAttr.prototype.nodeType = 2;
16 | cAttr.prototype.nodeName =
17 | cAttr.prototype.nodeValue =
18 | cAttr.prototype.ownerDocument =
19 | cAttr.prototype.localName =
20 | cAttr.prototype.namespaceURI =
21 | cAttr.prototype.prefix =
22 | cAttr.prototype.attributes =
23 | cAttr.prototype.childNodes =
24 | cAttr.prototype.firstChild =
25 | cAttr.prototype.lastChild =
26 | cAttr.prototype.previousSibling =
27 | cAttr.prototype.nextSibling =
28 | cAttr.prototype.parentNode =
29 |
30 | // Attr
31 | cAttr.prototype.name =
32 | cAttr.prototype.specified =
33 | cAttr.prototype.value =
34 | cAttr.prototype.ownerElement = null;
35 |
--------------------------------------------------------------------------------
/src/adapters/classes/LXDOMAdapter.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery XPath plugin (with full XPath 2.0 language support)
3 | *
4 | * Copyright (c) 2013 Sergey Ilinsky
5 | * Dual licensed under the MIT and GPL licenses.
6 | *
7 | *
8 | */
9 |
10 | function cLXDOMAdapter() {
11 |
12 | };
13 |
14 | cLXDOMAdapter.prototype = new cDOMAdapter;
15 |
16 | // Create default static context object to enable access implementation functions
17 | var oLXDOMAdapter_staticContext = new cStaticContext;
18 |
19 | // Standard members
20 | cLXDOMAdapter.prototype.getProperty = function(oNode, sName) {
21 | // Run native if there is one
22 | if (sName in oNode)
23 | return oNode[sName];
24 |
25 | // Otherwise run JS fallback
26 | if (sName == "baseURI") {
27 | var sBaseURI = '',
28 | fResolveUri = oLXDOMAdapter_staticContext.getFunction('{' + "http://www.w3.org/2005/xpath-functions" + '}' + "resolve-uri"),
29 | cXSString = oLXDOMAdapter_staticContext.getDataType('{' + "http://www.w3.org/2001/XMLSchema" + '}' + "string");
30 |
31 | for (var oParent = oNode, sUri; oParent; oParent = oParent.parentNode)
32 | if (oParent.nodeType == 1 /* cNode.ELEMENT_NODE */ && (sUri = oParent.getAttribute("xml:base")))
33 | sBaseURI = fResolveUri(new cXSString(sUri), new cXSString(sBaseURI)).toString();
34 | //
35 | return sBaseURI;
36 | }
37 | else
38 | if (sName == "textContent") {
39 | var aText = [];
40 | (function(oNode) {
41 | for (var nIndex = 0, oChild; oChild = oNode.childNodes[nIndex]; nIndex++)
42 | if (oChild.nodeType == 3 /* cNode.TEXT_NODE */ || oChild.nodeType == 4 /* cNode.CDATA_SECTION_NODE */)
43 | aText.push(oChild.data);
44 | else
45 | if (oChild.nodeType == 1 /* cNode.ELEMENT_NODE */ && oChild.firstChild)
46 | arguments.callee(oChild);
47 | })(oNode);
48 | return aText.join('');
49 | }
50 | };
51 |
52 | cLXDOMAdapter.prototype.compareDocumentPosition = function(oNode, oChild) {
53 | // Run native if there is one
54 | if ("compareDocumentPosition" in oNode)
55 | return oNode.compareDocumentPosition(oChild);
56 |
57 | // Otherwise run JS fallback
58 | if (oChild == oNode)
59 | return 0;
60 |
61 | //
62 | var oAttr1 = null,
63 | oAttr2 = null,
64 | aAttributes,
65 | oAttr, oElement, nIndex, nLength;
66 | if (oNode.nodeType == 2 /* cNode.ATTRIBUTE_NODE */) {
67 | oAttr1 = oNode;
68 | oNode = this.getProperty(oAttr1, "ownerElement");
69 | }
70 | if (oChild.nodeType == 2 /* cNode.ATTRIBUTE_NODE */) {
71 | oAttr2 = oChild;
72 | oChild = this.getProperty(oAttr2, "ownerElement");
73 | }
74 |
75 | // Compare attributes from same element
76 | if (oAttr1 && oAttr2 && oNode && oNode == oChild) {
77 | for (nIndex = 0, aAttributes = this.getProperty(oNode, "attributes"), nLength = aAttributes.length; nIndex < nLength; nIndex++) {
78 | oAttr = aAttributes[nIndex];
79 | if (oAttr == oAttr1)
80 | return 32 /* cNode.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC */ | 4 /* cNode.DOCUMENT_POSITION_FOLLOWING */;
81 | if (oAttr == oAttr2)
82 | return 32 /* cNode.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC */ | 2 /* cNode.DOCUMENT_POSITION_PRECEDING */;
83 | }
84 | }
85 |
86 | //
87 | var aChain1 = [], nLength1, oNode1,
88 | aChain2 = [], nLength2, oNode2;
89 | //
90 | if (oAttr1)
91 | aChain1.push(oAttr1);
92 | for (oElement = oNode; oElement; oElement = oElement.parentNode)
93 | aChain1.push(oElement);
94 | if (oAttr2)
95 | aChain2.push(oAttr2);
96 | for (oElement = oChild; oElement; oElement = oElement.parentNode)
97 | aChain2.push(oElement);
98 | // If nodes are from different documents or if they do not have common top, they are disconnected
99 | if (((oNode.ownerDocument || oNode) != (oChild.ownerDocument || oChild)) || (aChain1[aChain1.length - 1] != aChain2[aChain2.length - 1]))
100 | return 32 /* cNode.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC */ | 1 /* cNode.DOCUMENT_POSITION_DISCONNECTED */;
101 | //
102 | for (nIndex = cMath.min(nLength1 = aChain1.length, nLength2 = aChain2.length); nIndex; --nIndex)
103 | if ((oNode1 = aChain1[--nLength1]) != (oNode2 = aChain2[--nLength2])) {
104 | //
105 | if (oNode1.nodeType == 2 /* cNode.ATTRIBUTE_NODE */)
106 | return 4 /* cNode.DOCUMENT_POSITION_FOLLOWING */;
107 | if (oNode2.nodeType == 2 /* cNode.ATTRIBUTE_NODE */)
108 | return 2 /* cNode.DOCUMENT_POSITION_PRECEDING */;
109 | //
110 | if (!oNode2.nextSibling)
111 | return 4 /* cNode.DOCUMENT_POSITION_FOLLOWING */;
112 | if (!oNode1.nextSibling)
113 | return 2 /* cNode.DOCUMENT_POSITION_PRECEDING */;
114 | for (oElement = oNode2.previousSibling; oElement; oElement = oElement.previousSibling)
115 | if (oElement == oNode1)
116 | return 4 /* cNode.DOCUMENT_POSITION_FOLLOWING */;
117 | return 2 /* cNode.DOCUMENT_POSITION_PRECEDING */;
118 | }
119 | //
120 | return nLength1 < nLength2 ? 4 /* cNode.DOCUMENT_POSITION_FOLLOWING */ | 16 /* cNode.DOCUMENT_POSITION_CONTAINED_BY */ : 2 /* cNode.DOCUMENT_POSITION_PRECEDING */ | 8 /* cNode.DOCUMENT_POSITION_CONTAINS */;
121 | };
122 |
123 | cLXDOMAdapter.prototype.lookupNamespaceURI = function(oNode, sPrefix) {
124 | // Run native if there is one
125 | if ("lookupNamespaceURI" in oNode)
126 | return oNode.lookupNamespaceURI(sPrefix);
127 |
128 | // Otherwise run JS fallback
129 | for (; oNode && oNode.nodeType != 9 /* cNode.DOCUMENT_NODE */ ; oNode = oNode.parentNode)
130 | if (sPrefix == this.getProperty(oChild, "prefix"))
131 | return this.getProperty(oNode, "namespaceURI");
132 | else
133 | if (oNode.nodeType == 1) // cNode.ELEMENT_NODE
134 | for (var oAttributes = this.getProperty(oNode, "attributes"), nIndex = 0, nLength = oAttributes.length, sName = "xmlns" + ':' + sPrefix; nIndex < nLength; nIndex++)
135 | if (this.getProperty(oAttributes[nIndex], "nodeName") == sName)
136 | return this.getProperty(oAttributes[nIndex], "value");
137 | return null;
138 | };
139 |
140 | // Element/Document object members
141 | cLXDOMAdapter.prototype.getElementsByTagNameNS = function(oNode, sNameSpaceURI, sLocalName) {
142 | // Run native if there is one
143 | if ("getElementsByTagNameNS" in oNode)
144 | return oNode.getElementsByTagNameNS(sNameSpaceURI, sLocalName);
145 |
146 | // Otherwise run JS fallback
147 | var aElements = [],
148 | bNameSpaceURI = '*' == sNameSpaceURI,
149 | bLocalName = '*' == sLocalName;
150 | (function(oNode) {
151 | for (var nIndex = 0, oChild; oChild = oNode.childNodes[nIndex]; nIndex++)
152 | if (oChild.nodeType == 1) { // cNode.ELEMENT_NODE
153 | if ((bLocalName || sLocalName == this.getProperty(oChild, "localName")) && (bNameSpaceURI || sNameSpaceURI == this.getProperty(oChild, "namespaceURI")))
154 | aElements[aElements.length] = oChild;
155 | if (oChild.firstChild)
156 | arguments.callee(oChild);
157 | }
158 | })(oNode);
159 | return aElements;
160 | };
--------------------------------------------------------------------------------
/src/jquery-xpath.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery XPath plugin (with full XPath 2.0 language support)
3 | *
4 | * Copyright (c) 2013 Sergey Ilinsky
5 | * Dual licensed under the MIT and GPL licenses.
6 | *
7 | *
8 | */
9 |
10 | var cQuery = window.jQuery,
11 | oDocument = window.document,
12 | // Internet Explorer 8 or older
13 | bOldMS = !!oDocument.namespaces && !oDocument.createElementNS,
14 | // Older other browsers
15 | bOldW3 = !bOldMS && oDocument.documentElement.namespaceURI != "http://www.w3.org/1999/xhtml";
16 |
17 | // Create two separate HTML and XML contexts
18 | var oHTMLStaticContext = new cStaticContext,
19 | oXMLStaticContext = new cStaticContext;
20 |
21 | // Initialize HTML context (this has default xhtml namespace)
22 | oHTMLStaticContext.baseURI = oDocument.location.href;
23 | oHTMLStaticContext.defaultFunctionNamespace = "http://www.w3.org/2005/xpath-functions";
24 | oHTMLStaticContext.defaultElementNamespace = "http://www.w3.org/1999/xhtml";
25 |
26 | // Initialize XML context (this has default element null namespace)
27 | oXMLStaticContext.defaultFunctionNamespace = oHTMLStaticContext.defaultFunctionNamespace;
28 |
29 | //
30 | function fXPath_evaluate(oQuery, sExpression, fNSResolver) {
31 | // Return empty jQuery object if expression missing
32 | if (typeof sExpression == "undefined" || sExpression === null)
33 | sExpression = '';
34 |
35 | // Check if context specified
36 | var oNode = oQuery[0];
37 | if (typeof oNode == "undefined")
38 | oNode = null;
39 |
40 | // Choose static context
41 | var oStaticContext = oNode && (oNode.nodeType == 9 ? oNode : oNode.ownerDocument).createElement("div").tagName == "DIV" ? oHTMLStaticContext : oXMLStaticContext;
42 |
43 | // Set static context's resolver
44 | oStaticContext.namespaceResolver = fNSResolver;
45 |
46 | // Create expression tree
47 | var oExpression = new cExpression(cString(sExpression), oStaticContext);
48 |
49 | // Reset static context's resolver
50 | oStaticContext.namespaceResolver = null;
51 |
52 | // Evaluate expression
53 | var aSequence,
54 | oSequence = new cQuery,
55 | oAdapter = oL2DOMAdapter;
56 |
57 | // Determine which DOMAdapter to use based on browser and DOM type
58 | if (bOldMS)
59 | oAdapter = oStaticContext == oHTMLStaticContext ? oMSHTMLDOMAdapter : oMSXMLDOMAdapter;
60 | else
61 | if (bOldW3 && oStaticContext == oHTMLStaticContext)
62 | oAdapter = oL2HTMLDOMAdapter;
63 |
64 | // Evaluate expression tree
65 | aSequence = oExpression.evaluate(new cDynamicContext(oStaticContext, oNode, null, oAdapter));
66 | for (var nIndex = 0, nLength = aSequence.length, oItem; nIndex < nLength; nIndex++)
67 | oSequence.push(oAdapter.isNode(oItem = aSequence[nIndex]) ? oItem : cStaticContext.xs2js(oItem));
68 |
69 | return oSequence;
70 | };
71 |
72 | // Extend jQuery
73 | var oObject = {};
74 | oObject.xpath = function(oQuery, sExpression, fNSResolver) {
75 | return fXPath_evaluate(oQuery instanceof cQuery ? oQuery : new cQuery(oQuery), sExpression, fNSResolver);
76 | };
77 | cQuery.extend(cQuery, oObject);
78 |
79 | oObject = {};
80 | oObject.xpath = function(sExpression, fNSResolver) {
81 | return fXPath_evaluate(this, sExpression, fNSResolver);
82 | };
83 | cQuery.extend(cQuery.prototype, oObject);
84 |
--------------------------------------------------------------------------------
/src/jquery.xpath.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery XPath plugin (with full XPath 2.0 language support)
3 | *
4 | * Copyright (c) 2013 Sergey Ilinsky
5 | * Dual licensed under the MIT and GPL licenses.
6 | *
7 | *
8 | */
9 |
10 | // Source code loader
11 | (function() {
12 | // Get base folder
13 | var scripts = document.getElementsByTagName("script"),
14 | self = scripts[scripts.length-1],
15 | base = self.src.replace(/\/?[^\/]+$/, '/');
16 | // Remove self
17 | self.parentNode.removeChild(self);
18 | // Include loader
19 | document.write('');
20 | })();
21 |
--------------------------------------------------------------------------------
/test/lib/jquery.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * jQuery JavaScript Library v1.4.2
3 | * http://jquery.com/
4 | *
5 | * Copyright 2010, John Resig
6 | * Dual licensed under the MIT or GPL Version 2 licenses.
7 | * http://jquery.org/license
8 | *
9 | * Includes Sizzle.js
10 | * http://sizzlejs.com/
11 | * Copyright 2010, The Dojo Foundation
12 | * Released under the MIT, BSD, and GPL Licenses.
13 | *
14 | * Date: Sat Feb 13 22:33:48 2010 -0500
15 | */
16 | (function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/,
21 | Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&&
22 | (d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this,
23 | a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b===
24 | "find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,
25 | function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b