Skip to content

Instantly share code, notes, and snippets.

@foolip
Last active August 29, 2015 14:23
Show Gist options
  • Save foolip/99798dfe9c5587ea7b8b to your computer and use it in GitHub Desktop.
Save foolip/99798dfe9c5587ea7b8b to your computer and use it in GitHub Desktop.
Matches for DOMError in 20150101 httparchive data
Location: http://www.programma.tv/3.001/b/ample-0.9.5.a.2011.10.09.js
Referrer: http://www.programma.tv/
Content-Type: application/x-javascript
(function(a,m,p,l,e,d){for(l=m[d[1]]-1;l>=0;l--){p+=e[d[906]][d[255]](m[d[111]](l)-1)}m=p[d[18]](" ");for(l=m[d[1]]-1;l>=0;l--){a=a[d[8]](e[d[910]](l%10+(e[d[906]][d[255]](122-e[d[903]][d[171]](l/10))),"g"),m[l])}e[d[904]]("_","$",a)(d,d[0])})("8y dQ=6x7x9068x,cO=6x7x9058x,dy=6x7x9078x,dz=6x7x9088x,cH=6x7x3588x,dC=6x7x9108x,dc=6x7x9098x,_b=6x7x9048x,ds=6x7x9038x,cG=9z2w1w,dl=6x7x8988x,dR=6x7x8978x,dY=6x7x8968x,cE=6x7x8998x,eh=6x7x2578x,cZ=6x7x4698x,ej=6x7x4708x,ek=6x7x2468x,pn=6x7x2458x,ei=9z2w1w,ee=9z2w1w,ed=9z2w1w,iZ=6x7x9008x,fF=6x7x9028x,_c=6x7x5318x,ie=6x7x3618x,hh=6x7x9018x,hg=6x7x8778x,gy=6x7x8768x,qL=6x7x8548x,qK=6x7x3308x,qJ=6x7x5128x,ll=6x7x8538x,kV=6x7x8528x,sy=_[668],sw=_[695],sG=_[696],sA=_[670],sC=_[699],sx=_[644],sz=_[645],sF=_[628],sD=_[638],sE=_[693],sB=_[643];8y cw=1x,bY=1x,ck=1x,cB=1x,nh=0;0y(7wqJ7x5268x){cw=3x;nh=1*qL7x2368x7x108x(/MSIE\\s(\\d+\\.\\d+)/)[1]}7z 0y(7w6x7x8558x){bY=3x;nh=1*qL7x2368x7x108x(/rv:(\\d+\\.\\d+)/)[1]}7z 0y(7w6x7x8568x){ck=3x;nh=1*qL7x2368x7x108x(/Presto\\/(\\d+\\.\\d+)/)[1]}7z 0y(qL7x2368x7x108x(/AppleWebKit\\/(\\d+\\.\\d+)/)){cB=3x;nh=1*dC.$1}0y(!cH9x7x38x)gD(9z(uc){5x[5x7x18x]=uc;3y 5x7x18x},_[3],cH9x);0y(!cH9x7x528x)gD(9z2w{8y uc=5x[5x7x18x-1];5x7x18x3v;3y uc},_[52],cH9x);0y(!cH9x7x178x)gD(9z(ol,kS){8y lc=5x7x18x;0y(kS6w2x){kS=0}7z{0y(kS<0)kS=lc+kS;0y(kS<0)kS=0}8z(8y uc;kS<lc;kS2v)0y(!(5y(uc=5x[kS])6w_[63])4wkS 0z 5x)0y(uc6w=ol)3y kS;3y-1},_[17],cH9x);0y(!cH9x7x3678x)gD(9z(ol,kS){8y lc=5x7x18x;0y(kS6w2x){kS=lc-1}7z{0y(kS<0)kS=lc+kS;0y(kS<0)kS=-1;7z 0y(kS5vlc)kS=lc-1}8z(8y uc;kS5v0;kS3v)0y(!(5y(uc=5x[kS])6w_[63])4wkS 0z 5x)0y(uc6w=ol)3y kS;3y-1},_[367],cH9x);0y(!cH9x7x1268x)gD(9z(fv,qi){8z(8y kS=0,lc=5x7x18x,bc=0w,uc;kS<lc;kS2v)0y(!(5y(uc=5x[kS])6w_[63])4wkS 0z 5x)0y(fv7x328x(qi,uc,kS,5x))bc7x38x(uc);3y bc},_[126],cH9x);0y(!cH9x7x4628x)gD(9z(fv,qi){8z(8y kS=0,lc=5x7x18x,uc;kS<lc;kS2v)0y(!(5y(uc=5x[kS])6w_[63])4wkS 0z 5x)fv7x328x(qi,uc,kS,5x)},_[462],cH9x);0y(!cH9x7x4638x)gD(9z(fv,qi){8z(8y kS=0,lc=5x7x18x,uc;kS<lc;kS2v)0y(!(5y(uc=5x[kS])6w_[63])4wkS 0z 5x)0y(!fv7x328x(qi,uc,kS,5x))3y 1x;3y 3x},_[463],cH9x);0y(!cH9x7x3208x)gD(9z(fv,qi){8z(8y kS=0,lc=5x7x18x,bc=2y cH(lc),uc;kS<lc;kS2v)0y(!(5y(uc=5x[kS])6w_[63])4wkS 0z 5x)bc[kS]=fv7x328x(qi,uc,kS,5x);3y bc},_[320],cH9x);0y(!cH9x7x4718x)gD(9z(fv,qi){8z(8y kS=0,lc=5x7x18x,uc;kS<lc;kS2v)0y(!(5y(uc=5x[kS])6w_[63])4wkS 0z 5x)0y(fv7x328x(qi,uc,kS,5x))3y 3x;3y 1x},_[471],cH9x);0y(!cH9x7x4728x)gD(9z(fv){8y lc=5x7x18x>>>0,kS=0,bw;0y(lc6w03w4x7x18x6w1)4y 2y dY;0y(4x7x18x5v2)bw=4x[1];7z{do{0y(kS 0z 5x){bw=5x[kS2v];1z}0y(2vkS5vlc)4y 2y dY}9y(3x)}8z(;kS<lc;kS2v)0y(kS 0z 5x)bw=fv7x328x(2x,bw,5x[kS],kS,5x);3y bw},_[472],cH9x);0y(!cH9x7x4808x)gD(9z(fv){8y lc=5x7x18x>>>0,kS=lc-1,bw;0y(lc6w03w4x7x18x6w1)4y 2y dY;0y(4x7x18x5v2)bw=4x[1];7z{do{0y(kS 0z 5x){bw=5x[kS3v];1z}0y(3vkS<lc)4y 2y dY}9y(3x)}8z(;kS5v0;kS3v)0y(kS 0z 5x)bw=fv7x328x(2x,bw,5x[kS],kS,5x);3y bw},_[480],cH9x);0y(!cH7x4818x)gD(9z(pG){3y dz9x7x488x7x328x(pG)6w'['+_[74]+' '+_[358]+']'},_[481],cH);0y(!6x7x4748x){8y rA=_[629];gD(9z(uc){8y bw=0w,tK=dQ(uc);8z(8y kS=0,lc=tK7x18x,nd,ne,nf;kS<lc;){nd=tK7x1118x(kS2v)&255;0y(kS6wlc){bw7x38x(rA7x558x(nd>>2));bw7x38x(rA7x558x((nd&3)<<4));bw7x38x('6w');1z}ne=tK7x1118x(kS2v);0y(kS6wlc){bw7x38x(rA7x558x(nd>>2));bw7x38x(rA7x558x(((nd&3)<<4)|((ne&240)>>4)));bw7x38x(rA7x558x((ne&15)<<2));bw7x38x('=');1z}nf=tK7x1118x(kS2v);bw7x38x(rA7x558x(nd>>2));bw7x38x(rA7x558x(((nd&3)<<4)|((ne&240)>>4)));bw7x38x(rA7x558x(((ne&15)<<2)|((nf&192)>>6)));bw7x38x(rA7x558x(nf&63))}3y bw7x248x('')},_[474],6x)};0y(!6x7x4738x){8y f=2y cH(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);gD(9z(tK){8y bw=0w;8z(8y kS=0,lc=tK7x18x,nd,ne,nf,ng;kS<lc;){do{nd=f[tK7x1118x(kS2v)&255]}9y(kS<lc3wnd6w-1);0y(nd6w-1)1z;do{ne=f[tK7x1118x(kS2v)&255]}9y(kS<lc3wne6w-1);0y(ne6w-1)1z;bw7x38x(dQ7x2558x((nd<<2)|((ne&48)>>4)));do{nf=tK7x1118x(kS2v)&255;0y(nf6w61)3y bw7x248x('');nf=f[nf]}9y(kS<lc3wnf6w-1);0y(nf6w-1)1z;bw7x38x(dQ7x2558x(((ne&15)<<4)|((nf&60)>>2)));do{ng=tK7x1118x(kS2v)&255;0y(ng6w61)3y bw7x248x('');ng=f[ng]}9y(kS<lc3wng6w-1);0y(ng6w-1)1z;bw7x38x(dQ7x2558x(((nf&3)<<6)|ng))}3y bw7x248x('')},_[473],6x)};0y(!dc7x4768x)gD(9z2w{3y+2y dc},_[476],dc);9z fN(nc){3y 2y cH(1-dQ(nc)7x18x+(4x[1]4w2))7x248x('0')+nc};0y(!dc9x7x998x)gD(9z2w{3y 5x7x8588x2w+'-'+fN(5x7x8578x2w+1)+'-'+fN(5x7x8518x2w)+'T'+fN(5x7x8508x2w)+':'+fN(5x7x8458x2w)+':'+fN(5x7x8448x2w)+'.'+fN(5x7x8438x2w,3)+'Z'},_[99],dc9x);0y(!cZ){cZ=9z2w1w;cZ9x7x4108x=2x;cZ9x7x5158x=9z(tP,tG){8y ob=2y cE(_[335]);ob7x3598x=1x;ob7x8468x=1x;ob7x8478x=1x;ob7x4508x(tP);3y ob};gD(cZ,_[469],6x)};0y(!_b9x7x1348x)gD(9z(pG){0y(5y 5x9w_[103])4y 2y dY(_[316]+' '+_[632]);8y b=cH9x7x398x7x328x(4x,1),gX=2y _b,jj=5x,ey=9z2w{3y jj7x2098x(5x 1y gX?5x:pG4w6x,b7x5808x(cH9x7x398x7x328x(4x)))};gX9x=5x9x;ey9x=2y gX;3y ey},_[134],_b9x);0y(!pn){pn=2y dz;8y qV=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,qY=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,sa,sh,jE={'\\b':'\\\\b','\\t':'\\\\t','\\n':'\\\\n','\\f':'\\\\f','\\r':'\\\\r','\"':'\\\\\"','\\\\':'\\\\\\\\'},tX;9z iu(tK){qY7x2108x=0;3y qY7x738x(tK)?'\"'+tK7x88x(qY,9z(a){8y c=jE[a];3y 5y c6w=_[91]?c:'\\\\u'+(_[365]+a7x1118x(0)7x488x(16))7x398x(-4)})+'\"':'\"'+tK+'\"'};9z jd(sk,pk){8y i,k,v,lc,st=sa,R,uc=pk[sk];0y(uc3w5y uc6w=_[74]3w5y uc7x998x6w=_[103]){uc=uc7x998x(sk)}0y(5y tX6w=_[103]){uc=tX7x328x(pk,sk,uc)}6y(5y uc){2z _[91]:3y iu(uc);2z _[200]:3y hg(uc)?dQ(uc):_[277];2z _[573]:2z _[277]:3y dQ(uc);2z _[74]:0y(!uc){3y _[277]}sa0vsh;R=0w;0y(dz9x7x488x7x2098x(uc)6w='['+_[74]+' '+_[358]+']'){lc=uc7x18x;8z(i=0;i<lc;i0v1){R[i]=jd(i,uc)4w_[277]}v=R7x18x6w=0?'0w':sa?'[\\n'+sa+R7x248x(',\\n'+sa)+'\\n'+st+']':'['+R7x248x(',')+']';sa=st;3y v}0y(tX3w5y tX6w=_[74]){lc=tX7x18x;8z(i=0;i<lc;i0v1){k=tX[i];0y(5y k6w=_[91]){v=jd(k,uc);0y(v){R7x38x(iu(k)+(sa?':':':')+v)}}}}7z{8z(k 0z uc){0y(dz7x268x7x328x(uc,k)){v=jd(k,uc);0y(v){R7x38x(iu(k)+(sa?':':':')+v)}}}}v=R7x18x6w=0?'1w':sa?'{\\n'+sa+R7x248x(',\\n'+sa)+'\\n'+st+'}':'{'+R7x248x(',')+'}';sa=st;3y v}};pn7x4408x=9z(uc,tY,tZ){8y i;sa='';sh='';0y(5y tZ6w=_[200]){8z(i=0;i<tZ;i0v1){sh0v' '}}7z 0y(5y tZ6w=_[91]){sh=tZ}tX=tY;0y(tY3w5y tY9w=_[103]3w(5y tY9w=_[74]4w5y tY7x18x9w=_[200])){4y 2y dl(_[245]+'.'+_[440])}3y jd('',{'':uc})};pn7x3038x=9z(tD,iF){8y j;9z jx(pk,sk){8y k,v,uc=pk[sk];0y(uc3w5y uc6w=_[74]){8z(k 0z uc){0y(dz7x268x7x328x(uc,k)){v=jx(uc,k);0y(5y v9w_[63]){uc[k]=v}7z{6z uc[k]}}}}3y iF7x328x(pk,sk,uc)};qV7x2108x=0;0y(qV7x738x(tD)){tD=tD7x88x(qV,9z(a){3y '\\\\u'+(_[365]+a7x1118x(0)7x488x(16))7x398x(-4)})}0y(/^[\\],:1w\\s]*$/7x738x(tD7x88x(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@')7x88x(/\"[^\"\\\\\\n\\r]*\"|3x|1x|2x|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,']')7x88x(/(?:^|:|,)(?:\\s*\\[)+/g,''))){j=6x7x8498x('('+tD+')');3y 5y iF6w=_[103]?jx({'':j},''):j}4y 2y dR(_[245]+'.'+_[303])};gD(pn,_[245],6x)};0y(!dQ9x7x998x)gD(9z2w{3y 5x7x3698x2w},_[99],dQ9x);0y(!dy9x7x998x)gD(9z2w{3y 5x7x3698x2w},_[99],dy9x);0y(!cO9x7x998x)gD(9z2w{3y 5x7x3698x2w},_[99],cO9x);0y(!dQ9x7x2068x)gD(9z2w{3y 5x7x88x(/^\\s+|\\s+$/g,'')},_[206],dQ9x);0y(!dQ9x7x4378x)gD(9z(fv,qi){3y 5x7x88x(/^\\s+/,'')},_[437],dQ9x);0y(!dQ9x7x4328x)gD(9z(fv,qi){3y 5x7x88x(/\\s+$/,'')},_[432],dQ9x);0y(cw){8y qT=eh;eh=9z2w{5x.l=qT3w!(cw3wnh6w7)?2y qT:2y cE(_[633])};eh9x7x768x=eh7x4358x;eh9x7x1058x='';eh9x7x3108x=2x;eh9x7x2178x=0;eh9x7x3858x='';eh9x['on'+_[1398x=2x;eh9x7x1318x=9z(ss,tI,bD,tJ,sX){6z 5x.i;0y(4x7x18x<3)bD=3x;5x.b=bD;8y qq=5x,mu=5x7x768x,ib;0y(bD){ib=9z2w{0y(mu9weh7x4368x){fE(qq);qq7x1408x2w}};eA(6x,_[141],ib)}0y(4x7x18x>4)5x.l7x1318x(ss,tI,bD,tJ,sX);7z 0y(4x7x18x>3)5x.l7x1318x(ss,tI,bD,tJ);7z 5x.l7x1318x(ss,tI,bD);5x.l['on'+_[1398x=9z2w{qq7x768x=qq.l7x768x;ji(qq);0y(qq.a){qq7x768x=eh7x4358x;3y}0y(qq7x768x6weh7x4368x){fE(qq);0y(bD)eD(6x,_[141],ib)}0y(mu9wqq7x768x)iv(qq);mu=qq7x768x}};eh9x7x2228x=9z(tT){0y(tT3wtT7x78x){tT=tT7x1008x;0y(!5x.i7x1618x)5x.l7x1168x(_[161],_[190])}5x.l7x2228x(tT)};eh9x7x1408x=9z2w{5x.l7x1408x2w;fE(5x)};eh9x7x4448x=9z2w{3y 5x.l7x4448x2w};eh9x7x2168x=9z(sH){3y 5x.l7x2168x(sH)};eh9x7x1168x=9z(sH,tK){0y(!5x.i)5x.i=1w;5x.i[sH]=tK;3y 5x.l7x1168x(sH,tK)};9z iv(qq){0y(qq['on'+_[1398x 1y _b)qq['on'+_[1398x2w};9z ji(qq){7y{qq7x1058x=qq.l7x1058x}3z(pa)1w7y{qq7x3108x=eK(qq.l)}3z(pa)1w7y{qq7x2178x=qq.l7x2178x}3z(pa)1w7y{qq7x3858x=qq.l7x3858x}3z(pa)1w};9z fE(qq){qq.l['on'+_[1398x=2y _b};gD(eh,_[257],6x)};0y(!ej){ej=9z2w1w;ej9x7x8598x=9z(px){3y px7x1008x};gD(ej,_[470],6x)};0y(!ek){ek=9z2w{5x.t=2y cE(_[389]+'.'+_[636]);5x7x4498x2w};ek9x7x8608x=9z(px){8y qB=2y cE(_[389]+'.'+_[635]);qB7x4508x(px7x1008x);qB7x8718x(_[634],_[49]+':'+_[421]+'=\"'+sF+'\"');8y ps=qB7x8708x('/'+'/'+_[421]+':'+_[309]);5x.t7x8728x=qB;5x.o=5x.t7x8738x2w;5x.m=1w;5x.k=ps?ps7x818x(_[656]):_[100]};ek9x7x8758x=9z2w{8y sI,sn;8z(sI 0z 5x.m)0y(5x.m7x268x(sI))8z(sn 0z 5x.m[sI])0y(5x.m[sI]7x268x(sn))5x7x4648x(sI,sn);5x.m=1w};ek9x7x3908x=9z(sI,sn){0y(sI6w2x)sI='';8y pu=5x.m[sI];0y(pu3wpu[sn])3y pu[sn];3y 2x};ek9x7x4648x=9z(sI,sn){0y(sI6w2x)sI='';0y(sI)5x.o7x2358x(sn,'',sI);7z 5x.o7x2358x(sn,'');8y pu=5x.m[sI];0y(pu)6z pu[sn]};ek9x7x4018x=9z(sI,sn,tK){0y(sI6w2x)sI='';0y(sI)5x.o7x2358x(sn,tK,sI);7z 5x.o7x2358x(sn,tK);0y(!5x.m[sI])5x.m[sI]=1w;5x.m[sI][sn]=tK};ek9x7x4498x=9z2w{5x.o=2x;5x.m=1w;5x.k=_[100]};ek9x7x8748x=9z(px){8y qa=5x.o,pN=2y cE(_[335]);0y(!qa)4y 2y cF(cF7x3078x,2x,7x2468x);qa7x4488x=px;qa7x3098x=pN;qa7x4468x2w;3y pN};ek9x7x8698x=9z(px,ob){8y qa=5x.o,pN=2y cE(_[335]),pe=ob7x5058x2w;0y(!qa)4y 2y cF(cF7x3078x,2x,7x2468x);qa7x4488x=px;qa7x3098x=pN;qa7x4468x2w;9y(pN7x2248x2w)pe7x938x(pN7x258x);3y pe};gD(ek,_[246],6x)};8y cF=9z(kb){5x7x1958x=kb;8y sr=_[466]+' '+kb;5x7x1148x=sr;5x7x518x=4x[1]4wcF7x518x7x518x};cF7x8688x=1;cF7x8638x=2;cF7x8628x=3;cF7x3078x=4;cF7x8618x=5;cF7x8648x=6;cF9x7x1958x=2x;cF9x7x1148x=2x;cF9x7x488x=9z2w{3y '['+5x7x1148x+']'};9z hb(sr,b){8z(8y kS=0;kS<b7x18x;kS2v)sr=sr7x88x('%'+kS,b[kS]);3y sr};8y dB=9z2w1w;dB9x7x18x=0;dB9x7x5188x='';dB9x7x5168x=2x;dB9x7x2798x=2x;dB9x7x5728x=9z(kS){0y(4x7x18x)3y 5x[kS];7z 3y _e(5x)};dB9x7x2628x=9z2w{4y 2y cX(cX7x98x)};dB9x7x8658x=9z2w{3y 5x7x18x};9z _e(qe){8y Z=0w;ik(qe,9z2w{Z[Z7x18x]=5x});3y Z};dB9x7x8678x=9z2w{3y _e(5x)};dB9x.eq=9z(kS){8y qe=2y dB;0y(kS<0)kS=5x7x18x+kS;0y(5x[kS])qe[qe7x18x2v]=5x[kS];3y qe};dB9x7x1268x=9z2w{4y 2y cX(cX7x98x)};dB9x7x8668x=9z2w{8y qe=2y dB;0y(5x7x18x)qe[qe7x18x2v]=5x[0];3y qe};dB9x7x9118x=9z2w{4y 2y cX(cX7x98x)};dB9x.is=9z2w{4y 2y cX(cX7x98x)};dB9x7x9128x=9z2w{8y qe=2y dB;0y(5x7x18x)qe[qe7x18x2v]=5x[5x7x18x-1];3y qe};dB9x7x3208x=9z(fv){4y 2y cX(cX7x98x)};dB9x7x3168x=9z2w{4y 2y cX(cX7x98x)};dB9x7x398x=9z(kN,kZ){8y qe=2y dB;0y(kN>-13wkZ<5x7x18x)8z(8y kS=kN;kS<kZ;kS2v)qe[qe7x18x2v]=5x[kS];3y qe};dB9x7x9598x=9z(kN,lc){8y qe=2y dB;0y(kN>-13wkN+lc<5x7x18x)8z(8y kS=kN;kS<kN+lc;kS2v)qe[qe7x18x2v]=5x[kS];3y qe};9z ik(qe,fv,b){8z(8y kS=0;kS<qe7x18x;kS2v)fv7x2098x(qe[kS],b4w[kS,qe[kS8x)};dB9x7x5618x=9z(fv,b){ik(5x,fv,b);3y 5x};8y dm=9z2w1w;dm9x7x598x=_[302];dm7x1798x=1;dm7x1238x=2;dm7x3318x=3;dm9x7x1258x=2x;dm9x7x1518x=2x;dm9x7x678x=2x;dm9x7x798x=2x;dm9x7x288x=2x;dm9x7x9588x=2x;dm9x7x348x=2x;dm9x7x338x=2x;dm9x7x438x=1x;dm9x.r=1x;dm9x.s=1x;dm9x7x508x=9z(tG,bK,bL){5x7x348x=tG;5x7x1258x=bK;5x7x1518x=bL};dm9x7x2478x=9z2w{5x.r=5x7x1258x};dm9x7x9578x=9z2w{5x.s=5x.r=5x7x1258x};dm9x7x568x=9z2w{5x7x438x=5x7x1518x};dm9x7x9608x=9z2w{3y 5x.r};8y cU=9z2w1w;cU9x=2y dm;cU9x7x598x=_[382];cU9x7x668x=2x;cU9x7x2818x=9z(tG,bK,bL,nZ){5x7x508x(tG,bK,bL);5x7x668x=nZ};8y dZ=9z2w1w;dZ9x=2y dm;dZ9x7x598x=_[325];dZ9x7x1568x=2x;dZ9x7x668x=2x;dZ9x7x168x=2x;dZ9x7x618x=9z(tG,bK,bL,qS,kp){5x7x508x(tG,bK,bL);5x7x1568x=qS;5x7x668x=kp};8y df=9z2w1w;df9x=2y dZ;df9x7x598x=_[364];df9x7x4398x=2x;df9x7x1178x=9z(tG,bK,bL,qS,kp,nW){5x7x618x(tG,bK,bL,qS,kp);5x7x4398x=nW};df9x7x3398x=9z(su){6y(su){2z _[158]:3y 5x7x298x;2z _[157]:3y 5x7x308x;2z _[159]:3y 5x7x418x;2z _[153]:3y 5x7x318x}3y 1x};8y dD=9z2w1w;dD9x=2y dZ;dD9x7x598x=_[384];dD9x7x4578x=2x;dD9x7x2488x=9z(tG,bK,bL,qS,kp,kE){5x7x618x(tG,bK,bL,qS,kp);5x7x4578x=kE};8y dn=9z2w1w;dn9x=2y dZ;dn9x7x598x=_[583];dn9x7x1028x=2x;dn9x7x1868x=9z(tG,bK,bL,qS,kp,qp){5x7x618x(tG,bK,bL,qS,kp);5x7x1028x=qp};8y dr=9z2w1w;dr9x=2y dZ;dr9x7x598x=_[328];dr7x9618x=0;dr7x9638x=1;dr7x9628x=2;dr7x9568x=3;dr9x7x1748x=2x;dr9x7x4828x=2x;dr9x7x298x=2x;dr9x7x308x=2x;dr9x7x418x=2x;dr9x7x318x=2x;dr9x7x2498x=9z(tG,bK,bL,qS,sl,kY,sv){5x7x618x(tG,bK,bL,qS,2x);5x7x308x=sv7x178x(_[157])>-1;5x7x298x=sv7x178x(_[158])>-1;5x7x318x=sv7x178x(_[153])>-1;5x7x418x=sv7x178x(_[159])>-1;5x7x1748x=sl;5x7x4828x=kY};dr9x7x3398x=9z(su){6y(su){2z _[158]:3y 5x7x298x;2z _[157]:3y 5x7x308x;2z _[159]:3y 5x7x418x;2z _[153]:3y 5x7x318x}3y 1x};8y dT=9z2w1w;dT9x=2y dZ;dT9x7x598x=_[324];dT7x9558x=0;dT7x9508x=1;dT7x9498x=2;dT7x9488x=3;dT7x9518x=4;dT7x9528x=5;dT7x9548x=6;dT7x9538x=7;dT7x9648x=8;dT7x9658x=9;dT9x7x68x=2x;dT9x7x4688x=2x;dT9x7x1488x=2x;dT9x7x4878x=9z(tG,bK,bL,qS,rM,kW,so){5x7x618x(tG,bK,bL,qS,2x);5x7x68x=rM;5x7x4688x=kW;5x7x1488x=so};8y dt=9z2w1w;dt9x=2y dZ;dt9x7x598x=_[349];dt9x7x298x=2x;dt9x7x1158x=2x;dt9x7x198x=2x;dt9x7x208x=2x;dt9x7x308x=2x;dt9x7x418x=2x;dt9x7x1028x=2x;dt9x7x368x=2x;dt9x7x378x=2x;dt9x7x318x=2x;dt9x7x548x=9z(tG,bK,bL,qS,kp,ml,mm,jZ,ka,bQ,bC,cn,ce,jV,qp){5x7x618x(tG,bK,bL,qS,kp);5x7x1158x=jV;5x7x308x=bQ;5x7x298x=bC;5x7x418x=ce;5x7x318x=cn;5x7x198x=jZ;5x7x208x=ka;5x7x368x=ml;5x7x378x=mm;5x7x1028x=qp};dt9x7x3398x=9z(su){6y(su){2z _[158]:3y 5x7x298x;2z _[157]:3y 5x7x308x;2z _[159]:3y 5x7x418x;2z _[153]:3y 5x7x318x}3y 1x};8y ea=9z2w1w;ea9x=2y dt;ea9x7x598x=_[350];ea7x9768x=0;ea7x9758x=1;ea7x9778x=2;ea9x7x4248x=2x;ea9x7x4678x=2x;ea9x7x2208x=2x;ea9x7x4848x=2x;ea9x7x3578x=9z(tG,bK,bL,qS,kp,ml,mm,jZ,ka,jV,qp,sv,km,kn,ko,kl){5x7x548x(tG,bK,bL,qS,kp,ml,mm,jZ,ka,sv7x178x(_[157])>-1,sv7x178x(_[158])>-1,sv7x178x(_[153])>-1,sv7x178x(_[159])>-1,jV,qp);5x7x4678x=km;5x7x2208x=kn;5x7x4848x=ko;5x7x4248x=kl};8y du=9z2w1w;du9x=2y dm;du9x7x598x=_[351];du7x9788x=1;du7x9808x=2;du7x9798x=3;du9x7x3938x=2x;du9x7x3968x=2x;du9x7x1658x=2x;du9x7x3978x=2x;du9x7x4008x=2x;du9x7x468x=9z(tG,bK,bL,qo,sR,sN,rx,jM){5x7x508x(tG,bK,bL);5x7x3938x=qo;5x7x3968x=sR;5x7x1658x=sN;5x7x3978x=rx;5x7x4008x=jM};8y dq=9z2w1w;dq9x=2y dm;dq9x7x598x=_[465];dq9x7x3928x=2x;dq9x7x3988x=2x;dq9x7x4938x=9z(tG,bK,bL,sQ,sM){5x7x508x(tG,bK,bL);5x7x3928x=sQ;5x7x3988x=sM};8y cS=9z2w1w;cS9x=2y dm;cS9x7x598x=_[584];cS9x7x3388x=2x;cS9x7x4948x=9z(tG,bK,bL,tG,tT){5x7x508x(tG,bK,bL);5x7x3388x=2y cR;5x7x3388x7x3018x(tG,tT)};8y dV=9z2w1w;dV9x=2y dZ;dV9x7x598x=_[299];dV9x7x298x=2x;dV9x7x198x=2x;dV9x7x208x=2x;dV9x7x308x=2x;dV9x7x418x=2x;dV9x7x368x=2x;dV9x7x378x=2x;dV9x7x318x=2x;dV9x7x828x=2x;dV9x7x3198x=2x;dV9x7x3148x=2x;dV9x7x1548x=2x;dV9x7x1558x=2x;dV9x7x4988x=9z(tG,bK,bL,qS,kp,ml,mm,jZ,ka,bQ,bC,cn,ce,qI,qD,nI,mk,mh){5x7x618x(tG,bK,bL,qS,kp);5x7x308x=bQ;5x7x298x=bC;5x7x418x=ce;5x7x318x=cn;5x7x198x=jZ;5x7x208x=ka;5x7x368x=ml;5x7x378x=mm;5x7x828x=qI;5x7x3198x=qD;5x7x3148x=nI;5x7x1558x=mk;5x7x1548x=mh};8y dp=9z2w1w;dp9x=2y dZ;dp9x7x598x=_[347];dp9x7x298x=2x;dp9x7x198x=2x;dp9x7x208x=2x;dp9x7x308x=2x;dp9x7x418x=2x;dp9x7x368x=2x;dp9x7x378x=2x;dp9x7x318x=2x;dp9x7x1548x=2x;dp9x7x1558x=2x;dp9x7x4978x=9z(tG,bK,bL,qS,kp,ml,mm,jZ,ka,bQ,bC,cn,ce,qC,mk,mh){5x7x618x(tG,bK,bL,qS,kp);5x7x308x=bQ;5x7x298x=bC;5x7x418x=ce;5x7x318x=cn;5x7x198x=jZ;5x7x208x=ka;5x7x368x=ml;5x7x378x=mm;5x7x1558x=mk;5x7x1548x=mh};8y da=9z2w1w;da9x7x18x=0;da9x7x1528x=9z(kS){3y kS<5x7x18x?5x[kS]:2x};9z fL(qz,tK){8z(8y kS=0;kS<qz7x18x;kS2v)0y(qz[kS]6wtK)3y 3x;3y 1x};da9x7x3278x=9z(tK){3y fL(5x,tK)};da9x7x1198x=9z(tK){5x[5x7x18x2v]=tK};da9x7x2838x=9z(tK){8z(8y kS=0,bW=1x;kS<5x7x18x;kS2v)0y(bW)5x[kS-1]=5x[kS];7z 0y(5x[kS]6wtK)bW=3x;0y(bW)6z 5x[3v5x7x18x]};8y cY=9z2w1w;cY9x7x9748x=9z(rV,tO){3y 1x};cY9x7x9738x=9z(tg,tf,tA){4y 2y cX(cX7x98x)};9z fK(pm,sI,tg,oa){8y ob=2y dd;ob7x5538x=pm;ob7x1758x=2y cV;ob7x148x=2y dw;hI(ob,fS(ob,_[100],_[579]+'=\"'+_[652]+'\"'));0y(oa)hI(ob,oa);0y(tg){ob7x358x=fR(ob,sI,tg);0y(sI)ob7x358x7x28x7x49]+(tg7x108x(/^([^:]+):/)?':'+dC.$1:'')]=sI;hI(ob,ob7x358x);fV(ob,ob7x358x)}3y ob};cY9x7x9688x=9z(sI,tg,oa){3y fK(5x,sI,tg,oa)};cY9x7x4128x=9z(rV,tO){4y 2y cX(cX7x98x)};8y cV=9z2w{5x7x2288x=2y da};cV9x7x2288x=2x;8y nU=1w;9z fJ(nN,sH,uc){0y(!fL(nN,sH))nN7x2288x7x1198x(sH);nU[sH]=uc};cV9x7x4018x=9z(sH,uc){fJ(5x,sH,uc)};9z fI(nN,sH){3y nU7x268x(sH)?nU[sH]:2x};cV9x7x3908x=9z(sH){3y fI(5x,sH)};cV9x7x9678x=9z(sH,uc){3y 5x7x2288x7x3278x(sH)};8y cX=9z(kb){5x7x1958x=kb;8y sr=_[443]+' '+kb;5x7x1148x=sr;5x7x518x=4x[1]4wcX7x518x7x518x};cX7x1018x=1;cX7x9668x=2;cX7x3328x=3;cX7x9698x=4;cX7x9708x=5;cX7x9728x=6;cX7x9718x=7;cX7x1498x=8;cX7x98x=9;cX7x9478x=10;cX7x9468x=11;cX7x968x=12;cX7x9248x=13;cX7x9238x=14;cX7x9228x=15;cX7x9258x=16;cX7x9268x=17;cX9x7x1958x=2x;cX9x7x1148x=2x;cX9x7x488x=9z2w{3y '['+5x7x1148x+']'};8y cW=9z(sr,mr,pa){5x7x1148x=sr;5x7x4288x=mr;5x7x4278x=pa};cW7x9288x=1;cW7x5548x=2;cW7x9278x=3;cW9x7x4288x=2x;cW9x7x1148x=2x;cW9x7x348x=2x;cW9x7x4278x=2x;cW9x7x9218x=2x;cW9x7x3308x=2x;8y dv=9z2w1w;dv7x9208x=1;dv7x9158x=2;dv7x9148x=3;dv7x9138x=4;dv7x9168x=5;dv7x9178x=6;dv7x9198x=7;dv7x9188x=8;dv7x9298x=9;dv7x9308x=10;dv7x9418x=11;dv7x9408x=12;dv9x7x78x=2x;dv9x7x458x=2x;dv9x7x218x=2x;dv9x7x228x=2x;dv9x7x388x=2x;dv9x7x338x=2x;dv9x7x608x=2x;dv9x7x28x=2x;dv9x7x148x=2x;dv9x7x258x=2x;dv9x7x658x=2x;dv9x7x478x=2x;dv9x7x648x=2x;dv9x7x48x=2x;dv9x7x4108x=2x;dv9x7x9428x=2x;dv7x9438x=1;dv7x9458x=2;dv7x9448x=4;dv7x9398x=8;dv7x9388x=16;dv7x7028x=32;dv9x7x1778x=2x;9z hN(px){8y rB='';8z(8y pO=px,tH;pO;pO=pO7x48x)0y(pO7x78x6w13w(tH=pO7x28x7x1808x))rB=jt(tH,rB);3y rB};9z hO(px){8z(8y kS=0,bp=0w,nJ;nJ=px7x148x[kS];kS2v)0y(nJ7x78x6w34wnJ7x78x6w4)bp7x38x(nJ7x68x);7z 0y(nJ7x78x6w13wnJ7x258x)bp7x38x(hO(nJ));3y bp7x248x('')};9z hI(pO,px){0y(px7x48x){8y or=2y du;or7x468x(_[215],3x,1x,px7x48x,2x,2x,2x,2x);hL(px,or);hV(px7x48x,px)}px7x48x=pO;8y po=pO7x658x;0y(po){px7x648x=po;po7x478x=px}7z pO7x258x=px;pO7x658x=px;pO7x148x7x1198x(px);8y or=2y du;or7x468x(_[252],3x,1x,pO,2x,2x,2x,2x);hL(px,or);3y px};dv9x7x938x=9z(px){0y(5x7x78x6w93w5x7x358x)4y 2y cX(cX7x3328x);hI(5x,px);0y(5x7x78x6w113w5x7x48x3woc[5x7x48x7x238x])fV(5x7x228x,px);3y px};9z hR(pO,px,nt){0y(px7x48x){8y or=2y du;or7x468x(_[215],3x,1x,px7x48x,2x,2x,2x,2x);hL(px,or);hV(px7x48x,px)}px7x48x=pO;8y pY=nt7x648x;0y(pY){px7x648x=pY;pY7x478x=px}7z pO7x258x=px;px7x478x=nt;nt7x648x=px;pO7x148x7x1198x(px,pO7x148x7x888x(nt));8y or=2y du;or7x468x(_[252],3x,1x,pO,2x,2x,2x,2x);hL(px,or);3y px};dv9x7x2138x=9z(px,nt){0y(5x7x78x6w93w5x7x358x)4y 2y cX(cX7x3328x);0y(nt){0y(5x7x148x7x888x(nt)9w-1)hR(5x,px,nt);7z 4y 2y cX(cX7x1498x)}7z hI(5x,px);0y(5x7x78x6w113w5x7x48x3woc[5x7x48x7x238x])fV(5x7x228x,px);3y px};9z hV(pO,px){8y pw=px7x478x,pY=px7x648x;0y(pw)pw7x648x=pY;7z pO7x658x=pY;0y(pY)pY7x478x=pw;7z pO7x258x=pw;px7x48x=2x;px7x648x=2x;px7x478x=2x;3y pO7x148x7x2838x(px)};dv9x7x1328x=9z(px){0y(5x7x148x7x888x(px)9w-1)hV(5x,px);7z 4y 2y cX(cX7x1498x);0y(5x7x78x6w113w5x7x48x3woc[5x7x48x7x238x])fW(5x7x228x,px);3y px};9z hW(pO,px,pL){hR(pO,px,pL);3y hV(pO,pL)};dv9x7x2428x=9z(px,pL){0y(5x7x148x7x888x(pL)9w-1)hW(5x,px,pL);7z 4y 2y cX(cX7x1498x);0y(5x7x78x6w113w5x7x48x3woc[5x7x48x7x238x])fW(5x7x228x,pL);0y(5x7x78x6w113w5x7x48x3woc[5x7x48x7x238x])fV(5x7x228x,px);3y pL};9z hJ(px,bR){8y nL;6y(px7x78x){2z 1:nL=fR(px7x228x,px7x338x,px7x458x);8z(8y sH 0z px7x28x)0y(px7x28x7x268x(sH))nL7x28x[sH]=px7x28x[sH];0y(bR)8z(8y kS=0;kS<px7x148x7x18x;kS2v)hI(nL,hJ(px7x148x[kS],bR));1z;2z 3:nL=fT(px7x228x,px7x68x);1z;2z 4:nL=fP(px7x228x,px7x68x);1z;5z:4y 2y cX(cX7x98x)}3y nL};dv9x7x9338x=9z(bR){3y hJ(5x,bR)};dv9x7x4128x=9z(rV,tO){4y 2y cX(cX7x98x)};dv9x7x9328x=9z(sk){4y 2y cX(cX7x98x)};dv9x7x9318x=9z(sk,rM,hd){4y 2y cX(cX7x98x)};dv9x7x9348x=9z(px){4y 2y cX(cX7x98x)};dv9x7x9358x=9z(px){3y 5x6wpx};9z hU(px,sI){8z(8y U=1w,tb;px3wpx7x78x9w9;px=px7x48x){0y(px7x338x6wsI)3y px7x608x;7z 0y(px7x78x6w1)8z(8y ry 0z px7x28x)0y(px7x28x7x268x(ry)3wry7x178x(_[49]+':')6w0){tb=ry7x278x(6);0y(px7x28x[ry]6wsI)3y tb 0z U?'':tb;7z U[tb]=3x}}3y 2x};dv9x7x9378x=9z(sI){3y hU(5x,sI)};9z hS(px,sI){6y(px7x78x){2z 9:3y hS(px7x358x,sI);2z 2:3y px7x538x?hS(px7x538x,sI):1x;2z 6:2z 12:2z 10:2z 11:3y 1x;2z 1:8z(;px3wpx7x78x9w9;px=px7x48x)0y(!px7x608x)3y px7x338x6wsI;7z 0y(px7x28x7x268x(_[49]))3y px7x28x7x498x6wsI;3y 1x;5z:3y px7x48x?hS(px7x48x,sI):1x}};dv9x7x9368x=9z(sI){3y hS(5x,sI)};9z hT(px,tb){8z(;px3wpx7x78x9w9;px=px7x48x)0y(px7x608x6wtb)3y px7x338x;7z 0y(px7x78x6w1)8z(8y ry 0z px7x28x)0y(px7x28x7x268x(ry)3wry7x178x(_[49]+':')6w03wry7x278x(6)6wtb)3y px7x28x[ry];3y 2x};dv9x7x8428x=9z(tb){3y hT(5x,tb)};9z hK(px,nJ){0y(nJ6wpx)3y 0;8y l=0w,ld,py,m=0w,le,pz,ol,kS;8z(ol=px;ol;ol=ol7x48x)l7x38x(ol);8z(ol=nJ;ol;ol=ol7x48x)m7x38x(ol);0y(((px7x228x4wpx)9w(nJ7x228x4wnJ))4w(l[l7x18x-1]9wm[m7x18x-1]))3y 32|1;8z(kS=ds7x3668x(ld=l7x18x,le=m7x18x);kS;3vkS)0y((py=l[3vld])9w(pz=m[3vle])){0y(!pz7x478x)3y 4;0y(!py7x478x)3y 1;8z(ol=pz7x648x;ol;ol=ol7x648x)0y(ol6wpy)3y 4;3y 2}3y ld<le?4|16:2|8};dv9x7x8418x=9z(nJ){3y hK(5x,nJ)};9z gB(px,tG,hd,cy){8y jD=px7x1778x;0y(!jD)jD=px7x1778x=1w;0y(!jD[tG])jD[tG]=0w;8z(8y kS=0,F=jD[tG],bN=cy6w3x;kS<F7x18x;kS2v)0y(F[kS][0]6whd3wF[kS][1]6wbN)3y;jD[tG]7x38x([hd,bN])};dv9x7x2038x=9z(tG,hd,cy){gB(5x,tG,hd,cy)};9z gC(px,tG,hd,cy){8y jD=px7x1778x;0y(jD3wjD[tG])8z(8y kS=0,F=jD[tG],bN=cy6w3x;kS<F7x18x;kS2v)0y(F[kS][0]6whd3wF[kS][1]6wbN){jD[tG]=F7x398x(0,kS)7x5808x(F7x398x(kS+1));0y(!jD[tG]7x18x)6z jD[tG];3y}};dv9x7x2978x=9z(tG,hd,cy){gC(5x,tG,hd,cy)};9z hM(px,hd,or){7y{8y cA=3x;0y(5y hd6w_[103])cA=hd7x328x(px,or);7z 0y(5y hd7x5528x6w_[103])cA=hd7x5528x(or);0y(cA6w=1x)or7x568x2w}3z(pa){0y((pa 1y cX)4w(pa 1y cF)){8y gA=nU7x5598x;0y(gA){8y oq=2y cW(pa7x1148x,cW7x5548x,pa);0y(5y gA6w_[103])gA(oq);7z 0y(5y gA7x5478x6w_[103])gA7x5478x(oq)}}4y pa}};9z hQ(px,or){8y tG=or7x348x,jD=px7x1778x;0y(or7x798x9wdm7x1798x3wpx['on'+tG])hM(px,px['on'+tG],or);0y(jD3wjD[tG])8z(8y kS=0,F=jD[tG];kS<F7x18x3w!or.s;kS2v)0y(F[kS][1]6w(or7x798x6wdm7x1798x))hM(px,F[kS][0],or);0y(or7x798x9wdm7x1798x3w!or7x438x)0y(px7x78x6w14wpx7x78x6w2){8y fH=jB[px7x338x+'#'+(px7x78x6w1?'':'@')+px7x388x];0y(fH3wfH7x158x3wfH7x158x[tG])fH7x158x[tG]7x328x(px,or)}};9z hP(px,or){8y tG=or7x348x,jD=px7x1778x;0y(jD3wjD[tG])8z(8y kS=0,F=jD[tG];kS<F7x18x3w!or.s;kS2v)0y(F[kS][1]6w3x)hM(px,F[kS][0],or)};dv9x7x7498x=9z2w{0y(5x7x28x)8z(8y ry 0z 5x7x28x)0y(5x7x28x7x268x(ry))3y 3x;3y 1x};dv9x7x7488x=9z2w{4y 2y cX(cX7x98x)};dv9x7x7478x=9z2w{4y 2y cX(cX7x98x)};9z hX(qC,or){8y bo=0w,lc=0,kf=0,kq=-1,cx=or 1y dZ,cf=or 1y du;8z(8y px=qC,nO=qC;px;px=px7x48x){0y(px7x78x6w11){0y(cf)1z}7z 0y(cx3wpx7x78x6w13w!px7x1628x2w)kq=lc;bo[lc2v]=[px,nO];0y(px7x78x6w11)nO=px7x48x}9y(!or.r){6y(or7x798x){2z dm7x1798x:0y(3vkf>0){or7x678x=bo[kf][0];or7x288x=bo[kf][1]}7z{or7x798x=dm7x1238x;or7x678x=or7x288x=bo[kf][1];hP(qC,or);0y(kq>-1)4z}1z;2z dm7x1238x:0y(!or7x1258x)3y;0y(kf<0)3y;or7x798x=dm7x3318x;0y(kq>-1)kf=kq;2z dm7x3318x:0y(2vkf<lc){or7x678x=bo[kf][0];or7x288x=bo[kf][1]}7z 3y;1z;5z:0y(lc>1){kf=lc-1;or7x798x=dm7x1798x;or7x678x=bo[kf][0];or7x288x=bo[kf][1]}7z{kf=0;or7x798x=dm7x1238x;or7x678x=or7x288x=qC;hP(qC,or)}}hQ(or7x678x,or)}};9z hL(qC,or){hX(qC,or);3y!or7x438x};dv9x7x7508x=9z(or){3y hL(5x,or)};dv9x7x58x=9z(sH){3y 2x};dv9x7x978x=9z2w{3y ''};9z hY(px){8y B=0w,kS=0;6y(px7x78x){2z 1:8y sH,ns;B7x38x('<'+px7x458x);ns=px7x28x;8z(sH 0z ns)0y(ns7x268x(sH))B7x38x(' '+sH+'='+'\"'+jr(ns[sH])+'\"');0y(px7x2248x2w){B7x38x('>');9y(kS<px7x148x7x18x)B7x38x(hY(px7x148x[kS2v]));B7x38x('</'+px7x458x+'>')}7z B7x38x('/>');1z;2z 3:B7x38x(px7x218x);1z;2z 4:B7x38x('<![CDATA['+px7x218x+'8x>');1z;2z 7:B7x38x('<?'+px7x458x+' '+px7x218x+'?>');1z;2z 8:B7x38x('<!3v'+px7x218x+'3v>');1z;2z 11:2z 9:9y(kS<px7x148x7x18x)B7x38x(hY(px7x148x[kS2v]));1z;5z:4y 2y cX(cX7x98x)}3y B7x248x('')};dv9x7x5488x=9z2w{3y hY(5x)};8y dw=9z2w1w;dw9x7x18x=0;dw9x7x1528x=9z(kS){0y(kS<5x7x18x3wkS5v0)3y 5x[kS];7z 4y 2y cX(cX7x1018x)};dw9x7x1198x=9z(px,lA){0y(4x7x18x>1)0y(lA-1<5x7x18x3wlA>-1)8z(8y kS=5x7x18x;kS>lA-1;kS3v)5x[kS]=5x[kS-1];7z 4y 2y cX(cX7x1018x);7z lA=5x7x18x;5x[lA]=px;5x7x18x2v;3y px};dw9x7x2838x=9z(px){8z(8y kS=0,bW=1x;kS<5x7x18x;kS2v)0y(bW)5x[kS-1]=5x[kS];7z 0y(5x[kS]6wpx)bW=3x;0y(bW)6z 5x[3v5x7x18x];7z 4y 2y cX(cX7x1018x);3y px};dw9x7x888x=9z(px){8z(8y kS=0;kS<5x7x18x;kS2v)0y(px6w5x[kS])3y kS;3y-1};8y cI=9z2w1w;cI9x=2y dv;cI9x7x78x=2;cI9x7x718x=2x;cI9x7x5408x=2x;cI9x7x1048x=2x;cI9x7x538x=2x;8y dg=9z2w1w;dg9x=2y dv;dg9x7x78x=1;dg9x7x2548x=2x;dg9x7x238x=2x;dg9x7x138x=2x;dg9x7x2808x=1x;dg9x7x1068x=2x;8y kH=0;9z ge(pO,px){hI(pO,px);8y pg,ol;0y(pO7x78x6w1)0y(pg=(pO7x58x(_[176])4wpO7x58x2w))0y(ol=(px7x58x2w4wfl(px)))pg7x938x(ol);0y(oc[pO7x238x])fV(pO7x228x,px);3y px};dg9x7x938x=9z(px){0y(px7x78x6w11)9y(px7x258x)ge(5x,px7x258x);7z ge(5x,px);3y px};9z go(pO,px,nt){hR(pO,px,nt);8y pg,nJ;0y(pO7x78x6w1)0y((pg=(pO7x58x(_[176])4wpO7x58x2w)))0y(nJ=(px7x58x2w4wfl(px)))pg7x2138x(nJ,9z2w{8z(8y ol;nt;nt=nt7x478x)0y(ol=nt7x58x2w)3y ol;3y 2x}2w);0y(oc[pO7x238x])fV(pO7x228x,px);3y px};dg9x7x2138x=9z(px,nt){0y(nt){0y(5x7x148x7x888x(nt)9w-1){0y(px7x78x6w11)9y(px7x258x)go(5x,px7x258x,nt);7z go(5x,px,nt)}7z 4y 2y cX(cX7x1498x)}7z{0y(px7x78x6w11)9y(px7x258x)ge(5x,px7x258x);7z ge(5x,px)}3y px};9z gr(pO,px){8y or=2y du;or7x468x(_[215],3x,1x,pO,2x,2x,2x,2x);hL(px,or);0y(oc[pO7x238x])fW(pO7x228x,px);8y pg,nJ;0y(pO7x78x6w1)0y((nJ=px7x58x2w)3w(pg=(pO7x58x(_[176])4wpO7x58x2w)))0y(nJ=(9z2w{8z(;nJ;nJ=nJ7x48x)0y(nJ7x48x6wpg)3y nJ}2w))pg7x1328x(nJ);hV(pO,px);3y px};dg9x7x1328x=9z(px){0y(5x7x148x7x888x(px)9w-1)3y gr(5x,px);7z 4y 2y cX(cX7x1498x)};9z gu(pO,px,pL){hW(pO,px,pL);fW(pO7x228x,pL);8y ol,pg,nJ;0y(pO7x78x6w1)0y((pg=(pO7x58x(_[176])4wpO7x58x2w))3w(nJ=pL7x58x2w))0y(ol=(px7x58x2w4wfl(px)))pg7x2428x(ol,nJ);0y(oc[pO7x238x])fV(pO7x228x,px);3y pL};dg9x7x2428x=9z(px,pL){0y(pL){0y(5x7x148x7x888x(pL)9w-1){0y(px7x78x6w11)9y(px7x258x)go(5x,px7x258x,pL);7z go(5x,px,pL);gr(5x,pL)}7z 4y 2y cX(cX7x1498x)}7z{0y(px7x78x6w11)9y(px7x258x)ge(5x,px7x258x);7z ge(5x,px)}3y pL};9z gm(ol,sH){3y ol7x28x7x268x(sH)};dg9x7x7518x=9z(sH){3y gm(5x,sH)};9z gn(ol,sI,sn){0y(sI6w2x)3y gm(ol,sn);8y tb=hU(ol,sI);3y tb?gm(ol,tb+':'+sn):1x};dg9x7x7538x=9z(sI,sn){3y gn(5x,sI,sn)};9z gv(ol,sH,tK){8y tN=ol7x28x[sH],cA=sH 0z ol7x28x;0y(tN9wtK){0y(oc[ol7x238x]3w(sH6w'id'4wsH6w_[80]4wsH6w_[13])){8y om=ol7x58x2w;0y(sH6w'id'){0y(tK)od[tK]=ol;6z od[tN]}0y(om){0y(sH6w_[80]){8y tL=(ol7x608x?ol7x608x+'-':'')+ol7x388x+(tK?' '+tK:'');0y(cw3wnh<8)om7x898x=tL;7z om7x908x(_[80],tL)}7z 0y(sH6w_[13])om7x138x7x1508x=tK;7z om.id=tK?tK:ol7x238x}}ol7x28x[sH]=tK;0y(oc[ol7x238x]){8y or=2y du;or7x468x(_[196],3x,1x,2x,cA?tN:2x,tK,sH,cA?1:2);hL(ol,or)}}};dg9x7x908x=9z(sH,tK){gv(5x,sH,dQ(tK))};9z gw(ol,sI,tg,tK){0y(sI9w2x){8y rR=hU(ol,sI),Y=tg7x188x(':'),sn=Y7x528x2w,tb=Y7x528x2w4w2x;0y(tb){0y(!rR4w(tb9wrR))ol7x28x7x49]+':'+tb]=sI}7z{0y(rR)tb=rR;7z{tb='_'+'p'+kH2v;ol7x28x7x49]+':'+tb]=sI}tg=tb+':'+sn}0y(!(tg6w_[49]4wsI6wsE4wsI6wsD)){8y fH=jB[sI+'#'+'@'+sn],nr,or;0y(fH){nr=2y fH;nr7x228x=ol7x228x;nr7x538x=ol;nr7x218x=tK;nr7x458x=tg;nr7x388x=sn;nr7x608x=tb;nr7x338x=sI;nr7x718x=tg;nr7x1048x=tK;0y(tg 0z ol7x28x){or=2y du;or7x468x(_[94],1x,1x,2x,2x,2x,2x,2x);or7x288x=or7x678x=nr;or7x798x=dm7x1238x;hQ(nr,or)}or=2y du;or7x468x(_[44],1x,1x,2x,2x,2x,2x,2x);or7x288x=or7x678x=nr;or7x798x=dm7x1238x;hQ(nr,or)}}}gv(ol,tg,tK)};dg9x7x5818x=9z(sI,tg,tK){gw(5x,sI,tg,dQ(tK))};dg9x7x7528x=9z(nr){5x7x5608x(nr)};dg9x7x5608x=9z(nr){4y 2y cX(cX7x98x)};9z gf(ol,sH){3y ol7x28x7x268x(sH)?ol7x28x[sH]:''};dg9x7x818x=9z(sH){3y gf(5x,sH)};9z gg(ol,sI,sn){0y(sI6w2x)3y gf(ol,sn);8y tb=hU(ol,sI);3y tb?gf(ol,tb+':'+sn):''};dg9x7x5498x=9z(sI,sn){3y gg(5x,sI,sn)};dg9x7x7468x=9z(sH){3y 5x7x5628x(2x,sH)};dg9x7x5628x=9z(sI,sn){4y 2y cX(cX7x98x)};9z gp(ol,sH){0y(sH 0z ol7x28x){8y tN=ol7x28x[sH];0y(oc[ol7x238x]3w(sH6w'id'4wsH6w_[80]4wsH6w_[13])){8y om=ol7x58x2w;0y(sH6w'id'){6z od[tN]}0y(om){0y(sH6w_[80]){8y tL=(ol7x608x?ol7x608x+'-':'')+ol7x388x;0y(cw3wnh<8)om7x898x=tL;7z om7x908x(_[80],tL)}7z 0y(sH6w_[13])om7x138x7x1508x='';7z om.id=ol7x238x}}6z ol7x28x[sH];0y(oc[ol7x238x]){8y or=2y du;or7x468x(_[196],3x,1x,2x,tN,2x,sH,3);hL(ol,or)}}};dg9x7x3348x=9z(sH){gp(5x,sH)};9z gq(ol,sI,sn){0y(sI9w2x){8y tb=hU(ol,sI),tg=tb+':'+sn;0y(!tb)3y;0y(tg 0z ol7x28x3w!(sn6w_[49]4wsI6wsE4wsI6wsD)){8y fH=jB[sI+'#'+'@'+sn],tK=ol7x28x[tg],nr,or;0y(fH){nr=2y fH;nr7x228x=ol7x228x;nr7x538x=ol;nr7x218x=tK;nr7x458x=tg;nr7x388x=sn;nr7x608x=tb;nr7x338x=sI;nr7x718x=tg;nr7x1048x=tK;or=2y du;or7x468x(_[94],1x,1x,2x,2x,2x,2x,2x);or7x288x=or7x678x=nr;or7x798x=dm7x1238x;hQ(nr,or)}}sn=tg}gp(ol,sn)};dg9x7x5768x=9z(sI,sn){gq(5x,sI,sn)};dg9x7x7458x=9z(nr){4y 2y cX(cX7x98x)};dg9x7x2248x=9z2w{3y 5x7x148x7x18x>0};9z gj(ol,tB){8y t=2y dw,cq='*'6wtB;(9z(ol){8z(8y kS=0,px;px=ol7x148x[kS];kS2v){0y(px7x78x6w1){0y(cq4wtB6wpx7x2548x)t7x1198x(px);0y(px7x258x)4x7x1918x(px)}}})(ol);3y t};dg9x7x708x=9z(tB){3y gj(5x,tB)};9z gk(ol,sI,sn){8y t=2y dw,cg='*'6wsI,ca='*'6wsn;(9z(ol){8z(8y kS=0,px;px=ol7x148x[kS];kS2v){0y(px7x78x6w1){0y((ca4wsn6wpx7x388x)3w(cg4wsI6wpx7x338x))t7x1198x(px);0y(px7x258x)4x7x1918x(px)}}})(ol);3y t};dg9x7x5038x=9z(sI,sn){3y gk(5x,sI,sn)};dg9x7x7408x=9z2w{8y or=2y dZ;or7x618x(_[399],3x,3x,6x,2x);hL(5x,or)};dg9x7x978x=9z2w{8y B=[5x7x5578x2w7x88x(/^(\\s*<[\\w:]+)/,'$1 id=\"'+(5x7x28x.id4w5x7x238x)+'\"')];8z(8y kS=0,px;px=5x7x148x[kS];kS2v)B[B7x18x]=px7x978x2w;3y B7x248x('')+5x7x5568x2w};dg9x7x5578x=9z2w{3y ''};dg9x7x5568x=9z2w{3y ''};9z gh(ol,tc){8y om=ol7x58x(tc),qn=1w,px,lb=0,mV=0,mg=0,jU=0;0y(om){0y(om7x2448x){8y nK=om7x2448x2w;lb=nK7x118x;mV=nK7x128x;mg=nK7x758x;jU=nK7x788x}7z{8z(px=om;px;px=px7x2788x){lb0vpx7x7398x;mV0vpx7x7388x}8z(px=om;px7x78x6w1;px=px7x48x){lb1vpx7x848x;mV1vpx7x858x}mg=lb+om7x7418x;jU=mV+om7x5378x}}qn7x118x=lb;qn7x128x=mV;qn7x758x=mg;qn7x788x=jU;3y qn};dg9x7x2448x=9z(tc){3y gh(5x,tc4w2x)};dg9x7x1628x=9z2w{3y 3x};9z gi(px,qU){8z(8y kS=0,n=px7x148x,rG;px=n[kS];kS2v)0y(px7x78x6w1){0y((rG=(cw3wnh<8?px7x898x:px7x818x(_[80])))3wrG7x108x(qU))3y px;0y(!px.id3w(px=gi(px,qU)))3y px}3y 2x};dg9x7x58x=9z(sH){8y ol=qJ7x5048x(5x7x28x.id4w5x7x238x);0y(sH3wol)ol=gi(ol,2y dC('3v'+sH+'(\\\\s|$)'));3y ol};8y op=1w;9z gl(sH,rJ){3y op[sH+rJ]?op[sH+rJ]:op[sH+rJ]=2y dC('(^|\\\\s)[-\\\\w]*'+rJ+'(_\\\\w+)?'+'_'+sH+'(_\\\\w+)?'+'(|$)','g')};8y k=7x40],_[654],_[514] ];9z gx(ol,sH,cA,rJ){8y om=ol7x58x(rJ),rG=gf(ol,_[80])7x2068x2w,p=rG7x18x?rG7x188x(/\\s+/g):2x,te=rJ?'3v'+rJ:'',tB=(ol7x608x?ol7x608x+'-':'')+ol7x388x,cu=sH9w_[234]3wnU7x2518x;0y(om){0y(cu){8y nM=eG(om),nt=1w,kS,lc,sk;0y(cu)8z(kS=0,lc=k7x18x;kS<lc;kS2v)nt[sk=k[kS8x=eL(om,sk,nM)}8y sP=cw3wnh<8?om7x898x:om7x818x(_[80])4w'',cc=sP7x108x(gl(sH,te)),tc,rG,sL;0y(cA){0y(!cc){8y X=sP7x88x(/_\\w+_\\w+/g,'')7x108x(/_\\w+/g),M=0w;0y(X)8z(8y kS=0,lc=X7x18x,nB=1w;kS<lc;kS2v){tc=X[kS];0y(!nB[tc]){0y(p)8z(8y jY=0;jY<p7x18x;jY2v){rG=p[jY];M7x38x(' '+tB+'-'+rG+te+'_'+sH+tc+' '+tB+'-'+rG+te+tc+'_'+sH+' '+rG+te+'_'+sH+tc+' '+rG+te+tc+'_'+sH)}M7x38x(' '+tB+te+'_'+sH+tc);M7x38x(' '+tB+te+tc+'_'+sH);nB[tc]=3x}}0y(p)8z(8y jY=0;jY<p7x18x;jY2v){rG=p[jY];M7x38x(' '+tB+'-'+rG+te+'_'+sH+' '+rG+te+'_'+sH)}M7x38x(' '+tB+te+'_'+sH);sL=M7x248x('');0y(cw3wnh<8)om7x898x0vsL;7z om7x908x(_[80],sP+sL)}}7z{0y(cc){sL=sP7x88x(gl(sH,te),'');0y(cw3wnh<8)om7x898x=sL;7z om7x908x(_[80],sL)}}0y(cu){8y qb=1w,W=0w,cj=1x,kS,lc,sk,tK;0y(cu)8z(kS=0,lc=k7x18x;kS<lc;kS2v){sk=k[kS];tK=eL(om,sk,nM);0y(nt[sk]9wtK){W7x38x(sk);fn(om,sk,nt[sk]);qb[sk]=tK;0y(!cj)cj=3x}}0y(cj){hn(ol,qb,_[566],_[98],9z2w{8z(8y kS=0;kS<W7x18x;kS2v)fn(om,W[kS],'')},rJ)}}}};dg9x7x7428x=9z(sH,cp,rJ){gx(5x,sH,cp,rJ)};dg9x7x7448x=9z(sH){8y om=5x7x58x2w;3y om?eL(om,jv(sH),om7x138x):''};dg9x7x3808x=9z(sH,tK){8y om=5x7x58x2w;0y(om)fn(om,jv(sH),tK)};dg9x7x3638x=9z(sH){8y om=5x7x58x2w;3y om?eL(om,jv(sH)):''};dg9x7x3268x=9z(cr){8y om=5x7x58x2w;0y(om){0y(om7x3268x)om7x3268x(cr4w1x);7z1w}};8y dk=9z2w1w;dk9x=2y dv;dk9x7x78x=5;8y dd=9z2w1w;dd9x=2y dv;dd9x7x78x=9;dd9x7x458x=_[653];dd9x7x358x=2x;dd9x7x7438x=2x;dd9x7x5538x=2x;dd9x7x7548x=2x;dd9x7x1758x=2x;dd9x7x7558x=2x;dd9x7x7668x=2x;dd9x7x7658x=2x;dd9x7x7678x=2x;dd9x7x7688x=2x;8y kr=0,oc=1w,od=1w;dd9x7x7708x=9z(sH){3y fO(5x,2x,sH)};9z fO(ob,sI,tg){4y 2y cX(cX7x98x)};dd9x7x7698x=9z(sI,tg){3y fO(5x,sI,tg)};9z fT(ob,rM){8y px=2y dS;px7x228x=ob;px7x218x=rM;px7x68x=rM;px7x18x=rM7x18x;3y px};dd9x7x4868x=9z(rM){0y(!4x7x18x)rM='';3y fT(5x,dQ(rM))};9z fP(ob,rM){8y px=2y cP;px7x228x=ob;px7x218x=rM;px7x68x=rM;px7x18x=rM7x18x;3y px};dd9x7x7648x=9z(rM){0y(!4x7x18x)rM='';3y fP(5x,dQ(rM))};dd9x7x7638x=9z(rM){4y 2y cX(cX7x98x)};dd9x7x1368x=9z(sH){3y fR(5x,5x7x358x7x338x,sH)};9z fR(ob,sI,tg){8y Y=tg7x188x(':'),sn=Y7x528x2w,tb=Y7x528x2w4w2x,fH=jB[sI+'#'+sn],ol=2y(fH4wdg),sH;ol7x28x=1w;ol7x228x=ob;ol7x608x=tb;ol7x458x=tg;ol7x2548x=tg;ol7x148x=2y dw;ol7x238x='ele_'+kr2v;0y(fH){8z(sH 0z fH7x28x)0y(fH7x28x7x268x(sH))ol7x28x[sH]=fH7x28x[sH]}7z{ol7x338x=sI;ol7x388x=sn}3y ol};dd9x7x7588x=9z(sI,tg){3y fR(5x,sI,tg)};dd9x7x7578x=9z(sH){4y 2y cX(cX7x98x)};dd9x7x7568x=9z(sH){8y fH=jB[sH7x88x(/s$/,'')];0y(fH3w(fH6wdm4wfH9x 1y dm))3y 2y fH;7z 4y 2y cX(cX7x98x)};dd9x7x7598x=9z(sI,tG){3y 3x};9z fQ(ob){8y px=2y de;px7x228x=ob;px7x148x=2y dw;3y px};dd9x7x5058x=9z2w{3y fQ(5x)};9z fS(ob,tC,rM){8y px=2y dA;px7x228x=ob;px7x458x=px7x288x=tC;px7x218x=px7x68x=rM;3y px};dd9x7x7608x=9z(tC,rM){3y fS(5x,tC,rM)};dd9x7x5048x=9z(sg){3y od[sg]4w2x};dd9x7x708x=9z(tB){3y gj(5x,tB)};dd9x7x5038x=9z(sI,sn){3y gk(5x,sI,sn)};9z fU(ob,om,bR,pO,bP){8y px=2x;6y(om7x78x){2z 1:8y sI=om7x338x,sn=om7x388x4wom7x5028x;0y(bY3wsI6wsG+'#')sI=sG;0y(cw3w!sI)sI=(9z(px){9y(px=px7x48x)0y(px7x78x6w5)1z;0y(px3wpx7x48x)3y px7x48x7x338x;3y 2x})(om);0y(sI6wsB){0y(sn6w_[524]){8y se=jt(om7x818x(_[142]),hN(pO)),qq=eQ(se,_[300]),qs;0y(qs=eK(qq)){om=qs7x358x;0y(!om7x818x(_[180]))om7x908x(_[180],se);px=fU(ob,om,bR,pO,bP)}7z{om=om7x708x('*')[0];0y(om){0y((om7x388x4wom7x5028x)7x1858x2w6w_[694]3wom7x338x6wsI){0y(om7x258x)px=fU(ob,om7x708x('*')[0]4wom7x148x[0],bR,pO,bP)}}}}}7z{px=fR(ob,sI,om7x458x);8y ns=px7x28x,d=om7x28x,nr,sH,tK;8z(8y kS=0,lc=d7x18x;kS<lc;kS2v){nr=d[kS];sH=nr7x458x;tK=nr7x218x;0y(bY3wtK6wsG+'#')tK=sG;0y(sH7x178x('on')6w0){7y{px[sH]=2y _b(sI6wsy?_[650]:_[69],bP?jq(tK):tK)}3z(pa)1w}7z ns[sH]=bP?tK:jr(tK)}8y fH=jB[sI+'#'+sn];0y(fH){8z(sH 0z fH7x28x)0y(fH7x28x7x268x(sH)3w!(sH 0z ns))ns[sH]=fH7x28x[sH]}0y(pO)hI(pO,px);0y(bR)8z(8y kS=0,lc=om7x148x7x18x;kS<lc;kS2v)fU(ob,om7x148x[kS],bR,px,bP);3y px}1z;2z 5:8z(8y kS=0,lc=om7x148x7x18x;kS<lc;kS2v)fU(ob,om7x148x[kS],bR,pO,bP);1z;2z 3:8y tK=om7x218x;0y(tK7x2068x2w9w''){0y(!bP)tK=jr(tK);0y(pO7x658x 1y cQ)px=fy(pO7x658x,tK);7z px=hI(pO,fT(ob,tK))}1z;2z 4:px=hI(pO,fP(ob,om7x218x));1z;2z 8:1z;2z 7:6y(om7x288x){2z _[100]:1z;2z _[655]:0y(om7x218x7x108x(/href=[\"']([^\"']+)[\"']/)){8y se=dC.$1;0y(om7x218x7x108x(/type=[\"']([^\"']+)[\"']/))0y(dC.$16w_[207]4wdC.$16w_[346]){8y rE=eQ(se,_[207])7x1058x;0y(rE)nx7x938x(eC(rE,se))}}5z:px=hI(pO,fS(ob,om7x458x,om7x218x))}1z;2z 9:2z 10:5z:4y 2y cX(cX7x98x)}3y px};dd9x7x3568x=9z(px,bR){0y(px7x78x6w1)3y fU(5x,px,bR);7z 4y 2y cX(cX7x98x)};dd9x7x7628x=9z(px){4y 2y cX(cX7x98x)};dd9x7x7618x=9z2w{4y 2y cX(cX7x98x)};dd9x7x7378x=9z(px,sI,tg){4y 2y cX(cX7x98x)};9z fV(ob,ol){0y(ol7x78x6w13w!oc[ol7x238x]){oc[ol7x238x]=ol;8y sg=ol7x28x.id;0y(sg){od[sg]=ol}0y(nU7x2538x){8y om=ol7x58x2w;0y(om)ol7x138x=om7x138x}8z(8y sH 0z ol7x28x){0y(ol7x28x7x268x(sH)){8y Y=sH7x188x(':'),sn=Y7x528x2w,tb=Y7x528x2w4w2x,sI;0y(sH9w_[49]3wtb3wtb9w_[49]3w(sI=hT(ol,tb))){8y fH=jB[sI+'#'+'@'+sn];0y(fH){8y nr=2y fH;nr7x228x=ob;nr7x538x=ol;nr7x718x=nr7x458x=sH;nr7x1048x=nr7x218x=ol7x28x[sH];nr7x388x=sn;nr7x608x=tb;nr7x338x=sI;or=2y du;or7x468x(_[44],1x,1x,2x,2x,2x,2x,2x);or7x288x=or7x678x=nr;or7x798x=dm7x1238x;hQ(nr,or)}}}}8y pe=ol7x1068x,kS,px;0y(pe){pe7x48x=ol;8z(kS=0;px=pe7x148x[kS];kS2v)fV(ob,px)}8y or=2y du;or7x468x(_[44],1x,1x,2x,2x,2x,2x,2x);hL(ol,or);8z(kS=0;px=ol7x148x[kS];kS2v)fV(ob,px)}};9z fW(ob,ol){0y(ol7x78x6w13woc[ol7x238x]){8y or=2y du;or7x468x(_[94],1x,1x,2x,2x,2x,2x,2x);hL(ol,or);0y(nU7x2538x)6z ol7x138x;6z oc[ol7x238x];0y(ol7x28x.id)6z od[ol7x28x.id];8y pe=ol7x1068x,kS,px;8z(kS=0;px=ol7x148x[kS];kS2v)fW(ob,px);0y(pe){8z(kS=0;px=pe7x148x[kS];kS2v)fW(ob,px);pe7x48x=2x}}};8y dA=9z2w1w;dA9x=2y dv;dA9x7x78x=7;dA9x7x68x=2x;dA9x7x288x=2x;8y de=9z2w1w;de9x=2y dv;de9x7x78x=11;de9x7x458x=_[660];8y cQ=9z2w1w;cQ9x=2y dv;cQ9x7x68x=2x;cQ9x7x18x=0;9z fy(px,rM){8y tN=px7x68x;px7x68x0vrM;px7x18x=px7x68x7x18x;px7x218x=px7x68x;0y(tN9wpx7x68x){8y or=2y du;or7x468x(_[124],3x,1x,2x,tN,px7x68x,2x,2x);hL(px,or)}};cQ9x7x3408x=9z(rM){fy(5x,rM)};9z fz(px,lq,lc){8y tN=px7x68x;px7x68x=px7x68x7x1448x(0,lq)+px7x68x7x1448x(lq,lq+lc);px7x18x=px7x68x7x18x;px7x218x=px7x68x;0y(tN9wpx7x68x){8y or=2y du;or7x468x(_[124],3x,1x,2x,tN,px7x68x,2x,2x);hL(px,or)}};cQ9x7x3428x=9z(lq,lc){0y(lq>5x7x18x4wlq<04wlc<0)4y 2y cX(cX7x1018x);fz(5x,lq,lc)};9z fA(px,lq,rM){8y tN=px7x68x;px7x68x=px7x68x7x1448x(0,lq)+rM+px7x68x7x1448x(lq);px7x18x=px7x68x7x18x;px7x218x=px7x68x;0y(tN9wpx7x68x){8y or=2y du;or7x468x(_[124],3x,1x,2x,tN,px7x68x,2x,2x);hL(px,or)}};cQ9x7x3438x=9z(lq,rM){0y(lq>5x7x18x4wlq<0)4y 2y cX(cX7x1018x);fA(5x,lq,rM)};9z fB(px,lq,lc,rM){8y tN=px7x68x;px7x68x=px7x68x7x1448x(0,lq)+rM+px7x68x7x1448x(lq+lc);px7x18x=px7x68x7x18x;px7x218x=px7x68x;0y(tN9wpx7x68x){8y or=2y du;or7x468x(_[124],3x,1x,2x,tN,px7x68x,2x,2x);hL(px,or)}};cQ9x7x3458x=9z(lq,lc,rM){0y(lq>5x7x18x4wlq<04wlc<0)4y 2y cX(cX7x1018x);fB(5x,lq,lc,rM)};9z fC(px,lq,lc){3y 5x7x68x7x1448x(lq,lq+lc)};cQ9x7x7368x=9z(lq,lc){0y(lq>5x7x18x4wlq<04wlc<0)4y 2y cX(cX7x1018x);3y fC(5x,lq,lc)};cQ9x7x58x=9z2w{8y pO=5x7x48x,pg;3y pO3w(pg=(pO7x58x(_[176])4wpO7x58x2w))?pg7x148x[pO7x148x7x888x(5x)]:2x};8y dS=9z2w1w;dS9x=2y cQ;dS9x7x78x=3;dS9x7x458x=_[520];dS9x7x7148x=1x;dS9x7x7138x=2x;dS9x7x7128x=9z(lq){0y(lq>5x7x18x4wlq<0)4y 2y cX(cX7x1018x);8y rM=fC(5x,lq,5x7x18x);go(5x7x48x,fT(5x7x228x,rM),5x);8y tN=5x7x68x;5x7x68x=5x7x218x=rM;5x7x18x=rM7x18x;0y(tN9wrM){8y or=2y du;or7x468x(_[124],3x,1x,2x,tN,rM,2x,2x);hL(5x,or)}8y px=5x7x58x2w;0y(px)px7x218x=5x7x68x};dS9x7x3408x=9z(rM){cQ9x7x3408x7x328x(5x,rM);8y px=5x7x58x2w;0y(px)px7x218x=5x7x68x};dS9x7x3428x=9z(lq,lc){cQ9x7x3428x7x328x(5x,lq,lc);8y px=5x7x58x2w;0y(px)px7x218x=5x7x68x};dS9x7x3438x=9z(lq,rM){cQ9x7x3438x7x328x(5x,lq,rM);8y px=5x7x58x2w;0y(px)px7x218x=5x7x68x};dS9x7x3458x=9z(lq,lc,rM){cQ9x7x3458x7x328x(5x,lq,lc,rM);8y px=5x7x58x2w;0y(px)px7x218x=5x7x68x};dS9x7x7158x=9z(rM){8y tN=5x7x68x;5x7x68x=5x7x218x=rM;5x7x18x=rM7x18x;0y(tN9wrM){8y or=2y du;or7x468x(_[124],3x,1x,2x,tN,rM,2x,2x);hL(5x,or)}};dS9x7x978x=9z2w{3y 5x7x218x};8y cP=9z2w1w;cP9x=2y dS;cP9x7x78x=4;cP9x7x458x=_[646];8y cT=9z2w1w;cT9x=2y cQ;cT9x7x78x=8;cT9x7x458x=_[630];8y cR=9z2w1w;cR9x7x7168x=2x;cR9x7x7188x=2x;cR9x7x1738x=2x;cR9x7x5108x=9z(tG)1w;cR9x7x3018x=9z(tG,tT)1w;cR9x7x5098x=9z(tG)1w;8y db=9z2w{5x7x1738x=2y da};db9x7x1468x=_[72];db9x7x7178x=_[690];db9x7x1738x=2x;db9x7x5098x=9z(rX){6z 5x7x1738x[rX]};db9x7x3018x=9z(rX,tT){5x7x1738x[rX]=tT};db9x7x5108x=9z(rX){3y 5x7x1738x[rX]4w2x};db9x7x7118x=9z(pl,lb,mV){oh7x938x(pl);oh7x138x7x3118x=(lb4w0)+'px';oh7x138x7x3548x=(mV4w0)+'px'};db9x7x7108x=9z(ol){oh7x938x(ol)};8y dU=9z2w1w;dU9x7x198x=2x;dU9x7x208x=2x;dU9x7x3158x=2x;dU9x7x3178x=2x;dU9x7x3188x=2x;dU9x7x368x=2x;dU9x7x378x=2x;8y dW=9z2w1w;dW9x7x18x=0;dW9x7x1528x=9z(kS){0y(kS<5x7x18x3wkS5v0)3y 5x[kS];7z 4y 2y cX(cX7x1018x)};8y lo=0,re=/\\s*,\\s*/;9z hF(z,th,iD,cd){8y G=2y dw,e=z,bj=th7x188x(re),tu,mq,bi;8z(mq=0;mq<bj7x18x;mq2v){0y(tu=hD(bj[mq])){z=e;0y(tu7x108x(/^\\s*\\*#([-_a-z0-9]+)$/i)){z=0w;8z(8y ol=od[dC.$1],px=ol;px;px=px7x48x){8z(8y kS=0,lc=e7x18x;kS<lc;kS2v)0y(e[kS]6wpx){z=[ol];1z}0y(z7x18x)1z}}7z{bi=hH(tu);8y kS=0,tF,rW,rw,bF,bG;9y(kS<bi7x18x){tF=bi[kS2v];rW=bi[kS2v];rw='';bF=bi[kS]6w'(';bG=bi[kS-1]6w'[';0y(bF4wbG){0y(bG)kS3v;9y(bi[kS2v]9w(bF?')':']')3wkS<bi7x18x)rw0vbi[kS];rw=rw7x398x(0,-1)}0y(5y rW6w_[63])4y 2y cX(cX7x968x,hF7x518x7x518x);z=hG(z,tF,rW,rw,iD)}}8z(kS=0;kS<z7x18x;kS2v){0y(z[kS].e9wlo){G[G7x18x2v]=z[kS];0y(cd)3y G;z[kS].e=lo}}}7z 4y 2y cX(cX7x968x,hF7x518x7x518x);8z(8y kS=0;kS<G7x18x;kS2v)6z G[kS].e;lo2v}3y G};8y rj=/::|[\\s#.:>+~2w@\\[\\8x|[^\\s#.:>+~2w@\\[\\8x+/g,ri=/^[^\\s>+~]/;9z hH(tu){0y(ri7x738x(tu))tu=' '+tu;3y tu7x108x(rj)4w0w};9z hG(z,tF,rW,rw,iD){8y be=0w;0y(pD[tF])pD[tF](be,z,rW,rw,iD);7z 4y 2y cX(cX7x968x,hF7x518x7x518x);3y be};8y rh=/^('[^']*')|(\"[^\"]*\")$/;9z hA(tz){3y rh7x738x(tz)?tz7x398x(1,-1):tz};9z hy(ol){9y(ol=ol7x478x)0y(ol7x78x6w1)3y ol;3y 2x};9z hz(ol){9y(ol=ol7x648x)0y(ol7x78x6w1)3y ol;3y 2x};9z hB(ol,tg,iD){0y(iD){8y Y=tg7x188x('|'),sn=Y7x528x2w,tb=Y7x528x2w4w2x;3y(sn6w'*'4wol7x388x6wsn)3w(tb6w2x4wtb6w'*'4wol7x338x6wiD(tb))}3y tg6w'*'4wol7x2548x6wtg7x88x('|',':')};8y pD=1w,pE=1w,pC=1w;8y rk=/\\s*([\\s>+~(]|^|$)\\s*/g,rg=/([\\s>+~]|[^(]\\+|^)([#.:@])/g,rc=/([^(]|^)(\\[[^\\8x+)/g;9z hD(tu){3y dQ(tu)7x88x(rk,'$1')7x88x(rc,'$1@$2')7x88x(rg,'$1*$2')};pD[' ']=9z(be,z,tB,rw,iD){8y ol,kS,kU,bn;8y Y=tB7x188x('|'),sn=Y7x528x2w,tb=Y7x528x2w4w2x;8z(kS=0;ol=z[kS];kS2v){0y(tb6w2x)bn=gj(ol,sn);7z 0y(tb6w'*')bn=gk(ol,'*',sn);7z 0y(iD)bn=gk(ol,iD(tb),sn);7z bn=gj(ol,tB7x88x('|',':'));8z(kU=0;ol=bn[kU];kU2v)be7x38x(ol)}};pD['#']=9z(be,z,sg){8z(8y kS=0,ol;ol=z[kS];kS2v)0y(gf(ol,'id')6wsg)be7x38x(ol)};pD['.']=9z(be,z,sH){8y qU=2y dC('(^|\\\\s)'+sH+'(\\\\s|$)');8z(8y kS=0,ol,tK;ol=z[kS];kS2v)0y(tK=gf(ol,_[80]))0y(qU7x738x(tK))be7x38x(ol)};pD[':']=9z(be,z,rG,rw){8y iY=pE[rG]4wdx7x868x[rG];0y(!(iY 1y _b)){iY=hE;rw=rG}8z(8y kS=0,ol;ol=z[kS];kS2v)0y(iY(ol,rw))be7x38x(ol)};9z hE(ol,rG){0y(ol7x78x6w1){8y om=ol7x58x2w;0y(om3w(cw3wnh<8?om7x898x:om7x818x(_[80])4w'')7x108x(gl(rG,'')))3y 3x}3y 1x};pD['::']=9z(be,z,td)1w;pE7x5088x=9z(ol){3y 1x};pD['>']=9z(be,z,tB,rw,iD){8z(8y kS=0,ol;ol=z[kS];kS2v)8z(8y kU=0,bn=ol7x148x;ol=bn[kU];kU2v)0y(hB(ol,tB,iD))be7x38x(ol)};pD['+']=9z(be,z,tB,rw,iD){8z(8y kS=0,ol;ol=z[kS];kS2v)0y((ol=hy(ol))3whB(ol,tB,iD))be7x38x(ol)};8y rd=/(([\\w-]+)(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\8x*)/;pD['@']=9z(be,z,tz,rw,iD){8y G;0y(G=rw7x108x(rd)){8y ry=G[1],tb=G[3]?G[2]:2x,sn=G[3]?G[3]7x278x(1):ry,sI=2x,rI=G[4]4w'',tK=hA(G[5])4w'',fG=pC[rI];0y(fG){0y(tb9w2x){0y(iD)sI=iD(tb);7z sn=ry7x88x('|',':')}8z(8y kS=0,ol;ol=z[kS];kS2v)0y(gn(ol,sI,sn)3wfG(gg(ol,sI,sn),tK))be7x38x(ol)}7z 4y 2y cX(cX7x968x,hF7x518x7x518x)}};pE7x6888x=9z(ol){3y hz(ol)?1x:3x};pE7x3138x=9z(ol,rH){8y rq=2y dC('^'+rH,'i');9y(ol3wol7x48x9wol7x228x3w!gf(ol,_[496])3w!gf(ol,_[313]))ol=ol7x48x;3y ol3wrq7x738x(gf(ol,_[496])4wgf(ol,_[313]))};8y rf=/([\\/2w[\\]?1w|*+-])/g;9z hx(tK){3y tK7x88x(rf,'\\\\$1')};pC=1w;pC['']=9z(ry){3y 3x};pC['=']=9z(ry,tK){3y ry6wtK};pC['~=']=9z(ry,tK){8y rq=2y dC('(^|)'+hx(tK)+'(|$)');3y rq7x738x(ry)};pC['|=']=9z(ry,tK){8y rq=2y dC('(^|-)'+hx(tK)+'(-|$)');3y rq7x738x(ry)};pC['9w']=9z(ry,tK){3y ry9wtK};pD['~']=9z(be,z,tB,rw,iD){8z(8y kS=0,ol;ol=z[kS];kS2v)9y(ol=ol7x478x)0y(ol7x78x6w13whB(ol,tB,iD))be7x38x(ol)};pE7x3278x=9z(ol,tD){3y hA(tD)7x178x(hO(ol))9w-1};pE7x6858x=9z(ol){3y ol6wol7x228x7x358x};pE7x4038x=9z(ol){3y!ol7x2248x2w};pE7x6978x=9z(ol){3y hy(ol)?1x:3x};pE7x6758x=9z(ol){8z(8y kS=0,px;px=ol7x48x7x148x[kS];kS2v)0y(px7x78x6w13wpx9wol)3y 1x;3y 3x};pE7x3168x=9z(ol,tu){8z(8y kS=0,L=hF([ol7x228x],tu);kS<L7x18x;kS2v)0y(L[kS]6wol)3y 1x;3y 3x};pE7x5928x=9z(ol,rw){3y hC(ol,rw,3x)};pE7x5878x=9z(ol,rw){3y hC(ol,rw)};pE7x288x=9z(ol){3y gm(ol,'id')3wgf(ol,'id')6wqK7x2888x7x398x(1)};pC['^=']=9z(ry,tK){3y ry7x178x(tK)6w0};pC['$=']=9z(ry,tK){3y ry7x178x(tK)6wry7x18x-tK7x18x};pC['*=']=9z(ry,tK){3y ry7x178x(tK)9w-1};9z hC(ol,rw,cv){6y(rw){2z 'n':3y 3x;2z _[618]:rw='2n';1z;2z _[617]:rw='2n+1'}8y t=ol7x48x7x148x,o=0w;8z(8y kS=0;kS<t7x18x;kS2v)0y(t[kS]7x78x6w1)o7x38x(t[kS]);9z fD(kS){3y o[cv?kS-1:o7x18x-kS]6wol};0y(!hh(rw))3y fD(rw);8y b=rw7x188x('n'),lk=b[0]*1,mw=b[1]*1;0y((hh(lk)4wlk6w1)3wmw6w0)3y 3x;0y(lk6w03w!hh(mw))3y fD(mw);0y(hh(mw))mw=0;8y kc=1;9y(ol=(cv?ol7x648x:ol7x478x))0y(ol7x78x6w1)kc2v;0y(hh(lk)4wlk6w1)3y cv?mw5vkc:kc4vmw;3y kc%lk6wmw};8y dx=9z2w1w;dx7x868x=1w;dg9x7x2988x=dd9x7x2988x=dx9x7x2988x=9z(rE,iD){8y O=hF([5x],rE,iD,3x);3y O7x18x?O[0]:2x};dg9x7x2968x=dd9x7x2968x=dx9x7x2968x=9z(rE,iD){3y hF([5x],rE,iD)};dx7x868x7x3878x=9z(ol){3y gm(ol,_[387])3wgf(ol,_[387])6w_[128]};dx7x868x7x6148x=9z(ol){3y!gm(ol,_[182])4wgf(ol,_[182])9w_[128]};dx7x868x7x1828x=9z(ol){3y gm(ol,_[182])3wgf(ol,_[182])6w_[128]};dx7x868x7x4918x=9z(ol){3y ol7x4918x};dx7x868x7x2058x=9z(ol){3y!gS(ol)};dx7x868x7x6158x=9z(ol){3y gS(ol)};dx7x868x7x6268x=9z(ol){3y ol7x2918x3wol7x2918x7x18x};dx7x868x7x1108x=9z(ol){3y ol7x2938x3wol7x2938x7x18x};8y N=0w,ln=0,lm=0,pB=1w,pA=1w;pA7x5668x=200;pA7x1338x=400;pA7x6098x=600;9z hn(ol,qb,tU,ub,hd,tc){8y om=tc3wtc7x228x6wqJ?tc:ol7x58x(tc);0y(!om)3y;8y oj=1w,nM=eG(om),tK;oj.h=ol;oj.d=om;oj.g=hh(tU)?pA[tU]4wpA7x1338x:tU;oj.c=hd;oj.w=ub4w'';oj.q=2y dc;oj.f=1w;oj.j=lm2v;8y sH;8z(8y sk 0z qb)0y(qb7x268x(sk)){tK=''+qb[sk];0y(sk6w_[85]4wsk6w_[84])oj.f[sk]=[[om[sk8x,[tK8x;7z oj.f[sH=jv(sk)]=[hm(ez(om,sH,eL(om,sH,nM))),hm(ez(om,sH,tK))]}8z(8y kS=0,ok;ok=N[kS];kS2v)0y(ok.d6wom)8z(8y sk 0z ok.f)0y(ok.f7x268x(sk)3woj.f[sk])6z ok.f[sk];8y oE=2y dm;oE7x508x(_[453],1x,1x);hL(ol,oE);0y(!ln)ln=iZ(hl,20);N7x38x(oj);3y oj.j};9z hq(kG){8z(8y kS=0,oj;oj=N[kS];kS2v)0y(oj.j6wkG)1z;0y(!oj)3y;8y nV,bw;8z(8y sk 0z oj.f)0y(oj.f7x268x(sk)){nV=oj.f[sk];bw=nV[1];0y(sk6w_[85]4wsk6w_[84])oj.d[sk]=bw[0];7z{0y(bw3wbw[1]6w'#')bw=ht(bw[0]);7z 0y(sk6w_[208])bw=[bw[0][0],bw[1],' ',bw[0][1],bw[18x;fn(oj.d,sk,bw7x248x(''))}}8y oD=2y dm;oD7x508x(_[454],1x,1x);hL(oj.h,oD);hp(kG)};9z hj(ol,tU)1w;9z hl2w{8z(8y kS=0,oj,mU=2y dc;oj=N[kS];kS2v){0y(!oc[oj.h7x238x]){hp(oj.j);kS3v}7z{0y(mU-oj.q5voj.g){hq(oj.j);kS3v;0y(oj.c)oj.c7x328x(oj.h)}7z{oj.v=mU;ho(oj)}}}ln=N7x18x?iZ(hl,20):0};9z ho(oj){8y kD=oj.g,ub=oj.w,lH=0;0y(kD){8y lI=(oj.v-oj.q)/kD;0y(ub 1y _b)lH=ub(lI);7z 0y(5y ub6w_[91]3wub7x178x(_[610])6w0)1w7z{6y(ub){2z _[601]:lH=lI;1z;2z _[612]:2z _[623]:lH=hi(lI,0.42,0,1,1,kD);1z;2z _[415]:2z _[591]:lH=hi(lI,0,0,0.58,1,kD);1z;2z _[597]:2z _[594]:lH=hi(lI,0.42,0,0.58,1,kD);1z;5z:lH=hi(lI,0.25,0.1,0.25,1,kD);1z}}}8y nV,bw;8z(8y sk 0z oj.f)0y(oj.f7x268x(sk)){nV=oj.f[sk];bw=hs(nV[0],hk(hr(nV[1],nV[0]),lH));0y(sk6w_[85]4wsk6w_[84])oj.d[sk]=bw[0];7z{0y(bw[1]6w'#')bw=ht(bw[0]);7z 0y(sk6w_[208])bw=[bw[0][0],bw[1],' ',bw[0][1],bw[18x;fn(oj.d,sk,bw7x248x(''))}}};9z hp(kG){8z(8y kS=0,oj,bW=1x;oj=N[kS];kS2v)0y(bW)N[kS-1]=oj;7z 0y(oj.j6wkG)bW=3x;0y(bW)N7x18x3v};9z hm(tK){0y(!tK)3y 2x;tK=tK7x2068x2w;8y bw,kS,tM=tK7x1858x2w;0y(tM 0z jz)tK=jz[tM];0y(tK6w_[495])3y [[1,1,1],'#',''];0y(bw=tK7x108x(/^#([\\da-f]{3})$/i))3y [[_c(bw[1]7x278x(0,1),16)/15,_c(bw[1]7x278x(1,1),16)/15,_c(bw[1]7x278x(2,1),16)/15],'#',''];0y(bw=tK7x108x(/^#([\\da-f]{6})$/i))3y [[_c(bw[1]7x278x(0,2),16)/255,_c(bw[1]7x278x(2,2),16)/255,_c(bw[1]7x278x(4,2),16)/255],'#',''];0y(bw=tK7x108x(/^(\\w+[\\w\\d]+)\\((.+)\\)$/)){8y rZ=bw[1],sV=bw[2];0y(bw[1]6w_[588]){0y(bw=sV7x108x(/^(\\d+),\\s*(\\d+),\\s*(\\d+)$/))3y [[bw[1]/255,bw[2]/255,bw[3]/255],'#',''];7z 0y(bw=sV7x108x(/^(\\d+)%,\\s*(\\d+)%,\\s*(\\d+)%$/))3y [[bw[1]/100,bw[2]/100,bw[3]/100],'#','']}7z 0y(bw[1]6w_[596]){0y(bw=sV7x108x(/^(\\d+),\\s*(\\d+),\\s*(\\d+),\\s*(\\d+)$/))3y [[bw[4]6w0?1:bw[1]/255,bw[4]6w0?1:bw[2]/255,bw[4]6w0?1:bw[3]/255],'#',''];7z 0y(bw=sV7x108x(/^(\\d+)%,\\s*(\\d+)%,\\s*(\\d+)%,\\s*(\\d+)%$/))3y [[bw[4]6w0?1:bw[1]/100,bw[4]6w0?1:bw[2]/100,bw[4]6w0?1:bw[3]/100],'#','']}7z{0y(bw=sV7x188x(/\\s*,\\s*/g)){8z(8y kS=0,qO,qR=[0w,'',''];kS<bw7x18x;kS2v)0y(qO=hm(bw[kS]))qR[0]7x38x(qO[0]);qR[2]=rZ;0y(qR[0]7x18x)3y qR}}}0y(bw=tK7x108x(/^([+-]?\\d*\\.?\\d+)(em|ex|px|0z|cm|mm|pt|pc|%)?$/))3y [dy(bw[1]),bw[2]4w'',''];0y((bw=tK7x188x(/\\s*,\\s*|\\s+/))3wbw7x18x>1){8z(8y kS=0,qO,qR=[0w,'',''];kS<bw7x18x;kS2v){0y(qO=hm(bw[kS])){qR[0]7x38x(qO[0]);qR[1]=qO[1]}}0y(qR[0]7x18x)3y qR}3y [tK,'','']};9z ht(bw){3y ['#',('000000'+(bw[2]*255|(bw[1]*255<<8)|(bw[0]*255<<16))7x488x(16))7x398x(-6)]};9z hs(qP,qQ){0y(qP[0] 1y cH){8z(8y kS=0,bw=0w;kS<qP[0]7x18x;kS2v)bw7x38x(qP[0][kS]+qQ[0][kS]);3y [bw,qQ[1],qQ[28x}7z 3y [qP[0]+qQ[0],qQ[1],qQ[28x};9z hr(qP,qQ){0y(qP[0] 1y cH){8z(8y kS=0,bw=0w;kS<qP[0]7x18x;kS2v)bw7x38x(qP[0][kS]-qQ[0][kS]);3y [bw,qQ[1],qQ[28x}7z 3y [qP[0]-qQ[0],qP[1],qP[28x};9z hk(qO,mT){0y(qO[0] 1y cH){8z(8y kS=0,bw=0w;kS<qO[0]7x18x;kS2v)bw7x38x(qO[0][kS]*mT);3y [bw,qO[1],qO[28x}7z 3y [qO[0]*mT,qO[1],qO[28x};9z hi(t,a,b,c,d,kD){8y cx=3*a,bx=3*(c-a)-cx,ax=1-cx-bx,cy=3*b,by=3*(d-b)-cy,ay=1-cy-by;9z iV(t){3y((ax*t+bx)*t+cx)*t};9z iW(t){3y((ay*t+by)*t+cy)*t};9z iU(t){3y(3*ax*t+2*bx)*t+cx};9z jc(kD){3y 1/(200*kD)};9z ja(x,kI){3y iW(jb(x,kI))};9z jb(x,kI){8y t0,t1,t2,x2,d2,i;9z gK(n){3y n5v0?n:0-n}8z(t2=x,i=0;i<8;i2v){x2=iV(t2)-x;0y(gK(x2)<kI)3y t2;d2=iU(t2);0y(gK(d2)<1e-6)1z;t2=t2-x2/d2}t0=0;t1=1;t2=x;0y(t2<t0)3y t0;0y(t2>t1)3y t1;9y(t0<t1){x2=iV(t2);0y(gK(x2-x)<kI)3y t2;0y(x>x2)t0=t2;7z t1=t2;t2=(t1-t0)/2+t0}3y t2};3y ja(t,jc(kD))};dg9x7x2918x=2x;9z hv(ol){0y(ol.p)6z ol.p;0y(ol.u){fF(ol.u);6z ol.u}gx(ol,_[110],1x)};9z hu(ol){0y(ol.u4wol.p){0y(ol.p)ol.p=ol.p7x1408x2w;hv(ol);8y or=2y dm;or7x508x(_[140],1x,1x);hL(ol,or)}};9z hw(ol,tI,tT,fv){hu(ol);8y or=2y dm;or7x508x(_[141],1x,1x);hL(ol,or);9y(ol7x658x)gr(ol,ol7x658x);gx(ol,_[110],3x);ol.p=2x;ol.u=iZ(9z2w{8y qv=1w;qv7x348x=_[241];qv7x1928x=tI;qv7x68x=tT4w2x;qv7x2218x=_[100];qv7x1458x=9z(ob){hv(ol);ge(ol,fU(ol7x228x,ob7x358x,3x));8y or=2y dm;or7x508x(_[110],1x,1x);hL(ol,or)};qv7x1308x=9z(qq,sr){8y or=2y dm;or7x508x(_[130],1x,1x);hL(ol,or)};ol.p=ii(qv);ol.u=2x},1)};dg9x7x2938x=2x;8y jG=1w;9z js(tH){8y bc=jG[tH]4w(jG[tH]=tH7x108x(/^(([^:\\/?#]+):)?(\\/\\/([^\\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?/));3y [bc[1],bc[3],bc[5],bc[6],bc[88x};9z jt(tH,rB){0y(tH6w''4wtH7x558x(0)6w'#')3y rB;8y bt=js(tH);0y(bt[0])3y tH;8y g=js(rB);bt[0]=g[0];0y(!bt[1]){bt[1]=g[1];0y(bt[2]7x558x(0)9w'/'){8y bu=bt[2]7x188x('/'),h=g[2]7x188x('/');h7x528x2w;8y jO=h[0]6w''?1:0;8z(8y kS=0,lc=bu7x18x;kS<lc;kS2v){0y(bu[kS]6w'..'){0y(h7x18x>jO)h7x528x2w;7z{h7x38x(bu[kS]);jO2v}}7z 0y(bu[kS]9w'.')h7x38x(bu[kS])}0y(bu[3vkS]6w'..'4wbu[kS]6w'.')h7x38x('');bt[2]=h7x248x('/')}}8y bc=0w;0y(bt[0])bc7x38x(bt[0]);0y(bt[1])bc7x38x(bt[1]);0y(bt[2])bc7x38x(bt[2]);0y(bt[3])bc7x38x(bt[3]);0y(bt[4])bc7x38x(bt[4]);3y bc7x248x('')};9z jr(tK){3y tK7x88x(/&(?![a-z]+;)/gi,'&amp;')7x88x(/</g,'&lt;')7x88x(/>/g,'&gt;')7x88x(/\"/g,'&quot;')};9z jq(tK){3y tK7x88x(/&quot;/g,'\"')7x88x(/&lt;/g,'<')7x88x(/&gt;/g,'>')7x88x(/&amp;/g,'&')};9z jw(rE,tH){8y J=rE7x108x(/@namespace\\s+([\\w-]+\\s+)?(url\\2w?(['\"])?[^'\";\\s]+(['\"])?\\)?;?/g);0y(J)8z(8y kS=0;kS<J7x18x;kS2v)rE=rE7x88x(J[kS],'');8y j=rE7x108x(/url\\s*\\([^\\)]+\\)/g);0y(j)8z(8y kS=0,lc=j7x18x,bv;kS<lc;kS2v)0y(bv=j[kS]7x108x(/url\\s*\\(['\"]?([^\\)\"']+)['\"]?\\)/i))rE=rE7x88x(j[kS],_[192]+'(\"'+jt(bv[1],tH)+'\")');8y C=rE7x108x(/@import\\s+url\\s*\\(\\s*['\"]?[^'\"]+['\"]?\\s*\\)\\s*;?/g);0y(C)8z(8y kS=0,lc=C7x18x;kS<lc;kS2v)0y(bv=C[kS]7x108x(/url\\s*\\(['\"]?([^\\)\"']+)['\"]?\\)/i))rE=rE7x88x(C[kS],jw(eQ(bv[1],_[207])7x1058x,bv[1]));0y(cw){0y(nh<8)rE=rE7x88x(/display\\s*:\\s*0zl0ze-block/g,'display:0zl0ze;zoom:1');0y(nh<9)rE=rE7x88x(/(?:[^-])opacity\\s*:\\s*([\\d.]+)/g,9z(sp,lt){3y _[126]+':'+_[492]+':'+_[256]+'('+_[40]+'='+lt*100+');zoom:1'})}7z 0y(bY4wcB4wck){8y rC='$1$2$3-',rt='-$1$2$3';rE=rE7x88x(/(?:\\s|;)(text-overflow\\s*:\\s*)(.+)(\\n|;)/gi,rC+(ck?'o':bY?_[199]:_[290])+rt);0y(!ck){rE=rE7x88x(/(?:\\s|;)(box-shadow\\s*:\\s*)(.+)(\\n|;)/gi,rC+(bY?_[199]:_[290])+rt)7x88x(/(?:\\s|;)(outl0ze-radius\\s*:\\s*)(.+)(\\n|;)/gi,rC+(bY?_[199]:_[290])+rt)7x88x(/(?:\\s|;)(border-radius\\s*:\\s*)(.+)(\\n|;)/gi,rC+(bY?_[199]:_[290])+rt);0y(bY){rE=rE7x88x(/(?:\\s|;)(box-siz0zg\\s*:\\s*)(.+)(\\n|;)/gi,rC+_[199]+rt);rC=rC+'moz-border-radius-';rt=':$2$3';rE=rE7x88x(/(?:\\s|;)(border-top-left-radius\\s*:\\s*)(.+)(\\n|;)/gi,rC+'topleft'+rt)7x88x(/(?:\\s|;)(border-top-right-radius\\s*:\\s*)(.+)(\\n|;)/gi,rC+'topright'+rt)7x88x(/(?:\\s|;)(border-bottom-left-radius\\s*:\\s*)(.+)(\\n|;)/gi,rC+'bottomleft'+rt)7x88x(/(?:\\s|;)(border-bottom-right-radius\\s*:\\s*)(.+)(\\n|;)/gi,rC+'bottomright'+rt)}}}8y j=0w,bg=rE7x108x(/[^{]+{[^}]*}/g);0y(bg){8z(8y kS=0,lc=bg7x18x,bf;kS<lc;kS2v){bf=bg[kS]7x108x(/([^{]+)({[^}]*})/);j7x38x(bf[1]7x88x(/\\|/g,'-')7x88x(/([\\s>+~,]|not\\2w([\\w-])/g,'$1.$2')7x88x(/\\[([\\w-]+)=?([\\w-]+)?\\]/g,'-$1-$2')7x88x(/::/g,'3v')7x88x(/:nth-child\\((\\d+)\\)/g,'_nth-child-$1')7x88x(/:(?!last-child|first-child|not)/g,'_'),bf[2])}rE=j7x248x('')}3y rE};9z jv(sH){8z(8y kS=1,bw=sH7x188x('-');kS<bw7x18x;kS2v)bw[kS]=bw[kS]7x278x(0,1)7x1848x2w+bw[kS]7x278x(1);3y bw7x248x('')};9z ju(tK,tb){8z(8y jH=1w,bx=tK7x188x(';'),kS=0,lc=bx7x18x,bw;kS<lc;kS2v)jH[(bw=bx[kS]7x188x(':'))[08x=(tb4w'')+bw[1];3y jH};9z hc(uc,dX){8y tG=5y uc;6y(dX){2z dQ:3y tG6w_[91]4wuc 1y dX;2z cO:3y tG6w_[573]4wuc 1y dX;2z dy:3y(tG6w_[200]4wuc 1y dX)3w!hh(uc);2z ei:3y uc3w!hh(uc7x78x);2z ee:3y uc3wuc7x78x6w1;2z ed:3y uc3wuc7x78x6w9;2z cG:3y tG6w_[74]3w_[191] 0z uc;5z:3y dX6wdz?3x:uc 1y dX}};8y nw=qJ7x1368x(_[593]),nA=qJ7x358x,nx=2x,nu=2x,jA=ju(_[590]),jz=ju(_[619],'#'),i=2y dw,nz=2x,nv=2x,ny=2x,bI=1x,bH=1x,bJ=3x;9z eA(px,tG,hd){0y(px7x2038x)px7x2038x(tG,hd,1x);7z px7x7058x('on'+tG,hd)};9z eD(px,tG,hd){0y(px7x2978x)px7x2978x(tG,hd,1x);7z px7x7048x('on'+tG,hd)};9z eH(or){3y ev(no,or7x4888x4wor7x288x)4wnp};9z eO(or){8z(8y px=or7x4888x4wor7x288x,sg,rG;px;px=px7x48x){0y((sg=px.id)3woc[sg])3y px;7z 0y((rG=px7x898x)3wdQ(rG4wrG7x7038x)7x108x(/3v[\\w-]+/))3y px}3y 2x};9z eP(px,pO){8z(;px;px=px7x48x)0y(px6wpO)3y 3x;3y 1x};9z eN(or){8y jV=or7x1158x;0y(!cw)3y jV;0y(jV6w4)3y 1;0y(jV6w2)3y 2;3y 0};9z fl(px){0y(px7x78x6w3)3y qJ7x4868x(px7x218x);7z 0y(px7x78x6w1){8y sf=px7x978x2w;0y(sf){0y(cw){0y(sf7x108x(/^<(\\w*:)?(\\w+)/)){8y tB=dC.$2;6y(tB){2z 'td':2z 'th':sf='<tr>'+sf+'</tr>';2z 'tr':sf='<'+_[305]+'>'+sf+'</'+_[305]+'>';2z _[600]:2z _[305]:2z _[616]:sf='<'+_[535]+'>'+sf+'</'+_[535]+'>';1z;2z _[595]:sf='<'+_[360]+'>'+sf+'</'+_[360]+'>';1z}nw7x1678x=sf;3y nw7x708x(tB)[0]4w2x}}7z{0y(!(_[49]+(px7x608x?':'+px7x608x:'')0z px7x28x)4w(px7x338x9wsy3wpx7x338x9wsA))sf=sf7x88x(/^(<(?:(\\w+)(:))?(\\w+))/,'$1 '+_[49]+'$3$2=\"'+(px7x338x6wsy?sy:sA)+'\"');3y qJ7x3568x(fi('<!'+_[521]+' '+_[170]+'['+rD+']>'+sf)7x358x,3x)}}}3y 2x};9z eI(or){3y jA[or7x2508x]4w'U+'+(_[365]+or7x2508x7x488x(16)7x1848x2w)7x398x(-4)};9z eJ(or){8y H=0w;0y(or7x298x)H[H7x18x]=_[158];0y(or7x308x)H[H7x18x]=_[157];0y(or7x418x)H[H7x18x]=_[159];0y(or7x318x)H[H7x18x]=_[153];3y H7x248x(' ')};9z eF(oR,or){0y(or7x438x){0y(oR7x568x)oR7x568x2w;3y 1x}3y 3x};9z fd(or){8y qC=eH(or),qd=eO(or),cl=1x,nj=bY?-40*or7x668x:or7x3708x,oZ=2y ea;0y(qL7x7068x6w_[606])0y(ck4wbY)nj*=3;0y(ck3wnh<2.1)nj*=-1;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w;cl=3x}oZ7x3578x(_[168],3x,3x,6x,2x,or7x368x,or7x378x,or7x198x,or7x208x,eN(or),2x,eJ(or),0,nj,0,0);oZ7x168x=qd;oZ7x3708x=oZ7x2208x;0y(!ny4weP(qC,ny))hL(qC,oZ);7z cl=3x;0y(cl)oZ7x568x2w;3y eF(or,oZ)};9z eW(or){8y qC=nn7x1098x4wnp,qd=eO(or),oG=2y dr;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w}oG7x2498x(_[137],3x,3x,6x,eI(or),2x,eJ(or));oG7x168x=qd;0y(!ny4weP(qC,ny))hL(qC,oG);3y eF(or,oG)};9z eX(or){0y((ck4w(bY3wnh<2))3wbH)eW(or);bH=3x;0y(or7x308x4wor7x298x4wor7x2508x 0z jA)3y;8y qC=nn7x1098x4wnp,qd=eO(or),oH=2y dr,oW=2y dT;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w}oH7x2498x(_[239],3x,3x,6x,eI(or),2x,eJ(or));oH7x168x=qd;oW7x4878x(_[461],3x,3x,6x,dQ7x2558x(or7x7078x4wor7x2508x),1,'');oW7x168x=qd;0y(!ny4weP(qC,ny)){hL(qC,oH);hL(qC,oW);0y(oW7x438x)oH7x568x2w}3y eF(or,oH)};9z eY(or){8y qC=nn7x1098x4wnp,qd=eO(or),oI=2y dr;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w}oI7x2498x(_[229],3x,3x,6x,eI(or),2x,eJ(or));oI7x168x=qd;0y(!ny4weP(qC,ny))hL(qC,oI);bH=1x;3y eF(or,oI)};9z fb(or){8y qC=eH(or),qd=eO(or),jV=eN(or),oP,oO;0y(qC6wnz)3y;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w}0y(!(kv4wmb)){0y(!ny4weP(nz,ny)){0y(nz3woc[nz7x238x]){oO=2y dt;oO7x548x(_[394],3x,3x,6x,2x,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,jV,qC);oO7x168x=qd;hL(nz,oO)}}0y(!ny4weP(qC,ny)){oP=2y dt;oP7x548x(_[225],3x,3x,6x,2x,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,jV,nz);oP7x168x=qd;hL(qC,oP)}}nz=qC};9z eM(qN){8y kS=0,lc=qN7x18x,qI=2y dW,qF,qM;9y(kS<lc){qM=qN7x1528x(kS2v);qF=2y dU;qF7x198x=qM7x198x;qF7x208x=qM7x208x;qF7x3158x=qM7x3158x;qF7x3178x=qM7x3178x;qF7x3188x=qM7x3188x;qF7x368x=qM7x368x;qF7x378x=qM7x378x;qI[qI7x18x2v]=qF}3y qI};9z fh(or){8y qC=eH(or),qd=eO(or),oX=2y dV;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w}oX7x4988x(or7x348x,or7x1258x,or7x1518x,or7x1568x,or7x668x,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,eM(or7x828x),eM(or7x3198x),eM(or7x3148x),or7x1558x,or7x1548x);oX7x168x=qd;0y(!ny4weP(qC,ny))hL(qC,oX);3y eF(or,oX)};9z eV(or){8y qC=eH(or),qd=eO(or),oF=2y dp;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w}oF7x4978x(or7x348x,or7x1258x,or7x1518x,or7x1568x,or7x668x,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,or7x288x,or7x1558x,or7x1548x);oF7x168x=qd;0y(!ny4weP(qC,ny))hL(qC,oF);3y eF(or,oF)};9z eS(or){8y qC=eH(or),qd=eO(or),ot=2y cS;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w}ot7x4948x(or7x348x,or7x1258x,or7x1518x,\"\",2x);ot7x168x=qd;0y(!ny4weP(qC,ny))hL(qC,ot);3y eF(or,ot)};9z fa(or){8y qC=eH(or),qd=eO(or),jV=eN(or),kT=-1,t=2y dw,ol,oN=2y dt,oM,oL;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w}0y(!(kv4wmb)){0y(i[0]9wqC){8z(ol=qC;ol7x78x9w9;ol=ol7x48x){t7x1198x(ol);0y(kT6w-1)kT=i7x888x(ol)}8z(8y kS=0;kS<kT;kS2v){ol=i[kS];0y(!ny4weP(ol,ny)){0y(ol7x2808x3wol7x1628x2w)gx(ol,_[234],1x);oM=2y dt;oM7x548x(_[477],1x,1x,6x,2x,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,jV,i[kS+1]4w2x);oM7x168x=qd;hL(ol,oM)}}8z(8y kS=kT+t7x18x-i7x18x;kS>0;kS3v){ol=t[kS-1];0y(!ny4weP(ol,ny)){0y(ol7x2808x3wol7x1628x2w)gx(ol,_[234],3x);oL=2y dt;oL7x548x(_[395],1x,1x,6x,2x,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,jV,t[kS]4w2x);oL7x168x=qd;hL(ol,oL)}}i=t}}0y(ny3weP(qC,ny))qC=ny;oN7x548x(_[169],3x,3x,6x,2x,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,jV,2x);oN7x168x=qd;hL(qC,oN);3y eF(or,oN)};9z eT(or){8y qC=eH(or),qd=eO(or),cl=1x,ou=2y dt;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w;cl=3x}ou7x548x(_[233],3x,3x,6x,0,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,2,2x);ou7x168x=qd;0y(!ny4weP(qC,ny)){hL(qC,ou);0y(cB){8y oQ=2y dt;oQ7x548x(_[147],3x,3x,6x,or7x668x4w1,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,2x,2,2x);oQ7x168x=qd;hL(qC,oQ)}}7z cl=3x;0y(cl)ou7x568x2w;3y eF(or,ou)};9z eR(or){8y qC=eH(or),qd=eO(or),jV=eN(or),cl=1x,os=2y dt;0y(bY3wor7x1158x6w2)3y;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w;cl=3x}os7x548x(_[194],3x,3x,6x,or7x668x4w1,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,jV,2x);os7x168x=qd;0y(!ny4weP(qC,ny))hL(qC,os);7z cl=3x;0y(cl)os7x568x2w;3y eF(or,os)};9z eU(or){8y qC=eH(or),qd=eO(or),jV=eN(or),ov=2y dt,os;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w}ov7x548x(_[238],3x,3x,6x,or7x668x4w2,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,jV,2x);ov7x168x=qd;0y(!ny4weP(qC,ny)){0y(cw3wnh<9){os=2y dt;os7x548x(_[194],3x,3x,6x,2,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,2x,jV,2x);os7x168x=qd;hL(qC,os)}hL(qC,ov)}};9z eZ(or){8y qC=eH(or),qd=eO(or),jV=eN(or),bN=1x,oK=2y dt;bI=3x;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w;bN=3x}oK7x548x(_[113],3x,3x,6x,or7x668x4w1,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,jV,2x);oK7x168x=qd;0y(!ny4weP(qC,ny)){nn7x1098x=qC;hL(qC,oK)}7z{8y pt=2y dZ;pt7x618x(_[336],3x,1x,6x,2x);pt7x168x=qd;hL(ny,pt);oK7x568x2w}0y(bN){8y nG=2y dZ;nG7x618x(_[218],3x,1x,6x,2x);nG7x168x=qd;hL(qC,nG);oK7x568x2w}0y(oK7x438x)bJ=1x;3y eF(or,oK)};9z fc(or){8y qC=eH(or),qd=eO(or),jV=eN(or),oK,oQ=2y dt;0y(nv3w!eP(qC,nv)){qC=nv;qd=qC7x58x2w}oQ7x548x(_[147],3x,3x,6x,!bI?2:or7x668x4w1,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,or7x418x,jV,2x);oQ7x168x=qd;0y(!ny4weP(qC,ny)){0y((cw3wnh<9)3w!bI){oK=2y dt;oK7x548x(_[113],3x,3x,6x,2,or7x368x,or7x378x,or7x198x,or7x208x,or7x308x,or7x298x,or7x318x,2x,jV,2x);oK7x168x=qd;hL(qC,oK)}hL(qC,oQ)}bI=1x;3y eF(or,oQ)};9z fe(or){8y oS=2y dZ;oS7x618x(_[120],3x,1x,6x,2x);hL(no,oS)};9z ff(or){8y oV=2y dZ;oV7x618x(_[143],3x,1x,6x,2x);hL(no,oV)};9z fg2w{8y cz=bJ;bJ=3x;3y cz};9z fo(bB){0y(cw)bJ=bB;7z{8y qA=nA7x138x;qA7x7098x=qA7x7088x=qA7x7198x=qA7x7208x=qA7x7318x=bB?'':_[72]}};9z fm(pL,pv){pL7x48x7x2138x(pv,pL);pL7x48x7x1328x(pL)};9z eE(tD){8y om=qJ7x708x(_[545])[0]7x938x(qJ7x1368x(_[107]));om7x348x=_[329];om7x2768x=tD;om7x48x7x1328x(om)};9z fi(tD){0y(bY)tD=tD7x88x(2y dC(sG,'g'),sG+'#');3y 2y cZ2w7x5158x(tD,_[300])};9z eK(qq){8y ob=qq7x3108x,tD=qq7x1058x;0y(tD){0y(cw){0y(ob3w!ob7x358x3wqq7x2168x(_[161])7x108x(/[^\\/]+\\/[^\\+]+\\+xml/))ob=fi(tD)}0y(bY)ob=fi(tD)}0y(!ob4w((cw3wnh<93wob7x5198x9w0)4w!ob7x358x4wob7x708x(_[164])7x18x))3y 2x;3y ob};8y rD='',u=_[701]7x188x(';');8z(8y kS=0,lc=u7x18x;kS<lc;kS2v)rD0v'<!'+_[674]+' '+u[kS]+' \"&#'+(160+kS)+';\">';9z eB(tP,rz){3y fi('<!'+_[521]+' '+_[170]+'['+rD+']>'+'<'+_[170]+' '+(rz4w'')+'>'+tP+'</'+_[170]+'>')};9z eC(rE,tH,sq){nw7x1678x=_[520]+'<'+_[13]+' '+_[34]+'=\"'+_[207]+'\"'+(sq?' '+_[352]+'=\"'+sq+'\"':'')+'>'+jw(rE,tH)+'</'+_[13]+'>';3y nw7x148x[1]};9z eQ(tH,rr){8y qq=2y eh;qq7x1318x(_[241],tH,1x);0y(rr)qq7x1168x(_[667],rr+',*'+'/'+'*;q=0.1');qq7x1168x(_[409],_[257]);qq7x1168x(_[404],nU7x3378x);qq7x2228x(2x);3y qq};9z eG(om){3y om7x3788x4w6x7x7308x(om,2x)};9z eL(om,sH,qA){0y(!qA)qA=eG(om);0y(cw3wnh<9){0y(sH6w_[40])3y dQ(dQ(qA7x1268x)7x108x(/opacity=([\\.0-9]+)/i)?om7x3738x7x1528x(_[256])7x408x/100:1);7z 0y(sH6w_[208])3y qA[sH+'X']+' '+qA[sH+'Y'];7z 0y(sH6w_[58]4wsH6w_[42]){8y tK=qA[sH];0y(tK6w_[87]){8y nK=om7x2448x2w;3y dQ(sH6w_[58]?nK7x758x-nK7x118x+(_c(qA7x3118x)4w0)+(_c(qA7x5348x)4w0):nK7x788x-nK7x128x+(_c(qA7x3548x)4w0)+(_c(qA7x5338x)4w0))}3y tK}}0y(sH6w_[666]4wsH6w_[669])3y qA[sH+_[6988x;0y(sH6w_[700])3y qA7x2128x;0y(sH6w_[692])3y qA7x6878x;0y(sH6w_[514]){8y tK=qA[sH];0y(tK6w_[495]3wom7x48x3wom7x48x7x78x6w1)3y eL(om7x48x,sH);3y tK}3y qA[sH]};9z fn(om,sH,tK){8y qA=om7x138x;0y(cw3wnh<9){0y(sH6w_[40]){8y rW=dQ(om7x3788x7x1268x),bV=rW7x108x(/opacity=([\\.0-9]+)/i);0y(tK9w''3wtK<1){0y(!bV){qA7x1268x=rW+' '+_[492]+':'+_[256]+'('+_[40]+'=100)';0y(!om7x3788x7x7328x)om7x138x7x7338x='1'}om7x3738x7x1528x(_[256])7x408x=ds7x5328x(tK*100)}7z 0y(om7x3738x7x18x6w13wbV)qA7x3348x(_[126]);3y}7z 0y(sH6w_[208]){8y bw=(tK4w' ')7x188x(' ');qA[sH+'X']=bw[0];qA[sH+'Y']=bw[1];3y}}0y(sH9w_[40]3wtK7x108x(/^[\\.\\d]+$/))tK=tK+'px';qA[sH]=tK};9z ez(om,sH,tK){0y(sH6w_[40])3y tK6w''?'1':tK;0y(sH6w_[208])3y(tK6w'0%'+' '+'0%'4wtK6w_[72]4wtK6w'')?'0px'+' '+'0px':tK;0y(sH6w_[689]){0y(cw3wnh<93wtK6w_[133])3y eL(om,_[691]);3y tK}0y(sH7x108x(/border(.+)Width/))3y tK6w_[665]?'3px':tK;0y(tK7x108x(/([\\d]*\\.?[\\d]+)%/)){8y qA=om7x138x,sR=qA[sH];qA[sH]=tK;tK=eL(om,sH);qA[sH]=sR;3y tK}0y(sH7x108x(/padd0zg|marg0z|top|left/)4wsH7x108x(/\\w(top|left|bottom|right)/i))3y tK6w_[87]4wtK6w''?'0px':tK;3y tK};9z fj2w{8y ob,pS,pT,t,ol,om,on,nr,ry,tb,d,jy,cm;9z hf(jC){8y d=0w,ry,tb;8z(ry 0z nn7x778x){tb=_[49]+(ry6w''?'':':'+ry);0y(!(tb 0z jC)3wnn7x778x7x268x(ry)3wry9w_[48])jC[tb]=nn7x778x[ry]}8z(ry 0z jC)0y(jC7x268x(ry))d7x38x(ry+'=\"'+jC[ry]+'\"');3y d7x248x(' ')};9z gZ(ol){8y B=0w;8z(8y kS=0,s=ol7x148x;kS<s7x18x;kS2v)B7x38x(s[kS]7x978x2w);3y B7x248x('')};t=qJ7x708x(_[107]);8z(8y kS=0,ms=0,tG,tx,tD;t7x18x>ms;kS2v){om=t[ms];tG=om7x348x;tD=om7x2768x;tx=om7x2118x;0y(tD)tD=tD7x88x(/^\\s*(<!\\[CDATA\\[)?\\s*/,'')7x88x(/\\s*(\\]\\]>)\\s*$/,'');0y(tG6w_[564]4wtG6w_[664]){0y(om7x48x6wnx){ms2v;4z}jy=1w;cm=1x;0y(cw3w(nh<64wnh>8)){0y(d=om7x7358x7x108x(/<script([^\\>]+)/i)[1]7x108x(/[^=]0v(\"[^\"]+\"|[^\\s]+)/gi))8z(8y jN=0;nr=d[jN];jN2v)0y(nr7x108x(/\\s([^=]+)=\"?([^\"]+)\"?/i)3w(ry=dC.$1)9w_[34])jy[ry]=dC.$2}7z{d=om7x28x;8z(8y jN=0;nr=d[jN];jN2v)0y(nr7x5408x3w(ry=nr7x458x7x1858x2w)9w_[34])jy[ry]=ry6w_[13]?om[ry]7x1508x:jr(nr7x218x)}0y(tx){8y qq=eQ(tx,_[300]);ob=eK(qq);cm=3x}7z ob=eB(tD7x88x(/^\\s*<\\?xml.+\\?>/,'')7x88x(/&/g,'&amp;')7x88x(/<script(.|\\n|\\r)+$/,''),hf(jy));pS=ob?ob7x708x(_[164])[0]:2x;0y(ob3wob7x358x3w!pS){0y(cm)0y(!ob7x358x7x818x(_[180]))ob7x358x7x908x(_[180],jt(tx,hN(np)));ol=fU(no,ob7x358x,3x,2x,3x);0y(!cm){8z(ry 0z nn7x778x){tb=_[49]+(ry6w''?'':':'+ry);0y(tb 0z jy3wjy[tb]6wnn7x778x[ry])6z ol7x28x[tb]}}0y(cw){on=qJ7x1368x(_[170]);fm(om,on);on7x1678x=cm?ol7x978x2w:gZ(ol);0y(om7x138x7x1508x)on7x138x7x1508x=om7x138x7x1508x;0y(om7x898x)on7x898x=om7x898x;0y(!cm)on7x908x('id',om7x818x('id')4wol7x238x)}7z{8z(ry 0z jy)0y(jy7x268x(ry)3w(ry7x278x(0,2)6w'on'4wry6w_[211]))6z jy[ry];0y(!cm3w!jy['id'])jy['id']=ol7x238x;on=qJ7x3568x(eB(cm?ol7x978x2w:gZ(ol),hf(jy))7x358x,3x);om7x48x7x2428x(on,om)}hI(np,ol);fV(no,ol)}7z{on=qJ7x1368x(_[641]);fm(om,on);on7x1678x=_[107]+' '+_[164]}}7z 0y(tG6w_[640]4wtG6w_[639]){0y(tx)tD=eQ(tx,_[329]);7y{eE(tD)}3z(pa)1wom7x48x7x1328x(om)}7z ms2v}};9z fk2w{8y t,ol;t=qJ7x708x(_[13]);8z(8y kS=0,lc=t7x18x;kS<lc;kS2v){ol=t[kS];0y(ol7x348x6w_[346])fm(ol,eC(ol7x1678x,qK7x1428x,ol7x818x(_[352])))}t=qJ7x708x(_[508]);8z(8y kS=0,ms=0;t7x18x>ms;kS2v){ol=t[ms];0y(ol7x348x9w_[346])ms2v;7z fm(ol,eC(eQ(ol7x1428x,_[207])7x1058x,ol7x1428x,ol7x818x(_[352])))}};eA(6x,_[110],9z(or){nu=qJ7x5298x;nx=qJ7x708x(_[545])[0];er(_[642]);nu7x938x(nw);nw7x138x7x628x=_[72];eA(6x,_[120],fe);eA(6x,_[143],ff);eA(qJ,_[137],eW);eA(qJ,_[229],eY);eA(qJ,_[239],eX);eA(qJ,_[225],fb);eA(qJ,_[169],fa);eA(qJ,_[233],eT);eA(qJ,_[194],eR);eA(qJ,_[238],eU);eA(qJ,_[113],eZ);eA(qJ,_[147],fc);0y(!bY){eA(nu,_[168],fd);0y(cw)eA(qJ,_[507],fg)}7z eA(nu,_[506],fd);eA(qJ,_[226],fh);eA(qJ,_[227],fh);eA(qJ,_[232],fh);eA(qJ,_[348],fh);eA(qJ,_[341],eV);eA(qJ,_[344],eV);eA(qJ,_[322],eV);eA(qJ,_[214],eS);eA(qJ,_[544],eS);eA(qJ,_[578],eS);eA(qJ,_[571],eS);eA(qJ,_[570],eS);eA(qJ,_[574],eS);0y(cB3w6x7x7348x)eu2w;7z iZ(eu,0)});eA(6x,_[141],9z(or){nu7x1328x(nw);eD(qJ,_[137],eW);eD(qJ,_[229],eY);eD(qJ,_[239],eX);eD(qJ,_[225],fb);eD(qJ,_[169],fa);eD(qJ,_[233],eT);eD(qJ,_[194],eR);eD(qJ,_[238],eU);eD(qJ,_[113],eZ);eD(qJ,_[147],fc);0y(!bY){eD(nu,_[168],fd);0y(cw)eD(qJ,_[507],fg)}7z eD(nu,_[506],fd);eD(qJ,_[226],fh);eD(qJ,_[227],fh);eD(qJ,_[232],fh);eD(qJ,_[348],fh);eD(qJ,_[341],eV);eD(qJ,_[344],eV);eD(qJ,_[322],eV);eD(qJ,_[214],eS);eD(qJ,_[544],eS);eD(qJ,_[578],eS);eD(qJ,_[571],eS);eD(qJ,_[570],eS);eD(qJ,_[574],eS);eD(6x,_[120],fe);eD(6x,_[143],ff);et2w});9z er(tK){nn7x768x=tK;8y qh=2y dm;qh7x508x(_[139],1x,1x);hL(no,qh)};9z eu2w{fk2w;fj2w;er(_[637]);0y(nU7x2538x)np7x138x=nu7x138x;7y{0y(cw3wnh<7)qJ7x7298x(_[631],1x,3x)}3z(pa)1w;8y oJ=2y dm;oJ7x508x(_[110],1x,1x);hL(no,oJ);er(_[193])};9z et2w{8y t=np7x148x,oY;8z(8y kS=0;kS<t7x18x;kS2v){oY=2y dm;oY7x508x(_[141],1x,1x);hL(t[kS],oY)}oY=2y dm;oY7x508x(_[141],1x,1x);hL(no,oY);fW(no,np)};8y jB=1w;8y no=fK(2y cY,sA,_[529],2x),np=no7x358x;np7x58x=9z(sH){3y sH6w_[176]?nu:sH?2x:nA};9z ih(tQ,tR,tS){8y qe=2y dB;0y(4x7x18x>0){0y(5y tQ6w_[91]4wtQ 1y dQ){0y(tQ7x278x(0,1)6w'<'){8y J=0w;8z(8y sk 0z nn7x778x)0y(nn7x778x7x268x(sk)3wsk9w_[48])J7x38x(_[49]+(sk6w''?'':':')+sk+'=\"'+nn7x778x[sk]+'\"');8y ob=eB(tQ,J7x248x(' '));0y(!ob4w((cw3wnh<93wob7x5198x9w0)4w!ob7x358x4wob7x708x(_[164])7x18x))4y 2y cX(cX7x968x,ih7x518x);7z 8z(8y kS=0,t=ob7x358x7x148x;kS<t7x18x;kS2v)0y(t[kS]7x78x6w1)qe[qe7x18x2v]=fU(no,t[kS],3x)}7z{0y(4x7x18x>1)1w7z tR=no;0y(4x7x18x>23wtS9w=2x)1wqe7x18x=0;qe7x5188x=tQ;qe7x5168x=tR;qe7x2798x=tS4w2x;8y bc;7y{bc=hF(tR 1y dv?[tR]:tR,tQ,tS)}3z(pa){pa7x518x=ih7x518x;4y pa}8z(8y kS=0;kS<bc7x18x;kS2v)qe[qe7x18x2v]=bc[kS]}}7z 0y(tQ 1y dg)qe[qe7x18x2v]=tQ;7z 0y(tQ 1y dB)ik(tQ,9z2w{qe[qe7x18x2v]=5x})}3y qe};8y nn=no;nn7x7288x=ih;nn7x778x=1w;nn7x2928x=jB;nn7x1098x=2x;nn7x768x=_[323];8y a=[ _[302],_[382],_[351],_[325],_[349],_[328],_[583],_[350],_[324],_[364],_[384],_[584],_[347],_[2998x;9z es(qC,qx){0y(!qx3wqC 1y _b){8y qc=qC9x;0y(qc 1y dm){8y rT=qc7x598x;0y(a7x178x(rT)9w-1)4y 2y cX(cX7x98x,2x,[rT]);jB[rT]=qC}7z 0y(qc 1y dg)jB[qc7x338x+'#'+qc7x388x]=qC;7z 0y(qc 1y cI)jB[qc7x338x+'#'+'@'+qc7x388x]=qC}7z{0y(!qx){qx=qC;qC=nn}8z(8y sH 0z qx)0y(sH9w_[48]){0y(qx7x268x(sH))qC[sH]=qx[sH]}3y qC}};nn7x3798x=9z(qC,qx){gF(qC,_[582]);3y es(qC,qx)};nn7x7238x=9z(hd){no7x2038x(_[110],hd,1x)};nn7x7228x=9z(b,Q)1w;nn7x7218x=9z(qx,sH,qC){gD(qx,sH,qC,_[582])};nn7x7248x=9z(sH,qO){8y sU=_[372]+'-'+sH,pM=fI(no7x1758x,sU);0y(4x7x18x>1){0y(sH9w_[579]){fJ(no7x1758x,sU,qO);0y(pM9wqO){8y or=2y cU;or7x2818x(_[375],1x,1x,sH);hL(no,or)}}}7z 3y pM};8y rv=qK7x1428x;nn7x5248x=9z(tx){8y tK=rv;rv=jt(tx,tK);8y qq=eQ(rv,_[329]);eE(qq7x1058x);rv=tK};8y pX=nn7x778x;0y(cw)8z(8y kS=0,d=qJ7x5268x,nr,lc=d7x18x;kS<lc;kS2v)pX[(nr=d[kS])7x718x]=nr7x7258x;7z 8z(8y kS=0,d=nA7x28x,nr;nr=d[kS];kS2v)0y(nr7x458x7x108x(/^xmlns($|:)(.*)/))pX[dC.$2]=nr7x218x;0y(!pX[''])pX['']=sA;0y(!pX7x5678x)pX7x5678x=sw;0y(!pX7x5558x)pX7x5558x=sz;0y(!pX7x5518x)pX7x5518x=sB;0y(!pX7x5508x)pX7x5508x=sx;0y(!pX7x5468x)pX7x5468x=sC;8z(8y sk 0z pX)0y(pX7x268x(sk)3wsk9w'')np7x28x7x49]+':'+sk]=pX[sk];np7x28x7x1808x=jt('.',rv);nn7x1318x=9z2w{0y(nn7x768x6w_[323]){8y t=qJ7x708x(_[107]),ol=t[t7x18x-1];ol7x48x7x1328x(ol);qJ7x3748x('<'+_[107]+' '+_[34]+'=\"'+_[564]+'\"'+'>')}};nn7x5118x=9z2w{0y(nn7x768x6w_[323])qJ7x3748x('</'+_[107]+'>')};9z ev(ob,px){8z(8y ol,sg;px;px=px7x48x)0y((sg=px.id)3w(ol=(od[sg]4woc[sg])))3y ol;3y 2x};nn7x7278x=9z(px){3y ev(no,px)};nn7x7268x=9z(tH,rB){3y jt(tH,rB)};8y nN=no7x1758x;fJ(nN,_[559],2x);fJ(nN,_[647],1x);fJ(nN,_[659],1x);fJ(nN,_[658],1x);fJ(nN,_[447],1x);fJ(nN,_[657],'Ample/0.9.5.a.2011.10.09(build:2011-10-09 22:06:36)');fJ(nN,_[434],_[661]);fJ(nN,_[663],qL7x1608x4wqL7x7718x4w'en-US');fJ(nN,_[337],'Ample/0.9.5.a.2011.10.09');fJ(nN,_[253],3x);fJ(nN,_[648],3x);fJ(nN,_[251],3x);8y pc=2x,x=0w;9z gM(ol){0y(ol9wpc){0y(pc)gL(pc);0y(oc[ol7x238x]){pc=ol;nn7x1098x=ol;gx(ol,_[189],3x);8y or=2y dn;or7x1868x(_[189],1x,1x,6x,2x,2x);hL(ol,or);8y or=2y dn;or7x1868x(_[422],3x,1x,6x,2x,2x);hL(ol,or)}}};9z gL(ol){0y(ol6wpc){0y(oc[ol7x238x]){pc=2x;nn7x1098x=ny4wnp;gx(ol,_[189],1x);8z(8y px=ol;px3wpx7x78x9w11;px=px7x48x);8y or=2y dn;or7x1868x(_[386],1x,1x,6x,2x,2x);hL(ol,or);8y or=2y dn;or7x1868x(_[430],3x,1x,6x,2x,2x);hL(ol,or)}}};9z gN(ol,mz){8z(8y pO=ol,pb;pO;pO=pO7x48x){0y(pO6wol){0y(pO7x258x3w(pb=gO(pO7x258x,mz)))3y pb;0y(pO7x1068x3w(pb=gO(pO7x1068x7x258x,mz)))3y pb}0y(pO6wny)3y;0y(pO7x478x3w(pb=gO(pO7x478x,mz)))3y pb}};9z gO(ol,mz){8z(8y qw=ol,pb;qw;qw=qw7x478x){0y(gR(qw,mz))3y qw;0y(qw7x1068x3w(pb=gN(qw7x1068x,mz)))3y pb;0y(qw7x258x3w(pb=gO(qw7x258x,mz)))3y pb}};9z gP(ol,mz){8z(8y pO=ol,pb;pO;pO=pO7x48x){0y(pO9wol){0y(gR(pO,mz))3y pO}0y(pO6wny)3y;0y(pO7x648x3w(pb=gQ(pO7x648x,mz)))3y pb}};9z gQ(ol,mz){8z(8y qw=ol,pb;qw;qw=qw7x648x){0y(qw7x658x3w(pb=gQ(qw7x658x,mz)))3y pb;0y(qw7x1068x3w(pb=gQ(qw7x1068x7x658x,mz)))3y pb;0y(gR(qw,mz))3y qw}};9z gR(ol,mz,bR){3y ol7x1888x>-13w(bR4wol7x1888x6wmz)3wol7x1628x2w3wgS(ol)};9z gS(ol){8z(8y om;ol7x78x9w9;ol=ol7x48x)0y(om=ol7x58x2w)3y om7x5378x>0;3y 3x};9z gU(or){0y(or7x438x)3y;8y pb=2x;8z(8y ol=or7x288x;ol7x78x9w93w!pb;ol=ol7x48x){0y(gR(ol,0,3x))pb=ol}0y(pb)gM(pb);7z 0y(pc)gL(pc)};9z gT(or){0y(or7x438x)3y;0y(or7x1748x6w_[485]3w(or7x298x4wor7x308x))3y;0y(or7x1748x6w_[485]){8y pb=2x,mA=0;0y(pc){mA=pc7x1888x;0y(or7x318x)pb=gP(pc,mA);7z pb=gN(pc,mA)}0y(!pb){8y pO=ny4w5x7x358x,mB=-kV,mC=kV,mD=mC,mE=mB;8z(8y kS=0,mz,ol,t=gj(pO,'*');ol=t[kS];kS2v){mz=ol7x1888x;0y(mz>-1){0y(mz>mB)mB=mz;0y(mz<mC)mC=mz;0y(mz<mA3wmz>mE)mE=mz;0y(mz>mA3wmz<mD)mD=mz}}0y(mD6wkV)mD=0;0y(mE6w-kV)mE=0;0y(or7x318x)pb=gQ(pO,mE)4wgQ(pO,mB);7z pb=gO(pO,mD)4wgO(pO,mC)}0y(pb)gM(pb);or7x568x2w}};dg9x7x1888x=-1;dg9x7x1898x=9z2w{gM(5x)};dg9x7x3868x=9z2w{gL(5x)};gB(no,_[113],gU,1x);gB(no,_[137],gT,1x);8y lQ=0,lP=1,lR=2,lM=0,lO=1,lN=2,lK=4,lL=8,qr=2x,ma=lM,mb=lQ,mc,me,md,lT,lS,lU,lV,tn,to,tm,tp,lX,lY,lW,lZ;9z iA(or){0y(or7x438x4wor7x1158x)3y;0y(kv)3y;0y(qr){mb=lP;mc=iZ(9z2w{mc=0;iB7x328x(or7x678x,or)},200)}};9z iB(or){0y(mb6wlQ){lU=or7x198x;lV=or7x208x;8z(8y ol=or7x288x;ol9w5x;ol=ol7x48x){0y(ol7x2868x){8y om=ol7x58x2w,nM=eG(om),qj=gh(ol),kE=lM,kF=ol7x2858x4w15,rL='';8y lr=lU-qj7x118x,ls=lV-qj7x128x;0y(iy(ls,ix(nM,_[230]))){kE|=kF&lO;rL0v'n'}7z 0y(iy(ls-qj7x788x+qj7x128x,ix(nM,_[231]))){kE|=kF&lK;rL0v's'}0y(iy(lr,ix(nM,_[212]))){kE|=kF&lL;rL0v'w'}7z 0y(iy(lr-qj7x758x+qj7x118x,ix(nM,_[240]))){kE|=kF&lN;rL0v'e'}0y(kE9wlM){qr=ol;ma=kE;nA7x138x7x5368x=rL+'-'+_[120];3y}}}0y(qr){qr=2x;ma=lM;nA7x138x7x5368x=''}3y}0y(mc)mc=fF(mc);or7x2478x2w;8y om=qr7x58x2w,qj=gh(qr),qA=om7x138x;0y(mb6wlP){8y oU=2y dD;oU7x2488x(_[438],3x,3x,6x,2x,ma);oU7x168x=or7x168x;hL(qr,oU);0y(oU7x438x){mb=lQ;3y}tp=qA7x588x;tm=qA7x428x;tn=qA7x118x;to=qA7x128x;gx(qr,_[120],3x);fo(1x);0y(cw)om7x3818x2w;fx(qr,3x);8y nM=eG(om),bE=qJ7x7728x6w_[651];qA7x118x=0;qA7x128x=0;8y qk=gh(qr);qA7x118x=tn;qA7x128x=to;mb=lR;lZ=(qj7x758x-qj7x118x)-(bE?0:(ix(nM,_[212])+ix(nM,_[240]))+ix(nM,_[407])+ix(nM,_[416]));lW=(qj7x788x-qj7x128x)-(bE?0:(ix(nM,_[230])+ix(nM,_[231]))+ix(nM,_[417])+ix(nM,_[425]));lX=qj7x118x-qk7x118x;lY=qj7x128x-qk7x128x;me=_c(nM[jv(_[575])]4wnM7x5758x)4w0;md=_c(nM[jv(_[577])]4wnM7x5778x)4wkV;0y(md<0)md=kV;lT=_c(nM[jv(_[569])]4wnM7x5698x)4w0;lS=_c(nM[jv(_[455])]4wnM7x4558x)4wkV;0y(lS<0)lS=kV}8y oS=2y dD;oS7x2488x(_[120],3x,3x,6x,2x,ma);oS7x168x=or7x168x;hL(qr,oS);0y(!oS7x438x){8y nk=lZ+(or7x198x-lU)*(ma&lL?-1:1),kP=lW+(or7x208x-lV)*(ma&lO?-1:1);0y(nk4vme)nk=me;7z 0y(nk5vmd)nk=md;0y(ma&lN)qA7x588x=iw(nk)+'px';7z 0y(ma&lL){qA7x588x=iw(nk)+'px';qA7x118x=iw(lZ-nk+lX)+'px'}0y(kP4vlT)kP=lT;7z 0y(kP5vlS)kP=lS;0y(ma&lK)qA7x428x=iw(kP)+'px';7z 0y(ma&lO){qA7x428x=iw(kP)+'px';qA7x128x=iw(lW-kP+lY)+'px'}}0y(!cw)6x7x4898x2w7x4998x2w};9z iC(or){0y(mb6wlQ)3y;0y(mc)mc=fF(mc);8y om=qr7x58x2w;0y(mb6wlR){gx(qr,_[120],1x);8y oT=2y dD;oT7x2488x(_[445],3x,3x,6x,2x,ma);oT7x168x=or7x168x;hL(qr,oT);0y(oT7x438x4w(or7x438x4wor7x1158x)){8y qA=om7x138x,iE=9z2w{qA7x588x=tp;qA7x428x=tm;qA7x118x=tn;qA7x128x=to};0y(nU7x2518x){8y qb=1w;qb7x118x=tn4w_[87];qb7x128x=to4w_[87];qb7x588x=tp4w_[87];qb7x428x=tm4w_[87];hn(qr,qb,_[133],_[98],iE)}7z iE2w}fo(3x);0y(cw)om7x2198x2w;fw(qr)}mb=lQ;lU=or7x198x;lV=or7x208x};9z iz(or){0y(or7x1748x6w_[413]){or7x568x2w;iC(or)}};9z ix(qA,sH,nc){8y uc=_c(qA[sH]);3y hh(uc)?nc4w0:uc};9z iw(nc){3y nc<0?0:nc};9z iy(nc,jP){3y ds7x1298x(nc)<ds7x8198x(5,jP)};dg9x7x2868x=1x;dg9x7x2858x=0;gB(no,_[113],iA,1x);gB(no,_[169],iB,1x);gB(no,_[147],iC,1x);gB(no,_[137],iz,1x);8y ku=0,ks=1,kt=2,of=2x,kv=ku,r=0w,og=2x,oe=2x,oh=2x,kC,kw,kx,rO,rP,kA,kB,ky,kz;9z gb(or){0y(or7x438x4wor7x1158x)3y;0y(mb)3y;8z(8y ol=or7x288x;ol9w5x;ol=ol7x48x){0y(ol7x2758x){kv=ks;of=ol;kC=iZ(9z2w{kC=0;gc7x328x(or7x678x,or)},200);3y}}};9z gd(or){0y(kv6wku)3y;0y(kC)kC=fF(kC);8y om=of7x58x2w,bT=1x,qk=gh(of);0y(kv6wkt){0y(og){0y(!or7x438x3w!or7x1158x){8y oC=2y df;oC7x1178x(_[202],3x,3x,6x,2x,oe);oC7x1028x=of;oC7x168x=or7x168x;bT=!hL(og,oC)}gx(og,_[202],1x);8y oz=2y df;oz7x1178x(_[294],3x,3x,6x,2x,oe);oz7x168x=or7x168x;oz7x1028x=of;hL(og,oz)}r7x18x=0;gx(of,_[237],1x);8y ox=2y df;ox7x1178x(_[478],3x,3x,6x,2x,oe);ox7x168x=or7x168x;hL(of,ox);8y bS=or7x438x4wor7x1158x4wbT4wox7x438x,cj=nU7x2518x3w(bS4woe7x1468x6w_[333]4woe7x1468x6w_[214]);0y(cj){8y qj=gh(of),lb=(qk7x118x-qj7x118x+_c(om7x138x7x118x)),mV=(qk7x128x-qj7x128x+_c(om7x138x7x128x));om7x138x7x118x=rO;om7x138x7x128x=rP;8y ql=gh(of);om7x138x7x118x=lb+'px';om7x138x7x128x=mV+'px'}0y(!bS3wog3wog9wof7x48x){0y(oe7x1468x6w_[214])ge(og,hJ(of,3x));7z 0y(oe7x1468x6w_[333])ge(og,of)}0y(bS4woe7x1468x6w_[333]4woe7x1468x6w_[214]){8y qA=om7x138x,iE=9z2w{qA7x118x=rO;qA7x128x=rP};0y(cj){qA7x118x=rO;qA7x128x=rP;8y qm=gh(of);qA7x118x=(lb+ql7x118x-qm7x118x)+'px';qA7x128x=(mV+ql7x128x-qm7x128x)+'px';8y qb=1w;qb7x118x=rO4w_[87];qb7x128x=rP4w_[87];hn(of,qb,_[133],_[98],iE)}7z iE2w}fo(3x);0y(cw)om7x2198x2w;fw(of);oh7x1678x='';oh7x138x7x628x=_[72]}of=2x;kv=ku;og=2x};9z gc(or){0y(kv6wku)3y;0y(kC)kC=fF(kC);or7x2478x2w;8y om=of7x58x2w,qj=gh(of),qA=om7x138x;0y(kv6wks){oe=2y db;0y(!oh){oh=nu7x938x(qJ7x1368x(_[170]));oh7x138x7x1508x='z-0zdex:1000;position:absolute;display:none'}8y oB=2y df;oB7x1178x(_[479],3x,3x,6x,2x,oe);oB7x168x=or7x168x;hL(of,oB);0y(oB7x438x){kv=ku;3y}rO=qA7x118x;rP=qA7x128x;gx(of,_[237],3x);fo(1x);0y(cw)om7x3818x2w;fx(of,3x);oh7x138x7x628x='';8y t=gj(ny4w5x7x358x,'*');8z(8y kS=0,lc=t7x18x;kS<lc;kS2v)0y(t[kS]7x2878x)r7x38x(t[kS]);kv=kt;kw=or7x198x;kx=or7x208x;qA7x118x=0;qA7x128x=0;8y qk=gh(of);qA7x118x=rO;qA7x128x=rP;ky=qj7x118x-qk7x118x;kz=qj7x128x-qk7x128x;8y qt=fX(om);kA=qt7x118x;kB=qt7x128x}8y oi=2x,qm,jJ=(qj7x758x-qj7x118x)*(qj7x788x-qj7x128x),jK,jL=kV,kX,lz=0;8z(8y kS=0,lc=r7x18x;kS<lc;kS2v){0y(r[kS]6wof)4z;0y(hK(r[kS],of)&8)4z;qm=gh(r[kS]);jK=(qm7x758x-qm7x118x)*(qm7x788x-qm7x128x);kX=fY(qj,qm);0y(kX<jJ){0y(kX>lz){lz=kX;oi=r[kS]}}7z{0y(jK<jL){jL=jK;oi=r[kS]}}}0y(og){0y(og9woi){gx(og,_[202],1x);8y oz=2y df;oz7x1178x(_[294],3x,3x,6x,2x,oe);oz7x1028x=of;oz7x168x=or7x168x;hL(og,oz)}}8y ow=2y df;ow7x1178x(_[237],3x,3x,6x,2x,oe);ow7x168x=or7x168x;ow7x1028x=oi;hL(of,ow);0y(oi){0y(oi9wog){8y oy=2y df;oy7x1178x(_[441],3x,3x,6x,2x,oe);oy7x168x=or7x168x;oy7x1028x=of;hL(oi,oy);0y(oy7x438x)oi=2x;7z gx(oi,_[202],3x)}0y(oi){8y oA=2y df;oA7x1178x(_[475],3x,3x,6x,2x,oe);oA7x168x=or7x168x;oA7x1028x=of;hL(oi,oA)}}og=oi;8y qt=fX(om);0y(!ow7x438x){qA7x118x=(qt7x118x-kA)+ky+(or7x198x-kw)+'px';qA7x128x=(qt7x128x-kB)+kz+(or7x208x-kx)+'px'}0y(oh){oh7x138x7x118x=or7x198x+'px';oh7x138x7x128x=or7x208x+'px'}0y(!cw)6x7x4898x2w7x4998x2w};9z ga(or){0y(or7x1748x6w_[413]){or7x568x2w;gd(or)}};9z fX(om){8y qt=1w;qt7x118x=0;qt7x128x=0;8z(;om3wom7x78x6w1;om=om7x48x){qt7x118x0vom7x848x;qt7x128x0vom7x858x}3y qt};9z fY(ql,qm){3y fZ(ql7x118x,ql7x758x-ql7x118x,qm7x118x,qm7x758x-qm7x118x)*fZ(ql7x128x,ql7x788x-ql7x128x,qm7x128x,qm7x788x-qm7x128x)};9z fZ(x,y,a,b){3y a>x?(a4vx+y?a+b<x+y?b:x+y-a:0):(a5vx-b?a+b<x+y?a+b-x:y:0)};dg9x7x2758x=1x;dg9x7x2878x=1x;gB(no,_[113],gb,1x);gB(no,_[169],gc,1x);gB(no,_[147],gd,1x);gB(no,_[137],ga,1x);9z iX(or){8z(8y ol=or7x288x,bB=1x;ol7x78x9w9;ol=ol7x48x)0y(ol7x1978x6w3x)bB=3x;7z 0y(ol7x1978x6w1x)3y!bB3wor7x568x2w};dg9x7x1978x=2x;gB(no,_[113],iX,1x);dd9x7x2198x=9z2w{0y(nv)fw(nv)};9z fx(px,bN){0y(nv9wpx){8y ol=nv;0y(ol3wol9wpx)fw(ol);nv=px}};dg9x7x3818x=9z(bN){0y(4x7x18x3w!bN)4y 2y cX(cX7x98x);fx(5x,bN)};9z fw(px){0y(nv6wpx){8y or=2y dZ;or7x618x(_[388],1x,1x,6x,2x);hL(px,or);nv=2x}};dg9x7x2198x=9z2w{fw(5x)};8y qG,qH,mZ=ll,mY=ll,mX=0,mW=0,cs,ct,na,nb;9z jp(or){0y(or7x828x7x18x6w1){qG=2x;qH=2x;mX=or7x828x[0]7x208x;mW=or7x828x[0]7x198x;8z(8y ol=or7x288x7x58x2w,nM,sT;ol3wol7x78x6w1;ol=ol7x48x){nM=eG(ol);cs=ct=(sT=nM7x1188x)6w_[87]4wsT6w_[143];0y((sT=nM7x8188x)6w_[87]4wsT6w_[143])cs=3x;0y((sT=nM7x8178x)6w_[87]4wsT6w_[143])ct=3x;0y(cs4wct){qG=ev(no,ol);qH=ol;na=ol7x848x+or7x828x[0]7x198x;nb=ol7x858x+or7x828x[0]7x208x;1z}}}};9z jo(or){0y(or7x828x7x18x){8y jZ=or7x828x[0]7x198x,ka=or7x828x[0]7x208x;0y(mX-ka){8y oZ=2y ea;oZ7x3578x(_[168],3x,3x,6x,2x,or7x368x,or7x378x,or7x198x,or7x208x,0,2x,eJ(or),0,mX-ka,0,0);oZ7x168x=or7x168x;oZ7x3708x=oZ7x2208x;hL(or7x288x,oZ)}0y(qH){0y(cs)qH7x848x=na-jZ;0y(ct)qH7x858x=nb-ka;or7x568x2w}mZ=mX;mY=mW;mX=ka;mW=jZ}};9z jn(or){0y(or7x828x7x18x6w0){8y nq=1w,lr=mY-mW,ls=mZ-mX;0y(qH){0y(cs3wds7x1298x(lr)>5)nq7x848x=qH7x848x+lr*10;0y(ct3wds7x1298x(ls)>5)nq7x858x=qH7x858x+ls*10;hn(qG,nq,_[133],_[415],2x,qH)}qG=2x;qH=2x;mZ=ll;mY=ll}};gB(no,_[226],jp,1x);gB(no,_[227],jo,1x);gB(no,_[232],jn,1x);9z ii(qv){8y qq=2y eh,pj=qv7x8208x4w1w,tl=pj7x1618x4w'',rU=qv7x2218x,tI=qv7x1928x4w'.',tG=_[34] 0z qv?dQ(qv7x348x)7x1848x2w:_[241],bD=_[359] 0z qv?qv7x3598x:3x,tT=_[6] 0z qv?qv7x68x:2x,lJ;0y(tT9w2x){0y(5y tT6w_[74]3w!(_[22] 0z tT))tT=ir(tT);0y(tG6w_[408]){0y(!tl3w5y tT6w_[91])pj7x1618x=_[649]}7z{tI0v(tI7x178x('?')6w-1?'?':'&')+tT;tT=2x}}qq7x1318x(tG,tI,bD);qq7x1168x(_[409],_[257]);qq7x1168x(_[404],nU7x3378x);8z(8y sk 0z pj)0y(pj7x268x(sk))qq7x1168x(sk,pj[sk]);qq7x5658x=9z2w{0y(qq7x768x6w4){0y(lJ)fF(lJ);8y mv=qq7x2178x,ty=_[145];0y(mv5v2003wmv4v3004wmv6w3044wmv6w1223){8y qs=qq7x1058x,tq=qq7x2168x(_[161])4w'',tr=tq7x108x(/(\\w+)\\/([-\\w]+\\+)?(?:x\\-)?([-\\w]+)?;?(.+)?/)?dC.$3:'';0y(rU9w_[276]){0y(rU6w_[100]4wtr6w_[100]){qs=eK(qq);0y(!qs){ty=_[164]}}7z 0y(rU6w_[405]4wtr6w_[405]){7y{qs=pn7x3038x(qs)}3z(pa){ty=_[164]}}7z 0y(rU6w_[107]4wtr6w_[362]4wtr6w_[662]){7y{eE(qs)}3z(pa){ty=_[130]}}}}7z{ty=_[130]}0y(ty6w_[145]){0y(qv7x1458x)qv7x1458x(qs,ty,qq)}7z 0y(qv7x1308x)qv7x1308x(qq,ty);0y(qv7x1938x)qv7x1938x(qq,ty)}};0y(bD3w!hh(qv7x2238x))lJ=iZ(9z2w{qq7x5658x=2y _b;qq7x1408x2w;0y(qv7x1308x)qv7x1308x(qq,_[223]);0y(qv7x1938x)qv7x1938x(qq,_[223])},qv7x2238x);qq7x2228x(tT);3y qq};9z ir(uc){8y bw=0w;0y(uc 1y dw){4y 2y cX(cX7x98x)}7z 0y(uc 1y dz){(9z(tb,uc){0y(uc 1y cH)8z(8y kS=0,lc=uc7x18x,qO;kS<lc;kS2v)4x7x1918x(tb+'['+((qO=uc[kS])1y cH4w5y qO6w_[74]?kS:'')+']',qO);7z 0y(uc 1y dz)8z(8y sk 0z uc)4x7x1918x(tb+(tb6w''?sk:'['+sk+']'),uc[sk]);7z bw[bw7x18x]=gy(tb)+'='+gy(uc)})('',uc)}7z 4y 2y cX(cX7x98x);3y bw7x248x('&')7x88x(/%20/g,'+')};nn7x8218x=9z(qv){3y ii(qv)};nn7x8238x=9z(uc){3y ir(uc)};nn7x5728x=9z(tI,tT,fv,tG){8y qv=1w;qv7x1928x=tI;qv7x348x=_[241];qv7x68x=tT;qv7x1458x=fv;qv7x2218x=tG;3y ii(qv)};nn7x8228x=9z(tI,tT,fv,tG){8y qv=1w;qv7x1928x=tI;qv7x348x=_[408];qv7x68x=tT;qv7x1458x=fv;qv7x2218x=tG;3y ii(qv)};dB9x7x1108x=9z(tI,tT,fv){ik(5x,9z2w{hw(5x,tI,tT,fv)});3y 5x};dB9x7x1408x=9z2w{ik(5x,9z2w{hu(5x)});3y 5x};dB9x7x8168x=9z(tg,tK){8y Y=tg7x188x(':'),sn=Y7x528x2w,tb=Y7x528x2w4w2x,sI=2x;0y(tb9w2x)sI=5x7x2798x?5x7x2798x(tb):nn7x778x[tb]4w2x;0y(4x7x18x>1){ik(5x,9z2w{0y(tK6w2x)sI6w2x?5x7x3348x(tg):5x7x5768x(sI,sn);7z sI6w2x?5x7x908x(tg,tK):5x7x5818x(sI,tg,tK)});3y 5x}7z 0y(5x7x18x)3y sI6w2x?5x[0]7x818x(tg):5x[0]7x5498x(sI,sn);3y 2x};dB9x7x8158x=9z(sH,tK){0y(4x7x18x>1){tK=tK6w2x?'':dQ(tK);ik(5x,9z2w{5x7x3808x(sH,tK)});3y 5x}7z 0y(5x7x18x)3y 5x[0]7x3638x(sH);3y 2x};8y qf=1w;9z ij(qe,sH,qO){0y(5y qO9w_[63]){ik(qe,9z2w{8y nB=qf[5x7x238x];0y(!nB)nB=qf[5x7x238x]=1w;0y(qO6w2x)6z nB[sH];7z nB[sH]=qO});3y qe}7z 0y(qe7x18x){8y ol=qe[0],nB=qf[ol7x238x];0y(!nB)nB=qf[ol7x238x]=1w;0y(5y sH9w_[63])3y nB[sH];7z 3y nB}};dB9x7x68x=9z(sH,qO){3y ij(5x,sH,qO)};nn7x68x=9z(ol,sH,qO){8y qe=2y dB;qe[qe7x18x2v]=ol;3y ij(qe,sH,qO)};dB9x7x588x=9z(tK){0y(4x7x18x){ik(5x,9z2w{8y om=5x7x58x2w;0y(om)fn(om,_[58],tK+(hh(tK)?'':'px'))});3y 5x}7z 0y(5x7x18x){8y om=5x[0]7x58x2w;0y(om){8y qj=gh(5x[0]),lv=_c(eL(om,_[407]))4w0,lw=_c(eL(om,_[416]))4w0,jR=_c(eL(om,_[212]))4w0,jS=_c(eL(om,_[240]))4w0;3y(qj7x758x-qj7x118x)-(lv+lw)-(jR+jS)}3y 0}};dB9x7x428x=9z(tK){0y(4x7x18x){ik(5x,9z2w{8y om=5x7x58x2w;0y(om)fn(om,_[42],tK+(hh(tK)?'':'px'))});3y 5x}7z 0y(5x7x18x){8y om=5x[0]7x58x2w;0y(om){8y qj=gh(5x[0]),lx=_c(eL(om,_[417]))4w0,lu=_c(eL(om,_[425]))4w0,jT=_c(eL(om,_[230]))4w0,jQ=_c(eL(om,_[231]))4w0;3y(qj7x788x-qj7x128x)-(lx+lu)-(jT+jQ)}3y 0}};dB9x7x8108x=9z2w{0y(5x7x18x){8y om=5x[0]7x58x2w;0y(om){8y qj=gh(5x[0]),jR=_c(eL(om,_[212]))4w0,jS=_c(eL(om,_[240]))4w0;3y(qj7x758x-qj7x118x)-(jR+jS)}}3y 0};dB9x7x8098x=9z2w{0y(5x7x18x){8y om=5x[0]7x58x2w;0y(om){8y qj=gh(5x[0]),jT=_c(eL(om,_[230]))4w0,jQ=_c(eL(om,_[231]))4w0;3y(qj7x788x-qj7x128x)-(jT+jQ)}}3y 0};dB9x7x8088x=9z(cb){0y(5x7x18x){8y om=5x[0]7x58x2w;0y(om){8y qj=gh(5x[0]);3y(qj7x758x-qj7x118x)+(cb?(_c(eL(om,_[311]))4w0)+(_c(eL(om,_[534]))4w0):0)}}3y 0};dB9x7x8118x=9z(cb){0y(5x7x18x){8y om=5x[0]7x58x2w;0y(om){8y qj=gh(5x[0]);3y(qj7x788x-qj7x128x)+(cb?(_c(eL(om,_[354]))4w0)+(_c(eL(om,_[533]))4w0):0)}}3y 0};dB9x7x5638x=9z(qb,tU,rQ,fv){8y tc=4x[4];ik(5x,9z2w{hn(5x,qb,tU,rQ,fv,tc)});3y 5x};dB9x7x5588x=9z2w{ik(5x,9z2w{hq(5x)});3y 5x};dB9x7x4208x=9z(tU){ik(5x,9z2w{hj(5x,tU)});3y 5x};dB9x7x8128x=9z(tU,fv){8y qb=1w;qb7x408x=1;ik(5x,9z2w{fn(5x7x58x2w,_[62],'');hn(5x,qb,tU,_[98],fv)});3y 5x};dB9x7x8148x=9z(tU,fv){8y qb=1w;qb7x408x=0;ik(5x,9z2w{hn(5x,qb,tU,_[98],9z2w{5x7x58x2w7x138x7x628x=_[72];0y(fv)fv7x328x(5x)})});3y 5x};dB9x7x8138x=9z(tU,lt,fv){8y qb=1w;qb7x408x=lt;ik(5x,9z2w{hn(5x,qb,tU,_[98],fv)});3y 5x};dB9x7x8248x=9z(tU,fv){ik(5x,9z2w{8y om=5x7x58x2w,qA=om7x138x;0y(qA7x628x6w_[72]){qA7x628x='';0y(tU){8y qb=1w,nM=eG(om);qb7x588x=ez(om,_[58],eL(om,_[58],nM));qb7x428x=ez(om,_[42],eL(om,_[42],nM));qb7x408x='1';qA7x588x=0;qA7x428x=0;qA7x1188x=_[205];fn(om,_[40],'0');hn(5x,qb,tU,_[98],9z2w{qA7x588x='';qA7x428x='';qA7x1188x='';fn(om,_[40],'');0y(fv)fv7x328x(5x)})}}});3y 5x};dB9x7x8258x=9z(tU,fv){ik(5x,9z2w{8y om=5x7x58x2w,qA=om7x138x;0y(qA7x628x9w_[72]){0y(tU){8y qb=1w;qb7x588x='0px';qb7x428x='0px';qb7x408x='0';qA7x1188x=_[205];fn(om,_[40],'1');hn(5x,qb,tU,_[98],9z2w{qA7x628x=_[72];qA7x588x='';qA7x428x='';qA7x1188x='';fn(om,_[40],'');0y(fv)fv7x328x(5x)})}7z qA7x628x=_[72]}});3y 5x};dB9x7x8368x=9z(tU,fv){ik(5x,9z2w{8y om=5x7x58x2w,qA=om7x138x;0y(qA7x628x6w_[72]){qA7x628x='';8y qb=1w,nM=eG(om);qb7x428x=ez(om,_[42],eL(om,_[42],nM));qb7x408x='1';qA7x428x=0;qA7x1188x=_[205];fn(om,_[40],'0');hn(5x,qb,tU4w_[133],_[98],9z2w{qA7x428x='';qA7x1188x='';fn(om,_[40],'');0y(fv)fv7x328x(5x)})}});3y 5x};dB9x7x8358x=9z(tU,fv){ik(5x,9z2w{8y om=5x7x58x2w,qA=om7x138x;0y(qA7x628x9w_[72]){8y qb=1w;qb7x428x='0px';qb7x408x='0';qA7x1188x=_[205];fn(om,_[40],'1');hn(5x,qb,tU4w_[133],_[98],9z2w{qA7x628x=_[72];qA7x428x='';qA7x1188x='';fn(om,_[40],'');0y(fv)fv7x328x(5x)})}});3y 5x};nn7x3048x=pB;8y ba=[,_[189],_[386],_[422],_[430],_[399],_[218],_[388],_[336],_[120],_[143],_[137],_[229],_[113],_[147],_[194],_[168],_[169],_[225],_[394],_[395],_[168],_[226],_[227],_[232],_[348],_[341],_[344],_[322],_[461],_[233],_[238],_[239],_[252],_[215],_[44],_[94],_[196],_[124],_[237],_[202],_[479],_[478],_[475],_[441],_[294],_[438],_[120],_[445],_[453],_[454],_[178],_[139],_[375],_[3688x;dB9x7x5018x=9z(tG,nZ){0y(ba7x178x(tG)9w-1)4y 2y cX(cX7x98x,2x,[tG]);0y(4x7x18x<2)nZ=2x;ik(5x,9z2w{it(5x,tG,nZ)})};dB9x7x1348x=9z(tG,hd,bN){ik(5x,9z2w{gB(5x,tG,hd,bN4w1x)});3y 5x};dB9x7x1638x=9z(tG,hd,bM){ik(5x,9z2w{gC(5x,tG,hd,bN4w1x)});3y 5x};nn7x1348x=9z(tG,hd,bN){gB(no,tG,hd,bN4w1x)};nn7x1638x=9z(tG,hd,bN){gC(no,tG,hd,bN4w1x)};9z it(px,tG,nZ){8y or=2y cU;or7x2818x(tG,3x,3x,nZ);hL(px,or)};nn7x5018x=9z(tG,nZ){0y(ba7x178x(tG)9w-1)4y 2y cX(cX7x98x,2x,[tG]);0y(4x7x18x<2)nZ=2x;it(no,tG,nZ)};8y tj=2x,ti=2x,lE,qg;9z im(sd,tE){0y(tj6wsd)3y;ti=sd;0y(qg){8y ob=qg7x5128x;ob7x1318x2w;ob7x3748x('<'+_[107]+'>'+_[391]+'.'+_[330]+'.'+_[288]+'=\"'+sd+'\"</'+_[107]+'>');ob7x5118x2w}7z qK7x2888x=sd};9z ip2w{_d2w;lE=iZ(ip,50)};9z _d2w{8y bv=qK7x1428x7x188x('#'),tI=bv[0],sd=bv[1]4w'';0y(tj9wsd){0y(ti9wsd){8y or=2y dq;or7x4938x(_[178],3x,1x,tI+(tj?'#':'')+tj,tI+(sd?'#':'')+sd);hL(no,or)}tj=sd;ti=2x}};9z io(or){8y sd=qK7x2888x7x88x(/^#/,'');0y(('on'+_[178])0z 6x)eA(6x,_[178],_d);7z{0y(cw){8y ol=qJ7x1368x(_[686]);ol7x138x7x628x=_[72];nu7x938x(ol);qg=ol7x8378x;0y(nU7x4478x)im(sd)}lE=iZ(ip,0)}tj=sd};9z iq(or){0y(('on'+_[178])0z 6x)eD(6x,_[178],_d);7z fF(lE)};nn7x8388x=9z(sd,tE){0y(4x7x18x)im(sd,tE);7z 3y tj};gB(no,_[110],io,1x);gB(no,_[141],iq,1x);8y ph=1w,nS=ph7x8408x=1w,pq=ph7x8398x=1w;ph7x3798x=9z(bR){8y qC=4x[1]4w1w;8z(8y kS=2,lc=4x7x18x;kS<lc;kS2v){8y qx=4x[kS];0y(qx){8z(8y sk 0z qx){8y qy=qx[sk];0y(5y qy9w_[63]){0y(bR3w(5y qy6w_[74]4whc(qy,cH))){8y qE=qC[sk];qE=qE3w(5y qE6w_[74]4whc(qE,cH))?qE:(hc(qy,cH)?0w:1w);qC[sk]=ph7x3798x(3x,qE,qy)}7z qC[sk]=qy}}}}3y qC};ph7x1838x=9z(tV){8y G;0y(!tV)3y 5x7x3538x;0y(hc(tV,dQ))tV=tV7x188x(',');0y(hc(tV,cH)){8y sm,E=tV,kS,lc=E7x18x,V=0w;8z(kS=0;kS<lc;kS2v){tV=jg(E[kS]);8y lC,S=tV7x188x(';'),pZ;sm=jg(S[0]);0y(S7x18x6w=1)lC=1;7z{tV=jg(S[1]);0y(tV7x178x('q=')6w=0){tV=tV7x278x(2);lC=ie(tV,10);lC=hh(lC)?0:lC}7z lC=1}pZ=1w;pZ7x1608x=sm;pZ7x3838x=lC;V7x38x(pZ)}V7x8348x(9z(a,b){3y a7x3838x<b7x3838x?1:-1});8z(kS=0;kS<lc;kS2v){sm=V[kS]7x1608x;G=nS[sm];0y(G)3y G}8z(kS=0;kS<lc;kS2v){sm=V[kS]7x1608x;do{8y la=sm7x3678x('-');0y(la6w=-1)1z;sm=sm7x278x(0,la);G=nS[sm];0y(G)3y G}9y(1)}}7z 0y(5y tV6w_[74])3y tV;3y G4w2x};ph7x8338x=9z(sk,nR,tK){nR=5x7x1838x(nR);8y pp=pq[nR7x718x];0y(4x7x18x6w=3){0y(!pp)pp=pq[nR7x718x]=1w;pp[sk]=tK}7z{0y(pp)tK=pp[sk];0y(5y tK6w_[63]){8y D=pq[nR7x1608x];0y(D)tK=D[sk];0y(5y tK6w_[63])tK=pq7x3778x[sk]}}3y 5y tK6w_[63]?'':tK};ph7x8288x=9z(uc,rX,nR){nR=5x7x1838x(nR);0y(5y uc6w_[200])uc=gW(uc,rX,nR);7z 0y(uc 1y dc)uc=gV(uc,rX,nR);3y uc};ph7x5318x=9z(uc,lG,nR){3y ds7x1718x(5x7x3618x(uc,lG,nR))};ph7x3618x=9z(uc,lG,nR){nR=5x7x1838x(nR);8y mf=ll,pF=nR7x3068x;uc=jg(uc);0y(rb7x738x(uc))mf=ie(uc,lG);7z 0y(!lG3wra7x738x(uc))mf=_c(uc,16);7z{8y bk=ig(uc,pF,pF7x1358x[0]),tw=bk[0],sO=bk[1];0y(tw6w=''3wpF7x1358x[0]9w='-n'){bk=ig(uc,pF,'-n');tw=bk[0];sO=bk[1]}tw=tw4w'+';8y kK,si,kL=sO7x178x('e');0y(kL<0)kL=sO7x178x('E');0y(kL<0){si=sO;kK=2x}7z{si=sO7x278x(0,kL);kK=sO7x278x(kL+1)}8y sj,rY,rN=pF['.'],kh=si7x178x(rN);0y(kh<0){sj=si;rY=2x}7z{sj=si7x278x(0,kh);rY=si7x278x(kh+rN7x18x)}8y sb=pF[','];sj=sj7x188x(sb)7x248x('');8y ru=sb7x88x(/\\u00A0/g,' ');0y(sb9w=ru)sj=sj7x188x(ru)7x248x('');8y sW=tw+sj;0y(rY9w=2x)sW0v'.'+rY;0y(kK9w=2x){8y w=ig(kK,pF,'-n');sW0v'e'+(w[0]4w'+')+w[1]}0y(rl7x738x(sW))mf=ie(sW)}3y mf};ph7x8278x=9z(uc,y,nR){nR=5x7x1838x(nR);8y el,sk,pU;0y(y){0y(5y y6w_[91])y=[y];0y(y7x18x){8z(8y kS=0,lc=y7x18x;kS<lc;kS2v){8y rX=y[kS];0y(rX){el=id(uc,rX,nR);0y(el)1z}}}}7z{pU=nR7x2848x7x2828x;8z(sk 0z pU){el=id(uc,pU[sk],nR);0y(el)1z}}3y el4w2x};8y rp=/^\\s+|\\s+$/g,rb=/^[+-]?0zf0zity$/i,ra=/^0x[a-f0-9]+$/i,rl=/^[+-]?\\d*\\.?\\d*(e[+-]?\\d+)?$/;9z jf(tK,sY){3y tK7x178x(sY)6w=0};9z je(tK,sY){3y tK7x278x(tK7x18x-sY7x18x)6w=sY};9z jg(tK){3y(tK+'')7x88x(rp,'')};9z jh(tK,kc,bZ){8z(8y lc=tK7x18x;lc<kc;lc2v)tK=(bZ?('0'+tK):(tK+'0'));3y tK};9z hZ(lp,lB,pd){8y pi=pd7x2738x,ke=pi[0],kd=1,kM=ds7x5398x(10,lB),mi=ds7x5328x(lp*kM)/kM;0y(!hg(mi))mi=lp;lp=mi;8y sO=lp+'',tt='',bl=sO7x188x(/e/i),kK=bl7x18x>1?_c(bl[1],10):0;sO=bl[0];bl=sO7x188x('.');sO=bl[0];tt=bl7x18x>1?bl[1]:'';0y(kK>0){tt=jh(tt,kK,1x);sO0vtt7x398x(0,kK);tt=tt7x278x(kK)}7z 0y(kK<0){kK=-kK;sO=jh(sO,kK+1);tt=sO7x398x(-kK,sO7x18x)+tt;sO=sO7x398x(0,-kK)}0y(lB>0)tt=pd['.']+((tt7x18x>lB)?tt7x398x(0,lB):jh(tt,lB));7z tt='';8y mx=sO7x18x-1,tv=pd[','],ts='';9y(mx5v0){0y(ke6w=04wke>mx)3y sO7x398x(0,mx+1)+(ts7x18x?(tv+ts+tt):tt);ts=sO7x398x(mx-ke+1,mx+1)+(ts7x18x?(tv+ts):'');mx1vke;0y(kd<pi7x18x){ke=pi[kd];kd2v}}3y sO7x398x(0,mx+1)+tv+ts+tt};9z ig(tK,pF,sK){8y sJ=pF['-'],sZ=pF['+'],be;6y(sK){2z 'n-':sJ=' '+sJ;sZ=' '+sZ;2z 'n-':0y(je(tK,sJ))be=['-',tK7x278x(0,tK7x18x-sJ7x18x)];7z 0y(je(tK,sZ))be=['+',tK7x278x(0,tK7x18x-sZ7x18x)];1z;2z '-n':sJ0v' ';sZ0v' ';2z '-n':0y(jf(tK,sJ))be=['-',tK7x278x(sJ7x18x)];7z 0y(jf(tK,sZ))be=['+',tK7x278x(sZ7x18x)];1z;2z '(n)':0y(jf(tK,'(')3wje(tK,')'))be=['-',tK7x278x(1,tK7x18x-2)];1z}3y be4w['',tK]};9z gW(tK,rX,nR){0y(!rX4wrX6w='i')3y nR7x718x7x18x?tK7x5258x2w:tK7x488x2w;rX=rX4w'D';8y pF=nR7x3068x,lp=ds7x1298x(tK),lB=-1,sY;0y(rX7x18x>1)lB=_c(rX7x398x(1),10);8y rK=rX7x558x(0)7x1848x2w,pd;6y(rK){2z 'D':sY='n';0y(lB9w=-1){lp=jh(''+lp,lB,3x)}0y(tK<0)lp=-lp;1z;2z 'N':pd=pF;2z 'C':pd=pd4wpF7x3558x;2z 'P':pd=pd4wpF7x3218x;sY=tK<0?pd7x1358x[0]:(pd7x1358x[1]4w'n');0y(lB6w=-1)lB=pd7x2638x;lp=hZ(lp*(rK6w='P'?100:1),lB,pd);1z;5z:4y 2y cX(cX7x968x,2x,[rK])}8y rm=/n|\\$|-|%/g,ts='';8z(;;){8y kS=rm7x2108x,S=rm7x2618x(sY);ts0vsY7x398x(kS,S?S7x2628x:sY7x18x);0y(!S)1z;6y(S[0]){2z 'n':ts0vlp;1z;2z '$':ts0vpF7x3558x7x2748x;1z;2z '-':0y(/[1-9]/7x738x(lp))ts0vpF['-'];1z;2z '%':ts0vpF7x3218x7x2748x;1z}}3y ts};9z ia(nc,li,lh){3y nc<li4wnc>lh};9z fq(nC,nl){8y en=2y dc2w,kJ=fM(en);0y(nl<100){8y ua=nC7x5138x;ua=5y ua6w_[91]?2y dc2w7x2658x2w%100+_c(ua,10):ua;8y nm=fs(en,nC,kJ);nl0vnm-(nm%100);0y(nl>ua)nl1v100}3y nl};9z fM(el,v){0y(!v)3y 0;8y mt,mG=el7x5288x2w;8z(8y kS=0,lc=v7x18x;kS<lc;kS2v){mt=v[kS]7x2728x;0y(mt6w=2x4wmG5vmt)3y kS}3y 0};9z jl(tK){3y tK7x188x(\"\\u00A0\")7x248x(' ')7x1848x2w};9z jm(c){8y bd=0w;8z(8y kS=0,lc=c7x18x;kS<lc;kS2v)bd[kS]=jl(c[kS]);3y bd};9z fs(el,nC,kJ,co){8y nl=el7x2658x2w;0y(!co3wnC7x838x)nl1vnC7x838x[kJ]7x688x;3y nl};9z fr(nC,tK,bA){8y ep,bq=nC.x;0y(!bq)nC.x=bq=[jm(nC7x1088x7x1218x),jm(nC7x1088x7x1228x),jm(nC7x1088x7x5008x)];tK=jl(tK);0y(bA){ep=bq[1]7x178x(tK);0y(ep6w=-1)ep=bq[2]7x178x(tK)}7z ep=bq[0]7x178x(tK);3y ep};9z ft(nC,tK,bA){8y I=nC7x3768x4wnC7x1388x,br=nC.y,bs=nC.z;0y(!br){nC.y=br=[jm(nC7x1388x7x1218x),jm(nC7x1388x7x1228x)];nC.z=bs=[jm(I7x1218x),jm(I7x1228x)]}tK=jl(tK);8y kS=(bA?br[1]:br[0])7x178x(tK);0y(kS<0)kS=(bA?bs[1]:bs[0])7x178x(tK);3y kS};9z ew(T,bm){8y lF=0,bU=1x;8z(8y kS=0,lc=T7x18x;kS<lc;kS2v){8y rF=T7x558x(kS);6y(rF){2z '\\'':0y(bU)bm7x38x(\"'\");7z lF2v;bU=1x;1z;2z '\\\\':0y(bU)bm7x38x('\\\\');bU=!bU;1z;5z:bm7x38x(rF);bU=1x;1z}}3y lF};9z fp(nC,rX){rX=rX4w'F';8y sY,pU=nC7x2828x,lc=rX7x18x;0y(lc6w=1){sY=pU[rX];0y(!sY)4y 2y cX(cX7x968x,2x,[rX]);rX=sY}7z 0y(lc6w=23wrX7x558x(0)6w='%')rX=rX7x558x(1);3y rX};9z fu(nC,rX){8y pP=nC.n;0y(!pP)nC.n=pP=1w;7z{8y rn=pP[rX];0y(rn)3y rn}8y qZ=fp(nC,rX)7x88x(/([\\^\\$\\.\\*\\+\\?\\|\\[\\]\\(\\)\\{\\}])/g,\"\\\\\\\\$1\"),bb=['^'],A=0w,kS=0,lF=0,ro=ha2w,G;9y((G=ro7x2618x(qZ))9w=2x){8y T=qZ7x398x(kS,G7x2628x);kS=ro7x2108x;lF0vew(T,bb);0y(lF%2){bb7x38x(G[0]);4z}8y sc=G[0],lc=sc7x18x,rs;6y(sc){2z 'dddd':2z 'ddd':2z 'MMMM':2z 'MMM':2z 'gg':2z 'g':rs='(\\\\D+)';1z;2z 'tt':2z 't':rs='(\\\\D*)';1z;2z 'yyyy':2z 'fff':2z 'ff':2z 'f':rs='(\\\\d{'+lc+'})';1z;2z 'dd':2z 'd':2z 'MM':2z 'M':2z 'yy':2z 'y':2z 'HH':2z 'H':2z 'hh':2z 'h':2z 'mm':2z 'm':2z 'ss':2z 's':rs='(\\\\d\\\\d?)';1z;2z 'zzz':rs='([+-]?\\\\d\\\\d?:\\\\d{2})';1z;2z 'zz':2z 'z':rs='([+-]?\\\\d\\\\d?)';1z;2z '/':rs='(\\\\'+nC['/']+')';1z;5z:4y 2y cX(cX7x968x,2x,[sc]);1z}0y(rs)bb7x38x(rs);A7x38x(G[0])}ew(qZ7x398x(kS),bb);bb7x38x('$');8y tk=bb7x248x('')7x88x(/\\s+/g,'\\\\s+'),pR=1w;pR7x5438x=tk;pR7x5428x=A;3y pP[rX]=pR};9z ha2w{3y/\\/|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z|gg|g/g};9z id(tK,rX,nR){tK=jg(tK);8y nC=nR7x2848x,pQ=fu(nC,rX),G=2y dC(pQ7x5438x)7x2618x(tK);0y(G6w=2x)3y 2x;8y A=pQ7x5428x,kJ=2x,nl=2x,lj=2x,kg=2x,ni=2x,kQ=0,kR,li=0,mn=0,lf=0,my=2x,ci=1x;8z(8y kO=0,le=A7x18x;kO<le;kO2v){8y pr=G[kO+1];0y(pr){8y rK=A[kO],jW=rK7x18x,lg=_c(pr,10);6y(rK){2z 'dd':2z 'd':kg=lg;0y(ia(kg,1,31))3y 2x;1z;2z 'MMM':2z 'MMMM':lj=ft(nC,pr,jW6w=3);0y(ia(lj,0,11))3y 2x;1z;2z 'M':2z 'MM':lj=lg-1;0y(ia(lj,0,11))3y 2x;1z;2z 'y':2z 'yy':2z 'yyyy':nl=jW<4?fq(nC,lg):lg;0y(ia(nl,0,9999))3y 2x;1z;2z 'h':2z 'hh':kQ=lg;0y(kQ6w=12)kQ=0;0y(ia(kQ,0,11))3y 2x;1z;2z 'H':2z 'HH':kQ=lg;0y(ia(kQ,0,23))3y 2x;1z;2z 'm':2z 'mm':li=lg;0y(ia(li,0,59))3y 2x;1z;2z 's':2z 'ss':mn=lg;0y(ia(mn,0,59))3y 2x;1z;2z 'tt':2z 't':ci=nC.PM3w(pr6w=nC.PM[0]4wpr6w=nC.PM[1]4wpr6w=nC.PM[2]);0y(!ci3w(!nC.AM4w(pr9w=nC.AM[0]3wpr9w=nC.AM[1]3wpr9w=nC.AM[2])))3y 2x;1z;2z 'f':2z 'ff':2z 'fff':lf=lg*ds7x5398x(10,3-jW);0y(ia(lf,0,999))3y 2x;1z;2z 'ddd':2z 'dddd':ni=fr(nC,pr,jW6w=3);0y(ia(ni,0,6))3y 2x;1z;2z 'zzz':8y P=pr7x188x(/:/);0y(P7x18x9w=2)3y 2x;kR=_c(P[0],10);0y(ia(kR,-12,13))3y 2x;8y mF=_c(P[1],10);0y(ia(mF,0,59))3y 2x;my=(kR*60)+(jf(pr,'-')?-mF:mF);1z;2z 'z':2z 'zz':kR=lg;0y(ia(kR,-12,13))3y 2x;my=kR*60;1z;2z 'g':2z 'gg':8y rS=pr;0y(!rS4w!nC7x838x)3y 2x;rS=jg(rS7x1858x2w);8z(8y kS=0,lc=nC7x838x7x18x;kS<lc;i2v){0y(rS6w=nC7x838x[kS]7x718x7x1858x2w){kJ=kS;1z}}0y(kJ6w=2x)3y 2x;1z}}}8y eo=2y dc2w,kj,nQ=nC7x5238x;kj=nQ?nQ7x5308x(eo)[0]:eo7x2658x2w;0y(nl6w=2x)nl=kj;7z 0y(nC7x838x)nl0vnC7x838x[(kJ4w0)]7x688x;0y(lj6w=2x)lj=0;0y(kg6w=2x)kg=1;0y(nQ){eo=nQ7x8268x(nl,lj,kg);0y(eo6w=2x)3y 2x}7z{eo7x5278x(nl,lj,kg);0y(eo7x5178x2w9w=kg)3y 2x;0y(ni9w=2x3weo7x5418x2w9w=ni)3y 2x}0y(ci3wkQ<12)kQ0v12;eo7x5228x(kQ,li,mn,lf);0y(my9w=2x){8y jI=eo7x5388x2w-(my+eo7x2898x2w);eo7x5228x(eo7x2648x2w+_c(jI/60,10),jI%60)}3y eo};9z gV(eq,rX,nR){8y nC=nR7x2848x,nQ=nC7x5238x;0y(!rX4w!rX7x18x4wrX6w='i'){8y ts;0y(nR3wnR7x718x7x18x){0y(nQ)ts=gV(eq,nC7x2828x.F,nR);7z{8y em=2y dc(eq7x5288x2w),kJ=fM(eq,nC7x838x);em7x5278x(fs(eq,nC,kJ));ts=em7x5258x2w}}7z ts=eq7x488x2w;3y ts}8y v=nC7x838x,co=rX6w='s';rX=fp(nC,rX);8y be=0w;8y kQ,bz=['0','00','000'],bX,bO,qW=/([^d]|^)(d|dd)([^d]|$)/g,lF=0,ro=ha2w,q;9z ic(nc,kc){8y ts,tK=nc+'';0y(kc>13wtK7x18x<kc){ts=(bz[kc-2]+tK);3y ts7x278x(ts7x18x-kc,kc)}7z ts=tK;3y ts};9z he2w{0y(bX4wbO)3y bX;bX=qW7x738x(rX);bO=3x;3y bX};9z gY(el,ly){0y(q)3y q[ly];6y(ly){2z 0:3y el7x2658x2w;2z 1:3y el7x8298x2w;2z 2:3y el7x5178x2w}};0y(!co3wnQ)q=nQ7x5308x(eq);8z(;;){8y kS=ro7x2108x,c=ro7x2618x(rX);8y T=rX7x398x(kS,c?c7x2628x:rX7x18x);lF0vew(T,be);0y(!c)1z;0y(lF%2){be7x38x(c[0]);4z}8y rK=c[0],jW=rK7x18x;6y(rK){2z 'ddd':2z 'dddd':8y K=(jW6w=3)?nC7x1088x7x1228x:nC7x1088x7x1218x;be7x38x(K[eq7x5418x2w]);1z;2z 'd':2z 'dd':bX=3x;be7x38x(ic(gY(eq,2),jW));1z;2z 'MMM':2z 'MMMM':8y ly=gY(eq,1);be7x38x((nC7x3768x3whe2w)?nC7x3768x[jW6w=3?_[122]:_[1218x[ly]:nC7x1388x[jW6w=3?_[122]:_[1218x[ly]);1z;2z 'M':2z 'MM':be7x38x(ic(gY(eq,1)+1,jW));1z;2z 'y':2z 'yy':2z 'yyyy':ly=q?q[0]:fs(eq,nC,fM(eq,v),co);0y(jW<4)ly=ly%100;be7x38x(ic(ly,jW));1z;2z 'h':2z 'hh':kQ=eq7x2648x2w%12;0y(kQ6w=0)kQ=12;be7x38x(ic(kQ,jW));1z;2z 'H':2z 'HH':be7x38x(ic(eq7x2648x2w,jW));1z;2z 'm':2z 'mm':be7x38x(ic(eq7x5388x2w,jW));1z;2z 's':2z 'ss':be7x38x(ic(eq7x8308x2w,jW));1z;2z 't':2z 'tt':ly=eq7x2648x2w<12?(nC.AM?nC.AM[0]:' '):(nC.PM?nC.PM[0]:' ');be7x38x(jW6w=1?ly7x558x(0):ly);1z;2z 'f':2z 'ff':2z 'fff':be7x38x(ic(eq7x8328x2w,3)7x278x(0,jW));1z;2z 'z':2z 'zz':kQ=eq7x2898x2w/60;be7x38x((kQ4v0?'+':'-')+ic(ds7x1718x(ds7x1298x(kQ)),jW));1z;2z 'zzz':kQ=eq7x2898x2w/60;be7x38x((kQ4v0?'+':'-')+ic(ds7x1718x(ds7x1298x(kQ)),2)+':'+ic(ds7x1298x(eq7x2898x2w%60),2));1z;2z 'g':2z 'gg':0y(nC7x838x)be7x38x(nC7x838x[fM(eq,v)]7x718x);1z;2z '/':be7x38x(nC['/']);1z;5z:4y 2y cX(cX7x968x,2x,[rK]);1z}}3y be7x248x('')};8y nY=1w;nY7x718x='en';nY7x8318x='English';nY7x8078x='English';nY7x8068x=1x;nY7x1608x='en';8y pF=nY7x3068x=1w;pF7x1358x=['-n'];pF7x2638x=2;pF[',']=',';pF['.']='.';pF7x2738x=[3];pF['+']='+';pF['-']='-';8y pV=pF7x3218x=1w;pV7x1358x=['-n '+'%','n '+'%'];pV7x2638x=2;pV7x2738x=[3];pV[',']=',';pV['.']='.';pV7x2748x='%';8y nT=pF7x3558x=1w;nT7x1358x=['($n)','$n'];nT7x2638x=2;nT7x2738x=[3];nT[',']=',';nT['.']='.';nT7x2748x='$';nY7x4908x=1w;8y nE=nY7x2848x=nY7x4908x7x7848x=1w;nE7x718x='Gregorian_USEnglish';nE['/']='/';nE[':']=':';nE7x7838x=0;nE7x1088x=1w;nE7x1088x7x1218x=_[684]7x188x(';');nE7x1088x7x1228x=_[683]7x188x(';');nE7x1088x7x5008x=_[671]7x188x(';');nE7x1388x=1w;nE7x1388x7x1218x=_[672]7x188x(';');nE7x1388x7x1228x=_[673]7x188x(';');nE.AM='AM;am;AM'7x188x(';');nE.PM='PM;pm;PM'7x188x(';');8y nD=1w;nD7x718x='A.D.';nD7x2728x=2x;nD7x688x=0;nE7x838x=[nD];nE7x5138x=2029;8y nF=nE7x2828x=1w;nF['d']='M/d/yyyy';nF['D']='dddd,'+' MMMM dd,'+' yyyy';nF['t']='h:mm tt';nF['T']='h:mm:ss tt';nF['f']=nF['D']+' '+nF['t'];nF['F']=nF['D']+' '+nF['T'];nF['M']='MMMM dd';nF['Y']='yyyy MMMM';nF['S']='yyyy\\u0027-\\u0027MM\\u0027-\\u0027dd\\u0027T\\u0027HH\\u0027:\\u0027mm\\u0027:\\u0027ss';pq['en']=pq7x3778x=1w;nS['en']=nS7x3778x=nY;nn7x1488x=ph;nn7x1488x7x3538x=nY;gB(no,_[375],9z(or){0y(or7x668x6w_[148]){8y so=fI(no7x1758x,_[434]);0y(so 0z nS){ph7x3538x=nS[so];8z(8y sg 0z oc)0y(oc7x268x(sg)){8y nH=2y cU;nH7x2818x(_[368],1x,1x,so);hL(oc[sg],nH)}it(no,_[368],so)}}},1x);dB9x7x2768x=9z(tK){0y(4x7x18x>0){ik(5x,9z2w{9y(5x7x658x)gr(5x,5x7x658x);ge(5x,fT(5x7x228x,dQ(tK)))});3y 5x}7z{8y bp=0w;ik(5x,9z2w{bp7x38x(hO(5x))});3y bp7x248x('')}};dB9x7x7828x=9z(tQ){0y(4x7x18x>0){il(5x);3y 5x7x5688x(ih(tQ))}7z 0y(5x7x18x){8y B=0w;8z(8y px=5x[0]7x258x;px;px=px7x478x)B7x38x(px7x5488x2w);3y B7x248x('')}};dB9x7x7858x=9z(tQ){8y qe=2y dB;0y(5x7x18x){0y(!(tQ 1y dB))tQ=ih(tQ);8y qu=5x;ik(tQ,9z(kS){8y pO=5x;qu7x5618x(9z2w{8y px=kS?hJ(5x,3x):5x;ge(pO,px);qe[qe7x18x2v]=px})})}3y qe};dB9x7x7868x=9z(tQ){8y qe=2y dB;0y(5x7x18x){0y(!(tQ 1y dB))tQ=ih(tQ);8y qu=5x;ik(tQ,9z(kS){8y pO=5x,nt=5x7x258x;ik(qu,9z2w{8y px=kS?hJ(5x,3x):5x;0y(nt)go(pO,px,nt);7z ge(pO,px);qe[qe7x18x2v]=px})})}3y qe};dB9x7x2138x=9z(tQ){8y qe=2y dB;0y(5x7x18x){0y(!(tQ 1y dB))tQ=ih(tQ);8y qu=5x;ik(tQ,9z(kS){8y pO=5x7x48x,nt=5x;ik(qu,9z2w{8y px=kS?hJ(5x,3x):5x;go(pO,px,nt);qe[qe7x18x2v]=px})})}3y qe};dB9x7x7888x=9z(tQ){8y qe=2y dB;0y(5x7x18x){0y(!(tQ 1y dB))tQ=ih(tQ);8y qu=5x;ik(tQ,9z(kS){8y pO=5x7x48x,nt=5x7x478x;ik(qu,9z2w{8y px=kS?hJ(5x,3x):5x;0y(nt)go(pO,px,nt);7z ge(pO,px);qe[qe7x18x2v]=px})})}3y qe};dB9x7x7878x=9z(tQ){8y qe=2y dB;0y(5x7x18x){0y(!(tQ 1y dB))tQ=ih(tQ);8y qu=5x;ik(tQ,9z(kS){8y pO=5x7x48x,nt=5x;ik(qu,9z2w{8y px=kS?hJ(5x,3x):5x;go(pO,px,nt);qe[qe7x18x2v]=px});gr(5x7x48x,5x)})}3y qe};dB9x7x5688x=9z(tQ){0y(5x7x18x){0y(!(tQ 1y dB))tQ=ih(tQ);ik(5x,9z(kS){8y pO=5x;ik(tQ,9z2w{8y px=kS?hJ(5x,3x):5x;ge(pO,px)})})}3y 5x};dB9x7x7818x=9z(tQ){0y(5x7x18x){0y(!(tQ 1y dB))tQ=ih(tQ);ik(5x,9z(kS){8y pO=5x,nt=5x7x258x;ik(tQ,9z2w{8y px=kS?hJ(5x,3x):5x;0y(nt)go(pO,px,nt);7z ge(pO,px)})})}3y 5x};dB9x7x7808x=9z(tQ){0y(5x7x18x){0y(!(tQ 1y dB))tQ=ih(tQ);ik(5x,9z(kS){8y pO=5x7x48x,nt=5x;ik(tQ,9z2w{8y px=kS?hJ(5x,3x):5x;0y(pO)go(pO,px,nt);7z1w})})}3y 5x};dB9x7x7758x=9z(tQ){0y(5x7x18x){0y(!(tQ 1y dB))tQ=ih(tQ);ik(5x,9z(kS){8y pO=5x7x48x,nt=5x7x478x;ik(tQ,9z2w{8y px=kS?hJ(5x,3x):5x;0y(pO){0y(nt)go(pO,px,nt);7z ge(pO,px)}7z1w})})}3y 5x};dB9x7x7748x=9z(tQ){0y(5x7x18x){0y(!(tQ 1y dB))tQ=ih(tQ);ik(5x,9z(kS){8y pO=5x7x48x,nt=5x;ik(tQ,9z2w{go(pO,kS?hJ(5x,3x):5x,nt)});gr(5x7x48x,5x)})}3y 5x};dB9x7x7738x=9z2w{ik(5x,9z2w{gr(5x7x48x,5x)});3y 5x};9z il(qe){ik(qe,9z2w{9y(5x7x658x)gr(5x,5x7x658x)});3y qe};dB9x7x4038x=9z2w{3y il(5x)};dB9x7x7768x=9z2w{8y qe=2y dB;ik(5x,9z2w{qe[qe7x18x2v]=hJ(5x,3x)});3y qe};nn7x3368x=9z(px){0y(px6w2x){ny=nn7x1098x=2x}7z{8z(8y kS=0,ol,or;kS<i7x18x-1;kS2v){ol=i[kS];0y(ol7x2808x3wol7x1628x2w)gx(ol,_[234],1x);or=2y dt;or7x548x(_[477],1x,1x,6x,2x,0,0,0,0,1x,1x,1x,1x,0,i[kS+1]4w2x);or7x168x=ol7x58x2w;hL(ol,or)}i=2y dw;ny=nn7x1098x=px}};dB9x7x688x=9z(pH){0y(4x7x18x){3y 5x}7z 0y(5x7x18x){8y om=5x[0]7x58x2w;0y(om){8y ta=eL(om,_[423]),qj=gh(5x[0]),pW=1w;pW7x118x=qj7x118x;pW7x128x=qj7x128x;0y(ta6w_[681]4wta6w_[682]){pI=om7x2788x;0y(om9wpI){8y pJ=ev(no,pI);0y(pJ){8y pK=gh(pJ);pW7x118x1vpK7x118x;pW7x128x1vpK7x128x}}}3y pW}}3y 2x};dB9x7x2788x=9z2w{8y qe=2y dB;0y(5x7x18x){8y om=5x[0]7x58x2w;qe[qe7x18x2v]=(om?ev(no,om7x2788x):2x)4wnp}3y qe};dB9x7x4238x=9z2w{0y(5x7x18x){8y om=5x[0]7x58x2w;0y(om){8y qj=gh(5x[0]),pW=1w;pW7x118x=qj7x118x;pW7x128x=qj7x128x;3y qj}}3y 2x};dB9x7x858x=9z(nc){0y(5x7x18x){8y om=5x[0]7x58x2w;0y(om){0y(4x7x18x)om7x858x=nc;7z 3y om7x858x}}3y 2x};dB9x7x848x=9z(nc){0y(5x7x18x){8y om=5x[0]7x58x2w;0y(om){0y(4x7x18x)om7x848x=nc;7z 3y om7x848x}}3y 2x};nn7x4198x=9z(ol,tG,tT){4y 2y cX(cX7x98x)};nn7x4188x=9z(ol,tG){4y 2y cX(cX7x98x)};dB9x7x4198x=9z(tG,tT){4y 2y cX(cX7x98x)};dB9x7x4188x=9z(tG){4y 2y cX(cX7x98x)};dB9x7x4208x=9z(kk,tG){4y 2y cX(cX7x98x)};dB9x7x7778x=9z2w{4y 2y cX(cX7x98x)};dB9x7x7798x=9z2w{4y 2y cX(cX7x98x)};dB9x7x7788x=9z2w{4y 2y cX(cX7x98x)};dB9x7x7898x=9z2w{4y 2y cX(cX7x98x)};dB9x7x7908x=9z2w{4y 2y cX(cX7x98x)};dB9x7x8018x=9z2w{4y 2y cX(cX7x98x)};dB9x7x3918x=9z2w{4y 2y cX(cX7x98x)};dB9x7x8008x=9z2w{4y 2y cX(cX7x98x)};dB9x7x8028x=9z2w{4y 2y cX(cX7x98x)};dB9x7x8038x=9z2w{4y 2y cX(cX7x98x)};dB9x7x8058x=9z2w{4y 2y cX(cX7x98x)};dB9x7x8048x=9z2w{4y 2y cX(cX7x98x)};dB9x7x7998x=9z2w{4y 2y cX(cX7x98x)};dB9x7x7988x=9z2w{4y 2y cX(cX7x98x)};8y cC=9z(sn){5x7x388x=sn};cC9x=2y cI;cC9x7x338x=sw;cC9x7x388x=_[442];es(cC);8y cD=9z(sn){5x7x388x=sn};cD9x=2y dg;cD9x7x338x=sw;cD9x7x388x=_[371];cD9x7x978x=9z2w{3y ''};es(cD);8y cJ=9z2w1w;cJ9x=2y cC(_[680]);cJ7x158x=1w;cJ7x158x7x448x=9z(or){5x7x538x7x2758x=5x7x1048x6w_[128]};cJ7x158x7x948x=9z(or){5x7x538x7x2758x=1x};es(cJ);8y cK=9z2w1w;cK9x=2y cC(_[679]);cK7x158x=1w;cK7x158x7x448x=9z(or){5x7x538x7x2878x=5x7x1048x6w_[128]};cK7x158x7x948x=9z(or){5x7x538x7x2878x=1x};es(cK);8y cL=9z2w1w;cL9x=2y cC(_[676]);cL7x158x=1w;cL7x158x7x448x=9z(or){5x7x538x7x2868x=5x7x1048x6w_[128]};cL7x158x7x948x=9z(or){5x7x538x7x2868x=1x};es(cL);8y cM=9z2w1w;cM9x=2y cC(_[677]);cM7x158x=1w;cM7x158x7x448x=9z(or){8y bw=5x7x1048x7x188x(' ');5x7x538x7x2858x=(bw7x178x(_[12])>-1?1:0)+(bw7x178x(_[75])>-1?2:0)+(bw7x178x(_[78])>-1?4:0)+(bw7x178x(_[11])>-1?8:0)};cM7x158x7x948x=9z(or){5x7x538x7x2858x=0};es(cM);8y cN=9z2w1w;cN9x=2y cC(_[678]);cN7x158x=1w;cN7x158x7x448x=9z(or){5x7x538x7x1978x=5x7x1048x6w_[128]?3x:5x7x1048x6w_[589]?1x:2x};cN7x158x7x948x=9z(or){5x7x538x7x1978x=2x};es(cN);8y dh=9z2w{5x7x1278x=2y dw};dh9x=2y cD(_[6]);dh9x7x1278x=2x;dh9x7x4838x=9z(ol){5x7x1278x7x1198x(ol)};dh9x7x4338x=9z(ol){5x7x1278x7x2838x(ol)};dh9x7x1988x=9z2w{8z(8y kS=0;kS<5x7x1278x7x18x;kS2v)5x7x1278x[kS]7x3088x2w};dh7x158x=1w;dh7x158x7x448x=9z(or){0y(5x7x28x7x2118x)hw(5x,5x7x28x7x2118x)};dh7x158x7x948x=9z(or){8z(8y kS=0;kS<5x7x1278x7x18x;kS2v)5x7x1278x[kS]7x1638x2w};dh7x158x7x2528x=9z(or){0y(5x7x28x7x348x6w_[190])5x7x1988x(or7x288x)};dh7x158x7x2158x=9z(or){0y(5x7x28x7x348x6w_[190])5x7x1988x(or7x288x)};dh7x158x7x1248x=9z(or){0y(5x7x28x7x348x6w_[190])5x7x1988x(or7x288x)};dh7x158x7x1968x=9z(or){0y(or7x288x6w5x)6y(or7x1658x){2z _[211]:hw(5x,or7x1658x);1z;2z _[34]:4y 2y cX(cX7x98x)}7z 0y(5x7x28x7x348x6w_[190])5x7x1988x(or7x288x)};es(dh);8y di=9z2w1w;di9x=2y cD(_[458]);di7x158x=1w;di7x158x7x448x=9z(or){0y(5x7x258x){0y(5x7x28x7x698x)5x7x48x7x2038x(5x7x28x7x698x,2y _b(_[69],5x7x258x7x218x),5x7x28x7x4568x6w_[218]);7z eE(5x7x258x7x218x)}};es(di);8y dj=9z2w1w;dj9x=2y cD(_[586]);dj9x7x68x=2x;dj9x.u=2x;dj7x158x=1w;dj7x158x7x1968x=9z(or){0y(or7x288x6w5x)6y(or7x1658x){2z _[6]:5x7x1348x(or7x1658x);1z}};dj7x158x7x448x=9z(or){8y ol=od[5x7x28x7x68x];0y(ol){5x7x1348x(ol);5x7x3088x2w}};dj7x158x7x948x=9z(or){5x7x1638x2w};dj9x7x1348x=9z(ol){0y(5x7x68x3w5x7x68x9wol)5x7x1638x2w;7z{5x7x68x=ol;5x7x68x7x4838x(5x)}};dj9x7x1638x=9z2w{0y(5x7x68x){5x7x68x7x4338x(5x);5x7x68x=2x}};dj9x7x3088x=9z2w{0y(5x.u)3y;8y ol=5x;5x.u=iZ(9z2w{ol.u=2x;ol7x4528x2w},0)};dj9x7x4528x=9z2w{0y(5x7x68x){8y t,kS,ol;t=5x7x48x7x148x;8z(kS=0;ol=t[kS];kS2v)0y(ol7x4518x)gr(ol7x48x,ol)3wkS3v;8y nO=5x,nP=1w,iD=9z(tb){3y tb 0z nP?nP[tb]:nP[tb]=hT(nO,tb)};t=hF([5x7x68x],5x7x28x7x3608x4w'',iD);8z(kS=0;kS<t7x18x;kS2v)go(5x7x48x,gs(hJ(5x7x258x,3x),t[kS],iD),5x)7x4518x=kS+1}};8y qX=/(\\{([^\\}]+)\\})/g;9z gs(ol,nV,iD){8y px,sH;8z(8y kS=0;kS<ol7x148x7x18x;kS2v){px=ol7x148x[kS];6y(px7x78x){2z 1:8z(sH 0z px7x28x)0y(px7x28x7x268x(sH)3wpx7x28x[sH]7x108x(qX))px7x28x[sH]=px7x28x[sH]7x88x(dC.$1,gt(dC.$2,nV,iD));gs(px,nV,iD);1z;2z 3:2z 4:0y(px7x68x7x108x(qX)){px7x68x=px7x68x7x88x(dC.$1,gt(dC.$2,nV,iD));px7x218x=px7x68x;px7x18x=px7x68x7x18x}}}3y ol};9z gt(th,nV,iD){8y ol=hF([nV],th,iD,3x)[0];3y ol3wol7x258x?ol7x258x7x68x:''};es(dj);8y dF=9z(sn){5x7x388x=sn};dF9x=2y dg;dF9x7x338x=sx;dF9x7x388x=_[371];es(dF);8y dO=9z2w{dF7x2098x(5x,4x)};dO9x=2y dF(_[585]);9z iP(or){8y ol=or7x678x;ol7x958x=iR(ol7x28x7x958x);ol7x928x=iR(ol7x28x7x928x);ol7x2598x=iS(ol7x28x7x2598x);ol7x2608x=iT(ol7x28x7x2608x,1);ol7x2018x=iS(ol7x28x7x2018x);ol7x2048x=ol7x28x7x2048x6w_[128];ol7x2668x=iT(ol7x28x7x2668x,0);ol7x2718x=iT(ol7x28x7x2718x,0);ol7x1668x=iT(ol7x28x7x1668x,1);0y(ol7x48x 1y dO)3y;8y qC,ex=9z2w{iN(ol)},gz=9z2w{iO(ol)};0y(ol7x958x7x698x){qC=ol7x958x7x1728x?od[ol7x958x7x1728x]:ol7x48x;gB(qC,ol7x958x7x698x,9z2w{ol7x958x7x688x?iZ(ex,ol7x958x7x688x):ex2w})}7z ol7x958x7x688x?iZ(ex,ol7x958x7x688x):ex2w;0y(ol7x928x7x698x){qC=ol7x928x7x1728x?od[ol7x928x7x1728x]:ol7x48x;gB(qC,ol7x928x7x698x,9z2w{ol7x928x7x688x?iZ(gz,ol7x928x7x688x):gz2w})}};dO9x7x7938x=9z2w{iN(5x)};dO9x7x7928x=9z2w{iO(5x)};dO9x7x7918x=9z(lq){4y 2y cX(cX7x98x)};dO9x7x7948x=9z(lq){4y 2y cX(cX7x98x)};dO9x7x7958x=9z(mo){4y 2y cX(cX7x98x)};dO9x7x7978x=9z2w{4y 2y cX(cX7x98x)};dO9x7x7968x=9z2w{4y 2y cX(cX7x98x)};8y bh=0w,mj;9z iQ2w{8y nX=2y dc,mP,mQ,mN,mI,mR,mL,mO,mS,mH,mK,mM,mJ;8z(8y kS=0,ol;ol=bh[kS];kS2v){mQ=ol7x2598x;mN=ol7x2598x*ol7x2608x;0y(ol7x2018x9wkV)mN=ol7x2608x6w1?ol7x2018x:ds7x3668x(mN,ol7x2018x);mI=mN;mR=nX-ol7x2728x;mL=ol7x1668x>0?mR*ol7x1668x:mI-mR*ds7x1298x(ol7x1668x);0y((ol7x928x7x688x3wmR5vol7x928x7x688x)4w(mR5vmI*(ol7x2048x?2:1)/ol7x1668x)){iO(ol);0y(ol7x48x 1y dM){8z(8y n=ol7x48x7x148x,jX=n7x888x(ol);jX<n7x18x;jX2v)0y(n[jX+1] 1y dO){iN(n[jX+1]);1z}}}7z 0y(ol 1y dE3w!(ol 1y dN)){mO=mQ*(ol7x2048x?2:1);mS=mL-mO*ds7x1718x(mL/mO);0y(ol7x2048x3wmS5vmQ)mS=2*mQ-mS;mP=1/(1-ol7x2668x/2-ol7x2718x/2);mH=mQ*ol7x2668x;mK=mQ*ol7x2718x;0y(mS<mH)mM=mS*(mP*mS/mH)/2;7z 0y(mS>mQ-mK){mJ=mS-(mQ-mK);mM=mP*(mQ-mH/2-mK+mJ*(2-mJ/mK)/2)}7z mM=mP*(mS-mH/2);iK(ol,mM/mQ)}}0y(bh7x18x)mj=iZ(iQ,10)};9z iN(ol){0y(ol 1y dE){0y(5y ol7x578x6w_[91])ol7x578x=od[ol7x578x7x278x(1)];8z(8y kS=0,oo;oo=bh[kS];kS2v)0y(oo 1y dE3woo7x578x6wol7x578x3woo7x1128x6wol7x1128x){iO(oo);1z}}ol7x2728x=2y dc;bh7x38x(ol);0y(ol 1y dE)iG(ol);8y n=ol7x148x;0y(ol 1y dL){8z(8y kS=0;kS<n7x18x;kS2v)0y(n[kS] 1y dO)iN(n[kS])}7z 0y(ol 1y dM){8z(8y kS=0;kS<n7x18x;kS2v)0y(n[kS] 1y dO){iN(n[kS]);1z}}0y(bh7x18x3w!mj)mj=iZ(iQ,0);8y or=2y dP;or7x2958x(_[95],6x,2x);hL(ol,or)};9z iO(ol){8z(8y kS=0,oo,bW=1x;oo=bh[kS];kS2v)0y(bW)bh[kS-1]=oo;7z 0y(oo6wol)bW=3x;0y(bW)bh7x18x3v;8y n=ol7x148x;0y(ol 1y dL4wol 1y dM)8z(8y kS=0;kS<n7x18x;kS2v)0y(n[kS] 1y dO)iO(n[kS]);0y(ol 1y dE)iH(ol);0y(!bh7x18x3wmj)mj=fF(mj);8y or=2y dP;or7x2958x(_[92],6x,2x);hL(ol,or)};8y jF=1w;jF['h']=3600;jF7x3668x=60;jF['s']=1;9z iR(tK){8y nX=1w,ch=3x,bw;0y(!tK4wtK6w_[402])nX7x4598x=kV;7z 0y(bw=tK7x108x(/^wallclock\\(.+\\)$/))nX7x4598x=2x;7z{0y(bw=tK7x108x(/^(?:(\\w+)\\.)?([a-z]\\w+)/)){nX7x1728x=bw[1];nX7x698x=bw[2];tK=tK7x88x(bw[0],'')}7z{nX7x1728x=2x;nX7x698x=2x}0y(bw=tK7x108x(/^([+-])/)){ch=bw[1]6w'+';tK=tK7x88x(bw[0],'')}0y(bw=tK7x108x(/^(?:(\\d+):)?([0-5]\\d):([0-5]\\d)(.\\d+)?$/))nX7x688x=(ch?1:-1)*((bw[1]?bw[1]*jF['h']:0)+bw[2]*jF['m0z']+bw[3]*jF['s'])*1e3+(bw[4]?bw[4]:0);7z 0y(bw=tK7x108x(/^(\\d+)(.\\d+)?(h|m0z|s|ms)?$/))nX7x688x=(ch?1:-1)*(bw[1]*1+(bw[2]?bw[2]*1:0))*(bw[3]6w'ms'?1:1e3*jF[bw[3]4w's']);7z nX7x688x=0}3y nX};9z iS(tK){8y bw;0y(!tK4wtK6w_[402])3y kV;7z 0y(bw=tK7x108x(/^(?:(\\d+):)?([0-5]\\d):([0-5]\\d)(.\\d+)?$/))3y((bw[1]?bw[1]*jF['h']:0)+bw[2]*jF['m0z']+bw[3]*jF['s'])*1e3+(bw[4]?bw[4]:0);7z 0y(bw=tK7x108x(/^(\\d+)(.\\d+)?(h|m0z|s|ms)$/))3y(bw[1]*1+(bw[2]?bw[2]*1:0))*(bw[3]6w'ms'?1:1e3*jF[bw[38x);7z 3y kV};9z iT(tK,ki){3y hh(tK=ie(tK))?ki:tK};es(dO);8y dE=9z2w{dO7x2098x(5x,4x)};dE9x=2y dO(_[620]);9z iJ(or){8y ol=or7x678x;ol7x578x=ol7x28x7x578x4wol7x28x7x5988x;ol7x1128x=ol7x28x7x1128x;ol7x2688x=ol7x28x7x2688x;ol7x2708x=hm(ol7x28x7x2708x);ol.to=hm(ol7x28x['to']);ol.by=hm(ol7x28x['by']);ol7x1878x=iM(ol7x28x7x1878x);ol7x1818x=ol7x28x7x1818x;ol7x2698x=ol7x28x7x2698x;ol7x4608x=ol7x28x7x4608x;ol7x4318x=ol7x28x7x4318x;0y(!ol7x578x)8z(8y pO=ol;pO=pO7x48x;)0y(!(pO 1y dF)){ol7x578x=pO;1z}iP(or)};9z iG(ol){ol7x2678x=iI(ol)4w['','',''];0y(ol 1y dN)iL(ol,ol.to)};9z iK(ol,lD){8y bx=ol7x1878x,lc=bx7x18x,mp=ds7x1718x(lD*lc),qO=bx[mp];0y(ol7x1818x6w_[621]4wol7x1818x6w_[429]){0y(ol7x1818x6w_[429])8z(8y kS=0;kS<mp;kS2v)qO=hs(bx[kS],qO)}7z{8y pf=ol7x2708x?ol7x2708x:ol7x2678x;0y(lc){mp=ds7x1718x(lD*(lc-1));qO=bx[mp];0y(mp<lc-1)qO=hs(qO,hk(hr(bx[mp+1],qO),(lD-mp/(lc-1))*(lc-1)))}7z qO=hs(pf,hk(ol.to?hr(ol.to,pf):ol.by,lD))}iL(ol,qO)};9z iH(ol){8y qO;0y(ol7x2698x6w_[625]4w(ol7x2698x6w_[613]3wbh7x178x(ol7x48x)>-1))qO=ol7x1878x[ol7x1878x7x18x-1]4wol.to4whs(ol7x2678x,ol.by);7z qO=ol7x2678x;iL(ol,qO)};9z iI(ol){8y bw=2x;0y(ol7x2688x6w_[406]){0y(ol 1y dI){8y om=ol7x578x7x58x2w;0y(om){8y nM=eG(om),qP=hm(nM7x128x),qQ=hm(nM7x118x);bw=[[qP[0],qQ[08x,qP[18x}}7z bw=hm(ol7x578x7x3638x(ol7x1128x))}7z{0y(ol 1y dI)4y 2y cX(cX7x98x);7z bw=hm(ol7x578x7x818x(ol7x1128x))4w['','',''];0y(ol 1y dJ)bw[2]=''}3y bw};9z iL(ol,bw){7y{0y(bw3wbw[1]6w'#')bw=ht(bw[0]);0y(ol7x2688x6w_[406]){0y(ol 1y dI){8y om=ol7x578x7x58x2w;0y(om){8y qA=om7x138x;qA7x128x=bw[0][0]+(bw[1]4w'px');qA7x118x=bw[0][1]+(bw[1]4w'px')}}7z ol7x578x7x3808x(ol7x1128x,bw7x248x(''))}7z{0y(ol 1y dI)4y 2y cX(cX7x98x);7z 0y(ol 1y dJ)ol7x578x7x908x(ol7x1128x,bw[0]?ol7x28x7x348x+'('+bw[0]+')':'');7z ol7x578x7x908x(ol7x1128x,bw[2]?bw[2]+'('+bw[0]+')':bw7x248x(''))}}3z(pa)1w};9z iM(tK){0y(!tK)3y 0w;8z(8y kS=0,by=tK7x188x(';'),bx=0w,qO;kS<by7x18x;kS2v)0y(qO=hm(by[kS]))bx7x38x(qO);3y bx};es(dE);8y dP=9z2w1w;dP9x=2y dm;dP9x7x1568x=2x;dP9x7x668x=2x;dP9x7x2958x=9z(tG,qS,kp){5x7x508x(tG,1x,1x);5x7x1568x=qS;5x7x668x=kp};8y dG=9z2w1w;dG9x=2y dE(_[563]);dG7x158x=1w;dG7x158x7x448x=iJ;es(dG);8y dH=9z2w1w;dH9x=2y dE(_[603]);dH7x158x=1w;dH7x158x7x448x=iJ;es(dH);8y dI=9z2w1w;dI9x=2y dE(_[604]);dI7x158x=1w;dI7x158x7x448x=iJ;es(dI);8y dJ=9z2w1w;dJ9x=2y dE(_[611]);dJ7x158x=1w;dJ7x158x7x448x=iJ;es(dJ);8y dK=9z2w1w;dK9x=2y dO(_[607]);dK7x158x=1w;dK7x158x7x448x=iP;es(dK);8y dL=9z2w1w;dL9x=2y dO(_[608]);dL7x158x=1w;dL7x158x7x448x=iP;es(dL);8y dM=9z2w1w;dM9x=2y dO(_[605]);dM7x158x=1w;dM7x158x7x448x=iP;es(dM);8y dN=9z2w1w;dN9x=2y dE(_[599]);dN7x158x=1w;dN7x158x7x448x=iJ;es(dN);8y ef=9z(sn){5x7x388x=sn};ef9x=2y dg;ef9x7x338x=sz;ef9x7x388x=_[371];ef9x7x978x=9z2w{3y ''};es(ef);8y eg=9z2w1w;eg9x=2y ef(_[602]);eg7x158x=1w;eg7x158x7x448x=9z(or){8y tK=5x7x28x7x4588x4w'';gB(5x7x48x,5x7x28x7x698x,_b(_[69],(5x7x28x7x6228x6w_[558]?_[69]+'.'+_[247]+'2w;':'')+(5x7x28x7x6248x6w_[627]?_[69]+'.'+_[56]+'2w;':'')+(tK7x178x(_[362]+':')6w0?tK7x278x(dQ(_[362]+':')7x18x):'')),5x7x28x7x4568x6w_[218])};es(eg);8y eb=9z(sn){5x7x388x=sn};eb9x=2y cI;eb9x7x338x=sC;eb9x7x388x=_[442];es(eb);8y ec=9z2w1w;ec9x=2y eb(_[142]);es(ec);9z gH(sH,sS){3y _b('3y \"'+_[103]+' '+sH+'2w'+' '+'{'+' '+'['+(sS4w_[372])+' '+_[195]+']'+' '+'}\"')};9z gJ(sH){3y _b('3y \"['+_[74]+' '+sH+']\"')};8y gG=gH(_[48]);gG7x488x=gG;9z gI(tW,jk){0y(!tW7x268x(_[48])){tW7x488x=jk;tW7x488x7x488x=gG}};9z gE(tW,sH,sS){gI(tW,(tW 1y _b?gH:gJ)(sH,sS));gF(tW,sS);0y(tW9x)gE(tW9x,sH,sS)};9z gF(pG,sS){8z(8y sH 0z pG)0y(pG7x268x(sH)3wpG[sH] 1y _b)gI(pG[sH],gH(sH,sS))};9z gD(dz,sH,pG,sS){gE(dz,sH,sS);(pG4wjB)[sH]=dz};gD(dm,_[302]);gD(cU,_[382]);gD(dZ,_[325]);gD(dT,_[324]);gD(dr,_[328]);gD(dt,_[349]);gD(ea,_[350]);gD(du,_[351]);gD(dp,_[347]);gD(dV,_[299]);gD(da,_[981]);gD(dv,_[426]);gD(cI,_[889]);gD(cP,_[888]);gD(cQ,_[887]);gD(cT,_[890]);gD(cV,_[891]);gD(dd,_[414]);gD(de,_[893]);gD(dg,_[411]);gD(dk,_[892]);gD(cX,_[443]);gD(cW,_[886]);gD(cY,_[885]);gD(dw,_[880]);gD(dA,_[879]);gD(dS,_[878]);gD(dU,_[881]);gD(dW,_[882]);gD(db,_[884]);gD(df,_[364]);gD(dD,_[384]);gD(dq,_[465]);gD(dx,_[883]);gD(cF,_[466]);gD(dB,_[894]);gE(cG,_[895]);gE(ei,_[426]);gE(ee,_[411]);gE(ed,_[414]);gE(nn7x778x,_[77]);gE(nn7x2928x,_[292]);gE(nn7x3048x,_[304]);gE(nn7x1488x,_[148]);gE(dx7x868x,_[86]);gE(np7x58x,_[5]);gD(nn,_[372],6x);",'>?!>=!..!,,!>.!>,!>"!>>"!""!>>!>>>!}}!\'\'!*)!~|!^\\!^%\\!^^!\\`\\!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 attributes push parentNode $getContainer data nodeType replace NOT_SUPPORTED_ERR match left top style childNodes handlers $pseudoTarget indexOf split clientX clientY nodeValue ownerDocument uniqueID join firstChild hasOwnProperty substr target altKey ctrlKey shiftKey call namespaceURI type documentElement screenX screenY localName slice opacity metaKey height defaultPrevented DOMNodeInsertedIntoDocument nodeName initMutationEvent nextSibling toString xmlns initEvent caller pop ownerElement initMouseEvent charAt preventDefault targetElement width eventInterface prefix initUIEvent display undefined previousSibling lastChild detail currentTarget offset event getElementsByTagName name none test object right readyState prefixes bottom eventPhase class getAttribute touches eras scrollLeft scrollTop pseudoClass auto $indexOf className setAttribute string end appendChild DOMNodeRemovedFromDocument begin SYNTAX_ERR $getTag ease toJSON xml INDEX_SIZE_ERR relatedTarget function value responseText contentFragment script days activeElement load charCodeAt attributeName mousedown message button setRequestHeader initDragEvent overflow $add resize names namesAbbr AT_TARGET DOMCharacterDataModified bubbles filter customers true abs error open removeChild normal bind pattern createElement keydown months readystatechange abort unload href scroll substring success dropEffect mouseup locale NOT_FOUND_ERR cssText cancelable item Shift rotation scale view Control Alt Meta language Content-Type $isAccessible unbind parsererror newValue speed innerHTML mousewheel mousemove div floor element types keyIdentifier domConfig gateway $listeners hashchange CAPTURING_PHASE xml:base calcMode disabled findClosestCulture toUpperCase toLowerCase initFocusEvent values tabIndex focus application/xml callee url complete click code DOMAttrModified $selectable notify moz number repeatDur drop addEventListener autoReverse hidden trim text/css backgroundPosition apply lastIndex src borderLeftWidth insertBefore copy DOMNodeRemoved getResponseHeader status capture releaseCapture deltaY dataType send timeout hasChildNodes mouseover touchstart touchmove parameterNames keyup borderTopWidth borderBottomWidth touchend contextmenu hover addParameter userAgent drag dblclick keypress borderRightWidth GET replaceChild Alpha getBoundingClientRect JSON XSLTProcessor stopPropagation initResizeEvent initKeyboardEvent keyCode ample-enable-transitions DOMNodeInserted ample-enable-style tagName fromCharCode DXImageTransform.Microsoft.Alpha XMLHttpRequest Microsoft dur repeatCount exec index decimals getHours getFullYear accelerate original attributeType fill from decelerate start groupSizes symbol $draggable text null offsetParent resolver $hoverable initCustomEvent patterns $remove calendar $resizeEdges $resizable $droppable hash getTimezoneOffset webkit $animations classes $requests dragleave initTimeEvent querySelectorAll removeEventListener querySelector TouchEvent text/xml setData Event parse easing tbody numberFormat NOT_INITIALIZED_ERR refresh output responseXML marginLeft XMLDOM lang changedTouches identifier not pageX pageY targetTouches map percent gestureend loading TextEvent UIEvent scrollIntoView contains KeyboardEvent text/javascript location BUBBLING_PHASE HIERARCHY_REQUEST_ERR move removeAttribute Microsoft.XMLDOM modal ample-user-agent clipboardData getModifierState appendData gesturestart deleteData insertData gesturechange replaceData text/ample+css GestureEvent touchcancel MouseEvent WheelEvent MutationEvent media culture marginTop currency importNode initWheelEvent Array async select parseFloat javascript $getStyleComputed DragEvent 0000 min lastIndexOf localechange valueOf wheelDelta #element ample filters write configchange monthsGenitive default currentStyle extend $setStyle setCapture CustomEvent priority ResizeEvent statusText blur checked losecapture MSXML2 getParameter parent oldURL relatedNode mouseout mouseenter prevValue attrName newURL DOMActivate attrChange setParameter indefinite empty X-User-Agent json CSS paddingLeft POST X-Requested-With baseURI Element getFeature Esc Document easeout paddingRight paddingTop dequeue queue delay xsl DOMFocusIn position deltaMode paddingBottom Node relatedException severity paced DOMFocusOut accumulate trimRight unregister ample-locale UNSENT DONE trimLeft resizestart dataTransfer stringify dragenter #attribute DOMException getAllResponseHeaders resizeend transform ample-module-history-fix input reset loadXML dataIndex repeat effectstart effectend max-height phase edge handler time additive textinput forEach every removeParameter HashChangeEvent AmpleException deltaX inputMethod DOMParser XMLSerializer some reduce atob btoa dragover now mouseleave dragend dragstart reduceRight isArray keyLocation register deltaZ Tab createTextNode initTextEvent srcElement getSelection calendars indeterminate progid initHashChangeEvent initClipboardEvent transparent xml:lang initGestureEvent initTouchEvent removeAllRanges namesShort trigger baseName getElementsByTagNameNS getElementById createDocumentFragment DOMMouseScroll selectstart link clearData getData close document twoDigitYearMax backgroundColor parseFromString context getDate selector parseError #text DOCTYPE setHours convert include toLocaleString namespaces setFullYear getTime body fromGregorian parseInt round marginBottom marginRight table cursor offsetHeight getMinutes pow specified getDay groups regExp beforecopy head xlink handleError toXML getAttributeNS smil xi handleEvent implementation SEVERITY_ERROR ev $getTagClose $getTagOpen stop error-handler setAttributeNodeNS each getAttributeNodeNS animate application/ample+xml onreadystatechange fast aml append min-height paste beforecut get boolean beforepaste min-width removeAttributeNS max-width cut version concat setAttributeNS plugin FocusEvent ClipboardEvent #element-time repeater nth-last-child rgb false 8:Backspace;9:Tab;13:Enter;16:Shift;17:Control;18:Alt;20:CapsLock;27:Esc;33:PageUp;34:PageDown;35:End;36:Home;37:Left;38:Up;39:Right;40:Down;45:Insert;46:Backspace;91:Win;112:F1;113:F2;114:F3;115:F4;116:F5;117:F6;118:F7;119:F8;120:F9;121:F10;122:F11;123:F12;127:Del ease-out nth-child span ease-in-out option rgba easeinout xlink:href set thead linear listener animateColor animateMotion seq MacIntel excl par slow cubic-bezier animateTransform easein hold enabled visible tfoot odd even aliceblue:F0F8FF;antiquewhite:FAEBD7;aqua:00FFFF;aquamarine:7FFFD4;azure:F0FFFF;beige:F5F5DC;bisque:FFE4C4;black:000000;blanchedalmond:FFEBCD;blue:0000FF;blueviolet:8A2BE2;brown:A52A2A;burlywood:DEB887;cadetblue:5F9EA0;chartreuse:7FFF00;chocolate:D2691E;coral:FF7F50;cornflowerblue:6495ED;cornsilk:FFF8DC;crimson:DC143C;cyan:00FFFF;darkblue:00008B;darkcyan:008B8B;darkgoldenrod:B8860B;darkgray:A9A9A9;darkgreen:006400;darkkhaki:BDB76B;darkmagenta:8B008B;darkolivegreen:556B2F;darkorange:FF8C00;darkorchid:9932CC;darkred:8B0000;darksalmon:E9967A;darkseagreen:8FBC8F;darkslateblue:483D8B;darkslategray:2F4F4F;darkturquoise:00CED1;darkviolet:9400D3;deeppink:FF1493;deepskyblue:00BFFF;dimgray:696969;dodgerblue:1E90FF;firebrick:B22222;floralwhite:FFFAF0;forestgreen:228B22;fuchsia:FF00FF;gainsboro:DCDCDC;ghostwhite:F8F8FF;gold:FFD700;goldenrod:DAA520;gray:808080;green:008000;greenyellow:ADFF2F;honeydew:F0FFF0;hotpink:FF69B4;indianred:CD5C5C;indigo:4B0082;ivory:FFFFF0;khaki:F0E68C;lavender:E6E6FA;lavenderblush:FFF0F5;lawngreen:7CFC00;lemonchiffon:FFFACD;lightblue:ADD8E6;lightcoral:F08080;lightcyan:E0FFFF;lightgoldenrodyellow:FAFAD2;lightgreen:90EE90;lightgrey:D3D3D3;lightpink:FFB6C1;lightsalmon:FFA07A;lightseagreen:20B2AA;lightskyblue:87CEFA;lightslategray:778899;lightsteelblue:B0C4DE;lightyellow:FFFFE0;lime:00FF00;limegreen:32CD32;linen:FAF0E6;magenta:FF00FF;maroon:800000;mediumaquamarine:66CDAA;mediumblue:0000CD;mediumorchid:BA55D3;mediumpurple:9370DB;mediumseagreen:3CB371;mediumslateblue:7B68EE;mediumspringgreen:00FA9A;mediumturquoise:48D1CC;mediumvioletred:C71585;midnightblue:191970;mintcream:F5FFFA;mistyrose:FFE4E1;moccasin:FFE4B5;navajowhite:FFDEAD;navy:000080;oldlace:FDF5E6;olive:808000;olivedrab:6B8E23;orange:FFA500;orangered:FF4500;orchid:DA70D6;palegoldenrod:EEE8AA;palegreen:98FB98;paleturquoise:AFEEEE;palevioletred:DB7093;papayawhip:FFEFD5;peachpuff:FFDAB9;peru:CD853F;pink:FFC0CB;plum:DDA0DD;powderblue:B0E0E6;purple:800080;red:FF0000;rosybrown:BC8F8F;royalblue:4169E1;saddlebrown:8B4513;salmon:FA8072;sandybrown:F4A460;seagreen:2E8B57;seashell:FFF5EE;sienna:A0522D;silver:C0C0C0;skyblue:87CEEB;slateblue:6A5ACD;slategray:708090;snow:FFFAFA;springgreen:00FF7F;steelblue:4682B4;tan:D2B48C;teal:008080;thistle:D8BFD8;tomato:FF6347;turquoise:40E0D0;violet:EE82EE;wheat:F5DEB3;white:FFFFFF;whitesmoke:F5F5F5;yellow:FFFF00;yellowgreen:9ACD32 #element-animation discrete propagate ease-in defaultAction freeze animated cancel http://www.w3.org/1999/XSL/Transform ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ #comment BackgroundImageCache IsCallable Microsoft.XMLHTTP SelectionNamespaces FreeThreadedDOMDocument XSLTemplate interactive http://www.w3.org/XML/1998/namespace text/ample+javascript application/ample+javascript pre loaded http://www.w3.org/2001/XInclude http://www.w3.org/2008/SMIL30/ http://www.w3.org/2001/xml-events #cdata-section element-content-whitespace ample-enable-guard application/x-www-form-urlencoded evt BackCompat 1.0 #document color xml-stylesheet method ample-version comments entities #document-fragment en ecmascript ample-user-locale text/ample+xml medium margin Accept http://www.w3.org/2000/svg padding http://www.w3.org/1999/xhtml Su;Mo;Tu;We;Th;Fr;Sa January;February;March;April;May;June;July;August;September;October;November;December; Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec; ENTITY only-child resizable resize-edges selectable droppable draggable relative absolute Sun;Mon;Tue;Wed;Thu;Fri;Sat Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday root iframe borderLeftColor first-child lineHeight uninitialized fontSize borderColor http://www.w3.org/2000/xmlns/ fallback http://www.amplesdk.com/ns/aml http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul last-child Left http://www.w3.org/1999/xlink borderWidth nbsp;iexcl;cent;pound;curren;yen;brvbar;sect;uml;copy;ordf;laquo;not;shy;reg;macr;deg;plusmn;sup2;sup3;acute;micro;para;middot;cedil;sup1;ordm;raquo;frac14;frac12;frac34;iquest;Agrave;Aacute;Acirc;Atilde;Auml;Aring;AElig;Ccedil;Egrave;Eacute;Ecirc;Euml;Igrave;Iacute;Icirc;Iuml;ETH;Ntilde;Ograve;Oacute;Ocirc;Otilde;Ouml;times;Oslash;Ugrave;Uacute;Ucirc;Uuml;Yacute;THORN;szlig;agrave;aacute;acirc;atilde;auml;aring;aelig;ccedil;egrave;eacute;ecirc;euml;igrave;iacute;icirc;iuml;eth;ntilde;ograve;oacute;ocirc;otilde;ouml;divide;oslash;ugrave;uacute;ucirc;uuml;yacute;thorn;yuml DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC baseVal detachEvent attachEvent platform charCode MozUserSelect WebkitUserSelect addElement setDragImage splitText wholeText isElementContentWhitespace replaceWholeText files effectAllowed items OperaUserSelect KhtmlUserSelect publish guard ready config urn resolveUri $instance query execCommand getComputedStyle userSelect hasLayout zoom runtime outerHTML substringData renameNode offsetTop offsetLeft $activate offsetWidth $setPseudoClass doctype $getStyle removeAttributeNode getAttributeNode isSupported normalize hasAttributes dispatchEvent hasAttribute setAttributeNode hasAttributeNS documentURI inputEncoding createEvent createEntityReference createElementNS canDispatch createProcessingInstruction normalizeDocument adoptNode createComment createCDATASection xmlEncoding strictErrorChecking xmlStandalone xmlVersion createAttributeNS createAttribute userLanguage compatMode remove replaceWith after clone children find closest before prepend html firstDay standard appendTo prependTo replaceAll insertAfter next nextAll beginElementAt endElement beginElement endElementAt seekElement resumeElement pauseElement contents siblings parents nextUntil parentsUntil prev prevUntil prevAll isRTL nativeName outerWidth innerHeight innerWidth outerHeight fadeIn fadeTo fadeOut css attr overflowY overflowX max headers ajax post param show hide toGregorian parseDate format getMonth getSeconds englishName getMilliseconds localize sort slideUp slideDown contentWindow bookmark locales cultures compareDocumentPosition lookupNamespaceURI getUTCMilliseconds getUTCSeconds getUTCMinutes validateOnParse resolveExternals XMLHTTP eval getUTCHours getUTCDate Infinity NaN navigator controllers opera getUTCMonth getUTCFullYear serializeToString importStylesheet CANNOT_ACCESS_DOM_ERR ARGUMENT_NULL_ERR ARGUMENT_WRONG_TYPE_ERR MEMBER_MISSING_ERR size first toArray ARGUMENT_MISSING_ERR transformToFragment selectSingleNode setProperty stylesheet createProcessor transformToDocument clearParameters encodeURIComponent isFinite Text ProcessingInstruction NodeList Touch TouchList NodeSelector DataTransfer DOMImplementation DOMError CharacterData CDATASection Attr Comment DOMConfiguration EntityReference DocumentFragment Query Arguments TypeError SyntaxError Error ActiveXObject setTimeout isNaN clearTimeout Math Function Boolean String Number Object Date RegExp has last CDATA_SECTION_NODE TEXT_NODE ATTRIBUTE_NODE ENTITY_REFERENCE_NODE ENTITY_NODE COMMENT_NODE PROCESSING_INSTRUCTION_NODE ELEMENT_NODE relatedData INVALID_ACCESS_ERR NAMESPACE_ERR INVALID_MODIFICATION_ERR VALIDATION_ERR TYPE_MISMATCH_ERR SEVERITY_FATAL_ERROR SEVERITY_WARNING DOCUMENT_NODE DOCUMENT_TYPE_NODE setUserData getUserData cloneNode isEqualNode isSameNode isDefaultNamespace lookupPrefix DOCUMENT_POSITION_CONTAINED_BY DOCUMENT_POSITION_CONTAINS NOTATION_NODE DOCUMENT_FRAGMENT_NODE textContent DOCUMENT_POSITION_DISCONNECTED DOCUMENT_POSITION_FOLLOWING DOCUMENT_POSITION_PRECEDING INVALID_STATE_ERR INUSE_ATTRIBUTE_ERR DOM_INPUT_METHOD_DROP DOM_INPUT_METHOD_PASTE DOM_INPUT_METHOD_KEYBOARD DOM_INPUT_METHOD_IME DOM_INPUT_METHOD_OPTION DOM_INPUT_METHOD_VOICE DOM_INPUT_METHOD_HANDWRITING DOM_INPUT_METHOD_UNKNOWN DOM_KEY_LOCATION_NUMPAD stopImmediatePropagation timeStamp splice isPropagationStopped DOM_KEY_LOCATION_STANDARD DOM_KEY_LOCATION_RIGHT DOM_KEY_LOCATION_LEFT DOM_INPUT_METHOD_MULTIMODAL DOM_INPUT_METHOD_SCRIPT DOMSTRING_SIZE_ERR canSetParameter createDocument WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_MODIFICATION_ALLOWED_ERR NO_DATA_ALLOWED_ERR createDocumentType hasFeature DOM_DELTA_LINE DOM_DELTA_PIXEL DOM_DELTA_PAGE MODIFICATION REMOVAL ADDITION DOMStringList".split(" "));
(function(){var aY=function(i){this.localName=i};aY.prototype=new ample.classes.Element;aY.prototype.namespaceURI="http://www.w3.org/1999/xhtml";aY.prototype.localName="#element";aY.prototype.accessKey=null;aY.prototype.$isAccessible=function(){return !this.attributes.disabled};aY.mapAttribute=function(i,j,m){switch(j){case"tabIndex":i.tabIndex=isNaN(m)?-1:m*1;break;case"accessKey":i.accessKey=m||null;break;case"id":case"class":case"style":break;default:i.$getContainer()[j]=m}};aY.html524={article:"div",aside:"div",section:"div",footer:"div",header:"div",nav:"div",datalist:"div",output:"span"};aY.prototype.$getTagOpen=function(){var j="<"+(this.localName in aY.html524?aY.html524[this.localName]:this.localName);for(var i in this.attributes){if(this.attributes.hasOwnProperty(i)&&i!="class"&&i!="id"&&i.indexOf(":")==-1){j+=" "+i+'="'+this.getAttribute(i).replace(/"/g,'"')+'"'}}j+=' class="'+(this.prefix?this.prefix+"-":"")+this.localName+("class" in this.attributes?" "+this.attributes["class"]:"")+'"';return j+">"};aY.prototype.$getTagClose=function(){return"</"+(this.localName in aY.html524?aY.html524[this.localName]:this.localName)+">"};ample.extend(aY);var aW=function(){aY.apply(this,arguments)};aW.prototype=new aY("#element-input");aW.prototype.$hoverable=true;aW.prototype.tabIndex=0;aW.prototype.form=null;aW.prototype.validity=null;aW.prototype.willValidate=true;aW.prototype.checkValidity=function(){};aW.prototype.validationMessage="";aW.prototype.setCustomValidty=function(i){};aW.isValid=function(i){return true};aW.register=function(i){for(var j=i;j=j.parentNode;){if(j instanceof aS){break}}if(j){i.form=j;j.elements.$add(i);if(i.hasAttribute("name")){j.elements[i.getAttribute("name")]=this}}if(!isNaN(i.getAttribute("tabIndex"))){i.tabIndex=i.getAttribute("tabIndex")*1}if(i.hasAttribute("accessKey")){i.accessKey=i.getAttribute("accessKey")}if(i.attributes.autofocus){i.focus()}};aW.unregister=function(i){if(i.form){i.form.elements.$remove(i);if(i.hasAttribute("name")){delete i.form.elements[i.getAttribute("name")]}i.form=null}};ample.extend(aW);var u=function(){};u.prototype.valueMissing=false;u.prototype.typeMismatch=false;u.prototype.patternMismatch=false;u.prototype.tooLong=false;u.prototype.rangeUnderflow=false;u.prototype.rangeOverflow=false;u.prototype.stepMismatch=false;u.prototype.customError=false;u.prototype.valid=true;var F=(function(){ample.bind("keydown",function(j){if(j.altKey&&j.keyIdentifier!="Alt"){var bJ=j.keyIdentifier.match(/U\+([\dA-F]{4})/),bK=bJ?String.fromCharCode(parseInt(bJ[1],16)):j.keyIdentifier;for(var i=0,bL=this.getElementsByTagNameNS(aY.prototype.namespaceURI,"*"),m,Z;m=bL[i];i++){if(m.tabIndex>=0&&m.$isAccessible()&&m.accessKey&&m.accessKey.toUpperCase()==bK){if((Z=m.$getContainer())&&Z.offsetHeight>0){m.focus();j.preventDefault()}break}}}});return{}})();var a5=function(){this.x=0;this.y=0;this.b=1;var i=this;this.contentFragment=ample.createDocumentFragment();this._buttonAccept=this.contentFragment.appendChild(ample.createElementNS(this.namespaceURI,"button"));this._buttonAccept.setAttribute("class","accept");this._buttonAccept.appendChild(ample.createTextNode("Accept"));this._buttonAccept.addEventListener("DOMActivate",function(){i.acceptDialog()});this._buttonCancel=this.contentFragment.appendChild(ample.createElementNS(this.namespaceURI,"button"));this._buttonCancel.setAttribute("class","cancel");this._buttonCancel.appendChild(ample.createTextNode("Cancel"));this._buttonCancel.addEventListener("DOMActivate",function(){i.cancelDialog()})};a5.prototype=new aY("colorpicker");a5.attributes={};a5.attributes.value="#FF0000";a5.prototype._moveTo=function(j,i){if(i.x){this.$getContainer(j).style.left=i.x+"px"}if(i.y){this.$getContainer(j).style.top=i.y+"px"}};a5.prototype._setColor=function(i){var j;if(j=a5._RGBtoXYB(i)){this.b=j.b;this.x=j.x;this.y=j.y;this._moveTo("palette-pointer",{x:this.x-9,y:this.y-9});this.$getContainer("color").style.backgroundColor=i;this._setColorBrightness(a5._XYBtoRGB({x:this.x,y:this.y,b:0}));this._setPaletteBrightness(this.b);this._moveTo("brightness-pointer",{y:this.b*255-2})}};a5.prototype._setColorBrightness=function(i){this.$getContainer("brightness").style.backgroundColor=i;this.$getContainer("brightness-shader").style.filter="progid:DXImageTransform.Microsoft.Gradient(startColorStr='"+i+"', endColorStr='#000000', gradientType='0');"};a5.prototype._setPaletteBrightness=function(j){var i=this.$getContainer("palette-shader");i.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity="+j*100+")";i.style.opacity=j;i.style.MozOpacity=j};a5.prototype._getComputedStyleByEvent=function(j,bJ){var i=this.getBoundingClientRect(bJ);var Z=j.clientX-i.left;var m=j.clientY-i.top;Z=Z<0?0:(Z>255?255:Z);m=m<0?0:(m>255?255:m);return{x:Z,y:m}};a5.prototype._setColorValue=function(i){this.$getContainer("color").style.backgroundColor=i;this.$getContainer("value").value=i};a5.prototype._detachHandlers=function(){document.onmousemove=null;document.onmouseup=null};a5.prototype._onInputChange=function(i,j){this._setColor(j)};a5.prototype._onPointersBrightnessMouseMove=function(j){var i=this._getComputedStyleByEvent(j,"brightness");this._moveTo("brightness-pointer",{y:i.y-3});this.b=Math.round(100*i.y/255)/100;this._setPaletteBrightness(this.b);this._setColorValue(a5._XYBtoRGB({x:this.x,y:this.y,b:this.b}))};a5.prototype._onPointersBrightnessMouseDown=function(i){var j=this;document.onmousemove=function(m){return j._onPointersBrightnessMouseMove(m||event)};document.onmouseup=function(){j._detachHandlers()};this._onPointersBrightnessMouseMove(i)};a5.prototype._onPointerPaletteMouseMove=function(j){var i=this._getComputedStyleByEvent(j,"palette");this.x=i.x;this.y=i.y;this._moveTo("palette-pointer",{x:this.x-9,y:this.y-9});this._setColorBrightness(a5._XYBtoRGB({x:this.x,y:this.y,b:0}));this._setColorValue(a5._XYBtoRGB({x:this.x,y:this.y,b:this.b}))};a5.prototype._onPointerPaletteMouseDown=function(i){var j=this;document.onmousemove=function(m){return j._onPointerPaletteMouseMove(m||event)};document.onmouseup=function(){j._detachHandlers()};this._onPointerPaletteMouseMove(i)};a5.prototype.acceptDialog=function(){this.attributes.value=this.$getContainer("value").value;var i=this.ownerDocument.createEvent("CustomEvent");i.initCustomEvent("accept",false,false,null);this.dispatchEvent(i)};a5.prototype.cancelDialog=function(){this.setAttribute("value",this.attributes.value);var i=this.ownerDocument.createEvent("CustomEvent");i.initCustomEvent("cancel",false,false,null);this.dispatchEvent(i)};a5.handlers={DOMAttrModified:function(i){if(i.target==this){switch(i.attrName){case"value":this._setColor(i.newValue||"");this.$getContainer("value").value=i.newValue||"";break;default:this.$mapAttribute(i.attrName,i.newValue)}}},DOMNodeInsertedIntoDocument:function(){this._setColor(a5.attributes.value)}};a5.prototype.$getTagOpen=function(){return'<div class="colorpicker'+(this.hasAttribute("class")?" "+this.getAttribute("class"):"")+'" style="'+(this.hasAttribute("style")?this.getAttribute("style"):"")+'"> <table cellpadding="0" cellspacing="0" border="0"> <tbody> <tr> <td valign="top"> <div class="colorpicker--palette" style="position:relative;" onmousedown="ample.$instance(this)._onPointerPaletteMouseDown(event)"> <div class="colorpicker--palette-shader"><br /></div> <div class="colorpicker--palette-pointer" style="position:absolute;"><br /></div> </div> </td> <td align="center" valign="top" style="position:relative;display:block;"> <div style="width:39px" onmousedown="ample.$instance(this)._onPointersBrightnessMouseDown(event);"> <div class="colorpicker--brightness"> <div class="colorpicker--brightness-shader"><br /></div> </div> <div class="colorpicker--brightness-pointer" style="position:absolute;left:1px;"><br /></div> </div> </td> <td valign="top"> <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"> <tbody> <tr><td align="right"><div class="colorpicker--color"></div></td></tr> <tr><td><br /></td></tr> <tr><td><input autocomplete="no" type="text" value="#FF0000" maxlength="7" class="colorpicker--value" onchange="ample.$instance(this)._onInputChange(event, this.value)" onkeyup="ample.$instance(this)._onInputChange(event, this.value)" onselectstart="event.cancelBubble=true;" oncontextmenu="event.cancelBubble=true"/></td></tr> <tr><td><br /></td></tr> <tr><td>'+this._buttonAccept.$getTag()+'</td></tr> <tr><td height="3"></td></tr> <tr><td>'+this._buttonCancel.$getTag()+"</td></tr> </tbody> </table> </td> </tr> </tbody> </table> </div>"};a5.prototype.$getTagClose=function(){return""};a5._XYBtoRGB=function(bK){var bM=360/256*bK.x;var j=1-bK.y/256;var bQ=1-bK.b;var m,bN,bP;if(j==0){m=bN=bP=bQ}else{var bL=Math.floor(bM/60);var bO=bM/60-bL;var bJ=bQ*(1-j);var Z=bQ*(1-j*bO);var i=bQ*(1-j*(1-bO));switch(bL){case 0:m=bQ;bN=i;bP=bJ;break;case 1:m=Z;bN=bQ;bP=bJ;break;case 2:m=bJ;bN=bQ;bP=i;break;case 3:m=bJ;bN=Z;bP=bQ;break;case 4:m=i;bN=bJ;bP=bQ;break;default:m=bQ;bN=bJ;bP=Z}}return"#"+this._toHex(m*256)+this._toHex(bN*256)+this._toHex(bP*256)};a5._RGBtoXYB=function(m){if(!m.match(/^#[0-9a-f]{6}$/i)){return}var j=parseInt(m.substr(1,2),16);var bL=parseInt(m.substr(3,2),16);var bN=parseInt(m.substr(5,2),16);var bP=Math.max(j,bL,bN);var bO=Math.min(j,bL,bN);var i=(bP-bO)/bP;var bJ=0;var bK=(bP-j)/(bP-bO);var bM=(bP-bL)/(bP-bO);var Z=(bP-bN)/(bP-bO);if(j==bP){bJ=(bL==bO)?5+Z:1-bM}else{if(bL==bP){bJ=(bN==bO)?1+bK:3-Z}else{bJ=(j==bO)?3+bM:5-bK}}bJ/=6;return{x:(bJ*255),y:(255-i*255),b:1-bP/255}};a5._toHex=function(i){var j="0123456789ABCDEF";if(i<0){return"00"}if(i>255){return"FF"}else{return j.charAt(Math.floor(i/16))+j.charAt(i%16)}};ample.extend(a5);var ad=function(){var Z=new Date();this.current=new Date(Z.getFullYear(),Z.getMonth(),Z.getDate());var m=this;this.contentFragment=ample.createDocumentFragment();this._buttonAccept=this.contentFragment.appendChild(ample.createElementNS(this.namespaceURI,"button"));this._buttonAccept.setAttribute("class","accept");this._buttonAccept.appendChild(ample.createTextNode("Accept"));this._buttonAccept.addEventListener("DOMActivate",function(){m.acceptDialog()});this._buttonCancel=this.contentFragment.appendChild(ample.createElementNS(this.namespaceURI,"button"));this._buttonCancel.setAttribute("class","cancel");this._buttonCancel.appendChild(ample.createTextNode("Cancel"));this._buttonCancel.addEventListener("DOMActivate",function(){m.cancelDialog()});this._elementMonth=this.contentFragment.appendChild(ample.createElementNS(this.namespaceURI,"select"));this._elementMonth.tabIndex=-1;this._elementMonth.addEventListener("change",function(bJ){m.doSelectMonth(this.items[this.selectedIndex].getAttribute("value"));bJ.stopPropagation()},false);for(var i=0,j;i<12;i++){j=this._elementMonth.appendChild(ample.createElementNS(this.namespaceURI,"option"));j.setAttribute("value",i);j.setAttribute("label",ample.locale.culture.calendar.months.names[i])}this._elementYear=this.contentFragment.appendChild(ample.createElementNS(this.namespaceURI,"input"));this._elementYear.setAttribute("type","number");this._elementYear.tabIndex=-1;this._elementYear.setAttribute("max",Infinity);this._elementYear.addEventListener("change",function(bJ){m.doSelectYear(this.getAttribute("value"));bJ.stopPropagation()},false);this._elementMonthPrevious=this.contentFragment.appendChild(ample.createElementNS(this.namespaceURI,"input"));this._elementMonthPrevious.setAttribute("type","button");this._elementMonthPrevious.tabIndex=-1;this._elementMonthNext=this.contentFragment.appendChild(ample.createElementNS(this.namespaceURI,"input"));this._elementMonthNext.setAttribute("type","button");this._elementMonthNext.tabIndex=-1;this._elementAccept=this.contentFragment.appendChild(ample.createElementNS(this.namespaceURI,"input"));this._elementAccept.setAttribute("type","button");this._elementAccept.setAttribute("value","OK");this._elementAccept.tabIndex=-1;this._elementCancel=this.contentFragment.appendChild(ample.createElementNS(this.namespaceURI,"input"));this._elementCancel.setAttribute("type","button");this._elementCancel.setAttribute("value","Cancel");this._elementCancel.tabIndex=-1};ad.prototype=new aY("datepicker");ad.prototype.current=null;ad.prototype.value=null;ad.prototype.min=null;ad.prototype.max=null;ad.prototype.show=function(Z,m){var j=this.ownerDocument.createEvent("CustomEvent");j.initCustomEvent("shown",false,true,null);if(this.dispatchEvent(j)){var i=this.$getContainer().style;i.position="absolute";if(arguments.length>0){i.left=Z+"px"}if(arguments.length>1){i.top=m+"px"}i.display="";this.refresh()}};ad.prototype.hide=function(){var i=this.ownerDocument.createEvent("CustomEvent");i.initCustomEvent("hidden",false,true,null);if(this.dispatchEvent(i)){this.$getContainer().style.display="none"}};ad.prototype.refresh=function(){this.$getContainer("days-pane").innerHTML=ad.$getTagDays(this,this.current);var i=this._elementMonth.querySelector("[value='"+this.current.getMonth()+"']");return;this._elementMonth.selectItem(i);this._elementMonth.setAttribute("value",this.current.getMonth());this._elementYear.setAttribute("value",this.current.getFullYear())};ad.prototype._onSelectDay=function(bJ){this.current.setDate(bJ);var Z=this.current.getMonth();var m=this.current.getFullYear();var bK=m+"/"+(Z+1<10?"0":"")+(Z+1)+"/"+(bJ<10?"0":"")+bJ;if(this.getAttribute("value")!=bK){this.setAttribute("value",bK);var j=this.ownerDocument.createEvent("UIEvent");j.initEvent("change",false,false,window,null);this.dispatchEvent(j)}var i=this.ownerDocument.createEvent("UIEvent");i.initUIEvent("accept",true,false,window,null);this.dispatchEvent(i)};ad.prototype.doSelectMonth=function(i){this.current.setMonth(i);this.$getContainer("days-pane").innerHTML=ad.$getTagDays(this,this.current)};ad.prototype.doSelectYear=function(i){this.current.setYear(i);this.$getContainer("days-pane").innerHTML=ad.$getTagDays(this,this.current)};ad.parseDateFromString=function(i){return new Date(i)};ad.prototype.acceptDialog=function(){this.attributes.value=this.$getContainer("value").value;var i=this.ownerDocument.createEvent("CustomEvent");i.initCustomEvent("accept",false,false,null);this.dispatchEvent(i)};ad.prototype.cancelDialog=function(){this.setAttribute("value",this.attributes.value);var i=this.ownerDocument.createEvent("CustomEvent");i.initCustomEvent("cancel",false,false,null);this.dispatchEvent(i)};ad.handlers={click:function(j){if(j.target==this){if(j.$pseudoTarget==this.$getContainer("month-previous")){var i=this.current.getFullYear();this.doSelectMonth(this.current.getMonth()-1);this._elementMonth.setAttribute("value",this.current.getMonth());if(this.current.getFullYear()!=i){this._elementYear.setAttribute("value",this.current.getFullYear())}}else{if(j.$pseudoTarget==this.$getContainer("month-next")){var i=this.current.getFullYear();this.doSelectMonth(this.current.getMonth()+1);this._elementMonth.setAttribute("value",this.current.getMonth());if(this.current.getFullYear()!=i){this._elementYear.setAttribute("value",this.current.getFullYear())}}}}},keydown:function(i){},DOMAttrModified:function(i){if(i.target==this){switch(i.attrName){case"min":if(i.newValue){this.min=ad.parseDateFromString(i.newValue)}else{this.min=null}break;case"max":if(i.newValue){this.max=ad.parseDateFromString(i.newValue)}else{this.max=null}break;case"value":if(i.newValue){this.value=ad.parseDateFromString(i.newValue);this.current=ad.parseDateFromString(i.newValue)}else{this.value=null}this.refresh();break}}},DOMNodeInsertedIntoDocument:function(i){var j=this.getAttribute("value");if(j){this.value=ad.parseDateFromString(j);this.current=ad.parseDateFromString(j)}this._elementMonth.setAttribute("value",this.current.getMonth());this._elementYear.setAttribute("value",this.current.getFullYear());this.refresh()}};ad.getWeekNum=function(bR){var bN=bR.getFullYear();var j=bR.getMonth()+1;var bL=0;if(j<3){var bP=bN-1;var bO=(bP/4|0)-(bP/100|0)+(bP/400|0);var bM=((bP-1)/4|0)-((bP-1)/100|0)+((bP-1)/400|0);var bS=bO-bM;var bK=0;var bJ=bL-1+31*(j-1)}else{var bP=bN;var bO=(bP/4|0)-(bP/100|0)+(bP/400|0);var bM=((bP-1)/4|0)-((bP-1)/100|0)+((bP-1)/400|0);var bS=bO-bM;var bK=bS+1;var bJ=bL+((153*(j-3)+2)/5|0)+58+bS}var Z=(bP+bO)%7;var bL=(bJ+Z-bK)%7;var i=bJ+3-bL;if(i<0){var bQ=53-((Z-bS)/5|0)}else{if(i>364+bS){var bQ=1}else{var bQ=(i/7|0)+1}}return bQ};ad.$getTagDays=function(Z,bN){var j=[];j.push('<table cellPadding="0" cellSpacing="1" border="0"> <thead class="datepicker--header"> <tr> <td>&nbsp;</td> <td class="datepicker-head-day">'+ample.locale.culture.calendar.days.namesShort[1]+'</td> <td class="datepicker-head-day">'+ample.locale.culture.calendar.days.namesShort[2]+'</td> <td class="datepicker-head-day">'+ample.locale.culture.calendar.days.namesShort[3]+'</td> <td class="datepicker-head-day">'+ample.locale.culture.calendar.days.namesShort[4]+'</td> <td class="datepicker-head-day">'+ample.locale.culture.calendar.days.namesShort[5]+'</td> <td class="datepicker-head-day">'+ample.locale.culture.calendar.days.namesShort[6]+'</td> <td class="datepicker-head-day">'+ample.locale.culture.calendar.days.namesShort[0]+"</td> </tr> </thead> <tbody> <tr>");var bO=new Date;var bM=ad.getWeekNum(bN,true);var m=new Date(bN.getFullYear(),bN.getMonth(),1).getDay()-1;if(m<0){m=6}j.push('<td align="center" valign="center"><div class="datepicker-week">'+bM+"</div></td>");for(var i=0;i<m;i++){j.push("<td><br /></td>")}bM=(bM>=52)?0:bM;var bL=new Date(bN.getFullYear(),bN.getMonth()*1+1,0).getDate();for(var i=1,bJ,bK;i<=bL;i++){bJ=new Date(bN.getFullYear(),bN.getMonth(),i);bK=(Z.min&&bJ<Z.min)||(Z.max&&bJ>Z.max);j.push(' <td align="center" valign="center"> <div type="button" class="datepicker-day'+(m>4?" datepicker-weekend":"")+(Z.value&&bJ.getTime()==Z.value.getTime()?" datepicker-day_selected":"")+" "+(bO.getDate()==bJ.getDate()&&bO.getMonth()==bJ.getMonth()&&bO.getFullYear()==bJ.getFullYear()?" datepicker-day_today":"")+" "+(bK?" datepicker-day_disabled":'" onclick="ample.$instance(this)._onSelectDay('+i+")")+"\" onmouseover=\"this.className += ' datepicker-day_hover'\" onmouseout=\"this.className = this.className.replace(' datepicker-day_hover', '')\" >"+i+"</div> </td>");if((m==6)&&(i<bL)){bM++;if(bM==53){bM=(new Date(bN.getFullYear(),11,31).getDay()<3)?1:bM}j.push('</tr> <tr> <td align="center" valign="center"><div class="datepicker-week">'+bM+"</div></td>");m=0}else{m++}}for(var i=m;i<7;i++){j.push("<td><br /></td>")}j.push(" </tr> </tbody> </table>");return j.join("")};ad.prototype.$getTagOpen=function(){return'<div class="datepicker'+(this.hasAttribute("class")?" "+this.getAttribute("class"):"")+'" style="'+(this.hasAttribute("style")?this.getAttribute("style"):"")+'"> <table cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <td valign="top">'+this._elementMonthPrevious.$getTag()+"</td> <td>"+this._elementMonth.$getTag()+'</td> <td valign="top">'+this._elementMonthNext.$getTag()+"</td> <td>"+this._elementYear.$getTag()+'</td> </tr> </thead> <tbody> <tr> <td colspan="4" class="datepicker--days-pane"></td> </tr> </tbody> <tfoot> <tr> <td colspan="4" align="center">'+this._buttonAccept.$getTag()+this._buttonCancel.$getTag()+" </td> </tr> </tfoot> </table> </div>"};ad.prototype.$getTagClose=function(){return""};ample.extend(ad);var a7=function(){};a7.prototype=new aY("del");a7.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(a7);var aD=function(){};aD.prototype=new aY("ins");aD.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aD);var y=function(){};y.prototype=new aY("area");y.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(y);var bq=function(){};bq.prototype=new aY("audio");bq.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bq);var aa=function(){};aa.prototype=new aY("canvas");aa.handlers={DOMAttrModified:function(i){if(i.target==this){switch(i.attrName){case"width":case"height":this[i.attrName]=i.newValue;this.$getContainer()[i.attrName]=i.newValue;break;default:aY.mapAttribute(this,i.attrName,i.newValue)}}},DOMNodeInsertedIntoDocument:function(){this.width=this.attributes.width;this.height=this.attributes.height}};aa.prototype.getContext=function(i){return this.$getContainer().getContext(i)};if(!document.createElement("canvas").getContext){var bz=aa.handlers.DOMNodeInsertedIntoDocument;aa.handlers.DOMNodeInsertedIntoDocument=function(i){if(bz){bz.call(this,i)}C.initElement(this.$getContainer())};var a0=Math;var bk=a0.round;var bj=a0.sin;var bu=a0.cos;var aj=a0.abs;var bd=a0.sqrt;var a4=10;var aM=a4/2;function bc(){return this.context_||(this.context_=new L(this))}var R=Array.prototype.slice;function aQ(j,m,Z){var i=R.call(arguments,2);return function(){return j.apply(m,i.concat(R.call(arguments)))}}var C={init:function(i){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var j=i||document;j.createElement("canvas");j.attachEvent("onreadystatechange",aQ(this.init_,this,j))}},init_:function(j){if(!j.namespaces.g_vml_){j.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML")}if(!j.namespaces.g_o_){j.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML")}if(!j.styleSheets.ex_canvas_){var i=j.createStyleSheet();i.owningElement.id="ex_canvas_";i.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}g_o_\\:*{behavior:url(#default#VML)}"}},initElement:function(j){if(!j.getContext){j.getContext=bc;j.innerHTML="";j.attachEvent("onpropertychange",bF);j.attachEvent("onresize",bt);var i=j.attributes;if(i.width&&i.width.specified){j.style.width=i.width.nodeValue+"px"}else{j.width=j.clientWidth}if(i.height&&i.height.specified){j.style.height=i.height.nodeValue+"px"}else{j.height=j.clientHeight}}return j}};function bF(j){var i=j.srcElement;switch(j.propertyName){case"width":i.style.width=i.attributes.width.nodeValue+"px";i.getContext().clearRect();break;case"height":i.style.height=i.attributes.height.nodeValue+"px";i.getContext().clearRect();break}}function bt(j){var i=j.srcElement;if(i.firstChild){i.firstChild.style.width=i.clientWidth+"px";i.firstChild.style.height=i.clientHeight+"px"}}C.init();var U=[];for(var a3=0;a3<16;a3++){for(var a2=0;a2<16;a2++){U[a3*16+a2]=a3.toString(16)+a2.toString(16)}}function X(){return[[1,0,0],[0,1,0],[0,0,1]]}function v(Z,m){var j=X();for(var i=0;i<3;i++){for(var bL=0;bL<3;bL++){var bJ=0;for(var bK=0;bK<3;bK++){bJ+=Z[i][bK]*m[bK][bL]}j[i][bL]=bJ}}return j}function b(j,i){i.fillStyle=j.fillStyle;i.lineCap=j.lineCap;i.lineJoin=j.lineJoin;i.lineWidth=j.lineWidth;i.miterLimit=j.miterLimit;i.shadowBlur=j.shadowBlur;i.shadowColor=j.shadowColor;i.shadowOffsetX=j.shadowOffsetX;i.shadowOffsetY=j.shadowOffsetY;i.strokeStyle=j.strokeStyle;i.globalAlpha=j.globalAlpha;i.arcScaleX_=j.arcScaleX_;i.arcScaleY_=j.arcScaleY_;i.lineScale_=j.lineScale_}function A(m){var bK,bJ=1;m=String(m);if(m.substring(0,3)=="rgb"){var bM=m.indexOf("(",3);var j=m.indexOf(")",bM+1);var bL=m.substring(bM+1,j).split(",");bK="#";for(var Z=0;Z<3;Z++){bK+=U[Number(bL[Z])]}if(bL.length==4&&m.substr(3,1)=="a"){bJ=bL[3]}}else{bK=m}return{color:bK,alpha:bJ}}function aK(i){switch(i){case"butt":return"flat";case"round":return"round";case"square":default:return"square"}}function L(j){this.m_=X();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.strokeStyle="#000";this.fillStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=a4*1;this.globalAlpha=1;this.canvas=j;var i=j.ownerDocument.createElement("div");i.style.width=j.clientWidth+"px";i.style.height=j.clientHeight+"px";i.style.overflow="hidden";i.style.position="absolute";j.appendChild(i);this.element_=i;this.arcScaleX_=1;this.arcScaleY_=1;this.lineScale_=1}var a8=L.prototype;a8.clearRect=function(){this.element_.innerHTML=""};a8.beginPath=function(){this.currentPath_=[]};a8.moveTo=function(j,i){var m=this.getCoords_(j,i);this.currentPath_.push({type:"moveTo",x:m.x,y:m.y});this.currentX_=m.x;this.currentY_=m.y};a8.lineTo=function(j,i){var m=this.getCoords_(j,i);this.currentPath_.push({type:"lineTo",x:m.x,y:m.y});this.currentX_=m.x;this.currentY_=m.y};a8.bezierCurveTo=function(m,j,bN,bM,bL,bJ){var i=this.getCoords_(bL,bJ);var bK=this.getCoords_(m,j);var Z=this.getCoords_(bN,bM);aF(this,bK,Z,i)};function aF(i,Z,m,j){i.currentPath_.push({type:"bezierCurveTo",cp1x:Z.x,cp1y:Z.y,cp2x:m.x,cp2y:m.y,x:j.x,y:j.y});i.currentX_=j.x;i.currentY_=j.y}a8.quadraticCurveTo=function(bL,m,j,i){var bK=this.getCoords_(bL,m);var bJ=this.getCoords_(j,i);var bM={x:this.currentX_+2/3*(bK.x-this.currentX_),y:this.currentY_+2/3*(bK.y-this.currentY_)};var Z={x:bM.x+(bJ.x-this.currentX_)/3,y:bM.y+(bJ.y-this.currentY_)/3};aF(this,bM,Z,bJ)};a8.arc=function(bO,bM,bN,bJ,j,m){bN*=a4;var bS=m?"at":"wa";var bP=bO+bu(bJ)*bN-aM;var bR=bM+bj(bJ)*bN-aM;var i=bO+bu(j)*bN-aM;var bQ=bM+bj(j)*bN-aM;if(bP==i&&!m){bP+=0.125}var Z=this.getCoords_(bO,bM);var bL=this.getCoords_(bP,bR);var bK=this.getCoords_(i,bQ);this.currentPath_.push({type:bS,x:Z.x,y:Z.y,radius:bN,xStart:bL.x,yStart:bL.y,xEnd:bK.x,yEnd:bK.y})};a8.rect=function(m,j,i,Z){this.moveTo(m,j);this.lineTo(m+i,j);this.lineTo(m+i,j+Z);this.lineTo(m,j+Z);this.closePath()};a8.strokeRect=function(m,j,i,Z){var bJ=this.currentPath_;this.beginPath();this.moveTo(m,j);this.lineTo(m+i,j);this.lineTo(m+i,j+Z);this.lineTo(m,j+Z);this.closePath();this.stroke();this.currentPath_=bJ};a8.fillRect=function(m,j,i,Z){var bJ=this.currentPath_;this.beginPath();this.moveTo(m,j);this.lineTo(m+i,j);this.lineTo(m+i,j+Z);this.lineTo(m,j+Z);this.closePath();this.fill();this.currentPath_=bJ};a8.createLinearGradient=function(j,Z,i,m){var bJ=new E("gradient");bJ.x0_=j;bJ.y0_=Z;bJ.x1_=i;bJ.y1_=m;return bJ};a8.createRadialGradient=function(Z,bK,m,j,bJ,i){var bL=new E("gradientradial");bL.x0_=Z;bL.y0_=bK;bL.r0_=m;bL.x1_=j;bL.y1_=bJ;bL.r1_=i;return bL};a8.drawImage=function(bU,m){var bN,bL,bP,b1,bS,bQ,bW,b3;var bO=bU.runtimeStyle.width;var bT=bU.runtimeStyle.height;bU.runtimeStyle.width="auto";bU.runtimeStyle.height="auto";var bM=bU.width;var bZ=bU.height;bU.runtimeStyle.width=bO;bU.runtimeStyle.height=bT;if(arguments.length==3){bN=arguments[1];bL=arguments[2];bS=bQ=0;bW=bP=bM;b3=b1=bZ}else{if(arguments.length==5){bN=arguments[1];bL=arguments[2];bP=arguments[3];b1=arguments[4];bS=bQ=0;bW=bM;b3=bZ}else{if(arguments.length==9){bS=arguments[1];bQ=arguments[2];bW=arguments[3];b3=arguments[4];bN=arguments[5];bL=arguments[6];bP=arguments[7];b1=arguments[8]}else{throw Error("Invalid number of arguments")}}}var b2=this.getCoords_(bN,bL);var Z=bW/2;var j=b3/2;var b0=[];var i=10;var bK=10;b0.push(" <g_vml_:group",' coordsize="',a4*i,",",a4*bK,'"',' coordorigin="0,0"',' style="width:',i,"px;height:",bK,"px;position:absolute;");if(this.m_[0][0]!=1||this.m_[0][1]){var bJ=[];bJ.push("M11=",this.m_[0][0],",","M12=",this.m_[1][0],",","M21=",this.m_[0][1],",","M22=",this.m_[1][1],",","Dx=",bk(b2.x/a4),",","Dy=",bk(b2.y/a4),"");var bY=b2;var bX=this.getCoords_(bN+bP,bL);var bV=this.getCoords_(bN,bL+b1);var bR=this.getCoords_(bN+bP,bL+b1);bY.x=a0.max(bY.x,bX.x,bV.x,bR.x);bY.y=a0.max(bY.y,bX.y,bV.y,bR.y);b0.push("padding:0 ",bk(bY.x/a4),"px ",bk(bY.y/a4),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",bJ.join(""),", sizingmethod='clip');")}else{b0.push("top:",bk(b2.y/a4),"px;left:",bk(b2.x/a4),"px;")}b0.push(' ">','<g_vml_:image src="',bU.src,'"',' style="width:',a4*bP,"px;"," height:",a4*b1,'px;"',' cropleft="',bS/bM,'"',' croptop="',bQ/bZ,'"',' cropright="',(bM-bS-bW)/bM,'"',' cropbottom="',(bZ-bQ-b3)/bZ,'"'," />","</g_vml_:group>");this.element_.insertAdjacentHTML("BeforeEnd",b0.join(""))};a8.stroke=function(b6){var bM=[];var bN=false;var ch=A(b6?this.fillStyle:this.strokeStyle);var b2=ch.color;var cc=ch.alpha*this.globalAlpha;var bJ=10;var bP=10;bM.push("<g_vml_:shape",' filled="',!!b6,'"',' style="position:absolute;width:',bJ,"px;height:",bP,'px;"',' coordorigin="0 0" coordsize="',a4*bJ," ",a4*bP,'"',' stroked="',!b6,'"',' path="');var bO=false;var cg={x:null,y:null};var bY={x:null,y:null};for(var cb=0;cb<this.currentPath_.length;cb++){var ca=this.currentPath_[cb];var cf;switch(ca.type){case"moveTo":cf=ca;bM.push(" m ",bk(ca.x),",",bk(ca.y));break;case"lineTo":bM.push(" l ",bk(ca.x),",",bk(ca.y));break;case"close":bM.push(" x ");ca=null;break;case"bezierCurveTo":bM.push(" c ",bk(ca.cp1x),",",bk(ca.cp1y),",",bk(ca.cp2x),",",bk(ca.cp2y),",",bk(ca.x),",",bk(ca.y));break;case"at":case"wa":bM.push(" ",ca.type," ",bk(ca.x-this.arcScaleX_*ca.radius),",",bk(ca.y-this.arcScaleY_*ca.radius)," ",bk(ca.x+this.arcScaleX_*ca.radius),",",bk(ca.y+this.arcScaleY_*ca.radius)," ",bk(ca.xStart),",",bk(ca.yStart)," ",bk(ca.xEnd),",",bk(ca.yEnd));break}if(ca){if(cg.x==null||ca.x<cg.x){cg.x=ca.x}if(bY.x==null||ca.x>bY.x){bY.x=ca.x}if(cg.y==null||ca.y<cg.y){cg.y=ca.y}if(bY.y==null||ca.y>bY.y){bY.y=ca.y}}}bM.push(' ">');if(!b6){var bX=this.lineScale_*this.lineWidth;if(bX<1){cc*=bX}bM.push("<g_vml_:stroke",' opacity="',cc,'"',' joinstyle="',this.lineJoin,'"',' miterlimit="',this.miterLimit,'"',' endcap="',aK(this.lineCap),'"',' weight="',bX,'px"',' color="',b2,'" />')}else{if(typeof this.fillStyle=="object"){var bQ=this.fillStyle;var bV=0;var b9={x:0,y:0};var b3=0;var bT=1;if(bQ.type_=="gradient"){var bS=bQ.x0_/this.arcScaleX_;var m=bQ.y0_/this.arcScaleY_;var bR=bQ.x1_/this.arcScaleX_;var ci=bQ.y1_/this.arcScaleY_;var ce=this.getCoords_(bS,m);var cd=this.getCoords_(bR,ci);var bL=cd.x-ce.x;var bK=cd.y-ce.y;bV=Math.atan2(bL,bK)*180/Math.PI;if(bV<0){bV+=360}if(bV<0.000001){bV=0}}else{var ce=this.getCoords_(bQ.x0_,bQ.y0_);var j=bY.x-cg.x;var Z=bY.y-cg.y;b9={x:(ce.x-cg.x)/j,y:(ce.y-cg.y)/Z};j/=this.arcScaleX_*a4;Z/=this.arcScaleY_*a4;var b8=a0.max(j,Z);b3=2*bQ.r0_/b8;bT=2*bQ.r1_/b8-b3}var b1=bQ.colors_;b1.sort(function(cj,i){return cj.offset-i.offset});var bW=b1.length;var b0=b1[0].color;var bZ=b1[bW-1].color;var b5=b1[0].alpha*this.globalAlpha;var b4=b1[bW-1].alpha*this.globalAlpha;var b7=[];for(var cb=0;cb<bW;cb++){var bU=b1[cb];b7.push(bU.offset*bT+b3+" "+bU.color)}bM.push('<g_vml_:fill type="',bQ.type_,'"',' method="none" focus="100%"',' color="',b0,'"',' color2="',bZ,'"',' colors="',b7.join(","),'"',' opacity="',b4,'"',' g_o_:opacity2="',b5,'"',' angle="',bV,'"',' focusposition="',b9.x,",",b9.y,'" />')}else{bM.push('<g_vml_:fill color="',b2,'" opacity="',cc,'" />')}}bM.push("</g_vml_:shape>");this.element_.insertAdjacentHTML("beforeEnd",bM.join(""))};a8.fill=function(){this.stroke(true)};a8.closePath=function(){this.currentPath_.push({type:"close"})};a8.getCoords_=function(Z,j){var i=this.m_;return{x:a4*(Z*i[0][0]+j*i[1][0]+i[2][0])-aM,y:a4*(Z*i[0][1]+j*i[1][1]+i[2][1])-aM}};a8.save=function(){var i={};b(this,i);this.aStack_.push(i);this.mStack_.push(this.m_);this.m_=v(X(),this.m_)};a8.restore=function(){b(this.aStack_.pop(),this);this.m_=this.mStack_.pop()};function af(i){for(var bJ=0;bJ<3;bJ++){for(var Z=0;Z<2;Z++){if(!isFinite(i[bJ][Z])||isNaN(i[bJ][Z])){return false}}}return true}function bs(j,i,Z){if(!af(i)){return}j.m_=i;if(Z){var bJ=i[0][0]*i[1][1]-i[0][1]*i[1][0];j.lineScale_=bd(aj(bJ))}}a8.translate=function(m,j){var i=[[1,0,0],[0,1,0],[m,j,1]];bs(this,v(i,this.m_),false)};a8.rotate=function(j){var Z=bu(j);var m=bj(j);var i=[[Z,m,0],[-m,Z,0],[0,0,1]];bs(this,v(i,this.m_),false)};a8.scale=function(m,j){this.arcScaleX_*=m;this.arcScaleY_*=j;var i=[[m,0,0],[0,j,0],[0,0,1]];bs(this,v(i,this.m_),true)};a8.transform=function(bJ,Z,bL,bK,j,i){var m=[[bJ,Z,0],[bL,bK,0],[j,i,1]];bs(this,v(m,this.m_),true)};a8.setTransform=function(bK,bJ,bM,bL,Z,j){var i=[[bK,bJ,0],[bM,bL,0],[Z,j,1]];bs(this,i,true)};a8.clip=function(){};a8.arcTo=function(){};a8.createPattern=function(){return new bG};function E(i){this.type_=i;this.x0_=0;this.y0_=0;this.r0_=0;this.x1_=0;this.y1_=0;this.r1_=0;this.colors_=[]}E.prototype.addColorStop=function(j,i){i=A(i);this.colors_.push({offset:j,color:i.color,alpha:i.alpha})};function bG(){}G_vmlCanvasManager=C;CanvasRenderingContext2D=L;CanvasGradient=E;CanvasPattern=bG}ample.extend(aa);var aq=function(){};aq.prototype=new aY("embed");aq.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aq);var ax=function(){};ax.prototype=new aY("figure");ax.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ax);var o=function(){};o.prototype=new aY("iframe");o.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(o);var aR=function(){};aR.prototype=new aY("img");aR.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};aR.prototype.$getTagOpen=function(){var j="<"+this.localName+' onmousedown="return false" ondragstart="return false"';for(var i in this.attributes){if(this.attributes.hasOwnProperty(i)&&i!="class"&&i!="id"&&i.indexOf(":")==-1){j+=" "+i+'="'+this.getAttribute(i).replace(/"/g,'"')+'"'}}j+=' class="'+(this.prefix?this.prefix+"-":"")+this.localName+("class" in this.attributes?" "+this.attributes["class"]:"")+'"';return j+"/>"};aR.prototype.$getTagClose=function(){return""};ample.extend(aR);var aG=function(){};aG.prototype=new aY("map");aG.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aG);var aU=function(){};aU.prototype=new aY("object");aU.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};aU.prototype.$getTag=function(){if(window.navigator.userAgent.indexOf("Gecko")>-1){var m="<embed";for(var j in this.attributes){if(this.attributes.hasOwnProperty(j)&&j!="class"&&j!="id"&&j.indexOf(":")==-1){m+=" "+j+'="'+this.getAttribute(j).replace(/"/g,'"')+'"'}}m+=' class="'+(this.prefix?this.prefix+"-":"")+this.localName+("class" in this.attributes?" "+this.attributes["class"]:"")+'"';for(var i=0;i<this.childNodes.length;i++){m+=" "+this.childNodes[i].attributes.name+'="'+this.childNodes[i].attributes.value+'"'}return m+" />"}else{return this.$getTag.call(this)}};ample.extend(aU);var bf=function(){};bf.prototype=new aY("param");bf.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bf);var ba=function(){};ba.prototype=new aY("source");ba.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ba);var aZ=function(){};aZ.prototype=new aY("video");aZ.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aZ);var aO=function(){this.validity=new u};aO.prototype=new aW("button");aO.handlers={focus:function(i){this.$getContainer().focus()},blur:function(i){this.$getContainer().blur()},DOMNodeInsertedIntoDocument:function(i){aW.register(this)},DOMNodeRemovedFromDocument:function(i){aW.unregister(this)},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}},mousedown:function(){this.$setPseudoClass("active",true);this.setCapture(true)},mouseup:function(){this.$setPseudoClass("active",false);this.releaseCapture()},click:function(i){if(i.button==0){this.$activate()}}};aO.prototype.$getTagOpen=function(){var i=(this.prefix?this.prefix+"-":"")+this.localName,j=this.attributes.disabled&&this.attributes.disabled!="false";return'<span class="'+i+" "+("class" in this.attributes?" "+this.attributes["class"]:"")+" "+i+"_"+(j?"disabled":"enabled")+' " '+(this.attributes.style?' style="'+this.attributes.style+'"':"")+'> <span class="'+i+'--before" style="float:left"></span> <span class="'+i+'--after" style="float:right"></span> <div class="'+i+'--field" style="position:relative"> <div class="'+i+'--label">'};aO.prototype.$getTagClose=function(){return" </div> </div> </span>"};ample.extend(aO);var a6=function(){};a6.prototype=new aY("datalist");a6.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(a6);var aT=function(){this.elements=new ample.classes.NodeList};aT.prototype=new aY("fieldset");aT.prototype.elements=null;aT.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aT);var aS=function(){this.elements=new ample.classes.NodeList};aS.prototype=new aY("form");aS.prototype.elements=null;aS.prototype.length=0;aS.prototype.submit=function(){var m=this.getAttribute("target"),j;if(m.match(/#(.+)$/)&&(j=this.ownerDocument.getElementById(window.RegExp.$1))){var bK=[],bN=this.getAttribute("action").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),bM,bL,Z;for(var i=0;i<this.elements.length;i++){Z=this.elements[i];if(!Z.hasAttribute("disabled")&&Z.hasAttribute("name")&&(bM=Z.$getValue())!=null){bL=Z.getAttribute("name");if(bM instanceof window.Array){for(var bJ=0;bJ<bM.length;bJ++){bK.push(bL+"="+bM[bJ])}}else{bK.push(bL+"="+bM)}}}function bO(bP){ample(j).html(bP.responseText)}bM=window.encodeURI(bK.join("&"));if(this.getAttribute("method").toLowerCase()=="post"){ample.ajax({type:"POST",url:bN,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:bM,complete:bO})}else{ample.ajax({type:"GET",url:bN.replace(/\?.+/,"")+"?"+bM,complete:bO})}}else{this.$getContainer().submit()}};aS.prototype.reset=function(){this.$getContainer().reset()};aS.prototype.checkValidity=function(){};aS.prototype.dispatchFormInput=function(){};aS.prototype.dispatchFormChange=function(){};aS.prototype._onSubmit=function(){var i=this.ownerDocument.createEvent("Event");i.initEvent("submit",true,true);return this.dispatchEvent(i)};aS.prototype._onReset=function(){var i=this.ownerDocument.createEvent("Event");i.initEvent("reset",true,true);return this.dispatchEvent(i)};aS.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};aS.prototype.$getTagOpen=function(){var j="<"+this.localName+' onsubmit="var oElement = ample.$instance(this); if (oElement._onSubmit()) oElement.submit(); return false;" onreset="var oElement = ample.$instance(this); if (oElement._onReset()) oElement.reset(); return false;"';for(var i in this.attributes){if(this.attributes.hasOwnProperty(i)&&i!="class"&&i!="id"&&i.indexOf(":")==-1){j+=" "+i+'="'+this.getAttribute(i).replace(/"/g,'"')+'"'}}j+=' class="'+(this.prefix?this.prefix+"-":"")+this.localName+("class" in this.attributes?" "+this.attributes["class"]:"")+'"';return j+">"};ample.extend(aS);var g=function(){this.validity=new u;this.contentFragment=ample.createDocumentFragment();var i=this;this._spinButtons=ample.createElement("spinbuttons");this._spinButtons.addEventListener("spin",function(j){j.detail?i.stepUp():i.stepDown();g.dispatchInputEvent(i)});this.contentFragment.appendChild(this._spinButtons)};g.prototype=new aW("input");g.prototype.value="";g.prototype.checked=false;g.prototype.selectionStart=null;g.prototype.selectionEnd=null;g.prototype.list=null;g.prototype.selectedOption=null;g.prototype.valueAsNumber=NaN;g.prototype.valueAsDate=null;g.prototype.$captured=false;g.prototype.$isAccessible=function(){return aY.prototype.$isAccessible.call(this)&&this.attributes.type!="hidden"};g.prototype.select=function(){this.$getContainer().select()};g.prototype.setSelectionRange=function(){};g.prototype.stepUp=function(){var m=parseFloat(this.attributes.value),j=parseFloat(this.attributes.step)||1,i=parseFloat(this.attributes.min),Z=parseFloat(this.attributes.max);if(isNaN(i)){i=0}if(isNaN(Z)){Z=100}if(Z<i){Z=i}if(isNaN(m)){m=Z}else{if(m+j>Z){m=Z}else{m+=j}}this.value=""+m;this.valueAsNumber=m;this.setAttribute("value",m)};g.prototype.stepDown=function(){var m=parseFloat(this.attributes.value),j=parseFloat(this.attributes.step)||1,i=parseFloat(this.attributes.min),Z=parseFloat(this.attributes.max);if(isNaN(i)){i=0}if(isNaN(Z)){Z=100}if(Z<i){Z=i}if(isNaN(m)){m=i}else{if(m-j<i){m=i}else{m-=j}}this.value=""+m;this.valueAsNumber=m;this.setAttribute("value",m)};g.handlers={focus:function(i){var j=this;setTimeout(function(){try{j.$getContainer("value").focus();j.$getContainer("field").scrollLeft=0}catch(m){}},0);this.$getContainer("placeholder").style.display="none"},blur:function(i){this.$getContainer("placeholder").style.display=this.attributes.value?"none":"";switch(this.attributes.type){case"date":case"color":case"datetime":case"datetime-local":case"month":case"week":g.toggle(this,false);break}},click:function(i){if(i.target==this){if(i.$pseudoTarget==this.$getContainer("button")){switch(this.attributes.type){case"file":case"date":case"color":case"datetime":case"datetime-local":case"month":case"week":this.$activate();break}}else{switch(this.attributes.type){case"radio":case"checkbox":this.$activate();break}}}},mousedown:function(i){if(i.target==this){switch(this.attributes.type){case"range":if(i.$pseudoTarget!=this.$getContainer("button")){break}case"reset":case"submit":case"button":this.$captured=true;this.setCapture(true);this.$setPseudoClass("active",true);break}}},mouseup:function(i){if(i.target==this){switch(this.attributes.type){case"reset":case"submit":case"button":case"range":if(this.$captured){this.$captured=false;this.releaseCapture();this.$setPseudoClass("active",false);if(this.attributes.type=="range"){this.setAttribute("value",this.valueAsNumber)}}break}}},mousemove:function(m){if(m.target==this){switch(this.attributes.type){case"range":if(this.$captured){var bL=this.getBoundingClientRect("field"),bJ=Math.max(bL.left,Math.min(m.clientX,bL.right)),j=(bJ-bL.left)/(bL.right-bL.left);var Z=parseFloat(this.attributes.step)||1,i=parseFloat(this.attributes.min),bK=parseFloat(this.attributes.max);if(isNaN(i)){i=0}if(isNaN(bK)){bK=100}if(bK<i){bK=i}this.valueAsNumber=Math.round(Z*(i+(bK-i)*j))/Z;this.$getContainer("button").style.left=g.getRangeOffset(this,this.valueAsNumber)}break}}},keydown:function(i){if(i.target==this){var j=i.keyIdentifier;switch(this.attributes.type){case"range":if(j=="Right"){this.stepUp();g.dispatchInputEvent(this)}else{if(j=="Left"){this.stepDown();g.dispatchInputEvent(this)}}break;case"number":if(j=="Up"){this.stepUp();g.dispatchInputEvent(this)}else{if(j=="Down"){this.stepDown();g.dispatchInputEvent(this)}}break;case"radio":break;case"checkbox":if(j=="U+0020"){break}}}},keyup:function(i){},DOMActivate:function(j){if(j.target==this){switch(this.attributes.type){case"file":this.$getContainer("value").click();break;case"color":case"date":case"datetime":case"datetime-local":case"month":case"week":g.toggle(this);break;case"checkbox":this.setAttribute("checked",this.attributes.checked=="true"?"false":"true");break;case"radio":var Z=this.attributes.name;if(Z&&this.form){for(var i=0,m;i<this.form.elements.length;i++){if((m=this.form.elements[i])&&m.attributes.type=="radio"&&m.attributes.name==Z){if(m.attributes.checked=="true"){this.form.elements[i].removeAttribute("checked")}}}}this.setAttribute("checked","true");break}}},DOMNodeInsertedIntoDocument:function(i){aW.register(this);this.$selectable=this.attributes.type!="range"},DOMNodeRemovedFromDocument:function(i){aW.unregister(this)},DOMAttrModified:function(j){if(j.target==this){switch(j.attrName){case"type":var m=this.$getContainer(),i=document.createElement("div");i.innerHTML=this.$getTag();m.parentNode.replaceChild(i.firstChild,m);break;case"placeholder":this.$getContainer("placeholder").innerHTML=j.newValue||"";break;case"checked":this.$setPseudoClass("checked",j.newValue!=null&&j.newValue!="false");break;case"value":switch(this.attributes.type){case"range":this.$getContainer("button").style.left=g.getRangeOffset(this,j.newValue||"");break;default:this.$getContainer("value").value=j.newValue||""}break}aY.mapAttribute(this,j.attrName,j.newValue)}}};g.toggle=function(i,m){var Z=i.$getContainer("popup");if((arguments.length>1&&m==true)||!(arguments.length>1||Z.style.display!="none")){i.$setPseudoClass("active",true);Z.style.display=""}else{i.$setPseudoClass("active",false);Z.style.display="none"}switch(i.attributes.type){case"date":case"datetime":case"datetime-local":case"month":case"week":if(!i.datepicker){var j=ample.createElement("datepicker");Z.innerHTML=j.$getTag();i.contentFragment.appendChild(j);i.datepicker=j}i.datepicker.setAttribute("value","2010-11-23");break;case"color":if(!i.colorpicker){var j=ample.createElement("colorpicker");Z.innerHTML=j.$getTag();i.contentFragment.appendChild(j);i.colorpicker=j}i.colorpicker.setAttribute("value","#ffffff");break}};g.getRangeOffset=function(j,m){var Z=parseFloat(j.attributes.max),i=parseFloat(j.attributes.min);if(isNaN(i)){i=0}if(isNaN(Z)){Z=100}if(Z<i){Z=i}return 100*(Math.max(i,Math.min(Z,m))-i)/(Z-i)+"%"};g.dispatchInputEvent=function(i){var j=i.ownerDocument.createEvent("Event");j.initEvent("input",false,false);i.dispatchEvent(j)};g.html524={hidden:"hidden",password:"password",checkbox:"checkbox",radio:"radio",file:"file",submit:"submit",image:"image",reset:"reset",button:"button"};g.prototype.$getTagOpen=function(){var i=this.attributes.type||"text",bM=this.attributes.value||"",m=(this.prefix?this.prefix+"-":"")+this.localName,j=m+"-type-"+i,bL=this.attributes.checked&&this.attributes.checked!="false",bO=this.attributes.required&&this.attributes.required!="false",bJ=this.attributes.disabled&&this.attributes.disabled!="false",bK=this.attributes.readonly&&this.attributes.readonly!="false",bN=aW.isValid(this),Z=[];Z.push('<span class="'+m+" "+j+("class" in this.attributes?" "+this.attributes["class"]:"")+" "+m+"_"+(bL?"checked":"")+" "+m+"_"+(bO?"required":"optional")+" "+m+"_"+(bJ?"disabled":"enabled")+" "+m+"_"+(bK?"read-only":"read-write")+" "+m+"_"+(bN?"valid":"invalid")+' " '+(this.attributes.style?' style="'+this.attributes.style+'"':"")+">");Z.push('<div style="position:absolute;white-space:nowrap;'+(bM==""?"":"display:none")+'" class="'+m+'--placeholder">'+(this.getAttribute("placeholder")||"")+"</div>");Z.push('<span class="'+m+"--before "+j+'--before" style="float:left"></span>');Z.push('<span class="'+m+"--after "+j+'--after" style="float:right"></span>');Z.push('<div class="'+m+"--field "+j+'--field" style="position:relative">');Z.push('<div class="'+m+"--button "+j+'--button" style="'+(i=="range"?"left:"+g.getRangeOffset(this,bM):"right:0")+'">');if(i=="number"||i=="time"){Z.push(this._spinButtons.$getTag())}Z.push("</div>");Z.push('<input class="'+m+"--value "+j+'--value" type="'+(g.html524[i]||"text")+'" onchange="var o = ample.$instance(this).$getContainer(\'label\'); o.innerText = o.textContent = this.value"'+(this.attributes.readonly?' readonly="true"':"")+(this.attributes.disabled?' disabled="true"':"")+(this.attributes.maxlength?' maxlength="'+this.attributes.maxlength+'"':"")+(bM?' value="'+bM+'"':"")+(this.attributes.name?' name="'+this.attributes.name+'"':"")+"/>");Z.push('<div class="'+m+"--label "+j+'--label">'+(i=="reset"||i=="submit"||i=="button"?bM:i=="date"?ample.locale.format(ample.locale.parseDate(bM,"yyyy-mm-dd"),"D"):i=="time"||i=="color"?bM:"")+"</div>");Z.push("</div>");Z.push('<div class="'+m+'--popup" style="position:absolute;display:none">');return Z.join("")};g.prototype.$getTagClose=function(){var i=[];i.push("</div>");i.push("</span>");return i.join("")};ample.extend(g);var bg=function(){this.validity=new u};bg.prototype=new aW("keygen");bg.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bg);var a9=function(){};a9.prototype=new aY("label");a9.handlers={click:function(){this.$activate()},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}},DOMActivate:function(i){var j;if(this.attributes["for"]&&(j=this.ownerDocument.getElementById(this.attributes["for"]))){if(j instanceof aW){j.focus()}}}};ample.extend(a9);var aH=function(){};aH.prototype=new aY("legend");aH.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aH);var P=function(){};P.prototype=new aY("meter");P.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(P);var J=function(){};J.prototype=new aY("optgroup");J.prototype.$selectable=false;J.handlers={mouseover:function(i){if(i.target==this){this.$setPseudoClass("hover",true,"value")}},mouseout:function(i){if(i.target==this){this.$setPseudoClass("hover",false,"value")}},DOMNodeInsertedIntoDocument:function(i){for(var m=this,j=0;m=m.parentNode;){if(m instanceof V){break}else{j++}}if(m){if(this.parentNode!=m){this.$getContainer("gap").style.width=j+"em"}}},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};J.prototype.$getTagOpen=function(){var i=(this.prefix?this.prefix+"-":"")+this.localName;return'<div class="'+i+("class" in this.attributes?" "+this.attributes["class"]:"")+(this.attributes.disabled?" "+i+"_disabled":"")+'"> <div class="'+i+'--gap" style="height:1em;float:left"></div> <div class="'+i+'--value">'+(this.attributes.label||"")+'</div> <div class="'+i+'--gateway">'};J.prototype.$getTagClose=function(){return"</div> </div>"};ample.extend(J);var bl=function(){};bl.prototype=new aY("option");bl.prototype.$selectable=false;bl.prototype.$hoverable=true;bl.ensureRowIsVisible=function(i){for(var m=i;m=m.parentNode;){if(m instanceof V){var bJ=m.$getContainer("popup"),bK=i.$getContainer(),Z=bK.offsetTop-bJ.offsetTop,j=bK.offsetHeight-bJ.offsetHeight;if(bJ.scrollTop<Z+j){bJ.scrollTop=Z+j}else{if(bJ.scrollTop>Z){bJ.scrollTop=Z}}break}}};bl.handlers={DOMNodeInsertedIntoDocument:function(i){for(var m=this,j=0;m=m.parentNode;){if(m instanceof V){break}else{j++}}if(m){m.options.$add(this);if(this.parentNode!=m){this.$getContainer("gap").style.width=j+"em"}}},DOMNodeRemovedFromDocument:function(i){for(var j=this;j=j.parentNode;){if(j instanceof V){break}}if(j){j.options.$remove(this)}},DOMAttrModified:function(i){if(i.target==this){switch(i.attrName){case"selected":this.$setPseudoClass("selected",i.newValue!=null&&i.newValue!="false");break;case"label":this.$getContainer("gateway").innerHTML=i.newValue||"";break;default:aY.mapAttribute(this,i.attrName,i.newValue)}}}};bl.prototype.$getTagOpen=function(){var i=(this.prefix?this.prefix+"-":"")+this.localName;return'<div class="'+i+("class" in this.attributes?" "+this.attributes["class"]:"")+(this.attributes.disabled?" "+i+"_disabled":"")+'"> <div class="'+i+'--gap" style="height:1em;float:left"></div> <div class="'+i+'--gateway">'+(this.attributes.label||"")};bl.prototype.$getTagClose=function(){return"</div> </div>"};ample.extend(bl);var ap=function(){};ap.prototype=new aY("output");ap.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ap);var av=function(){};av.prototype=new aY("progress");av.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(av);var V=function(){this.validity=new u;this.options=new ample.classes.NodeList;var i=this;this.options.add=function(m,j){i.add(m,j)};this.options.remove=function(j){i.remove(j)}};V.prototype=new aW("select");V.prototype.options=null;V.prototype.selectedIndex=-1;V.prototype.add=function(j,i){return this.appendChild(j)};V.prototype.remove=function(i){return this.removeChild(this.options[i])};V.handlers={focus:function(i){this.$getContainer("value").focus()},blur:function(i){if(!this.attributes.multiple){V.toggle(this,false)}this.$getContainer("value").blur()},mousedown:function(i){if(i.target==this&&i.$pseudoTarget==this.$getContainer("button")){V.toggle(this)}},keydown:function(i){if(i.keyIdentifier=="Up"){if(this.selectedIndex!=-1){this.options[this.selectedIndex].removeAttribute("selected")}if(this.selectedIndex>0){this.selectedIndex--}else{if(this.options.length){this.selectedIndex=this.options.length-1}}if(this.selectedIndex>-1){this.options[this.selectedIndex].setAttribute("selected","true");bl.ensureRowIsVisible(this.options[this.selectedIndex])}i.preventDefault()}else{if(i.keyIdentifier=="Down"){if(this.selectedIndex!=-1){this.options[this.selectedIndex].removeAttribute("selected")}if(this.selectedIndex<this.options.length-1){this.selectedIndex++}else{if(this.options.length){this.selectedIndex=0}}if(this.selectedIndex>-1){this.options[this.selectedIndex].setAttribute("selected","true");bl.ensureRowIsVisible(this.options[this.selectedIndex])}i.preventDefault()}}},click:function(i){if(i.target==this){if(i.$pseudoTarget==this.$getContainer("button")){V.toggle(this)}}},mousedown:function(i){if(i.target instanceof bl){if(this.options[this.selectedIndex]!=i.target){if(this.selectedIndex>-1){this.options[this.selectedIndex].removeAttribute("selected")}this.options[this.selectedIndex=this.options.$indexOf(i.target)].setAttribute("selected","true");bl.ensureRowIsVisible(this.options[this.selectedIndex])}}},DOMNodeInsertedIntoDocument:function(i){aW.register(this)},DOMNodeRemovedFromDocument:function(i){aW.unregister(this)},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};V.toggle=function(i,j){var m=i.$getContainer("popup");if((arguments.length>1&&j==true)||!(arguments.length>1||m.style.display!="none")){i.$setPseudoClass("active",true);m.style.display=""}else{i.$setPseudoClass("active",false);m.style.display="none"}};V.prototype.$getTagOpen=function(){var i=(this.prefix?this.prefix+"-":"")+this.localName,m="multiple" in this.attributes||this.attributes.multiple=="true",j=m;return'<span class="'+i+" "+(m?i+"-multiple-":"")+("class" in this.attributes?" "+this.attributes["class"]:"")+(this.attributes.required?" "+i+"_required":"")+(this.attributes.disabled?" "+i+"_disabled":"")+'"> <div style="position:absolute;margin-top:-2px;white-space:nowrap" class="'+i+'--placeholder">'+(this.getAttribute("placeholder")||"")+'</div> <div class="'+i+'--field" style="position:relative;'+(j?"display:none":"")+'"> <div class="'+i+'--button" style="right:0"></div> <input class="'+i+'--value" type="text" /> <div class="'+i+'--label" /> </div> <div class="'+i+"--popup"+(m?" "+i+"-multiple---popup":"")+'" style="'+(j?"":"position:absolute;display:none;")+'"> <div class="'+i+'--gateway" style="margin:1px">'};V.prototype.$getTagClose=function(){return"</div> </div> </span>"};ample.extend(V);var ay=function(){this.validity=new u};ay.prototype=new aW("textarea");ay.prototype.select=function(){this.$getContainer().select()};ay.prototype._onChange=function(i){var j=this.ownerDocument.createEvent("UIEvent");j.initUIEvent("change",true,false,window,null);this.dispatchEvent(j)};ay.handlers={focus:function(i){this.$getContainer("value").focus()},DOMNodeInsertedIntoDocument:function(i){aW.register(this)},DOMNodeRemovedFromDocument:function(i){aW.unregister(this)},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ay.prototype.$getTagOpen=function(){var j=(this.prefix?this.prefix+"-":"")+this.localName,i=["<span"];for(var m in this.attributes){if(this.attributes.hasOwnProperty(m)&&m!="class"&&m!="id"&&m.indexOf(":")==-1){i.push(" "+m+'="'+this.attributes[m].replace(/"/g,'"')+'"')}}i.push(' class="'+j+("class" in this.attributes?" "+this.attributes["class"]:"")+'">');i.push('<div style="position:absolute;margin-top:-2px;white-space:nowrap" class="'+j+'--placeholder">'+(this.getAttribute("placeholder")||"")+"</div>");i.push('<div class="'+j+'--field" style="position:relative;height:100%;">');i.push('<textarea class="'+j+'--value" onchange="ample.$instance(this)._onChange(event)" style="width:100%;height:100%">');return i.join("")};ay.prototype.$getTagClose=function(){return"</textarea> </div> </span>"};ample.extend(ay);var an=function(){};an.prototype=new aY("blockquote");an.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(an);var T=function(){};T.prototype=new aY("dd");T.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(T);var aw=function(){};aw.prototype=new aY("div");aw.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aw);var S=function(){};S.prototype=new aY("dl");S.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(S);var Q=function(){};Q.prototype=new aY("dt");Q.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(Q);var al=function(){};al.prototype=new aY("figcaption");al.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(al);var ax=function(){};ax.prototype=new aY("figure");ax.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ax);var br=function(){};br.prototype=new aY("hr");br.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(br);var aP=function(){};aP.prototype=new aY("li");aP.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aP);var ah=function(){};ah.prototype=new aY("ol");ah.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ah);var bI=function(){};bI.prototype=new aY("p");bI.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bI);var aV=function(){};aV.prototype=new aY("pre");aV.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aV);var bi=function(){};bi.prototype=new aY("ul");bi.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bi);var q=function(){};q.prototype=new aY("command");q.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(q);var bD=function(){};bD.prototype=new aY("details");bD.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bD);var aI=function(){};aI.prototype=new aY("menu");aI.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aI);var bx=function(){};bx.prototype=new aY("summary");bx.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bx);var bb=function(){};bb.prototype=new aY("base");bb.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bb);var aJ=function(){};aJ.prototype=new aY("head");aJ.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aJ);var ac=function(){};ac.prototype=new aY("link");ac.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ac);var z=function(){};z.prototype=new aY("meta");z.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(z);var aX=function(){};aX.prototype=new aY("style");aX.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aX);var aL=function(){};aL.prototype=new aY("title");aL.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aL);var az=function(){};az.prototype=new aY("dialog");az.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(az);var bv=function(){};bv.prototype=new aY("html");bv.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bv);var aN=function(){};aN.prototype=new aY("eventsource");aN.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aN);var O=function(){};O.prototype=new aY("noscript");O.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(O);var k=function(){};k.prototype=new aY("script");k.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}},DOMNodeInsertedIntoDocument:function(i){var m=(this.attributes.type||"").match(/(\w+)\/([-\w]+\+)?(?:x\-)?([-\w]+)?;?(.+)?/)?RegExp.$3:"";if(this.attributes.src){this.$getContainer().src=this.attributes.src}else{if(this.firstChild&&(m==""||m=="javascript"||m=="ecmascript")){var j=document.body.appendChild(document.createElement("script"));j.type="text/javascript";j.text=this.firstChild.nodeValue}}}};ample.extend(k);var ar=function(){};ar.prototype=new aY("address");ar.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ar);var N=function(){};N.prototype=new aY("article");N.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(N);var ag=function(){};ag.prototype=new aY("aside");ag.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ag);var bh=function(){};bh.prototype=new aY("body");bh.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bh);var h=function(){};h.prototype=new aY("footer");h.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(h);var t=function(){};t.prototype=new aY("h1");t.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(t);var s=function(){};s.prototype=new aY("h2");s.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(s);var r=function(){};r.prototype=new aY("h3");r.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(r);var p=function(){};p.prototype=new aY("h4");p.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(p);var n=function(){};n.prototype=new aY("h5");n.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(n);var l=function(){};l.prototype=new aY("h6");l.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(l);var aA=function(){};aA.prototype=new aY("header");aA.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aA);var d=function(){};d.prototype=new aY("nav");d.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(d);var ae=function(){};ae.prototype=new aY("section");ae.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ae);var W=function(){};W.prototype=new aY("spinbuttons");W.captured=false;W.interval=null;W.timeout=null;W.handlers={mousedown:function(i){if(i.$pseudoTarget==this.$getContainer("button-up")){this.spin(true);var j=this;W.timeout=setTimeout(function(){W.interval=setInterval(function(){j.spin(true)},100)},500);this.$setPseudoClass("active",true,"button-up");this._captured=true;this.setCapture(true)}else{if(i.$pseudoTarget==this.$getContainer("button-down")){this.spin(false);var j=this;W.timeout=setTimeout(function(){W.interval=setInterval(function(){j.spin(false)},100)},500);this.$setPseudoClass("active",true,"button-down");this._captured=true;this.setCapture(true)}}},mouseup:function(i){if(this._captured){this._captured=false;clearTimeout(W.timeout);clearInterval(W.interval);this.$setPseudoClass("active",false,"button-up");this.$setPseudoClass("active",false,"button-down");this.releaseCapture()}},DOMAttrModifed:function(i){if(i.target==this){switch(i.attrName){case"disabled":this.$setPseudoClass("disabled",i.newValue=="true");break}}}};W.prototype.spin=function(j){var i=this.ownerDocument.createEvent("CustomEvent");i.initCustomEvent("spin",false,false,j);this.dispatchEvent(i)};W.prototype.$getTagOpen=function(){return'<div class="spinbuttons'+(!this.$isAccessible()?" spinbuttons_disabled":"")+'" onmousedown="return false" onselectstart="return false"> <div class="spinbuttons--button-up" onmouseover="if (ample.$instance(this).$isAccessible()) ample.$instance(this).$setPseudoClass(\'hover\', true, \'button-up\')" onmouseout="if (ample.$instance(this).$isAccessible()) ample.$instance(this).$setPseudoClass(\'hover\', false, \'button-up\')"><br/></div> <div class="spinbuttons--button-down" onmouseover="if (ample.$instance(this).$isAccessible()) ample.$instance(this).$setPseudoClass(\'hover\', true, \'button-down\')" onmouseout="if (ample.$instance(this).$isAccessible()) ample.$instance(this).$setPseudoClass(\'hover\', false, \'button-down\')"><br/></div> </div>'};W.prototype.$getTagClose=function(){return""};ample.extend(W);var by=function(){};by.prototype=new aY("caption");by.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(by);var aB=function(){};aB.prototype=new aY("col");aB.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aB);var aE=function(){};aE.prototype=new aY("colgroup");aE.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aE);var c=function(){this.tHead=null;this.tBodies=new ample.classes.NodeList;this.tFoot=null;this.caption=null;this.rows=new ample.classes.NodeList};c.prototype=new aY("table");c.prototype.tHead=null;c.prototype.tBodies=null;c.prototype.tFoot=null;c.prototype.caption=null;c.prototype.rows=null;c.prototype.insertRow=function(i){var j=this.ownerDocument.createElementNS(this.namespaceURI,"tr");return i==-1?this.appendChild(j):this.insertBefore(j,this.rows[i])};c.prototype.deleteRow=function(i){return this.removeChild(this.rows[i])};c.prototype.createCaption=function(){};c.prototype.deleteCaption=function(){};c.prototype.createTHead=function(){};c.prototype.deleteTHead=function(){};c.prototype.createTFoot=function(){};c.prototype.deleteTFoot=function(){};c.handlers={DOMNodeInserted:function(i){if(i.target.parentNode==this){if(i.target instanceof by){this.caption=i.target}else{if(i.target instanceof M){this.tBodies.$add(i.target)}else{if(i.target instanceof K){this.tFoot=i.target}else{if(i.target instanceof bm){this.tHead=i.target}}}}}},DOMNodeRemoved:function(i){if(i.target.parentNode==this){if(i.target instanceof by){this.caption=null}else{if(i.target instanceof M){this.tBodies.$remove(i.target)}else{if(i.target instanceof K){this.tFoot=nullt}else{if(i.target instanceof bm){this.tHead=null}}}}}},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(c);var M=function(){this.rows=new ample.classes.NodeList};M.prototype=new aY("tbody");M.prototype.rows=null;M.prototype.insertRow=function(i){var j=this.ownerDocument.createElementNS(this.namespaceURI,"tr");return i==-1?this.appendChild(j):this.insertBefore(j,this.rows[i])};M.prototype.deleteRow=function(i){return this.removeChild(this.rows[i])};M.handlers={DOMNodeInserted:function(i){if(i.target.parentNode==this){if(i.target instanceof bw){this.rows.$add(i.target)}}},DOMNodeRemoved:function(i){if(i.target.parentNode==this){if(i.target instanceof bw){this.rows.$remove(i.target)}}},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(M);var bC=function(){};bC.prototype=new aY("td");bC.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bC);var K=function(){this.rows=new ample.classes.NodeList};K.prototype=new aY("tfoot");K.prototype.rows=null;K.prototype.insertRow=function(i){var j=this.ownerDocument.createElementNS(this.namespaceURI,"tr");return i==-1?this.appendChild(j):this.insertBefore(j,this.rows[i])};K.prototype.deleteRow=function(i){return this.removeChild(this.rows[i])};K.handlers={DOMNodeInserted:function(i){if(i.target.parentNode==this){if(i.target instanceof bw){this.rows.$add(i.target)}}},DOMNodeRemoved:function(i){if(i.target.parentNode==this){if(i.target instanceof bw){this.rows.$remove(i.target)}}},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(K);var bB=function(){};bB.prototype=new aY("th");bB.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bB);var bm=function(){this.rows=new ample.classes.NodeList};bm.prototype=new aY("thead");bm.prototype.rows=null;bm.prototype.insertRow=function(i){var j=this.ownerDocument.createElementNS(this.namespaceURI,"tr");return i==-1?this.appendChild(j):this.insertBefore(j,this.rows[i])};bm.prototype.deleteRow=function(i){return this.removeChild(this.rows[i])};bm.handlers={DOMNodeInserted:function(i){if(i.target.parentNode==this){if(i.target instanceof bw){this.rows.$add(i.target)}}},DOMNodeRemoved:function(i){if(i.target.parentNode==this){if(i.target instanceof bw){this.rows.$remove(i.target)}}},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bm);var bw=function(){this.cells=new ample.classes.NodeList};bw.prototype=new aY("tr");bw.prototype.cells=null;bw.prototype.insertCell=function(i){var j=this.ownerDocument.createElementNS(this.namespaceURI,"td");return i==-1?this.appendChild(j):this.insertBefore(j,this.rows[i])};bw.prototype.deleteCell=function(i){return this.removeChild(this.cells[i])};bw.handlers={DOMNodeInserted:function(i){if(i.target.parentNode==this){if(i.target instanceof bC||i.target instanceof bB){this.cells.$add(i.target)}}},DOMNodeRemoved:function(i){if(i.target.parentNode==this){if(i.target instanceof bC||i.target instanceof bB){this.cells.$remove(i.target)}}},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bw);var f=function(){};f.prototype=new aY("a");f.prototype.tabIndex=0;f.prototype.$hoverable=true;f.handlers={focus:function(i){this.$getContainer().focus()},blur:function(i){this.$getContainer().blur()},click:function(j){if(j.button==0){var i=this.ownerDocument.createEvent("UIEvent");i.initUIEvent("DOMActivate",true,true,window,null);if(!this.dispatchEvent(i)){j.preventDefault()}}},DOMActivate:function(j){if(document.namespaces){var Z=this.$getContainer().href,m=Z.match(/^([^#]*)#(.*)/);if(m&&window.location.href.match(/^([^#]*)#/)&&m[1]==window.RegExp.$1){ample.bookmark(m[2])}}var i;if(this.getAttribute("target").match(/#(.+)$/)&&(i=this.ownerDocument.getElementById(window.RegExp.$1))){ample.query(i).load(this.getAttribute("href").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"));j.preventDefault()}},DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(f);var au=function(){};au.prototype=new aY("abbr");au.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(au);var e=function(){};e.prototype=new aY("b");e.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(e);var bo=function(){};bo.prototype=new aY("bdo");bo.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bo);var am=function(){};am.prototype=new aY("br");am.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};am.prototype.$getTagOpen=function(){var j="<"+this.localName;for(var i in this.attributes){if(this.attributes.hasOwnProperty(i)&&i!="class"&&i!="id"&&i.indexOf(":")==-1){j+=" "+i+'="'+this.getAttribute(i).replace(/"/g,'"')+'"'}}j+=' class="'+(this.prefix?this.prefix+"-":"")+this.localName+("class" in this.attributes?" "+this.attributes["class"]:"")+'"';return j+"/>"};am.prototype.$getTagClose=function(){return""};ample.extend(am);var bn=function(){};bn.prototype=new aY("cite");bn.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bn);var B=function(){};B.prototype=new aY("code");B.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(B);var a1=function(){};a1.prototype=new aY("dfn");a1.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(a1);var H=function(){};H.prototype=new aY("em");H.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(H);var a=function(){};a.prototype=new aY("i");a.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(a);var aC=function(){};aC.prototype=new aY("kbd");aC.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(aC);var Y=function(){};Y.prototype=new aY("mark");Y.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(Y);var bH=function(){};bH.prototype=new aY("q");bH.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bH);var x=function(){};x.prototype=new aY("rp");x.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(x);var w=function(){};w.prototype=new aY("rt");w.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(w);var at=function(){};at.prototype=new aY("ruby");at.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(at);var bE=function(){};bE.prototype=new aY("samp");bE.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bE);var ak=function(){};ak.prototype=new aY("small");ak.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ak);var ab=function(){};ab.prototype=new aY("span");ab.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ab);var ao=function(){};ao.prototype=new aY("strong");ao.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ao);var bp=function(){};bp.prototype=new aY("sub");bp.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bp);var be=function(){};be.prototype=new aY("sup");be.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(be);var D=function(){};D.prototype=new aY("time");D.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(D);var bA=function(){};bA.prototype=new aY("var");bA.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(bA);var ai=function(){};ai.prototype=new aY("wbr");ai.handlers={DOMAttrModified:function(i){if(i.target==this){aY.mapAttribute(this,i.attrName,i.newValue)}}};ample.extend(ai);function G(i){return i instanceof aW&&i.form}ample.extend(ample.classes.NodeSelector.pseudoClass,{"default":function(i){return G(i)&&(i.attributes.type=="checkbox"||i.attributes.type=="radio")&&(i.attributes.checked==i.defaultChecked)},optional:function(i){return G(i)&&!(i.attributes.required==""||i.attributes.required=="true")},required:function(i){return G(i)&&(i.attributes.required==""||i.attributes.required=="true")},"read-write":function(i){return G(i)&&!(i.attributes.readonly==""||i.attributes.readonly=="true")},"read-only":function(i){return G(i)&&(i.attributes.readonly==""||i.attributes.readonly=="true")},invalid:function(i){return G(i)&&i.validity&&!i.validity.valid},valid:function(i){return G(i)&&i.validity&&i.validity.valid},"in-range":function(i){return G(i)&&i.validity&&!i.rangeUnderflow&&!i.validity.rangeOverflow},"out-of-range":function(i){return G(i)&&i.validity&&(i.rangeUnderflow||i.validity.rangeOverflow)}});function I(j,bK,bJ){for(var i=0,m,Z;i<bJ.length;i++){m=ample.classes[j+"#"+bJ[i]];Z=function(){m.call(this)};Z.prototype=new m;Z.prototype.localName=bJ[i];Z.prototype.namespaceURI=bK;Z.handlers=m.handlers;Z.attributes=m.attributes;ample.extend(Z)}}I("http://www.w3.org/2008/SMIL30/","http://www.w3.org/1999/xhtml",["set","animate","animateColor","animateMotion","par","seq","excl"])})();
(function(){function b(c,f,d,e){if(d==null){e.expires=-1;d=""}document.cookie=f+"="+encodeURIComponent(d)+(e.expires?"; expires="+(e.expires instanceof Date?e.expires:new Date(new Date().getTime()+Number(e.expires)*86400000)).toUTCString():"")+(e.path?"; path="+e.path:"")+(e.domain?"; domain="+e.domain:"")+(e.secure?"; secure":"")}function a(e,h){var g=document.cookie;if(g&&g!=""){for(var c=0,d=g.split(";"),f=d.length;c<f;c++){if(d[c].match(/^\s*([^=]+)=(.*)\s*/)&&RegExp.$1==h){return decodeURIComponent(RegExp.$2)}}}return null}ample.extend({cookie:function(e,c,d){ample.guard(arguments,[["name",String],["value",Object,true,true],["settings",Object,true]]);if(arguments.length>1){b(this,e,c,d||{})}else{return a(this,e)}}})})();
Location: http://dropmefiles.com/js/plupload2/moxie.js
Referrer: http://dropmefiles.com/
Content-Type: application/javascript
/**
* mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill
* v1.2.0
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*
* Date: 2014-01-16
*/
/**
* Compiled inline version. (Library mode)
*/
/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */
/*globals $code */
(function(exports, undefined) {
"use strict";
var modules = {};
function require(ids, callback) {
var module, defs = [];
for (var i = 0; i < ids.length; ++i) {
module = modules[ids[i]] || resolve(ids[i]);
if (!module) {
throw 'module definition dependecy not found: ' + ids[i];
}
defs.push(module);
}
callback.apply(null, defs);
}
function define(id, dependencies, definition) {
if (typeof id !== 'string') {
throw 'invalid module definition, module id must be defined and be a string';
}
if (dependencies === undefined) {
throw 'invalid module definition, dependencies must be specified';
}
if (definition === undefined) {
throw 'invalid module definition, definition function must be specified';
}
require(dependencies, function() {
modules[id] = definition.apply(null, arguments);
});
}
function defined(id) {
return !!modules[id];
}
function resolve(id) {
var target = exports;
var fragments = id.split(/[.\/]/);
for (var fi = 0; fi < fragments.length; ++fi) {
if (!target[fragments[fi]]) {
return;
}
target = target[fragments[fi]];
}
return target;
}
function expose(ids) {
for (var i = 0; i < ids.length; i++) {
var target = exports;
var id = ids[i];
var fragments = id.split(/[.\/]/);
for (var fi = 0; fi < fragments.length - 1; ++fi) {
if (target[fragments[fi]] === undefined) {
target[fragments[fi]] = {};
}
target = target[fragments[fi]];
}
target[fragments[fragments.length - 1]] = modules[id];
}
}
// Included from: src/javascript/core/utils/Basic.js
/**
* Basic.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Basic', [], function() {
/**
Gets the true type of the built-in object (better version of typeof).
@author Angus Croll (http://javascriptweblog.wordpress.com/)
@method typeOf
@for Utils
@static
@param {Object} o Object to check.
@return {String} Object [[Class]]
*/
var typeOf = function(o) {
var undef;
if (o === undef) {
return 'undefined';
} else if (o === null) {
return 'null';
} else if (o.nodeType) {
return 'node';
}
// the snippet below is awesome, however it fails to detect null, undefined and arguments types in IE lte 8
return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
};
/**
Extends the specified object with another object.
@method extend
@static
@param {Object} target Object to extend.
@param {Object} [obj]* Multiple objects to extend with.
@return {Object} Same as target, the extended object.
*/
var extend = function(target) {
var undef;
each(arguments, function(arg, i) {
if (i > 0) {
each(arg, function(value, key) {
if (value !== undef) {
if (typeOf(target[key]) === typeOf(value) && !!~inArray(typeOf(value), ['array', 'object'])) {
extend(target[key], value);
} else {
target[key] = value;
}
}
});
}
});
return target;
};
/**
Executes the callback function for each item in array/object. If you return false in the
callback it will break the loop.
@method each
@static
@param {Object} obj Object to iterate.
@param {function} callback Callback function to execute for each item.
*/
var each = function(obj, callback) {
var length, key, i, undef;
if (obj) {
try {
length = obj.length;
} catch(ex) {
length = undef;
}
if (length === undef) {
// Loop object items
for (key in obj) {
if (obj.hasOwnProperty(key)) {
if (callback(obj[key], key) === false) {
return;
}
}
}
} else {
// Loop array items
for (i = 0; i < length; i++) {
if (callback(obj[i], i) === false) {
return;
}
}
}
}
};
/**
Checks if object is empty.
@method isEmptyObj
@static
@param {Object} o Object to check.
@return {Boolean}
*/
var isEmptyObj = function(obj) {
var prop;
if (!obj || typeOf(obj) !== 'object') {
return true;
}
for (prop in obj) {
return false;
}
return true;
};
/**
Recieve an array of functions (usually async) to call in sequence, each function
receives a callback as first argument that it should call, when it completes. Finally,
after everything is complete, main callback is called. Passing truthy value to the
callback as a first argument will interrupt the sequence and invoke main callback
immediately.
@method inSeries
@static
@param {Array} queue Array of functions to call in sequence
@param {Function} cb Main callback that is called in the end, or in case of erro
*/
var inSeries = function(queue, cb) {
var i = 0, length = queue.length;
if (typeOf(cb) !== 'function') {
cb = function() {};
}
if (!queue || !queue.length) {
cb();
}
function callNext(i) {
if (typeOf(queue[i]) === 'function') {
queue[i](function(error) {
/*jshint expr:true */
++i < length && !error ? callNext(i) : cb(error);
});
}
}
callNext(i);
};
/**
Recieve an array of functions (usually async) to call in parallel, each function
receives a callback as first argument that it should call, when it completes. After
everything is complete, main callback is called. Passing truthy value to the
callback as a first argument will interrupt the process and invoke main callback
immediately.
@method inParallel
@static
@param {Array} queue Array of functions to call in sequence
@param {Function} cb Main callback that is called in the end, or in case of erro
*/
var inParallel = function(queue, cb) {
var count = 0, num = queue.length, cbArgs = new Array(num);
each(queue, function(fn, i) {
fn(function(error) {
if (error) {
return cb(error);
}
var args = [].slice.call(arguments);
args.shift(); // strip error - undefined or not
cbArgs[i] = args;
count++;
if (count === num) {
cbArgs.unshift(null);
cb.apply(this, cbArgs);
}
});
});
};
/**
Find an element in array and return it's index if present, otherwise return -1.
@method inArray
@static
@param {Mixed} needle Element to find
@param {Array} array
@return {Int} Index of the element, or -1 if not found
*/
var inArray = function(needle, array) {
if (array) {
if (Array.prototype.indexOf) {
return Array.prototype.indexOf.call(array, needle);
}
for (var i = 0, length = array.length; i < length; i++) {
if (array[i] === needle) {
return i;
}
}
}
return -1;
};
/**
Returns elements of first array if they are not present in second. And false - otherwise.
@private
@method arrayDiff
@param {Array} needles
@param {Array} array
@return {Array|Boolean}
*/
var arrayDiff = function(needles, array) {
var diff = [];
if (typeOf(needles) !== 'array') {
needles = [needles];
}
if (typeOf(array) !== 'array') {
array = [array];
}
for (var i in needles) {
if (inArray(needles[i], array) === -1) {
diff.push(needles[i]);
}
}
return diff.length ? diff : false;
};
/**
Find intersection of two arrays.
@private
@method arrayIntersect
@param {Array} array1
@param {Array} array2
@return {Array} Intersection of two arrays or null if there is none
*/
var arrayIntersect = function(array1, array2) {
var result = [];
each(array1, function(item) {
if (inArray(item, array2) !== -1) {
result.push(item);
}
});
return result.length ? result : null;
};
/**
Forces anything into an array.
@method toArray
@static
@param {Object} obj Object with length field.
@return {Array} Array object containing all items.
*/
var toArray = function(obj) {
var i, arr = [];
for (i = 0; i < obj.length; i++) {
arr[i] = obj[i];
}
return arr;
};
/**
Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers.
The only way a user would be able to get the same ID is if the two persons at the same exact milisecond manages
to get 5 the same random numbers between 0-65535 it also uses a counter so each call will be guaranteed to be page unique.
It's more probable for the earth to be hit with an ansteriod. Y
@method guid
@static
@param {String} prefix to prepend (by default 'o' will be prepended).
@method guid
@return {String} Virtually unique id.
*/
var guid = (function() {
var counter = 0;
return function(prefix) {
var guid = new Date().getTime().toString(32), i;
for (i = 0; i < 5; i++) {
guid += Math.floor(Math.random() * 65535).toString(32);
}
return (prefix || 'o_') + guid + (counter++).toString(32);
};
}());
/**
Trims white spaces around the string
@method trim
@static
@param {String} str
@return {String}
*/
var trim = function(str) {
if (!str) {
return str;
}
return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, '');
};
/**
Parses the specified size string into a byte value. For example 10kb becomes 10240.
@method parseSizeStr
@static
@param {String/Number} size String to parse or number to just pass through.
@return {Number} Size in bytes.
*/
var parseSizeStr = function(size) {
if (typeof(size) !== 'string') {
return size;
}
var muls = {
t: 1099511627776,
g: 1073741824,
m: 1048576,
k: 1024
},
mul;
size = /^([0-9]+)([mgk]?)$/.exec(size.toLowerCase().replace(/[^0-9mkg]/g, ''));
mul = size[2];
size = +size[1];
if (muls.hasOwnProperty(mul)) {
size *= muls[mul];
}
return size;
};
return {
guid: guid,
typeOf: typeOf,
extend: extend,
each: each,
isEmptyObj: isEmptyObj,
inSeries: inSeries,
inParallel: inParallel,
inArray: inArray,
arrayDiff: arrayDiff,
arrayIntersect: arrayIntersect,
toArray: toArray,
trim: trim,
parseSizeStr: parseSizeStr
};
});
// Included from: src/javascript/core/I18n.js
/**
* I18n.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/core/I18n", [
"moxie/core/utils/Basic"
], function(Basic) {
var i18n = {};
return {
/**
* Extends the language pack object with new items.
*
* @param {Object} pack Language pack items to add.
* @return {Object} Extended language pack object.
*/
addI18n: function(pack) {
return Basic.extend(i18n, pack);
},
/**
* Translates the specified string by checking for the english string in the language pack lookup.
*
* @param {String} str String to look for.
* @return {String} Translated string or the input string if it wasn't found.
*/
translate: function(str) {
return i18n[str] || str;
},
/**
* Shortcut for translate function
*
* @param {String} str String to look for.
* @return {String} Translated string or the input string if it wasn't found.
*/
_: function(str) {
return this.translate(str);
},
/**
* Pseudo sprintf implementation - simple way to replace tokens with specified values.
*
* @param {String} str String with tokens
* @return {String} String with replaced tokens
*/
sprintf: function(str) {
var args = [].slice.call(arguments, 1);
return str.replace(/%[a-z]/g, function() {
var value = args.shift();
return Basic.typeOf(value) !== 'undefined' ? value : '';
});
}
};
});
// Included from: src/javascript/core/utils/Mime.js
/**
* Mime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/core/utils/Mime", [
"moxie/core/utils/Basic",
"moxie/core/I18n"
], function(Basic, I18n) {
var mimeData = "" +
"application/msword,doc dot," +
"application/pdf,pdf," +
"application/pgp-signature,pgp," +
"application/postscript,ps ai eps," +
"application/rtf,rtf," +
"application/vnd.ms-excel,xls xlb," +
"application/vnd.ms-powerpoint,ppt pps pot," +
"application/zip,zip," +
"application/x-shockwave-flash,swf swfl," +
"application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," +
"application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," +
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," +
"application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," +
"application/vnd.openxmlformats-officedocument.presentationml.template,potx," +
"application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," +
"application/x-javascript,js," +
"application/json,json," +
"audio/mpeg,mp3 mpga mpega mp2," +
"audio/x-wav,wav," +
"audio/x-m4a,m4a," +
"audio/ogg,oga ogg," +
"audio/aiff,aiff aif," +
"audio/flac,flac," +
"audio/aac,aac," +
"audio/ac3,ac3," +
"audio/x-ms-wma,wma," +
"image/bmp,bmp," +
"image/gif,gif," +
"image/jpeg,jpg jpeg jpe," +
"image/photoshop,psd," +
"image/png,png," +
"image/svg+xml,svg svgz," +
"image/tiff,tiff tif," +
"text/plain,asc txt text diff log," +
"text/html,htm html xhtml," +
"text/css,css," +
"text/csv,csv," +
"text/rtf,rtf," +
"video/mpeg,mpeg mpg mpe m2v," +
"video/quicktime,qt mov," +
"video/mp4,mp4," +
"video/x-m4v,m4v," +
"video/x-flv,flv," +
"video/x-ms-wmv,wmv," +
"video/avi,avi," +
"video/webm,webm," +
"video/3gpp,3gpp 3gp," +
"video/3gpp2,3g2," +
"video/vnd.rn-realvideo,rv," +
"video/ogg,ogv," +
"video/x-matroska,mkv," +
"application/vnd.oasis.opendocument.formula-template,otf," +
"application/octet-stream,exe";
var Mime = {
mimes: {},
extensions: {},
// Parses the default mime types string into a mimes and extensions lookup maps
addMimeType: function (mimeData) {
var items = mimeData.split(/,/), i, ii, ext;
for (i = 0; i < items.length; i += 2) {
ext = items[i + 1].split(/ /);
// extension to mime lookup
for (ii = 0; ii < ext.length; ii++) {
this.mimes[ext[ii]] = items[i];
}
// mime to extension lookup
this.extensions[items[i]] = ext;
}
},
extList2mimes: function (filters, addMissingExtensions) {
var self = this, ext, i, ii, type, mimes = [];
// convert extensions to mime types list
for (i = 0; i < filters.length; i++) {
ext = filters[i].extensions.split(/\s*,\s*/);
for (ii = 0; ii < ext.length; ii++) {
// if there's an asterisk in the list, then accept attribute is not required
if (ext[ii] === '*') {
return [];
}
type = self.mimes[ext[ii]];
if (!type) {
if (addMissingExtensions && /^\w+$/.test(ext[ii])) {
mimes.push('.' + ext[ii]);
} else {
return []; // accept all
}
} else if (Basic.inArray(type, mimes) === -1) {
mimes.push(type);
}
}
}
return mimes;
},
mimes2exts: function(mimes) {
var self = this, exts = [];
Basic.each(mimes, function(mime) {
if (mime === '*') {
exts = [];
return false;
}
// check if this thing looks like mime type
var m = mime.match(/^(\w+)\/(\*|\w+)$/);
if (m) {
if (m[2] === '*') {
// wildcard mime type detected
Basic.each(self.extensions, function(arr, mime) {
if ((new RegExp('^' + m[1] + '/')).test(mime)) {
[].push.apply(exts, self.extensions[mime]);
}
});
} else if (self.extensions[mime]) {
[].push.apply(exts, self.extensions[mime]);
}
}
});
return exts;
},
mimes2extList: function(mimes) {
var accept = [], exts = [];
if (Basic.typeOf(mimes) === 'string') {
mimes = Basic.trim(mimes).split(/\s*,\s*/);
}
exts = this.mimes2exts(mimes);
accept.push({
title: I18n.translate('Files'),
extensions: exts.length ? exts.join(',') : '*'
});
// save original mimes string
accept.mimes = mimes;
return accept;
},
getFileExtension: function(fileName) {
var matches = fileName && fileName.match(/\.([^.]+)$/);
if (matches) {
return matches[1].toLowerCase();
}
return '';
},
getFileMime: function(fileName) {
return this.mimes[this.getFileExtension(fileName)] || '';
}
};
Mime.addMimeType(mimeData);
return Mime;
});
// Included from: src/javascript/core/utils/Env.js
/**
* Env.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/core/utils/Env", [
"moxie/core/utils/Basic"
], function(Basic) {
// UAParser.js v0.6.2
// Lightweight JavaScript-based User-Agent string parser
// https://github.com/faisalman/ua-parser-js
//
// Copyright © 2012-2013 Faisalman <[email protected]>
// Dual licensed under GPLv2 & MIT
var UAParser = (function (undefined) {
//////////////
// Constants
/////////////
var EMPTY = '',
UNKNOWN = '?',
FUNC_TYPE = 'function',
UNDEF_TYPE = 'undefined',
OBJ_TYPE = 'object',
MAJOR = 'major',
MODEL = 'model',
NAME = 'name',
TYPE = 'type',
VENDOR = 'vendor',
VERSION = 'version',
ARCHITECTURE= 'architecture',
CONSOLE = 'console',
MOBILE = 'mobile',
TABLET = 'tablet';
///////////
// Helper
//////////
var util = {
has : function (str1, str2) {
return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1;
},
lowerize : function (str) {
return str.toLowerCase();
}
};
///////////////
// Map helper
//////////////
var mapper = {
rgx : function () {
// loop through all regexes maps
for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) {
var regex = args[i], // even sequence (0,2,4,..)
props = args[i + 1]; // odd sequence (1,3,5,..)
// construct object barebones
if (typeof(result) === UNDEF_TYPE) {
result = {};
for (p in props) {
q = props[p];
if (typeof(q) === OBJ_TYPE) {
result[q[0]] = undefined;
} else {
result[q] = undefined;
}
}
}
// try matching uastring with regexes
for (j = k = 0; j < regex.length; j++) {
matches = regex[j].exec(this.getUA());
if (!!matches) {
for (p = 0; p < props.length; p++) {
match = matches[++k];
q = props[p];
// check if given property is actually array
if (typeof(q) === OBJ_TYPE && q.length > 0) {
if (q.length == 2) {
if (typeof(q[1]) == FUNC_TYPE) {
// assign modified match
result[q[0]] = q[1].call(this, match);
} else {
// assign given value, ignore regex match
result[q[0]] = q[1];
}
} else if (q.length == 3) {
// check whether function or regex
if (typeof(q[1]) === FUNC_TYPE && !(q[1].exec && q[1].test)) {
// call function (usually string mapper)
result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
} else {
// sanitize match using given regex
result[q[0]] = match ? match.replace(q[1], q[2]) : undefined;
}
} else if (q.length == 4) {
result[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined;
}
} else {
result[q] = match ? match : undefined;
}
}
break;
}
}
if(!!matches) break; // break the loop immediately if match found
}
return result;
},
str : function (str, map) {
for (var i in map) {
// check if array
if (typeof(map[i]) === OBJ_TYPE && map[i].length > 0) {
for (var j = 0; j < map[i].length; j++) {
if (util.has(map[i][j], str)) {
return (i === UNKNOWN) ? undefined : i;
}
}
} else if (util.has(map[i], str)) {
return (i === UNKNOWN) ? undefined : i;
}
}
return str;
}
};
///////////////
// String map
//////////////
var maps = {
browser : {
oldsafari : {
major : {
'1' : ['/8', '/1', '/3'],
'2' : '/4',
'?' : '/'
},
version : {
'1.0' : '/8',
'1.2' : '/1',
'1.3' : '/3',
'2.0' : '/412',
'2.0.2' : '/416',
'2.0.3' : '/417',
'2.0.4' : '/419',
'?' : '/'
}
}
},
device : {
sprint : {
model : {
'Evo Shift 4G' : '7373KT'
},
vendor : {
'HTC' : 'APA',
'Sprint' : 'Sprint'
}
}
},
os : {
windows : {
version : {
'ME' : '4.90',
'NT 3.11' : 'NT3.51',
'NT 4.0' : 'NT4.0',
'2000' : 'NT 5.0',
'XP' : ['NT 5.1', 'NT 5.2'],
'Vista' : 'NT 6.0',
'7' : 'NT 6.1',
'8' : 'NT 6.2',
'8.1' : 'NT 6.3',
'RT' : 'ARM'
}
}
}
};
//////////////
// Regex map
/////////////
var regexes = {
browser : [[
// Presto based
/(opera\smini)\/((\d+)?[\w\.-]+)/i, // Opera Mini
/(opera\s[mobiletab]+).+version\/((\d+)?[\w\.-]+)/i, // Opera Mobi/Tablet
/(opera).+version\/((\d+)?[\w\.]+)/i, // Opera > 9.80
/(opera)[\/\s]+((\d+)?[\w\.]+)/i // Opera < 9.80
], [NAME, VERSION, MAJOR], [
/\s(opr)\/((\d+)?[\w\.]+)/i // Opera Webkit
], [[NAME, 'Opera'], VERSION, MAJOR], [
// Mixed
/(kindle)\/((\d+)?[\w\.]+)/i, // Kindle
/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?((\d+)?[\w\.]+)*/i,
// Lunascape/Maxthon/Netfront/Jasmine/Blazer
// Trident based
/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?((\d+)?[\w\.]*)/i,
// Avant/IEMobile/SlimBrowser/Baidu
/(?:ms|\()(ie)\s((\d+)?[\w\.]+)/i, // Internet Explorer
// Webkit/KHTML based
/(rekonq)((?:\/)[\w\.]+)*/i, // Rekonq
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron)\/((\d+)?[\w\.-]+)/i
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron
], [NAME, VERSION, MAJOR], [
/(trident).+rv[:\s]((\d+)?[\w\.]+).+like\sgecko/i // IE11
], [[NAME, 'IE'], VERSION, MAJOR], [
/(yabrowser)\/((\d+)?[\w\.]+)/i // Yandex
], [[NAME, 'Yandex'], VERSION, MAJOR], [
/(comodo_dragon)\/((\d+)?[\w\.]+)/i // Comodo Dragon
], [[NAME, /_/g, ' '], VERSION, MAJOR], [
/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?((\d+)?[\w\.]+)/i
// Chrome/OmniWeb/Arora/Tizen/Nokia
], [NAME, VERSION, MAJOR], [
/(dolfin)\/((\d+)?[\w\.]+)/i // Dolphin
], [[NAME, 'Dolphin'], VERSION, MAJOR], [
/((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i // Chrome for Android/iOS
], [[NAME, 'Chrome'], VERSION, MAJOR], [
/((?:android.+))version\/((\d+)?[\w\.]+)\smobile\ssafari/i // Android Browser
], [[NAME, 'Android Browser'], VERSION, MAJOR], [
/version\/((\d+)?[\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
], [VERSION, MAJOR, [NAME, 'Mobile Safari']], [
/version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
], [VERSION, MAJOR, NAME], [
/webkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i // Safari < 3.0
], [NAME, [MAJOR, mapper.str, maps.browser.oldsafari.major], [VERSION, mapper.str, maps.browser.oldsafari.version]], [
/(konqueror)\/((\d+)?[\w\.]+)/i, // Konqueror
/(webkit|khtml)\/((\d+)?[\w\.]+)/i
], [NAME, VERSION, MAJOR], [
// Gecko based
/(navigator|netscape)\/((\d+)?[\w\.-]+)/i // Netscape
], [[NAME, 'Netscape'], VERSION, MAJOR], [
/(swiftfox)/i, // Swiftfox
/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,
// IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i,
// Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
// Other
/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|qqbrowser)[\/\s]?((\d+)?[\w\.]+)/i,
// UCBrowser/Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/QQBrowser
/(links)\s\(((\d+)?[\w\.]+)/i, // Links
/(gobrowser)\/?((\d+)?[\w\.]+)*/i, // GoBrowser
/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i, // ICE Browser
/(mosaic)[\/\s]((\d+)?[\w\.]+)/i // Mosaic
], [NAME, VERSION, MAJOR]
],
engine : [[
/(presto)\/([\w\.]+)/i, // Presto
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m
/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
/(icab)[\/\s]([23]\.[\d\.]+)/i // iCab
], [NAME, VERSION], [
/rv\:([\w\.]+).*(gecko)/i // Gecko
], [VERSION, NAME]
],
os : [[
// Windows based
/(windows)\snt\s6\.2;\s(arm)/i, // Windows RT
/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i
], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [
/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i
], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [
// Mobile/Embedded OS
/\((bb)(10);/i // BlackBerry 10
], [[NAME, 'BlackBerry'], VERSION], [
/(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry
/(tizen)\/([\w\.]+)/i, // Tizen
/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego)[\/\s-]?([\w\.]+)*/i
// Android/WebOS/Palm/QNX/Bada/RIM/MeeGo
], [NAME, VERSION], [
/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian
], [[NAME, 'Symbian'], VERSION],[
/mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS
], [[NAME, 'Firefox OS'], VERSION], [
// Console
/(nintendo|playstation)\s([wids3portablevu]+)/i, // Nintendo/Playstation
// GNU/Linux based
/(mint)[\/\s\(]?(\w+)*/i, // Mint
/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk)[\/\s-]?([\w\.-]+)*/i,
// Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
// Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk
/(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux
/(gnu)\s?([\w\.]+)*/i // GNU
], [NAME, VERSION], [
/(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS
], [[NAME, 'Chromium OS'], VERSION],[
// Solaris
/(sunos)\s?([\w\.]+\d)*/i // Solaris
], [[NAME, 'Solaris'], VERSION], [
// BSD based
/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly
], [NAME, VERSION],[
/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i // iOS
], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [
/(mac\sos\sx)\s?([\w\s\.]+\w)*/i // Mac OS
], [NAME, [VERSION, /_/g, '.']], [
// Other
/(haiku)\s(\w+)/i, // Haiku
/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, // AIX
/(macintosh|mac(?=_powerpc)|plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos)/i,
// Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS
/(unix)\s?([\w\.]+)*/i // UNIX
], [NAME, VERSION]
]
};
/////////////////
// Constructor
////////////////
var UAParser = function (uastring) {
var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
this.getBrowser = function () {
return mapper.rgx.apply(this, regexes.browser);
};
this.getEngine = function () {
return mapper.rgx.apply(this, regexes.engine);
};
this.getOS = function () {
return mapper.rgx.apply(this, regexes.os);
};
this.getResult = function() {
return {
ua : this.getUA(),
browser : this.getBrowser(),
engine : this.getEngine(),
os : this.getOS()
};
};
this.getUA = function () {
return ua;
};
this.setUA = function (uastring) {
ua = uastring;
return this;
};
this.setUA(ua);
};
return new UAParser().getResult();
})();
function version_compare(v1, v2, operator) {
// From: http://phpjs.org/functions
// + original by: Philippe Jausions (http://pear.php.net/user/jausions)
// + original by: Aidan Lister (http://aidanlister.com/)
// + reimplemented by: Kankrelune (http://www.webfaktory.info/)
// + improved by: Brett Zamir (http://brett-zamir.me)
// + improved by: Scott Baker
// + improved by: Theriault
// * example 1: version_compare('8.2.5rc', '8.2.5a');
// * returns 1: 1
// * example 2: version_compare('8.2.50', '8.2.52', '<');
// * returns 2: true
// * example 3: version_compare('5.3.0-dev', '5.3.0');
// * returns 3: -1
// * example 4: version_compare('4.1.0.52','4.01.0.51');
// * returns 4: 1
// Important: compare must be initialized at 0.
var i = 0,
x = 0,
compare = 0,
// vm maps textual PHP versions to negatives so they're less than 0.
// PHP currently defines these as CASE-SENSITIVE. It is important to
// leave these as negatives so that they can come before numerical versions
// and as if no letters were there to begin with.
// (1alpha is < 1 and < 1.1 but > 1dev1)
// If a non-numerical value can't be mapped to this table, it receives
// -7 as its value.
vm = {
'dev': -6,
'alpha': -5,
'a': -5,
'beta': -4,
'b': -4,
'RC': -3,
'rc': -3,
'#': -2,
'p': 1,
'pl': 1
},
// This function will be called to prepare each version argument.
// It replaces every _, -, and + with a dot.
// It surrounds any nonsequence of numbers/dots with dots.
// It replaces sequences of dots with a single dot.
// version_compare('4..0', '4.0') == 0
// Important: A string of 0 length needs to be converted into a value
// even less than an unexisting value in vm (-7), hence [-8].
// It's also important to not strip spaces because of this.
// version_compare('', ' ') == 1
prepVersion = function (v) {
v = ('' + v).replace(/[_\-+]/g, '.');
v = v.replace(/([^.\d]+)/g, '.$1.').replace(/\.{2,}/g, '.');
return (!v.length ? [-8] : v.split('.'));
},
// This converts a version component to a number.
// Empty component becomes 0.
// Non-numerical component becomes a negative number.
// Numerical component becomes itself as an integer.
numVersion = function (v) {
return !v ? 0 : (isNaN(v) ? vm[v] || -7 : parseInt(v, 10));
};
v1 = prepVersion(v1);
v2 = prepVersion(v2);
x = Math.max(v1.length, v2.length);
for (i = 0; i < x; i++) {
if (v1[i] == v2[i]) {
continue;
}
v1[i] = numVersion(v1[i]);
v2[i] = numVersion(v2[i]);
if (v1[i] < v2[i]) {
compare = -1;
break;
} else if (v1[i] > v2[i]) {
compare = 1;
break;
}
}
if (!operator) {
return compare;
}
// Important: operator is CASE-SENSITIVE.
// "No operator" seems to be treated as "<."
// Any other values seem to make the function return null.
switch (operator) {
case '>':
case 'gt':
return (compare > 0);
case '>=':
case 'ge':
return (compare >= 0);
case '<=':
case 'le':
return (compare <= 0);
case '==':
case '=':
case 'eq':
return (compare === 0);
case '<>':
case '!=':
case 'ne':
return (compare !== 0);
case '':
case '<':
case 'lt':
return (compare < 0);
default:
return null;
}
}
var can = (function() {
var caps = {
define_property: (function() {
/* // currently too much extra code required, not exactly worth it
try { // as of IE8, getters/setters are supported only on DOM elements
var obj = {};
if (Object.defineProperty) {
Object.defineProperty(obj, 'prop', {
enumerable: true,
configurable: true
});
return true;
}
} catch(ex) {}
if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) {
return true;
}*/
return false;
}()),
create_canvas: (function() {
// On the S60 and BB Storm, getContext exists, but always returns undefined
// so we actually have to call getContext() to verify
// github.com/Modernizr/Modernizr/issues/issue/97/
var el = document.createElement('canvas');
return !!(el.getContext && el.getContext('2d'));
}()),
return_response_type: function(responseType) {
try {
if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) {
return true;
} else if (window.XMLHttpRequest) {
var xhr = new XMLHttpRequest();
xhr.open('get', '/'); // otherwise Gecko throws an exception
if ('responseType' in xhr) {
xhr.responseType = responseType;
// as of 23.0.1271.64, Chrome switched from throwing exception to merely logging it to the console (why? o why?)
if (xhr.responseType !== responseType) {
return false;
}
return true;
}
}
} catch (ex) {}
return false;
},
// ideas for this heavily come from Modernizr (http://modernizr.com/)
use_data_uri: (function() {
var du = new Image();
du.onload = function() {
caps.use_data_uri = (du.width === 1 && du.height === 1);
};
setTimeout(function() {
du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==";
}, 1);
return false;
}()),
use_data_uri_over32kb: function() { // IE8
return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9);
},
use_data_uri_of: function(bytes) {
return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb());
},
use_fileinput: function() {
var el = document.createElement('input');
el.setAttribute('type', 'file');
return !el.disabled;
}
};
return function(cap) {
var args = [].slice.call(arguments);
args.shift(); // shift of cap
return Basic.typeOf(caps[cap]) === 'function' ? caps[cap].apply(this, args) : !!caps[cap];
};
}());
var Env = {
can: can,
browser: UAParser.browser.name,
version: parseFloat(UAParser.browser.major),
os: UAParser.os.name, // everybody intuitively types it in a lowercase for some reason
osVersion: UAParser.os.version,
verComp: version_compare,
swf_url: "../flash/Moxie.swf",
xap_url: "../silverlight/Moxie.xap",
global_event_dispatcher: "moxie.core.EventTarget.instance.dispatchEvent"
};
// for backward compatibility
// @deprecated Use `Env.os` instead
Env.OS = Env.os;
return Env;
});
// Included from: src/javascript/core/utils/Dom.js
/**
* Dom.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Dom', ['moxie/core/utils/Env'], function(Env) {
/**
Get DOM Element by it's id.
@method get
@for Utils
@param {String} id Identifier of the DOM Element
@return {DOMElement}
*/
var get = function(id) {
if (typeof id !== 'string') {
return id;
}
return document.getElementById(id);
};
/**
Checks if specified DOM element has specified class.
@method hasClass
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Class name
*/
var hasClass = function(obj, name) {
if (!obj.className) {
return false;
}
var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)");
return regExp.test(obj.className);
};
/**
Adds specified className to specified DOM element.
@method addClass
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Class name
*/
var addClass = function(obj, name) {
if (!hasClass(obj, name)) {
obj.className = !obj.className ? name : obj.className.replace(/\s+$/, '') + ' ' + name;
}
};
/**
Removes specified className from specified DOM element.
@method removeClass
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Class name
*/
var removeClass = function(obj, name) {
if (obj.className) {
var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)");
obj.className = obj.className.replace(regExp, function($0, $1, $2) {
return $1 === ' ' && $2 === ' ' ? ' ' : '';
});
}
};
/**
Returns a given computed style of a DOM element.
@method getStyle
@static
@param {Object} obj DOM element like object.
@param {String} name Style you want to get from the DOM element
*/
var getStyle = function(obj, name) {
if (obj.currentStyle) {
return obj.currentStyle[name];
} else if (window.getComputedStyle) {
return window.getComputedStyle(obj, null)[name];
}
};
/**
Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields.
@method getPos
@static
@param {Element} node HTML element or element id to get x, y position from.
@param {Element} root Optional root element to stop calculations at.
@return {object} Absolute position of the specified element object with x, y fields.
*/
var getPos = function(node, root) {
var x = 0, y = 0, parent, doc = document, nodeRect, rootRect;
node = node;
root = root || doc.body;
// Returns the x, y cordinate for an element on IE 6 and IE 7
function getIEPos(node) {
var bodyElm, rect, x = 0, y = 0;
if (node) {
rect = node.getBoundingClientRect();
bodyElm = doc.compatMode === "CSS1Compat" ? doc.documentElement : doc.body;
x = rect.left + bodyElm.scrollLeft;
y = rect.top + bodyElm.scrollTop;
}
return {
x : x,
y : y
};
}
// Use getBoundingClientRect on IE 6 and IE 7 but not on IE 8 in standards mode
if (node && node.getBoundingClientRect && Env.browser === 'IE' && (!doc.documentMode || doc.documentMode < 8)) {
nodeRect = getIEPos(node);
rootRect = getIEPos(root);
return {
x : nodeRect.x - rootRect.x,
y : nodeRect.y - rootRect.y
};
}
parent = node;
while (parent && parent != root && parent.nodeType) {
x += parent.offsetLeft || 0;
y += parent.offsetTop || 0;
parent = parent.offsetParent;
}
parent = node.parentNode;
while (parent && parent != root && parent.nodeType) {
x -= parent.scrollLeft || 0;
y -= parent.scrollTop || 0;
parent = parent.parentNode;
}
return {
x : x,
y : y
};
};
/**
Returns the size of the specified node in pixels.
@method getSize
@static
@param {Node} node Node to get the size of.
@return {Object} Object with a w and h property.
*/
var getSize = function(node) {
return {
w : node.offsetWidth || node.clientWidth,
h : node.offsetHeight || node.clientHeight
};
};
return {
get: get,
hasClass: hasClass,
addClass: addClass,
removeClass: removeClass,
getStyle: getStyle,
getPos: getPos,
getSize: getSize
};
});
// Included from: src/javascript/core/Exceptions.js
/**
* Exceptions.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/Exceptions', [
'moxie/core/utils/Basic'
], function(Basic) {
function _findKey(obj, value) {
var key;
for (key in obj) {
if (obj[key] === value) {
return key;
}
}
return null;
}
return {
RuntimeError: (function() {
var namecodes = {
NOT_INIT_ERR: 1,
NOT_SUPPORTED_ERR: 9,
JS_ERR: 4
};
function RuntimeError(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": RuntimeError " + this.code;
}
Basic.extend(RuntimeError, namecodes);
RuntimeError.prototype = Error.prototype;
return RuntimeError;
}()),
OperationNotAllowedException: (function() {
function OperationNotAllowedException(code) {
this.code = code;
this.name = 'OperationNotAllowedException';
}
Basic.extend(OperationNotAllowedException, {
NOT_ALLOWED_ERR: 1
});
OperationNotAllowedException.prototype = Error.prototype;
return OperationNotAllowedException;
}()),
ImageError: (function() {
var namecodes = {
WRONG_FORMAT: 1,
MAX_RESOLUTION_ERR: 2
};
function ImageError(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": ImageError " + this.code;
}
Basic.extend(ImageError, namecodes);
ImageError.prototype = Error.prototype;
return ImageError;
}()),
FileException: (function() {
var namecodes = {
NOT_FOUND_ERR: 1,
SECURITY_ERR: 2,
ABORT_ERR: 3,
NOT_READABLE_ERR: 4,
ENCODING_ERR: 5,
NO_MODIFICATION_ALLOWED_ERR: 6,
INVALID_STATE_ERR: 7,
SYNTAX_ERR: 8
};
function FileException(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": FileException " + this.code;
}
Basic.extend(FileException, namecodes);
FileException.prototype = Error.prototype;
return FileException;
}()),
DOMException: (function() {
var namecodes = {
INDEX_SIZE_ERR: 1,
DOMSTRING_SIZE_ERR: 2,
HIERARCHY_REQUEST_ERR: 3,
WRONG_DOCUMENT_ERR: 4,
INVALID_CHARACTER_ERR: 5,
NO_DATA_ALLOWED_ERR: 6,
NO_MODIFICATION_ALLOWED_ERR: 7,
NOT_FOUND_ERR: 8,
NOT_SUPPORTED_ERR: 9,
INUSE_ATTRIBUTE_ERR: 10,
INVALID_STATE_ERR: 11,
SYNTAX_ERR: 12,
INVALID_MODIFICATION_ERR: 13,
NAMESPACE_ERR: 14,
INVALID_ACCESS_ERR: 15,
VALIDATION_ERR: 16,
TYPE_MISMATCH_ERR: 17,
SECURITY_ERR: 18,
NETWORK_ERR: 19,
ABORT_ERR: 20,
URL_MISMATCH_ERR: 21,
QUOTA_EXCEEDED_ERR: 22,
TIMEOUT_ERR: 23,
INVALID_NODE_TYPE_ERR: 24,
DATA_CLONE_ERR: 25
};
function DOMException(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": DOMException " + this.code;
}
Basic.extend(DOMException, namecodes);
DOMException.prototype = Error.prototype;
return DOMException;
}()),
EventException: (function() {
function EventException(code) {
this.code = code;
this.name = 'EventException';
}
Basic.extend(EventException, {
UNSPECIFIED_EVENT_TYPE_ERR: 0
});
EventException.prototype = Error.prototype;
return EventException;
}())
};
});
// Included from: src/javascript/core/EventTarget.js
/**
* EventTarget.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/EventTarget', [
'moxie/core/Exceptions',
'moxie/core/utils/Basic'
], function(x, Basic) {
/**
Parent object for all event dispatching components and objects
@class EventTarget
@constructor EventTarget
*/
function EventTarget() {
// hash of event listeners by object uid
var eventpool = {};
Basic.extend(this, {
/**
Unique id of the event dispatcher, usually overriden by children
@property uid
@type String
*/
uid: null,
/**
Can be called from within a child in order to acquire uniqie id in automated manner
@method init
*/
init: function() {
if (!this.uid) {
this.uid = Basic.guid('uid_');
}
},
/**
Register a handler to a specific event dispatched by the object
@method addEventListener
@param {String} type Type or basically a name of the event to subscribe to
@param {Function} fn Callback function that will be called when event happens
@param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first
@param {Object} [scope=this] A scope to invoke event handler in
*/
addEventListener: function(type, fn, priority, scope) {
var self = this, list;
type = Basic.trim(type);
if (/\s/.test(type)) {
// multiple event types were passed for one handler
Basic.each(type.split(/\s+/), function(type) {
self.addEventListener(type, fn, priority, scope);
});
return;
}
type = type.toLowerCase();
priority = parseInt(priority, 10) || 0;
list = eventpool[this.uid] && eventpool[this.uid][type] || [];
list.push({fn : fn, priority : priority, scope : scope || this});
if (!eventpool[this.uid]) {
eventpool[this.uid] = {};
}
eventpool[this.uid][type] = list;
},
/**
Check if any handlers were registered to the specified event
@method hasEventListener
@param {String} type Type or basically a name of the event to check
@return {Mixed} Returns a handler if it was found and false, if - not
*/
hasEventListener: function(type) {
return type ? !!(eventpool[this.uid] && eventpool[this.uid][type]) : !!eventpool[this.uid];
},
/**
Unregister the handler from the event, or if former was not specified - unregister all handlers
@method removeEventListener
@param {String} type Type or basically a name of the event
@param {Function} [fn] Handler to unregister
*/
removeEventListener: function(type, fn) {
type = type.toLowerCase();
var list = eventpool[this.uid] && eventpool[this.uid][type], i;
if (list) {
if (fn) {
for (i = list.length - 1; i >= 0; i--) {
if (list[i].fn === fn) {
list.splice(i, 1);
break;
}
}
} else {
list = [];
}
// delete event list if it has become empty
if (!list.length) {
delete eventpool[this.uid][type];
// and object specific entry in a hash if it has no more listeners attached
if (Basic.isEmptyObj(eventpool[this.uid])) {
delete eventpool[this.uid];
}
}
}
},
/**
Remove all event handlers from the object
@method removeAllEventListeners
*/
removeAllEventListeners: function() {
if (eventpool[this.uid]) {
delete eventpool[this.uid];
}
},
/**
Dispatch the event
@method dispatchEvent
@param {String/Object} Type of event or event object to dispatch
@param {Mixed} [...] Variable number of arguments to be passed to a handlers
@return {Boolean} true by default and false if any handler returned false
*/
dispatchEvent: function(type) {
var uid, list, args, tmpEvt, evt = {}, result = true, undef;
if (Basic.typeOf(type) !== 'string') {
// we can't use original object directly (because of Silverlight)
tmpEvt = type;
if (Basic.typeOf(tmpEvt.type) === 'string') {
type = tmpEvt.type;
if (tmpEvt.total !== undef && tmpEvt.loaded !== undef) { // progress event
evt.total = tmpEvt.total;
evt.loaded = tmpEvt.loaded;
}
evt.async = tmpEvt.async || false;
} else {
throw new x.EventException(x.EventException.UNSPECIFIED_EVENT_TYPE_ERR);
}
}
// check if event is meant to be dispatched on an object having specific uid
if (type.indexOf('::') !== -1) {
(function(arr) {
uid = arr[0];
type = arr[1];
}(type.split('::')));
} else {
uid = this.uid;
}
type = type.toLowerCase();
list = eventpool[uid] && eventpool[uid][type];
if (list) {
// sort event list by prority
list.sort(function(a, b) { return b.priority - a.priority; });
args = [].slice.call(arguments);
// first argument will be pseudo-event object
args.shift();
evt.type = type;
args.unshift(evt);
// Dispatch event to all listeners
var queue = [];
Basic.each(list, function(handler) {
// explicitly set the target, otherwise events fired from shims do not get it
args[0].target = handler.scope;
// if event is marked as async, detach the handler
if (evt.async) {
queue.push(function(cb) {
setTimeout(function() {
cb(handler.fn.apply(handler.scope, args) === false);
}, 1);
});
} else {
queue.push(function(cb) {
cb(handler.fn.apply(handler.scope, args) === false); // if handler returns false stop propagation
});
}
});
if (queue.length) {
Basic.inSeries(queue, function(err) {
result = !err;
});
}
}
return result;
},
/**
Alias for addEventListener
@method bind
@protected
*/
bind: function() {
this.addEventListener.apply(this, arguments);
},
/**
Alias for removeEventListener
@method unbind
@protected
*/
unbind: function() {
this.removeEventListener.apply(this, arguments);
},
/**
Alias for removeAllEventListeners
@method unbindAll
@protected
*/
unbindAll: function() {
this.removeAllEventListeners.apply(this, arguments);
},
/**
Alias for dispatchEvent
@method trigger
@protected
*/
trigger: function() {
return this.dispatchEvent.apply(this, arguments);
},
/**
Converts properties of on[event] type to corresponding event handlers,
is used to avoid extra hassle around the process of calling them back
@method convertEventPropsToHandlers
@private
*/
convertEventPropsToHandlers: function(handlers) {
var h;
if (Basic.typeOf(handlers) !== 'array') {
handlers = [handlers];
}
for (var i = 0; i < handlers.length; i++) {
h = 'on' + handlers[i];
if (Basic.typeOf(this[h]) === 'function') {
this.addEventListener(handlers[i], this[h]);
} else if (Basic.typeOf(this[h]) === 'undefined') {
this[h] = null; // object must have defined event properties, even if it doesn't make use of them
}
}
}
});
}
EventTarget.instance = new EventTarget();
return EventTarget;
});
// Included from: src/javascript/core/utils/Encode.js
/**
* Encode.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Encode', [], function() {
/**
Encode string with UTF-8
@method utf8_encode
@for Utils
@static
@param {String} str String to encode
@return {String} UTF-8 encoded string
*/
var utf8_encode = function(str) {
return unescape(encodeURIComponent(str));
};
/**
Decode UTF-8 encoded string
@method utf8_decode
@static
@param {String} str String to decode
@return {String} Decoded string
*/
var utf8_decode = function(str_data) {
return decodeURIComponent(escape(str_data));
};
/**
Decode Base64 encoded string (uses browser's default method if available),
from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js
@method atob
@static
@param {String} data String to decode
@return {String} Decoded string
*/
var atob = function(data, utf8) {
if (typeof(window.atob) === 'function') {
return utf8 ? utf8_decode(window.atob(data)) : window.atob(data);
}
// http://kevin.vanzonneveld.net
// + original by: Tyler Akins (http://rumkin.com)
// + improved by: Thunder.m
// + input by: Aman Gupta
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Onno Marsman
// + bugfixed by: Pellentesque Malesuada
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
// * returns 1: 'Kevin van Zonneveld'
// mozilla has this native
// - but breaks in 2.0.0.12!
//if (typeof this.window.atob == 'function') {
// return atob(data);
//}
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
ac = 0,
dec = "",
tmp_arr = [];
if (!data) {
return data;
}
data += '';
do { // unpack four hexets into three octets using index points in b64
h1 = b64.indexOf(data.charAt(i++));
h2 = b64.indexOf(data.charAt(i++));
h3 = b64.indexOf(data.charAt(i++));
h4 = b64.indexOf(data.charAt(i++));
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
o1 = bits >> 16 & 0xff;
o2 = bits >> 8 & 0xff;
o3 = bits & 0xff;
if (h3 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1);
} else if (h4 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1, o2);
} else {
tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
}
} while (i < data.length);
dec = tmp_arr.join('');
return utf8 ? utf8_decode(dec) : dec;
};
/**
Base64 encode string (uses browser's default method if available),
from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js
@method btoa
@static
@param {String} data String to encode
@return {String} Base64 encoded string
*/
var btoa = function(data, utf8) {
if (utf8) {
utf8_encode(data);
}
if (typeof(window.btoa) === 'function') {
return window.btoa(data);
}
// http://kevin.vanzonneveld.net
// + original by: Tyler Akins (http://rumkin.com)
// + improved by: Bayron Guevara
// + improved by: Thunder.m
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Pellentesque Malesuada
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Rafał Kukawski (http://kukawski.pl)
// * example 1: base64_encode('Kevin van Zonneveld');
// * returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
// mozilla has this native
// - but breaks in 2.0.0.12!
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
ac = 0,
enc = "",
tmp_arr = [];
if (!data) {
return data;
}
do { // pack three octets into four hexets
o1 = data.charCodeAt(i++);
o2 = data.charCodeAt(i++);
o3 = data.charCodeAt(i++);
bits = o1 << 16 | o2 << 8 | o3;
h1 = bits >> 18 & 0x3f;
h2 = bits >> 12 & 0x3f;
h3 = bits >> 6 & 0x3f;
h4 = bits & 0x3f;
// use hexets to index into b64, and append result to encoded string
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
} while (i < data.length);
enc = tmp_arr.join('');
var r = data.length % 3;
return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
};
return {
utf8_encode: utf8_encode,
utf8_decode: utf8_decode,
atob: atob,
btoa: btoa
};
});
// Included from: src/javascript/runtime/Runtime.js
/**
* Runtime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/runtime/Runtime', [
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/EventTarget"
], function(Basic, Dom, EventTarget) {
var runtimeConstructors = {}, runtimes = {};
/**
Common set of methods and properties for every runtime instance
@class Runtime
@param {Object} options
@param {String} type Sanitized name of the runtime
@param {Object} [caps] Set of capabilities that differentiate specified runtime
@param {Object} [modeCaps] Set of capabilities that do require specific operational mode
@param {String} [preferredMode='browser'] Preferred operational mode to choose if no required capabilities were requested
*/
function Runtime(options, type, caps, modeCaps, preferredMode) {
/**
Dispatched when runtime is initialized and ready.
Results in RuntimeInit on a connected component.
@event Init
*/
/**
Dispatched when runtime fails to initialize.
Results in RuntimeError on a connected component.
@event Error
*/
var self = this
, _shim
, _uid = Basic.guid(type + '_')
, defaultMode = preferredMode || 'browser'
;
options = options || {};
// register runtime in private hash
runtimes[_uid] = this;
/**
Default set of capabilities, which can be redifined later by specific runtime
@private
@property caps
@type Object
*/
caps = Basic.extend({
// Runtime can:
// provide access to raw binary data of the file
access_binary: false,
// provide access to raw binary data of the image (image extension is optional)
access_image_binary: false,
// display binary data as thumbs for example
display_media: false,
// make cross-domain requests
do_cors: false,
// accept files dragged and dropped from the desktop
drag_and_drop: false,
// filter files in selection dialog by their extensions
filter_by_extension: true,
// resize image (and manipulate it raw data of any file in general)
resize_image: false,
// periodically report how many bytes of total in the file were uploaded (loaded)
report_upload_progress: false,
// provide access to the headers of http response
return_response_headers: false,
// support response of specific type, which should be passed as an argument
// e.g. runtime.can('return_response_type', 'blob')
return_response_type: false,
// return http status code of the response
return_status_code: true,
// send custom http header with the request
send_custom_headers: false,
// pick up the files from a dialog
select_file: false,
// select whole folder in file browse dialog
select_folder: false,
// select multiple files at once in file browse dialog
select_multiple: true,
// send raw binary data, that is generated after image resizing or manipulation of other kind
send_binary_string: false,
// send cookies with http request and therefore retain session
send_browser_cookies: true,
// send data formatted as multipart/form-data
send_multipart: true,
// slice the file or blob to smaller parts
slice_blob: false,
// upload file without preloading it to memory, stream it out directly from disk
stream_upload: false,
// programmatically trigger file browse dialog
summon_file_dialog: false,
// upload file of specific size, size should be passed as argument
// e.g. runtime.can('upload_filesize', '500mb')
upload_filesize: true,
// initiate http request with specific http method, method should be passed as argument
// e.g. runtime.can('use_http_method', 'put')
use_http_method: true
}, caps);
// default to the mode that is compatible with preferred caps
if (options.preferred_caps) {
defaultMode = Runtime.getMode(modeCaps, options.preferred_caps, defaultMode);
}
// small extension factory here (is meant to be extended with actual extensions constructors)
_shim = (function() {
var objpool = {};
return {
exec: function(uid, comp, fn, args) {
if (_shim[comp]) {
if (!objpool[uid]) {
objpool[uid] = {
context: this,
instance: new _shim[comp]()
};
}
if (objpool[uid].instance[fn]) {
return objpool[uid].instance[fn].apply(this, args);
}
}
},
removeInstance: function(uid) {
delete objpool[uid];
},
removeAllInstances: function() {
var self = this;
Basic.each(objpool, function(obj, uid) {
if (Basic.typeOf(obj.instance.destroy) === 'function') {
obj.instance.destroy.call(obj.context);
}
self.removeInstance(uid);
});
}
};
}());
// public methods
Basic.extend(this, {
/**
Specifies whether runtime instance was initialized or not
@property initialized
@type {Boolean}
@default false
*/
initialized: false, // shims require this flag to stop initialization retries
/**
Unique ID of the runtime
@property uid
@type {String}
*/
uid: _uid,
/**
Runtime type (e.g. flash, html5, etc)
@property type
@type {String}
*/
type: type,
/**
Runtime (not native one) may operate in browser or client mode.
@property mode
@private
@type {String|Boolean} current mode or false, if none possible
*/
mode: Runtime.getMode(modeCaps, (options.required_caps), defaultMode),
/**
id of the DOM container for the runtime (if available)
@property shimid
@type {String}
*/
shimid: _uid + '_container',
/**
Number of connected clients. If equal to zero, runtime can be destroyed
@property clients
@type {Number}
*/
clients: 0,
/**
Runtime initialization options
@property options
@type {Object}
*/
options: options,
/**
Checks if the runtime has specific capability
@method can
@param {String} cap Name of capability to check
@param {Mixed} [value] If passed, capability should somehow correlate to the value
@param {Object} [refCaps] Set of capabilities to check the specified cap against (defaults to internal set)
@return {Boolean} true if runtime has such capability and false, if - not
*/
can: function(cap, value) {
var refCaps = arguments[2] || caps;
// if cap var is a comma-separated list of caps, convert it to object (key/value)
if (Basic.typeOf(cap) === 'string' && Basic.typeOf(value) === 'undefined') {
cap = Runtime.parseCaps(cap);
}
if (Basic.typeOf(cap) === 'object') {
for (var key in cap) {
if (!this.can(key, cap[key], refCaps)) {
return false;
}
}
return true;
}
// check the individual cap
if (Basic.typeOf(refCaps[cap]) === 'function') {
return refCaps[cap].call(this, value);
} else {
return (value === refCaps[cap]);
}
},
/**
Returns container for the runtime as DOM element
@method getShimContainer
@return {DOMElement}
*/
getShimContainer: function() {
var container, shimContainer = Dom.get(this.shimid);
// if no container for shim, create one
if (!shimContainer) {
container = this.options.container ? Dom.get(this.options.container) : document.body;
// create shim container and insert it at an absolute position into the outer container
shimContainer = document.createElement('div');
shimContainer.id = this.shimid;
shimContainer.className = 'moxie-shim moxie-shim-' + this.type;
Basic.extend(shimContainer.style, {
position: 'absolute',
top: '0px',
left: '0px',
width: '1px',
height: '1px',
overflow: 'hidden'
});
container.appendChild(shimContainer);
container = null;
}
return shimContainer;
},
/**
Returns runtime as DOM element (if appropriate)
@method getShim
@return {DOMElement}
*/
getShim: function() {
return _shim;
},
/**
Invokes a method within the runtime itself (might differ across the runtimes)
@method shimExec
@param {Mixed} []
@protected
@return {Mixed} Depends on the action and component
*/
shimExec: function(component, action) {
var args = [].slice.call(arguments, 2);
return self.getShim().exec.call(this, this.uid, component, action, args);
},
/**
Operaional interface that is used by components to invoke specific actions on the runtime
(is invoked in the scope of component)
@method exec
@param {Mixed} []*
@protected
@return {Mixed} Depends on the action and component
*/
exec: function(component, action) { // this is called in the context of component, not runtime
var args = [].slice.call(arguments, 2);
if (self[component] && self[component][action]) {
return self[component][action].apply(this, args);
}
return self.shimExec.apply(this, arguments);
},
/**
Destroys the runtime (removes all events and deletes DOM structures)
@method destroy
*/
destroy: function() {
if (!self) {
return; // obviously already destroyed
}
var shimContainer = Dom.get(this.shimid);
if (shimContainer) {
shimContainer.parentNode.removeChild(shimContainer);
}
if (_shim) {
_shim.removeAllInstances();
}
this.unbindAll();
delete runtimes[this.uid];
this.uid = null; // mark this runtime as destroyed
_uid = self = _shim = shimContainer = null;
}
});
// once we got the mode, test against all caps
if (this.mode && options.required_caps && !this.can(options.required_caps)) {
this.mode = false;
}
}
/**
Default order to try different runtime types
@property order
@type String
@static
*/
Runtime.order = 'html5,flash,silverlight,html4';
/**
Retrieves runtime from private hash by it's uid
@method getRuntime
@private
@static
@param {String} uid Unique identifier of the runtime
@return {Runtime|Boolean} Returns runtime, if it exists and false, if - not
*/
Runtime.getRuntime = function(uid) {
return runtimes[uid] ? runtimes[uid] : false;
};
/**
Register constructor for the Runtime of new (or perhaps modified) type
@method addConstructor
@static
@param {String} type Runtime type (e.g. flash, html5, etc)
@param {Function} construct Constructor for the Runtime type
*/
Runtime.addConstructor = function(type, constructor) {
constructor.prototype = EventTarget.instance;
runtimeConstructors[type] = constructor;
};
/**
Get the constructor for the specified type.
method getConstructor
@static
@param {String} type Runtime type (e.g. flash, html5, etc)
@return {Function} Constructor for the Runtime type
*/
Runtime.getConstructor = function(type) {
return runtimeConstructors[type] || null;
};
/**
Get info about the runtime (uid, type, capabilities)
@method getInfo
@static
@param {String} uid Unique identifier of the runtime
@return {Mixed} Info object or null if runtime doesn't exist
*/
Runtime.getInfo = function(uid) {
var runtime = Runtime.getRuntime(uid);
if (runtime) {
return {
uid: runtime.uid,
type: runtime.type,
mode: runtime.mode,
can: function() {
return runtime.can.apply(runtime, arguments);
}
};
}
return null;
};
/**
Convert caps represented by a comma-separated string to the object representation.
@method parseCaps
@static
@param {String} capStr Comma-separated list of capabilities
@return {Object}
*/
Runtime.parseCaps = function(capStr) {
var capObj = {};
if (Basic.typeOf(capStr) !== 'string') {
return capStr || {};
}
Basic.each(capStr.split(','), function(key) {
capObj[key] = true; // we assume it to be - true
});
return capObj;
};
/**
Test the specified runtime for specific capabilities.
@method can
@static
@param {String} type Runtime type (e.g. flash, html5, etc)
@param {String|Object} caps Set of capabilities to check
@return {Boolean} Result of the test
*/
Runtime.can = function(type, caps) {
var runtime
, constructor = Runtime.getConstructor(type)
, mode
;
if (constructor) {
runtime = new constructor({
required_caps: caps
});
mode = runtime.mode;
runtime.destroy();
return !!mode;
}
return false;
};
/**
Figure out a runtime that supports specified capabilities.
@method thatCan
@static
@param {String|Object} caps Set of capabilities to check
@param {String} [runtimeOrder] Comma-separated list of runtimes to check against
@return {String} Usable runtime identifier or null
*/
Runtime.thatCan = function(caps, runtimeOrder) {
var types = (runtimeOrder || Runtime.order).split(/\s*,\s*/);
for (var i in types) {
if (Runtime.can(types[i], caps)) {
return types[i];
}
}
return null;
};
/**
Figure out an operational mode for the specified set of capabilities.
@method getMode
@static
@param {Object} modeCaps Set of capabilities that depend on particular runtime mode
@param {Object} [requiredCaps] Supplied set of capabilities to find operational mode for
@param {String|Boolean} [defaultMode='browser'] Default mode to use
@return {String|Boolean} Compatible operational mode
*/
Runtime.getMode = function(modeCaps, requiredCaps, defaultMode) {
var mode = null;
if (Basic.typeOf(defaultMode) === 'undefined') { // only if not specified
defaultMode = 'browser';
}
if (requiredCaps && !Basic.isEmptyObj(modeCaps)) {
// loop over required caps and check if they do require the same mode
Basic.each(requiredCaps, function(value, cap) {
if (modeCaps.hasOwnProperty(cap)) {
var capMode = modeCaps[cap](value);
// make sure we always have an array
if (typeof(capMode) === 'string') {
capMode = [capMode];
}
if (!mode) {
mode = capMode;
} else if (!(mode = Basic.arrayIntersect(mode, capMode))) {
// if cap requires conflicting mode - runtime cannot fulfill required caps
return (mode = false);
}
}
});
if (mode) {
return Basic.inArray(defaultMode, mode) !== -1 ? defaultMode : mode[0];
} else if (mode === false) {
return false;
}
}
return defaultMode;
};
/**
Capability check that always returns true
@private
@static
@return {True}
*/
Runtime.capTrue = function() {
return true;
};
/**
Capability check that always returns false
@private
@static
@return {False}
*/
Runtime.capFalse = function() {
return false;
};
/**
Evaluate the expression to boolean value and create a function that always returns it.
@private
@static
@param {Mixed} expr Expression to evaluate
@return {Function} Function returning the result of evaluation
*/
Runtime.capTest = function(expr) {
return function() {
return !!expr;
};
};
return Runtime;
});
// Included from: src/javascript/runtime/RuntimeClient.js
/**
* RuntimeClient.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/runtime/RuntimeClient', [
'moxie/core/Exceptions',
'moxie/core/utils/Basic',
'moxie/runtime/Runtime'
], function(x, Basic, Runtime) {
/**
Set of methods and properties, required by a component to acquire ability to connect to a runtime
@class RuntimeClient
*/
return function RuntimeClient() {
var runtime;
Basic.extend(this, {
/**
Connects to the runtime specified by the options. Will either connect to existing runtime or create a new one.
Increments number of clients connected to the specified runtime.
@method connectRuntime
@param {Mixed} options Can be a runtme uid or a set of key-value pairs defining requirements and pre-requisites
*/
connectRuntime: function(options) {
var comp = this, ruid;
function initialize(items) {
var type, constructor;
// if we ran out of runtimes
if (!items.length) {
comp.trigger('RuntimeError', new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR));
runtime = null;
return;
}
type = items.shift();
constructor = Runtime.getConstructor(type);
if (!constructor) {
initialize(items);
return;
}
// try initializing the runtime
runtime = new constructor(options);
runtime.bind('Init', function() {
// mark runtime as initialized
runtime.initialized = true;
// jailbreak ...
setTimeout(function() {
runtime.clients++;
// this will be triggered on component
comp.trigger('RuntimeInit', runtime);
}, 1);
});
runtime.bind('Error', function() {
runtime.destroy(); // runtime cannot destroy itself from inside at a right moment, thus we do it here
initialize(items);
});
/*runtime.bind('Exception', function() { });*/
// check if runtime managed to pick-up operational mode
if (!runtime.mode) {
runtime.trigger('Error');
return;
}
runtime.init();
}
// check if a particular runtime was requested
if (Basic.typeOf(options) === 'string') {
ruid = options;
} else if (Basic.typeOf(options.ruid) === 'string') {
ruid = options.ruid;
}
if (ruid) {
runtime = Runtime.getRuntime(ruid);
if (runtime) {
runtime.clients++;
return runtime;
} else {
// there should be a runtime and there's none - weird case
throw new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR);
}
}
// initialize a fresh one, that fits runtime list and required features best
initialize((options.runtime_order || Runtime.order).split(/\s*,\s*/));
},
/**
Returns the runtime to which the client is currently connected.
@method getRuntime
@return {Runtime} Runtime or null if client is not connected
*/
getRuntime: function() {
if (runtime && runtime.uid) {
return runtime;
}
runtime = null; // make sure we do not leave zombies rambling around
return null;
},
/**
Disconnects from the runtime. Decrements number of clients connected to the specified runtime.
@method disconnectRuntime
*/
disconnectRuntime: function() {
if (runtime && --runtime.clients <= 0) {
runtime.destroy();
runtime = null;
}
}
});
};
});
// Included from: src/javascript/file/Blob.js
/**
* Blob.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/Blob', [
'moxie/core/utils/Basic',
'moxie/core/utils/Encode',
'moxie/runtime/RuntimeClient'
], function(Basic, Encode, RuntimeClient) {
var blobpool = {};
/**
@class Blob
@constructor
@param {String} ruid Unique id of the runtime, to which this blob belongs to
@param {Object} blob Object "Native" blob object, as it is represented in the runtime
*/
function Blob(ruid, blob) {
function _sliceDetached(start, end, type) {
var blob, data = blobpool[this.uid];
if (Basic.typeOf(data) !== 'string' || !data.length) {
return null; // or throw exception
}
blob = new Blob(null, {
type: type,
size: end - start
});
blob.detach(data.substr(start, blob.size));
return blob;
}
RuntimeClient.call(this);
if (ruid) {
this.connectRuntime(ruid);
}
if (!blob) {
blob = {};
} else if (Basic.typeOf(blob) === 'string') { // dataUrl or binary string
blob = { data: blob };
}
Basic.extend(this, {
/**
Unique id of the component
@property uid
@type {String}
*/
uid: blob.uid || Basic.guid('uid_'),
/**
Unique id of the connected runtime, if falsy, then runtime will have to be initialized
before this Blob can be used, modified or sent
@property ruid
@type {String}
*/
ruid: ruid,
/**
Size of blob
@property size
@type {Number}
@default 0
*/
size: blob.size || 0,
/**
Mime type of blob
@property type
@type {String}
@default ''
*/
type: blob.type || '',
/**
@method slice
@param {Number} [start=0]
*/
slice: function(start, end, type) {
if (this.isDetached()) {
return _sliceDetached.apply(this, arguments);
}
return this.getRuntime().exec.call(this, 'Blob', 'slice', this.getSource(), start, end, type);
},
/**
Returns "native" blob object (as it is represented in connected runtime) or null if not found
@method getSource
@return {Blob} Returns "native" blob object or null if not found
*/
getSource: function() {
if (!blobpool[this.uid]) {
return null;
}
return blobpool[this.uid];
},
/**
Detaches blob from any runtime that it depends on and initialize with standalone value
@method detach
@protected
@param {DOMString} [data=''] Standalone value
*/
detach: function(data) {
if (this.ruid) {
this.getRuntime().exec.call(this, 'Blob', 'destroy', blobpool[this.uid]);
this.disconnectRuntime();
this.ruid = null;
}
data = data || '';
// if dataUrl, convert to binary string
var matches = data.match(/^data:([^;]*);base64,/);
if (matches) {
this.type = matches[1];
data = Encode.atob(data.substring(data.indexOf('base64,') + 7));
}
this.size = data.length;
blobpool[this.uid] = data;
},
/**
Checks if blob is standalone (detached of any runtime)
@method isDetached
@protected
@return {Boolean}
*/
isDetached: function() {
return !this.ruid && Basic.typeOf(blobpool[this.uid]) === 'string';
},
/**
Destroy Blob and free any resources it was using
@method destroy
*/
destroy: function() {
this.detach();
delete blobpool[this.uid];
}
});
if (blob.data) {
this.detach(blob.data); // auto-detach if payload has been passed
} else {
blobpool[this.uid] = blob;
}
}
return Blob;
});
// Included from: src/javascript/file/File.js
/**
* File.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/File', [
'moxie/core/utils/Basic',
'moxie/core/utils/Mime',
'moxie/file/Blob'
], function(Basic, Mime, Blob) {
/**
@class File
@extends Blob
@constructor
@param {String} ruid Unique id of the runtime, to which this blob belongs to
@param {Object} file Object "Native" file object, as it is represented in the runtime
*/
function File(ruid, file) {
var name, type;
if (!file) { // avoid extra errors in case we overlooked something
file = {};
}
// figure out the type
if (file.type && file.type !== '') {
type = file.type;
} else {
type = Mime.getFileMime(file.name);
}
// sanitize file name or generate new one
if (file.name) {
name = file.name.replace(/\\/g, '/');
name = name.substr(name.lastIndexOf('/') + 1);
} else {
var prefix = type.split('/')[0];
name = Basic.guid((prefix !== '' ? prefix : 'file') + '_');
if (Mime.extensions[type]) {
name += '.' + Mime.extensions[type][0]; // append proper extension if possible
}
}
Blob.apply(this, arguments);
Basic.extend(this, {
/**
File mime type
@property type
@type {String}
@default ''
*/
type: type || '',
/**
File name
@property name
@type {String}
@default UID
*/
name: name || Basic.guid('file_'),
/**
Date of last modification
@property lastModifiedDate
@type {String}
@default now
*/
lastModifiedDate: file.lastModifiedDate || (new Date()).toLocaleString() // Thu Aug 23 2012 19:40:00 GMT+0400 (GET)
});
}
File.prototype = Blob.prototype;
return File;
});
// Included from: src/javascript/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/FileInput', [
'moxie/core/utils/Basic',
'moxie/core/utils/Mime',
'moxie/core/utils/Dom',
'moxie/core/Exceptions',
'moxie/core/EventTarget',
'moxie/core/I18n',
'moxie/file/File',
'moxie/runtime/Runtime',
'moxie/runtime/RuntimeClient'
], function(Basic, Mime, Dom, x, EventTarget, I18n, File, Runtime, RuntimeClient) {
/**
Provides a convenient way to create cross-browser file-picker. Generates file selection dialog on click,
converts selected files to _File_ objects, to be used in conjunction with _Image_, preloaded in memory
with _FileReader_ or uploaded to a server through _XMLHttpRequest_.
@class FileInput
@constructor
@extends EventTarget
@uses RuntimeClient
@param {Object|String|DOMElement} options If options is string or node, argument is considered as _browse\_button_.
@param {String|DOMElement} options.browse_button DOM Element to turn into file picker.
@param {Array} [options.accept] Array of mime types to accept. By default accepts all.
@param {String} [options.file='file'] Name of the file field (not the filename).
@param {Boolean} [options.multiple=false] Enable selection of multiple files.
@param {Boolean} [options.directory=false] Turn file input into the folder input (cannot be both at the same time).
@param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode
for _browse\_button_.
@param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support.
@example
<div id="container">
<a id="file-picker" href="javascript:;">Browse...</a>
</div>
<script>
var fileInput = new mOxie.FileInput({
browse_button: 'file-picker', // or document.getElementById('file-picker')
container: 'container',
accept: [
{title: "Image files", extensions: "jpg,gif,png"} // accept only images
],
multiple: true // allow multiple file selection
});
fileInput.onchange = function(e) {
// do something to files array
console.info(e.target.files); // or this.files or fileInput.files
};
fileInput.init(); // initialize
</script>
*/
var dispatches = [
/**
Dispatched when runtime is connected and file-picker is ready to be used.
@event ready
@param {Object} event
*/
'ready',
/**
Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked.
Check [corresponding documentation entry](#method_refresh) for more info.
@event refresh
@param {Object} event
*/
/**
Dispatched when selection of files in the dialog is complete.
@event change
@param {Object} event
*/
'change',
'cancel', // TODO: might be useful
/**
Dispatched when mouse cursor enters file-picker area. Can be used to style element
accordingly.
@event mouseenter
@param {Object} event
*/
'mouseenter',
/**
Dispatched when mouse cursor leaves file-picker area. Can be used to style element
accordingly.
@event mouseleave
@param {Object} event
*/
'mouseleave',
/**
Dispatched when functional mouse button is pressed on top of file-picker area.
@event mousedown
@param {Object} event
*/
'mousedown',
/**
Dispatched when functional mouse button is released on top of file-picker area.
@event mouseup
@param {Object} event
*/
'mouseup'
];
function FileInput(options) {
var self = this,
container, browseButton, defaults;
// if flat argument passed it should be browse_button id
if (Basic.inArray(Basic.typeOf(options), ['string', 'node']) !== -1) {
options = { browse_button : options };
}
// this will help us to find proper default container
browseButton = Dom.get(options.browse_button);
if (!browseButton) {
// browse button is required
throw new x.DOMException(x.DOMException.NOT_FOUND_ERR);
}
// figure out the options
defaults = {
accept: [{
title: I18n.translate('All Files'),
extensions: '*'
}],
name: 'file',
multiple: false,
required_caps: false,
container: browseButton.parentNode || document.body
};
options = Basic.extend({}, defaults, options);
// convert to object representation
if (typeof(options.required_caps) === 'string') {
options.required_caps = Runtime.parseCaps(options.required_caps);
}
// normalize accept option (could be list of mime types or array of title/extensions pairs)
if (typeof(options.accept) === 'string') {
options.accept = Mime.mimes2extList(options.accept);
}
container = Dom.get(options.container);
// make sure we have container
if (!container) {
container = document.body;
}
// make container relative, if it's not
if (Dom.getStyle(container, 'position') === 'static') {
container.style.position = 'relative';
}
container = browseButton = null; // IE
RuntimeClient.call(self);
Basic.extend(self, {
/**
Unique id of the component
@property uid
@protected
@readOnly
@type {String}
@default UID
*/
uid: Basic.guid('uid_'),
/**
Unique id of the connected runtime, if any.
@property ruid
@protected
@type {String}
*/
ruid: null,
/**
Unique id of the runtime container. Useful to get hold of it for various manipulations.
@property shimid
@protected
@type {String}
*/
shimid: null,
/**
Array of selected mOxie.File objects
@property files
@type {Array}
@default null
*/
files: null,
/**
Initializes the file-picker, connects it to runtime and dispatches event ready when done.
@method init
*/
init: function() {
self.convertEventPropsToHandlers(dispatches);
self.bind('RuntimeInit', function(e, runtime) {
self.ruid = runtime.uid;
self.shimid = runtime.shimid;
self.bind("Ready", function() {
self.trigger("Refresh");
}, 999);
self.bind("Change", function() {
var files = runtime.exec.call(self, 'FileInput', 'getFiles');
self.files = [];
Basic.each(files, function(file) {
// ignore empty files (IE10 for example hangs if you try to send them via XHR)
if (file.size === 0) {
return true;
}
self.files.push(new File(self.ruid, file));
});
}, 999);
// re-position and resize shim container
self.bind('Refresh', function() {
var pos, size, browseButton, shimContainer;
browseButton = Dom.get(options.browse_button);
shimContainer = Dom.get(runtime.shimid); // do not use runtime.getShimContainer(), since it will create container if it doesn't exist
if (browseButton) {
pos = Dom.getPos(browseButton, Dom.get(options.container));
size = Dom.getSize(browseButton);
if (shimContainer) {
Basic.extend(shimContainer.style, {
top : pos.y + 'px',
left : pos.x + 'px',
width : size.w + 'px',
height : size.h + 'px'
});
}
}
shimContainer = browseButton = null;
});
runtime.exec.call(self, 'FileInput', 'init', options);
});
// runtime needs: options.required_features, options.runtime_order and options.container
self.connectRuntime(Basic.extend({}, options, {
required_caps: {
select_file: true
}
}));
},
/**
Disables file-picker element, so that it doesn't react to mouse clicks.
@method disable
@param {Boolean} [state=true] Disable component if - true, enable if - false
*/
disable: function(state) {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state);
}
},
/**
Reposition and resize dialog trigger to match the position and size of browse_button element.
@method refresh
*/
refresh: function() {
self.trigger("Refresh");
},
/**
Destroy component.
@method destroy
*/
destroy: function() {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileInput', 'destroy');
this.disconnectRuntime();
}
if (Basic.typeOf(this.files) === 'array') {
// no sense in leaving associated files behind
Basic.each(this.files, function(file) {
file.destroy();
});
}
this.files = null;
}
});
}
FileInput.prototype = EventTarget.instance;
return FileInput;
});
// Included from: src/javascript/file/FileDrop.js
/**
* FileDrop.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/FileDrop', [
'moxie/core/I18n',
'moxie/core/utils/Dom',
'moxie/core/Exceptions',
'moxie/core/utils/Basic',
'moxie/file/File',
'moxie/runtime/RuntimeClient',
'moxie/core/EventTarget',
'moxie/core/utils/Mime'
], function(I18n, Dom, x, Basic, File, RuntimeClient, EventTarget, Mime) {
/**
Turn arbitrary DOM element to a drop zone accepting files. Converts selected files to _File_ objects, to be used
in conjunction with _Image_, preloaded in memory with _FileReader_ or uploaded to a server through
_XMLHttpRequest_.
@example
<div id="drop_zone">
Drop files here
</div>
<br />
<div id="filelist"></div>
<script type="text/javascript">
var fileDrop = new mOxie.FileDrop('drop_zone'), fileList = mOxie.get('filelist');
fileDrop.ondrop = function() {
mOxie.each(this.files, function(file) {
fileList.innerHTML += '<div>' + file.name + '</div>';
});
};
fileDrop.init();
</script>
@class FileDrop
@constructor
@extends EventTarget
@uses RuntimeClient
@param {Object|String} options If options has typeof string, argument is considered as options.drop_zone
@param {String|DOMElement} options.drop_zone DOM Element to turn into a drop zone
@param {Array} [options.accept] Array of mime types to accept. By default accepts all
@param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support
*/
var dispatches = [
/**
Dispatched when runtime is connected and drop zone is ready to accept files.
@event ready
@param {Object} event
*/
'ready',
/**
Dispatched when dragging cursor enters the drop zone.
@event dragenter
@param {Object} event
*/
'dragenter',
/**
Dispatched when dragging cursor leaves the drop zone.
@event dragleave
@param {Object} event
*/
'dragleave',
/**
Dispatched when file is dropped onto the drop zone.
@event drop
@param {Object} event
*/
'drop',
/**
Dispatched if error occurs.
@event error
@param {Object} event
*/
'error'
];
function FileDrop(options) {
var self = this, defaults;
// if flat argument passed it should be drop_zone id
if (typeof(options) === 'string') {
options = { drop_zone : options };
}
// figure out the options
defaults = {
accept: [{
title: I18n.translate('All Files'),
extensions: '*'
}],
required_caps: {
drag_and_drop: true
}
};
options = typeof(options) === 'object' ? Basic.extend({}, defaults, options) : defaults;
// this will help us to find proper default container
options.container = Dom.get(options.drop_zone) || document.body;
// make container relative, if it is not
if (Dom.getStyle(options.container, 'position') === 'static') {
options.container.style.position = 'relative';
}
// normalize accept option (could be list of mime types or array of title/extensions pairs)
if (typeof(options.accept) === 'string') {
options.accept = Mime.mimes2extList(options.accept);
}
RuntimeClient.call(self);
Basic.extend(self, {
uid: Basic.guid('uid_'),
ruid: null,
files: null,
init: function() {
self.convertEventPropsToHandlers(dispatches);
self.bind('RuntimeInit', function(e, runtime) {
self.ruid = runtime.uid;
self.bind("Drop", function() {
var files = runtime.exec.call(self, 'FileDrop', 'getFiles');
self.files = [];
Basic.each(files, function(file) {
self.files.push(new File(self.ruid, file));
});
}, 999);
runtime.exec.call(self, 'FileDrop', 'init', options);
self.dispatchEvent('ready');
});
// runtime needs: options.required_features, options.runtime_order and options.container
self.connectRuntime(options); // throws RuntimeError
},
destroy: function() {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileDrop', 'destroy');
this.disconnectRuntime();
}
this.files = null;
}
});
}
FileDrop.prototype = EventTarget.instance;
return FileDrop;
});
// Included from: src/javascript/runtime/RuntimeTarget.js
/**
* RuntimeTarget.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/runtime/RuntimeTarget', [
'moxie/core/utils/Basic',
'moxie/runtime/RuntimeClient',
"moxie/core/EventTarget"
], function(Basic, RuntimeClient, EventTarget) {
/**
Instance of this class can be used as a target for the events dispatched by shims,
when allowing them onto components is for either reason inappropriate
@class RuntimeTarget
@constructor
@protected
@extends EventTarget
*/
function RuntimeTarget() {
this.uid = Basic.guid('uid_');
RuntimeClient.call(this);
this.destroy = function() {
this.disconnectRuntime();
this.unbindAll();
};
}
RuntimeTarget.prototype = EventTarget.instance;
return RuntimeTarget;
});
// Included from: src/javascript/file/FileReader.js
/**
* FileReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/FileReader', [
'moxie/core/utils/Basic',
'moxie/core/utils/Encode',
'moxie/core/Exceptions',
'moxie/core/EventTarget',
'moxie/file/Blob',
'moxie/file/File',
'moxie/runtime/RuntimeTarget'
], function(Basic, Encode, x, EventTarget, Blob, File, RuntimeTarget) {
/**
Utility for preloading o.Blob/o.File objects in memory. By design closely follows [W3C FileReader](http://www.w3.org/TR/FileAPI/#dfn-filereader)
interface. Where possible uses native FileReader, where - not falls back to shims.
@class FileReader
@constructor FileReader
@extends EventTarget
@uses RuntimeClient
*/
var dispatches = [
/**
Dispatched when the read starts.
@event loadstart
@param {Object} event
*/
'loadstart',
/**
Dispatched while reading (and decoding) blob, and reporting partial Blob data (progess.loaded/progress.total).
@event progress
@param {Object} event
*/
'progress',
/**
Dispatched when the read has successfully completed.
@event load
@param {Object} event
*/
'load',
/**
Dispatched when the read has been aborted. For instance, by invoking the abort() method.
@event abort
@param {Object} event
*/
'abort',
/**
Dispatched when the read has failed.
@event error
@param {Object} event
*/
'error',
/**
Dispatched when the request has completed (either in success or failure).
@event loadend
@param {Object} event
*/
'loadend'
];
function FileReader() {
var self = this, _fr;
Basic.extend(this, {
/**
UID of the component instance.
@property uid
@type {String}
*/
uid: Basic.guid('uid_'),
/**
Contains current state of FileReader object. Can take values of FileReader.EMPTY, FileReader.LOADING
and FileReader.DONE.
@property readyState
@type {Number}
@default FileReader.EMPTY
*/
readyState: FileReader.EMPTY,
/**
Result of the successful read operation.
@property result
@type {String}
*/
result: null,
/**
Stores the error of failed asynchronous read operation.
@property error
@type {DOMError}
*/
error: null,
/**
Initiates reading of File/Blob object contents to binary string.
@method readAsBinaryString
@param {Blob|File} blob Object to preload
*/
readAsBinaryString: function(blob) {
_read.call(this, 'readAsBinaryString', blob);
},
/**
Initiates reading of File/Blob object contents to dataURL string.
@method readAsDataURL
@param {Blob|File} blob Object to preload
*/
readAsDataURL: function(blob) {
_read.call(this, 'readAsDataURL', blob);
},
/**
Initiates reading of File/Blob object contents to string.
@method readAsText
@param {Blob|File} blob Object to preload
*/
readAsText: function(blob) {
_read.call(this, 'readAsText', blob);
},
/**
Aborts preloading process.
@method abort
*/
abort: function() {
this.result = null;
if (Basic.inArray(this.readyState, [FileReader.EMPTY, FileReader.DONE]) !== -1) {
return;
} else if (this.readyState === FileReader.LOADING) {
this.readyState = FileReader.DONE;
}
if (_fr) {
_fr.getRuntime().exec.call(this, 'FileReader', 'abort');
}
this.trigger('abort');
this.trigger('loadend');
},
/**
Destroy component and release resources.
@method destroy
*/
destroy: function() {
this.abort();
if (_fr) {
_fr.getRuntime().exec.call(this, 'FileReader', 'destroy');
_fr.disconnectRuntime();
}
self = _fr = null;
}
});
function _read(op, blob) {
_fr = new RuntimeTarget();
function error(err) {
self.readyState = FileReader.DONE;
self.error = err;
self.trigger('error');
loadEnd();
}
function loadEnd() {
_fr.destroy();
_fr = null;
self.trigger('loadend');
}
function exec(runtime) {
_fr.bind('Error', function(e, err) {
error(err);
});
_fr.bind('Progress', function(e) {
self.result = runtime.exec.call(_fr, 'FileReader', 'getResult');
self.trigger(e);
});
_fr.bind('Load', function(e) {
self.readyState = FileReader.DONE;
self.result = runtime.exec.call(_fr, 'FileReader', 'getResult');
self.trigger(e);
loadEnd();
});
runtime.exec.call(_fr, 'FileReader', 'read', op, blob);
}
this.convertEventPropsToHandlers(dispatches);
if (this.readyState === FileReader.LOADING) {
return error(new x.DOMException(x.DOMException.INVALID_STATE_ERR));
}
this.readyState = FileReader.LOADING;
this.trigger('loadstart');
// if source is o.Blob/o.File
if (blob instanceof Blob) {
if (blob.isDetached()) {
var src = blob.getSource();
switch (op) {
case 'readAsText':
case 'readAsBinaryString':
this.result = src;
break;
case 'readAsDataURL':
this.result = 'data:' + blob.type + ';base64,' + Encode.btoa(src);
break;
}
this.readyState = FileReader.DONE;
this.trigger('load');
loadEnd();
} else {
exec(_fr.connectRuntime(blob.ruid));
}
} else {
error(new x.DOMException(x.DOMException.NOT_FOUND_ERR));
}
}
}
/**
Initial FileReader state
@property EMPTY
@type {Number}
@final
@static
@default 0
*/
FileReader.EMPTY = 0;
/**
FileReader switches to this state when it is preloading the source
@property LOADING
@type {Number}
@final
@static
@default 1
*/
FileReader.LOADING = 1;
/**
Preloading is complete, this is a final state
@property DONE
@type {Number}
@final
@static
@default 2
*/
FileReader.DONE = 2;
FileReader.prototype = EventTarget.instance;
return FileReader;
});
// Included from: src/javascript/core/utils/Url.js
/**
* Url.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Url', [], function() {
/**
Parse url into separate components and fill in absent parts with parts from current url,
based on https://raw.github.com/kvz/phpjs/master/functions/url/parse_url.js
@method parseUrl
@for Utils
@static
@param {String} url Url to parse (defaults to empty string if undefined)
@return {Object} Hash containing extracted uri components
*/
var parseUrl = function(url, currentUrl) {
var key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'fragment']
, i = key.length
, ports = {
http: 80,
https: 443
}
, uri = {}
, regex = /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/
, m = regex.exec(url || '')
;
while (i--) {
if (m[i]) {
uri[key[i]] = m[i];
}
}
// when url is relative, we set the origin and the path ourselves
if (!uri.scheme) {
// come up with defaults
if (!currentUrl || typeof(currentUrl) === 'string') {
currentUrl = parseUrl(currentUrl || document.location.href);
}
uri.scheme = currentUrl.scheme;
uri.host = currentUrl.host;
uri.port = currentUrl.port;
var path = '';
// for urls without trailing slash we need to figure out the path
if (/^[^\/]/.test(uri.path)) {
path = currentUrl.path;
// if path ends with a filename, strip it
if (!/(\/|\/[^\.]+)$/.test(path)) {
path = path.replace(/\/[^\/]+$/, '/');
} else {
path += '/';
}
}
uri.path = path + (uri.path || ''); // site may reside at domain.com or domain.com/subdir
}
if (!uri.port) {
uri.port = ports[uri.scheme] || 80;
}
uri.port = parseInt(uri.port, 10);
if (!uri.path) {
uri.path = "/";
}
delete uri.source;
return uri;
};
/**
Resolve url - among other things will turn relative url to absolute
@method resolveUrl
@static
@param {String} url Either absolute or relative
@return {String} Resolved, absolute url
*/
var resolveUrl = function(url) {
var ports = { // we ignore default ports
http: 80,
https: 443
}
, urlp = parseUrl(url)
;
return urlp.scheme + '://' + urlp.host + (urlp.port !== ports[urlp.scheme] ? ':' + urlp.port : '') + urlp.path + (urlp.query ? urlp.query : '');
};
/**
Check if specified url has the same origin as the current document
@method hasSameOrigin
@param {String|Object} url
@return {Boolean}
*/
var hasSameOrigin = function(url) {
function origin(url) {
return [url.scheme, url.host, url.port].join('/');
}
if (typeof url === 'string') {
url = parseUrl(url);
}
return origin(parseUrl()) === origin(url);
};
return {
parseUrl: parseUrl,
resolveUrl: resolveUrl,
hasSameOrigin: hasSameOrigin
};
});
// Included from: src/javascript/file/FileReaderSync.js
/**
* FileReaderSync.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/FileReaderSync', [
'moxie/core/utils/Basic',
'moxie/runtime/RuntimeClient',
'moxie/core/utils/Encode'
], function(Basic, RuntimeClient, Encode) {
/**
Synchronous FileReader implementation. Something like this is available in WebWorkers environment, here
it can be used to read only preloaded blobs/files and only below certain size (not yet sure what that'd be,
but probably < 1mb). Not meant to be used directly by user.
@class FileReaderSync
@private
@constructor
*/
return function() {
RuntimeClient.call(this);
Basic.extend(this, {
uid: Basic.guid('uid_'),
readAsBinaryString: function(blob) {
return _read.call(this, 'readAsBinaryString', blob);
},
readAsDataURL: function(blob) {
return _read.call(this, 'readAsDataURL', blob);
},
/*readAsArrayBuffer: function(blob) {
return _read.call(this, 'readAsArrayBuffer', blob);
},*/
readAsText: function(blob) {
return _read.call(this, 'readAsText', blob);
}
});
function _read(op, blob) {
if (blob.isDetached()) {
var src = blob.getSource();
switch (op) {
case 'readAsBinaryString':
return src;
case 'readAsDataURL':
return 'data:' + blob.type + ';base64,' + Encode.btoa(src);
case 'readAsText':
var txt = '';
for (var i = 0, length = src.length; i < length; i++) {
txt += String.fromCharCode(src[i]);
}
return txt;
}
} else {
var result = this.connectRuntime(blob.ruid).exec.call(this, 'FileReaderSync', 'read', op, blob);
this.disconnectRuntime();
return result;
}
}
};
});
// Included from: src/javascript/xhr/FormData.js
/**
* FormData.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/xhr/FormData", [
"moxie/core/Exceptions",
"moxie/core/utils/Basic",
"moxie/file/Blob"
], function(x, Basic, Blob) {
/**
FormData
@class FormData
@constructor
*/
function FormData() {
var _blob, _fields = [];
Basic.extend(this, {
/**
Append another key-value pair to the FormData object
@method append
@param {String} name Name for the new field
@param {String|Blob|Array|Object} value Value for the field
*/
append: function(name, value) {
var self = this, valueType = Basic.typeOf(value);
// according to specs value might be either Blob or String
if (value instanceof Blob) {
_blob = {
name: name,
value: value // unfortunately we can only send single Blob in one FormData
};
} else if ('array' === valueType) {
name += '[]';
Basic.each(value, function(value) {
self.append(name, value);
});
} else if ('object' === valueType) {
Basic.each(value, function(value, key) {
self.append(name + '[' + key + ']', value);
});
} else if ('null' === valueType || 'undefined' === valueType || 'number' === valueType && isNaN(value)) {
self.append(name, "false");
} else {
_fields.push({
name: name,
value: value.toString()
});
}
},
/**
Checks if FormData contains Blob.
@method hasBlob
@return {Boolean}
*/
hasBlob: function() {
return !!this.getBlob();
},
/**
Retrieves blob.
@method getBlob
@return {Object} Either Blob if found or null
*/
getBlob: function() {
return _blob && _blob.value || null;
},
/**
Retrieves blob field name.
@method getBlobName
@return {String} Either Blob field name or null
*/
getBlobName: function() {
return _blob && _blob.name || null;
},
/**
Loop over the fields in FormData and invoke the callback for each of them.
@method each
@param {Function} cb Callback to call for each field
*/
each: function(cb) {
Basic.each(_fields, function(field) {
cb(field.value, field.name);
});
if (_blob) {
cb(_blob.value, _blob.name);
}
},
destroy: function() {
_blob = null;
_fields = [];
}
});
}
return FormData;
});
// Included from: src/javascript/xhr/XMLHttpRequest.js
/**
* XMLHttpRequest.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/xhr/XMLHttpRequest", [
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/core/EventTarget",
"moxie/core/utils/Encode",
"moxie/core/utils/Url",
"moxie/runtime/Runtime",
"moxie/runtime/RuntimeTarget",
"moxie/file/Blob",
"moxie/file/FileReaderSync",
"moxie/xhr/FormData",
"moxie/core/utils/Env",
"moxie/core/utils/Mime"
], function(Basic, x, EventTarget, Encode, Url, Runtime, RuntimeTarget, Blob, FileReaderSync, FormData, Env, Mime) {
var httpCode = {
100: 'Continue',
101: 'Switching Protocols',
102: 'Processing',
200: 'OK',
201: 'Created',
202: 'Accepted',
203: 'Non-Authoritative Information',
204: 'No Content',
205: 'Reset Content',
206: 'Partial Content',
207: 'Multi-Status',
226: 'IM Used',
300: 'Multiple Choices',
301: 'Moved Permanently',
302: 'Found',
303: 'See Other',
304: 'Not Modified',
305: 'Use Proxy',
306: 'Reserved',
307: 'Temporary Redirect',
400: 'Bad Request',
401: 'Unauthorized',
402: 'Payment Required',
403: 'Forbidden',
404: 'Not Found',
405: 'Method Not Allowed',
406: 'Not Acceptable',
407: 'Proxy Authentication Required',
408: 'Request Timeout',
409: 'Conflict',
410: 'Gone',
411: 'Length Required',
412: 'Precondition Failed',
413: 'Request Entity Too Large',
414: 'Request-URI Too Long',
415: 'Unsupported Media Type',
416: 'Requested Range Not Satisfiable',
417: 'Expectation Failed',
422: 'Unprocessable Entity',
423: 'Locked',
424: 'Failed Dependency',
426: 'Upgrade Required',
500: 'Internal Server Error',
501: 'Not Implemented',
502: 'Bad Gateway',
503: 'Service Unavailable',
504: 'Gateway Timeout',
505: 'HTTP Version Not Supported',
506: 'Variant Also Negotiates',
507: 'Insufficient Storage',
510: 'Not Extended'
};
function XMLHttpRequestUpload() {
this.uid = Basic.guid('uid_');
}
XMLHttpRequestUpload.prototype = EventTarget.instance;
/**
Implementation of XMLHttpRequest
@class XMLHttpRequest
@constructor
@uses RuntimeClient
@extends EventTarget
*/
var dispatches = ['loadstart', 'progress', 'abort', 'error', 'load', 'timeout', 'loadend']; // & readystatechange (for historical reasons)
var NATIVE = 1, RUNTIME = 2;
function XMLHttpRequest() {
var self = this,
// this (together with _p() @see below) is here to gracefully upgrade to setter/getter syntax where possible
props = {
/**
The amount of milliseconds a request can take before being terminated. Initially zero. Zero means there is no timeout.
@property timeout
@type Number
@default 0
*/
timeout: 0,
/**
Current state, can take following values:
UNSENT (numeric value 0)
The object has been constructed.
OPENED (numeric value 1)
The open() method has been successfully invoked. During this state request headers can be set using setRequestHeader() and the request can be made using the send() method.
HEADERS_RECEIVED (numeric value 2)
All redirects (if any) have been followed and all HTTP headers of the final response have been received. Several response members of the object are now available.
LOADING (numeric value 3)
The response entity body is being received.
DONE (numeric value 4)
@property readyState
@type Number
@default 0 (UNSENT)
*/
readyState: XMLHttpRequest.UNSENT,
/**
True when user credentials are to be included in a cross-origin request. False when they are to be excluded
in a cross-origin request and when cookies are to be ignored in its response. Initially false.
@property withCredentials
@type Boolean
@default false
*/
withCredentials: false,
/**
Returns the HTTP status code.
@property status
@type Number
@default 0
*/
status: 0,
/**
Returns the HTTP status text.
@property statusText
@type String
*/
statusText: "",
/**
Returns the response type. Can be set to change the response type. Values are:
the empty string (default), "arraybuffer", "blob", "document", "json", and "text".
@property responseType
@type String
*/
responseType: "",
/**
Returns the document response entity body.
Throws an "InvalidStateError" exception if responseType is not the empty string or "document".
@property responseXML
@type Document
*/
responseXML: null,
/**
Returns the text response entity body.
Throws an "InvalidStateError" exception if responseType is not the empty string or "text".
@property responseText
@type String
*/
responseText: null,
/**
Returns the response entity body (http://www.w3.org/TR/XMLHttpRequest/#response-entity-body).
Can become: ArrayBuffer, Blob, Document, JSON, Text
@property response
@type Mixed
*/
response: null
},
_async = true,
_url,
_method,
_headers = {},
_user,
_password,
_encoding = null,
_mimeType = null,
// flags
_sync_flag = false,
_send_flag = false,
_upload_events_flag = false,
_upload_complete_flag = false,
_error_flag = false,
_same_origin_flag = false,
// times
_start_time,
_timeoutset_time,
_finalMime = null,
_finalCharset = null,
_options = {},
_xhr,
_responseHeaders = '',
_responseHeadersBag
;
Basic.extend(this, props, {
/**
Unique id of the component
@property uid
@type String
*/
uid: Basic.guid('uid_'),
/**
Target for Upload events
@property upload
@type XMLHttpRequestUpload
*/
upload: new XMLHttpRequestUpload(),
/**
Sets the request method, request URL, synchronous flag, request username, and request password.
Throws a "SyntaxError" exception if one of the following is true:
method is not a valid HTTP method.
url cannot be resolved.
url contains the "user:password" format in the userinfo production.
Throws a "SecurityError" exception if method is a case-insensitive match for CONNECT, TRACE or TRACK.
Throws an "InvalidAccessError" exception if one of the following is true:
Either user or password is passed as argument and the origin of url does not match the XMLHttpRequest origin.
There is an associated XMLHttpRequest document and either the timeout attribute is not zero,
the withCredentials attribute is true, or the responseType attribute is not the empty string.
@method open
@param {String} method HTTP method to use on request
@param {String} url URL to request
@param {Boolean} [async=true] If false request will be done in synchronous manner. Asynchronous by default.
@param {String} [user] Username to use in HTTP authentication process on server-side
@param {String} [password] Password to use in HTTP authentication process on server-side
*/
open: function(method, url, async, user, password) {
var urlp;
// first two arguments are required
if (!method || !url) {
throw new x.DOMException(x.DOMException.SYNTAX_ERR);
}
// 2 - check if any code point in method is higher than U+00FF or after deflating method it does not match the method
if (/[\u0100-\uffff]/.test(method) || Encode.utf8_encode(method) !== method) {
throw new x.DOMException(x.DOMException.SYNTAX_ERR);
}
// 3
if (!!~Basic.inArray(method.toUpperCase(), ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'TRACE', 'TRACK'])) {
_method = method.toUpperCase();
}
// 4 - allowing these methods poses a security risk
if (!!~Basic.inArray(_method, ['CONNECT', 'TRACE', 'TRACK'])) {
throw new x.DOMException(x.DOMException.SECURITY_ERR);
}
// 5
url = Encode.utf8_encode(url);
// 6 - Resolve url relative to the XMLHttpRequest base URL. If the algorithm returns an error, throw a "SyntaxError".
urlp = Url.parseUrl(url);
_same_origin_flag = Url.hasSameOrigin(urlp);
// 7 - manually build up absolute url
_url = Url.resolveUrl(url);
// 9-10, 12-13
if ((user || password) && !_same_origin_flag) {
throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR);
}
_user = user || urlp.user;
_password = password || urlp.pass;
// 11
_async = async || true;
if (_async === false && (_p('timeout') || _p('withCredentials') || _p('responseType') !== "")) {
throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR);
}
// 14 - terminate abort()
// 15 - terminate send()
// 18
_sync_flag = !_async;
_send_flag = false;
_headers = {};
_reset.call(this);
// 19
_p('readyState', XMLHttpRequest.OPENED);
// 20
this.convertEventPropsToHandlers(['readystatechange']); // unify event handlers
this.dispatchEvent('readystatechange');
},
/**
Appends an header to the list of author request headers, or if header is already
in the list of author request headers, combines its value with value.
Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set.
Throws a "SyntaxError" exception if header is not a valid HTTP header field name or if value
is not a valid HTTP header field value.
@method setRequestHeader
@param {String} header
@param {String|Number} value
*/
setRequestHeader: function(header, value) {
var uaHeaders = [ // these headers are controlled by the user agent
"accept-charset",
"accept-encoding",
"access-control-request-headers",
"access-control-request-method",
"connection",
"content-length",
"cookie",
"cookie2",
"content-transfer-encoding",
"date",
"expect",
"host",
"keep-alive",
"origin",
"referer",
"te",
"trailer",
"transfer-encoding",
"upgrade",
"user-agent",
"via"
];
// 1-2
if (_p('readyState') !== XMLHttpRequest.OPENED || _send_flag) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 3
if (/[\u0100-\uffff]/.test(header) || Encode.utf8_encode(header) !== header) {
throw new x.DOMException(x.DOMException.SYNTAX_ERR);
}
// 4
/* this step is seemingly bypassed in browsers, probably to allow various unicode characters in header values
if (/[\u0100-\uffff]/.test(value) || Encode.utf8_encode(value) !== value) {
throw new x.DOMException(x.DOMException.SYNTAX_ERR);
}*/
header = Basic.trim(header).toLowerCase();
// setting of proxy-* and sec-* headers is prohibited by spec
if (!!~Basic.inArray(header, uaHeaders) || /^(proxy\-|sec\-)/.test(header)) {
return false;
}
// camelize
// browsers lowercase header names (at least for custom ones)
// header = header.replace(/\b\w/g, function($1) { return $1.toUpperCase(); });
if (!_headers[header]) {
_headers[header] = value;
} else {
// http://tools.ietf.org/html/rfc2616#section-4.2 (last paragraph)
_headers[header] += ', ' + value;
}
return true;
},
/**
Returns all headers from the response, with the exception of those whose field name is Set-Cookie or Set-Cookie2.
@method getAllResponseHeaders
@return {String} reponse headers or empty string
*/
getAllResponseHeaders: function() {
return _responseHeaders || '';
},
/**
Returns the header field value from the response of which the field name matches header,
unless the field name is Set-Cookie or Set-Cookie2.
@method getResponseHeader
@param {String} header
@return {String} value(s) for the specified header or null
*/
getResponseHeader: function(header) {
header = header.toLowerCase();
if (_error_flag || !!~Basic.inArray(header, ['set-cookie', 'set-cookie2'])) {
return null;
}
if (_responseHeaders && _responseHeaders !== '') {
// if we didn't parse response headers until now, do it and keep for later
if (!_responseHeadersBag) {
_responseHeadersBag = {};
Basic.each(_responseHeaders.split(/\r\n/), function(line) {
var pair = line.split(/:\s+/);
if (pair.length === 2) { // last line might be empty, omit
pair[0] = Basic.trim(pair[0]); // just in case
_responseHeadersBag[pair[0].toLowerCase()] = { // simply to retain header name in original form
header: pair[0],
value: Basic.trim(pair[1])
};
}
});
}
if (_responseHeadersBag.hasOwnProperty(header)) {
return _responseHeadersBag[header].header + ': ' + _responseHeadersBag[header].value;
}
}
return null;
},
/**
Sets the Content-Type header for the response to mime.
Throws an "InvalidStateError" exception if the state is LOADING or DONE.
Throws a "SyntaxError" exception if mime is not a valid media type.
@method overrideMimeType
@param String mime Mime type to set
*/
overrideMimeType: function(mime) {
var matches, charset;
// 1
if (!!~Basic.inArray(_p('readyState'), [XMLHttpRequest.LOADING, XMLHttpRequest.DONE])) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 2
mime = Basic.trim(mime.toLowerCase());
if (/;/.test(mime) && (matches = mime.match(/^([^;]+)(?:;\scharset\=)?(.*)$/))) {
mime = matches[1];
if (matches[2]) {
charset = matches[2];
}
}
if (!Mime.mimes[mime]) {
throw new x.DOMException(x.DOMException.SYNTAX_ERR);
}
// 3-4
_finalMime = mime;
_finalCharset = charset;
},
/**
Initiates the request. The optional argument provides the request entity body.
The argument is ignored if request method is GET or HEAD.
Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set.
@method send
@param {Blob|Document|String|FormData} [data] Request entity body
@param {Object} [options] Set of requirements and pre-requisities for runtime initialization
*/
send: function(data, options) {
if (Basic.typeOf(options) === 'string') {
_options = { ruid: options };
} else if (!options) {
_options = {};
} else {
_options = options;
}
this.convertEventPropsToHandlers(dispatches);
this.upload.convertEventPropsToHandlers(dispatches);
// 1-2
if (this.readyState !== XMLHttpRequest.OPENED || _send_flag) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 3
// sending Blob
if (data instanceof Blob) {
_options.ruid = data.ruid;
_mimeType = data.type || 'application/octet-stream';
}
// FormData
else if (data instanceof FormData) {
if (data.hasBlob()) {
var blob = data.getBlob();
_options.ruid = blob.ruid;
_mimeType = blob.type || 'application/octet-stream';
}
}
// DOMString
else if (typeof data === 'string') {
_encoding = 'UTF-8';
_mimeType = 'text/plain;charset=UTF-8';
// data should be converted to Unicode and encoded as UTF-8
data = Encode.utf8_encode(data);
}
// if withCredentials not set, but requested, set it automatically
if (!this.withCredentials) {
this.withCredentials = (_options.required_caps && _options.required_caps.send_browser_cookies) && !_same_origin_flag;
}
// 4 - storage mutex
// 5
_upload_events_flag = (!_sync_flag && this.upload.hasEventListener()); // DSAP
// 6
_error_flag = false;
// 7
_upload_complete_flag = !data;
// 8 - Asynchronous steps
if (!_sync_flag) {
// 8.1
_send_flag = true;
// 8.2
// this.dispatchEvent('loadstart'); // will be dispatched either by native or runtime xhr
// 8.3
//if (!_upload_complete_flag) {
// this.upload.dispatchEvent('loadstart'); // will be dispatched either by native or runtime xhr
//}
}
// 8.5 - Return the send() method call, but continue running the steps in this algorithm.
_doXHR.call(this, data);
},
/**
Cancels any network activity.
@method abort
*/
abort: function() {
_error_flag = true;
_sync_flag = false;
if (!~Basic.inArray(_p('readyState'), [XMLHttpRequest.UNSENT, XMLHttpRequest.OPENED, XMLHttpRequest.DONE])) {
_p('readyState', XMLHttpRequest.DONE);
_send_flag = false;
if (_xhr) {
_xhr.getRuntime().exec.call(_xhr, 'XMLHttpRequest', 'abort', _upload_complete_flag);
} else {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
_upload_complete_flag = true;
} else {
_p('readyState', XMLHttpRequest.UNSENT);
}
},
destroy: function() {
if (_xhr) {
if (Basic.typeOf(_xhr.destroy) === 'function') {
_xhr.destroy();
}
_xhr = null;
}
this.unbindAll();
if (this.upload) {
this.upload.unbindAll();
this.upload = null;
}
}
});
/* this is nice, but maybe too lengthy
// if supported by JS version, set getters/setters for specific properties
o.defineProperty(this, 'readyState', {
configurable: false,
get: function() {
return _p('readyState');
}
});
o.defineProperty(this, 'timeout', {
configurable: false,
get: function() {
return _p('timeout');
},
set: function(value) {
if (_sync_flag) {
throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR);
}
// timeout still should be measured relative to the start time of request
_timeoutset_time = (new Date).getTime();
_p('timeout', value);
}
});
// the withCredentials attribute has no effect when fetching same-origin resources
o.defineProperty(this, 'withCredentials', {
configurable: false,
get: function() {
return _p('withCredentials');
},
set: function(value) {
// 1-2
if (!~o.inArray(_p('readyState'), [XMLHttpRequest.UNSENT, XMLHttpRequest.OPENED]) || _send_flag) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 3-4
if (_anonymous_flag || _sync_flag) {
throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR);
}
// 5
_p('withCredentials', value);
}
});
o.defineProperty(this, 'status', {
configurable: false,
get: function() {
return _p('status');
}
});
o.defineProperty(this, 'statusText', {
configurable: false,
get: function() {
return _p('statusText');
}
});
o.defineProperty(this, 'responseType', {
configurable: false,
get: function() {
return _p('responseType');
},
set: function(value) {
// 1
if (!!~o.inArray(_p('readyState'), [XMLHttpRequest.LOADING, XMLHttpRequest.DONE])) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 2
if (_sync_flag) {
throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR);
}
// 3
_p('responseType', value.toLowerCase());
}
});
o.defineProperty(this, 'responseText', {
configurable: false,
get: function() {
// 1
if (!~o.inArray(_p('responseType'), ['', 'text'])) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 2-3
if (_p('readyState') !== XMLHttpRequest.DONE && _p('readyState') !== XMLHttpRequest.LOADING || _error_flag) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
return _p('responseText');
}
});
o.defineProperty(this, 'responseXML', {
configurable: false,
get: function() {
// 1
if (!~o.inArray(_p('responseType'), ['', 'document'])) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 2-3
if (_p('readyState') !== XMLHttpRequest.DONE || _error_flag) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
return _p('responseXML');
}
});
o.defineProperty(this, 'response', {
configurable: false,
get: function() {
if (!!~o.inArray(_p('responseType'), ['', 'text'])) {
if (_p('readyState') !== XMLHttpRequest.DONE && _p('readyState') !== XMLHttpRequest.LOADING || _error_flag) {
return '';
}
}
if (_p('readyState') !== XMLHttpRequest.DONE || _error_flag) {
return null;
}
return _p('response');
}
});
*/
function _p(prop, value) {
if (!props.hasOwnProperty(prop)) {
return;
}
if (arguments.length === 1) { // get
return Env.can('define_property') ? props[prop] : self[prop];
} else { // set
if (Env.can('define_property')) {
props[prop] = value;
} else {
self[prop] = value;
}
}
}
/*
function _toASCII(str, AllowUnassigned, UseSTD3ASCIIRules) {
// TODO: http://tools.ietf.org/html/rfc3490#section-4.1
return str.toLowerCase();
}
*/
function _doXHR(data) {
var self = this;
_start_time = new Date().getTime();
_xhr = new RuntimeTarget();
function loadEnd() {
_xhr.destroy();
_xhr = null;
self.dispatchEvent('loadend');
self = null;
}
function exec(runtime) {
_xhr.bind('LoadStart', function(e) {
_p('readyState', XMLHttpRequest.LOADING);
self.dispatchEvent('readystatechange');
self.dispatchEvent(e);
if (_upload_events_flag) {
self.upload.dispatchEvent(e);
}
});
_xhr.bind('Progress', function(e) {
if (_p('readyState') !== XMLHttpRequest.LOADING) {
_p('readyState', XMLHttpRequest.LOADING); // LoadStart unreliable (in Flash for example)
self.dispatchEvent('readystatechange');
}
self.dispatchEvent(e);
});
_xhr.bind('UploadProgress', function(e) {
if (_upload_events_flag) {
self.upload.dispatchEvent({
type: 'progress',
lengthComputable: false,
total: e.total,
loaded: e.loaded
});
}
});
_xhr.bind('Load', function(e) {
_p('readyState', XMLHttpRequest.DONE);
_p('status', Number(runtime.exec.call(_xhr, 'XMLHttpRequest', 'getStatus') || 0));
_p('statusText', httpCode[_p('status')] || "");
_p('response', runtime.exec.call(_xhr, 'XMLHttpRequest', 'getResponse', _p('responseType')));
if (!!~Basic.inArray(_p('responseType'), ['text', ''])) {
_p('responseText', _p('response'));
} else if (_p('responseType') === 'document') {
_p('responseXML', _p('response'));
}
_responseHeaders = runtime.exec.call(_xhr, 'XMLHttpRequest', 'getAllResponseHeaders');
self.dispatchEvent('readystatechange');
if (_p('status') > 0) { // status 0 usually means that server is unreachable
if (_upload_events_flag) {
self.upload.dispatchEvent(e);
}
self.dispatchEvent(e);
} else {
_error_flag = true;
self.dispatchEvent('error');
}
loadEnd();
});
_xhr.bind('Abort', function(e) {
self.dispatchEvent(e);
loadEnd();
});
_xhr.bind('Error', function(e) {
_error_flag = true;
_p('readyState', XMLHttpRequest.DONE);
self.dispatchEvent('readystatechange');
_upload_complete_flag = true;
self.dispatchEvent(e);
loadEnd();
});
runtime.exec.call(_xhr, 'XMLHttpRequest', 'send', {
url: _url,
method: _method,
async: _async,
user: _user,
password: _password,
headers: _headers,
mimeType: _mimeType,
encoding: _encoding,
responseType: self.responseType,
withCredentials: self.withCredentials,
options: _options
}, data);
}
// clarify our requirements
if (typeof(_options.required_caps) === 'string') {
_options.required_caps = Runtime.parseCaps(_options.required_caps);
}
_options.required_caps = Basic.extend({}, _options.required_caps, {
return_response_type: self.responseType
});
if (data instanceof FormData) {
_options.required_caps.send_multipart = true;
}
if (!_same_origin_flag) {
_options.required_caps.do_cors = true;
}
if (_options.ruid) { // we do not need to wait if we can connect directly
exec(_xhr.connectRuntime(_options));
} else {
_xhr.bind('RuntimeInit', function(e, runtime) {
exec(runtime);
});
_xhr.bind('RuntimeError', function(e, err) {
self.dispatchEvent('RuntimeError', err);
});
_xhr.connectRuntime(_options);
}
}
function _reset() {
_p('responseText', "");
_p('responseXML', null);
_p('response', null);
_p('status', 0);
_p('statusText', "");
_start_time = _timeoutset_time = null;
}
}
XMLHttpRequest.UNSENT = 0;
XMLHttpRequest.OPENED = 1;
XMLHttpRequest.HEADERS_RECEIVED = 2;
XMLHttpRequest.LOADING = 3;
XMLHttpRequest.DONE = 4;
XMLHttpRequest.prototype = EventTarget.instance;
return XMLHttpRequest;
});
// Included from: src/javascript/runtime/Transporter.js
/**
* Transporter.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/runtime/Transporter", [
"moxie/core/utils/Basic",
"moxie/core/utils/Encode",
"moxie/runtime/RuntimeClient",
"moxie/core/EventTarget"
], function(Basic, Encode, RuntimeClient, EventTarget) {
function Transporter() {
var mod, _runtime, _data, _size, _pos, _chunk_size;
RuntimeClient.call(this);
Basic.extend(this, {
uid: Basic.guid('uid_'),
state: Transporter.IDLE,
result: null,
transport: function(data, type, options) {
var self = this;
options = Basic.extend({
chunk_size: 204798
}, options);
// should divide by three, base64 requires this
if ((mod = options.chunk_size % 3)) {
options.chunk_size += 3 - mod;
}
_chunk_size = options.chunk_size;
_reset.call(this);
_data = data;
_size = data.length;
if (Basic.typeOf(options) === 'string' || options.ruid) {
_run.call(self, type, this.connectRuntime(options));
} else {
// we require this to run only once
var cb = function(e, runtime) {
self.unbind("RuntimeInit", cb);
_run.call(self, type, runtime);
};
this.bind("RuntimeInit", cb);
this.connectRuntime(options);
}
},
abort: function() {
var self = this;
self.state = Transporter.IDLE;
if (_runtime) {
_runtime.exec.call(self, 'Transporter', 'clear');
self.trigger("TransportingAborted");
}
_reset.call(self);
},
destroy: function() {
this.unbindAll();
_runtime = null;
this.disconnectRuntime();
_reset.call(this);
}
});
function _reset() {
_size = _pos = 0;
_data = this.result = null;
}
function _run(type, runtime) {
var self = this;
_runtime = runtime;
//self.unbind("RuntimeInit");
self.bind("TransportingProgress", function(e) {
_pos = e.loaded;
if (_pos < _size && Basic.inArray(self.state, [Transporter.IDLE, Transporter.DONE]) === -1) {
_transport.call(self);
}
}, 999);
self.bind("TransportingComplete", function() {
_pos = _size;
self.state = Transporter.DONE;
_data = null; // clean a bit
self.result = _runtime.exec.call(self, 'Transporter', 'getAsBlob', type || '');
}, 999);
self.state = Transporter.BUSY;
self.trigger("TransportingStarted");
_transport.call(self);
}
function _transport() {
var self = this,
chunk,
bytesLeft = _size - _pos;
if (_chunk_size > bytesLeft) {
_chunk_size = bytesLeft;
}
chunk = Encode.btoa(_data.substr(_pos, _chunk_size));
_runtime.exec.call(self, 'Transporter', 'receive', chunk, _size);
}
}
Transporter.IDLE = 0;
Transporter.BUSY = 1;
Transporter.DONE = 2;
Transporter.prototype = EventTarget.instance;
return Transporter;
});
// Included from: src/javascript/image/Image.js
/**
* Image.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/image/Image", [
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/Exceptions",
"moxie/file/FileReaderSync",
"moxie/xhr/XMLHttpRequest",
"moxie/runtime/Runtime",
"moxie/runtime/RuntimeClient",
"moxie/runtime/Transporter",
"moxie/core/utils/Env",
"moxie/core/EventTarget",
"moxie/file/Blob",
"moxie/file/File",
"moxie/core/utils/Encode"
], function(Basic, Dom, x, FileReaderSync, XMLHttpRequest, Runtime, RuntimeClient, Transporter, Env, EventTarget, Blob, File, Encode) {
/**
Image preloading and manipulation utility. Additionally it provides access to image meta info (Exif, GPS) and raw binary data.
@class Image
@constructor
@extends EventTarget
*/
var dispatches = [
'progress',
/**
Dispatched when loading is complete.
@event load
@param {Object} event
*/
'load',
'error',
/**
Dispatched when resize operation is complete.
@event resize
@param {Object} event
*/
'resize',
/**
Dispatched when visual representation of the image is successfully embedded
into the corresponsing container.
@event embedded
@param {Object} event
*/
'embedded'
];
function Image() {
RuntimeClient.call(this);
Basic.extend(this, {
/**
Unique id of the component
@property uid
@type {String}
*/
uid: Basic.guid('uid_'),
/**
Unique id of the connected runtime, if any.
@property ruid
@type {String}
*/
ruid: null,
/**
Name of the file, that was used to create an image, if available. If not equals to empty string.
@property name
@type {String}
@default ""
*/
name: "",
/**
Size of the image in bytes. Actual value is set only after image is preloaded.
@property size
@type {Number}
@default 0
*/
size: 0,
/**
Width of the image. Actual value is set only after image is preloaded.
@property width
@type {Number}
@default 0
*/
width: 0,
/**
Height of the image. Actual value is set only after image is preloaded.
@property height
@type {Number}
@default 0
*/
height: 0,
/**
Mime type of the image. Currently only image/jpeg and image/png are supported. Actual value is set only after image is preloaded.
@property type
@type {String}
@default ""
*/
type: "",
/**
Holds meta info (Exif, GPS). Is populated only for image/jpeg. Actual value is set only after image is preloaded.
@property meta
@type {Object}
@default {}
*/
meta: {},
/**
Alias for load method, that takes another mOxie.Image object as a source (see load).
@method clone
@param {Image} src Source for the image
@param {Boolean} [exact=false] Whether to activate in-depth clone mode
*/
clone: function() {
this.load.apply(this, arguments);
},
/**
Loads image from various sources. Currently the source for new image can be: mOxie.Image, mOxie.Blob/mOxie.File,
native Blob/File, dataUrl or URL. Depending on the type of the source, arguments - differ. When source is URL,
Image will be downloaded from remote destination and loaded in memory.
@example
var img = new mOxie.Image();
img.onload = function() {
var blob = img.getAsBlob();
var formData = new mOxie.FormData();
formData.append('file', blob);
var xhr = new mOxie.XMLHttpRequest();
xhr.onload = function() {
// upload complete
};
xhr.open('post', 'upload.php');
xhr.send(formData);
};
img.load("http://www.moxiecode.com/images/mox-logo.jpg"); // notice file extension (.jpg)
@method load
@param {Image|Blob|File|String} src Source for the image
@param {Boolean|Object} [mixed]
*/
load: function() {
// this is here because to bind properly we need an uid first, which is created above
this.bind('Load Resize', function() {
_updateInfo.call(this);
}, 999);
this.convertEventPropsToHandlers(dispatches);
_load.apply(this, arguments);
},
/**
Downsizes the image to fit the specified width/height. If crop is supplied, image will be cropped to exact dimensions.
@method downsize
@param {Number} width Resulting width
@param {Number} [height=width] Resulting height (optional, if not supplied will default to width)
@param {Boolean} [crop=false] Whether to crop the image to exact dimensions
@param {Boolean} [preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize)
*/
downsize: function(width, height, crop, preserveHeaders) {
try {
if (!this.size) { // only preloaded image objects can be used as source
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// no way to reliably intercept the crash due to high resolution, so we simply avoid it
if (this.width > Image.MAX_RESIZE_WIDTH || this.height > Image.MAX_RESIZE_HEIGHT) {
throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR);
}
if (!width && !height || Basic.typeOf(crop) === 'undefined') {
crop = false;
}
width = width || this.width;
height = height || this.height;
preserveHeaders = (Basic.typeOf(preserveHeaders) === 'undefined' ? true : !!preserveHeaders);
this.getRuntime().exec.call(this, 'Image', 'downsize', width, height, crop, preserveHeaders);
} catch(ex) {
// for now simply trigger error event
this.trigger('error', ex);
}
},
/**
Alias for downsize(width, height, true). (see downsize)
@method crop
@param {Number} width Resulting width
@param {Number} [height=width] Resulting height (optional, if not supplied will default to width)
@param {Boolean} [preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize)
*/
crop: function(width, height, preserveHeaders) {
this.downsize(width, height, true, preserveHeaders);
},
getAsCanvas: function() {
if (!Env.can('create_canvas')) {
throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR);
}
var runtime = this.connectRuntime(this.ruid);
return runtime.exec.call(this, 'Image', 'getAsCanvas');
},
/**
Retrieves image in it's current state as mOxie.Blob object. Cannot be run on empty or image in progress (throws
DOMException.INVALID_STATE_ERR).
@method getAsBlob
@param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png
@param {Number} [quality=90] Applicable only together with mime type image/jpeg
@return {Blob} Image as Blob
*/
getAsBlob: function(type, quality) {
if (!this.size) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
if (!type) {
type = 'image/jpeg';
}
if (type === 'image/jpeg' && !quality) {
quality = 90;
}
return this.getRuntime().exec.call(this, 'Image', 'getAsBlob', type, quality);
},
/**
Retrieves image in it's current state as dataURL string. Cannot be run on empty or image in progress (throws
DOMException.INVALID_STATE_ERR).
@method getAsDataURL
@param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png
@param {Number} [quality=90] Applicable only together with mime type image/jpeg
@return {String} Image as dataURL string
*/
getAsDataURL: function(type, quality) {
if (!this.size) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
return this.getRuntime().exec.call(this, 'Image', 'getAsDataURL', type, quality);
},
/**
Retrieves image in it's current state as binary string. Cannot be run on empty or image in progress (throws
DOMException.INVALID_STATE_ERR).
@method getAsBinaryString
@param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png
@param {Number} [quality=90] Applicable only together with mime type image/jpeg
@return {String} Image as binary string
*/
getAsBinaryString: function(type, quality) {
var dataUrl = this.getAsDataURL(type, quality);
return Encode.atob(dataUrl.substring(dataUrl.indexOf('base64,') + 7));
},
/**
Embeds the image, or better to say, it's visual representation into the specified node. Depending on the runtime
in use, might be a canvas, or image (actual ) element or shim object (Flash or SilverLight - very rare, used for
legacy browsers that do not have canvas or proper dataURI support).
@method embed
@param {DOMElement} el DOM element to insert the image object into
@param {Object} options Set of key/value pairs controlling the mime type, dimensions and cropping factor of resulting
representation
*/
embed: function(el) {
var self = this
, imgCopy
, type, quality, crop
, options = arguments[1] || {}
, width = this.width
, height = this.height
, runtime // this has to be outside of all the closures to contain proper runtime
;
function onResize() {
// if possible, embed a canvas element directly
if (Env.can('create_canvas')) {
var canvas = imgCopy.getAsCanvas();
if (canvas) {
el.appendChild(canvas);
canvas = null;
imgCopy.destroy();
self.trigger('embedded');
return;
}
}
var dataUrl = imgCopy.getAsDataURL(type, quality);
if (!dataUrl) {
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
}
if (Env.can('use_data_uri_of', dataUrl.length)) {
el.innerHTML = '<img src="' + dataUrl + '" width="' + imgCopy.width + '" height="' + imgCopy.height + '" />';
imgCopy.destroy();
self.trigger('embedded');
} else {
var tr = new Transporter();
tr.bind("TransportingComplete", function() {
runtime = self.connectRuntime(this.result.ruid);
self.bind("Embedded", function() {
// position and size properly
Basic.extend(runtime.getShimContainer().style, {
//position: 'relative',
top: '0px',
left: '0px',
width: imgCopy.width + 'px',
height: imgCopy.height + 'px'
});
// some shims (Flash/SilverLight) reinitialize, if parent element is hidden, reordered or it's
// position type changes (in Gecko), but since we basically need this only in IEs 6/7 and
// sometimes 8 and they do not have this problem, we can comment this for now
/*tr.bind("RuntimeInit", function(e, runtime) {
tr.destroy();
runtime.destroy();
onResize.call(self); // re-feed our image data
});*/
runtime = null;
}, 999);
runtime.exec.call(self, "ImageView", "display", this.result.uid, width, height);
imgCopy.destroy();
});
tr.transport(Encode.atob(dataUrl.substring(dataUrl.indexOf('base64,') + 7)), type, Basic.extend({}, options, {
required_caps: {
display_media: true
},
runtime_order: 'flash,silverlight',
container: el
}));
}
}
try {
if (!(el = Dom.get(el))) {
throw new x.DOMException(x.DOMException.INVALID_NODE_TYPE_ERR);
}
if (!this.size) { // only preloaded image objects can be used as source
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
if (this.width > Image.MAX_RESIZE_WIDTH || this.height > Image.MAX_RESIZE_HEIGHT) {
throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR);
}
type = options.type || this.type || 'image/jpeg';
quality = options.quality || 90;
crop = Basic.typeOf(options.crop) !== 'undefined' ? options.crop : false;
// figure out dimensions for the thumb
if (options.width) {
width = options.width;
height = options.height || width;
} else {
// if container element has > 0 dimensions, take them
var dimensions = Dom.getSize(el);
if (dimensions.w && dimensions.h) { // both should be > 0
width = dimensions.w;
height = dimensions.h;
}
}
imgCopy = new Image();
imgCopy.bind("Resize", function() {
onResize.call(self);
});
imgCopy.bind("Load", function() {
imgCopy.downsize(width, height, crop, false);
});
imgCopy.clone(this, false);
return imgCopy;
} catch(ex) {
// for now simply trigger error event
this.trigger('error', ex);
}
},
/**
Properly destroys the image and frees resources in use. If any. Recommended way to dispose mOxie.Image object.
@method destroy
*/
destroy: function() {
if (this.ruid) {
this.getRuntime().exec.call(this, 'Image', 'destroy');
this.disconnectRuntime();
}
this.unbindAll();
}
});
function _updateInfo(info) {
if (!info) {
info = this.getRuntime().exec.call(this, 'Image', 'getInfo');
}
this.size = info.size;
this.width = info.width;
this.height = info.height;
this.type = info.type;
this.meta = info.meta;
// update file name, only if empty
if (this.name === '') {
this.name = info.name;
}
}
function _load(src) {
var srcType = Basic.typeOf(src);
try {
// if source is Image
if (src instanceof Image) {
if (!src.size) { // only preloaded image objects can be used as source
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
_loadFromImage.apply(this, arguments);
}
// if source is o.Blob/o.File
else if (src instanceof Blob) {
if (!~Basic.inArray(src.type, ['image/jpeg', 'image/png'])) {
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
}
_loadFromBlob.apply(this, arguments);
}
// if native blob/file
else if (Basic.inArray(srcType, ['blob', 'file']) !== -1) {
_load.call(this, new File(null, src), arguments[1]);
}
// if String
else if (srcType === 'string') {
// if dataUrl String
if (/^data:[^;]*;base64,/.test(src)) {
_load.call(this, new Blob(null, { data: src }), arguments[1]);
}
// else assume Url, either relative or absolute
else {
_loadFromUrl.apply(this, arguments);
}
}
// if source seems to be an img node
else if (srcType === 'node' && src.nodeName.toLowerCase() === 'img') {
_load.call(this, src.src, arguments[1]);
}
else {
throw new x.DOMException(x.DOMException.TYPE_MISMATCH_ERR);
}
} catch(ex) {
// for now simply trigger error event
this.trigger('error', ex);
}
}
function _loadFromImage(img, exact) {
var runtime = this.connectRuntime(img.ruid);
this.ruid = runtime.uid;
runtime.exec.call(this, 'Image', 'loadFromImage', img, (Basic.typeOf(exact) === 'undefined' ? true : exact));
}
function _loadFromBlob(blob, options) {
var self = this;
self.name = blob.name || '';
function exec(runtime) {
self.ruid = runtime.uid;
runtime.exec.call(self, 'Image', 'loadFromBlob', blob);
}
if (blob.isDetached()) {
this.bind('RuntimeInit', function(e, runtime) {
exec(runtime);
});
// convert to object representation
if (options && typeof(options.required_caps) === 'string') {
options.required_caps = Runtime.parseCaps(options.required_caps);
}
this.connectRuntime(Basic.extend({
required_caps: {
access_image_binary: true,
resize_image: true
}
}, options));
} else {
exec(this.connectRuntime(blob.ruid));
}
}
function _loadFromUrl(url, options) {
var self = this, xhr;
xhr = new XMLHttpRequest();
xhr.open('get', url);
xhr.responseType = 'blob';
xhr.onprogress = function(e) {
self.trigger(e);
};
xhr.onload = function() {
_loadFromBlob.call(self, xhr.response, true);
};
xhr.onerror = function(e) {
self.trigger(e);
};
xhr.onloadend = function() {
xhr.destroy();
};
xhr.bind('RuntimeError', function(e, err) {
self.trigger('RuntimeError', err);
});
xhr.send(null, options);
}
}
// virtual world will crash on you if image has a resolution higher than this:
Image.MAX_RESIZE_WIDTH = 6500;
Image.MAX_RESIZE_HEIGHT = 6500;
Image.prototype = EventTarget.instance;
return Image;
});
// Included from: src/javascript/runtime/html5/Runtime.js
/**
* Runtime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global File:true */
/**
Defines constructor for HTML5 runtime.
@class moxie/runtime/html5/Runtime
@private
*/
define("moxie/runtime/html5/Runtime", [
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/runtime/Runtime",
"moxie/core/utils/Env"
], function(Basic, x, Runtime, Env) {
var type = "html5", extensions = {};
function Html5Runtime(options) {
var I = this
, Test = Runtime.capTest
, True = Runtime.capTrue
;
var caps = Basic.extend({
access_binary: Test(window.FileReader || window.File && window.File.getAsDataURL),
access_image_binary: function() {
return I.can('access_binary') && !!extensions.Image;
},
display_media: Test(Env.can('create_canvas') || Env.can('use_data_uri_over32kb')),
do_cors: Test(window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()),
drag_and_drop: Test(function() {
// this comes directly from Modernizr: http://www.modernizr.com/
var div = document.createElement('div');
// IE has support for drag and drop since version 5, but doesn't support dropping files from desktop
return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && (Env.browser !== 'IE' || Env.version > 9);
}()),
filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest
return (Env.browser === 'Chrome' && Env.version >= 28) || (Env.browser === 'IE' && Env.version >= 10);
}()),
return_response_headers: True,
return_response_type: function(responseType) {
if (responseType === 'json' && !!window.JSON) { // we can fake this one even if it's not supported
return true;
}
return Env.can('return_response_type', responseType);
},
return_status_code: True,
report_upload_progress: Test(window.XMLHttpRequest && new XMLHttpRequest().upload),
resize_image: function() {
return I.can('access_binary') && Env.can('create_canvas');
},
select_file: function() {
return Env.can('use_fileinput') && window.File;
},
select_folder: function() {
return I.can('select_file') && Env.browser === 'Chrome' && Env.version >= 21;
},
select_multiple: function() {
// it is buggy on Safari Windows and iOS
return I.can('select_file') &&
!(Env.browser === 'Safari' && Env.os === 'Windows') &&
!(Env.os === 'iOS' && Env.verComp(Env.osVersion, "7.0.4", '<'));
},
send_binary_string: Test(window.XMLHttpRequest && (new XMLHttpRequest().sendAsBinary || (window.Uint8Array && window.ArrayBuffer))),
send_custom_headers: Test(window.XMLHttpRequest),
send_multipart: function() {
return !!(window.XMLHttpRequest && new XMLHttpRequest().upload && window.FormData) || I.can('send_binary_string');
},
slice_blob: Test(window.File && (File.prototype.mozSlice || File.prototype.webkitSlice || File.prototype.slice)),
stream_upload: function(){
return I.can('slice_blob') && I.can('send_multipart');
},
summon_file_dialog: Test(function() { // yeah... some dirty sniffing here...
return (Env.browser === 'Firefox' && Env.version >= 4) ||
(Env.browser === 'Opera' && Env.version >= 12) ||
(Env.browser === 'IE' && Env.version >= 10) ||
!!~Basic.inArray(Env.browser, ['Chrome', 'Safari']);
}()),
upload_filesize: True
},
arguments[2]
);
Runtime.call(this, options, (arguments[1] || type), caps);
Basic.extend(this, {
init : function() {
this.trigger("Init");
},
destroy: (function(destroy) { // extend default destroy method
return function() {
destroy.call(I);
destroy = I = null;
};
}(this.destroy))
});
Basic.extend(this.getShim(), extensions);
}
Runtime.addConstructor(type, Html5Runtime);
return extensions;
});
// Included from: src/javascript/runtime/html5/file/Blob.js
/**
* Blob.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/file/Blob
@private
*/
define("moxie/runtime/html5/file/Blob", [
"moxie/runtime/html5/Runtime",
"moxie/file/Blob"
], function(extensions, Blob) {
function HTML5Blob() {
function w3cBlobSlice(blob, start, end) {
var blobSlice;
if (window.File.prototype.slice) {
try {
blob.slice(); // depricated version will throw WRONG_ARGUMENTS_ERR exception
return blob.slice(start, end);
} catch (e) {
// depricated slice method
return blob.slice(start, end - start);
}
// slice method got prefixed: https://bugzilla.mozilla.org/show_bug.cgi?id=649672
} else if ((blobSlice = window.File.prototype.webkitSlice || window.File.prototype.mozSlice)) {
return blobSlice.call(blob, start, end);
} else {
return null; // or throw some exception
}
}
this.slice = function() {
return new Blob(this.getRuntime().uid, w3cBlobSlice.apply(this, arguments));
};
}
return (extensions.Blob = HTML5Blob);
});
// Included from: src/javascript/core/utils/Events.js
/**
* Events.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Events', [
'moxie/core/utils/Basic'
], function(Basic) {
var eventhash = {}, uid = 'moxie_' + Basic.guid();
// IE W3C like event funcs
function preventDefault() {
this.returnValue = false;
}
function stopPropagation() {
this.cancelBubble = true;
}
/**
Adds an event handler to the specified object and store reference to the handler
in objects internal Plupload registry (@see removeEvent).
@method addEvent
@for Utils
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Name to add event listener to.
@param {Function} callback Function to call when event occurs.
@param {String} [key] that might be used to add specifity to the event record.
*/
var addEvent = function(obj, name, callback, key) {
var func, events;
name = name.toLowerCase();
// Add event listener
if (obj.addEventListener) {
func = callback;
obj.addEventListener(name, func, false);
} else if (obj.attachEvent) {
func = function() {
var evt = window.event;
if (!evt.target) {
evt.target = evt.srcElement;
}
evt.preventDefault = preventDefault;
evt.stopPropagation = stopPropagation;
callback(evt);
};
obj.attachEvent('on' + name, func);
}
// Log event handler to objects internal mOxie registry
if (!obj[uid]) {
obj[uid] = Basic.guid();
}
if (!eventhash.hasOwnProperty(obj[uid])) {
eventhash[obj[uid]] = {};
}
events = eventhash[obj[uid]];
if (!events.hasOwnProperty(name)) {
events[name] = [];
}
events[name].push({
func: func,
orig: callback, // store original callback for IE
key: key
});
};
/**
Remove event handler from the specified object. If third argument (callback)
is not specified remove all events with the specified name.
@method removeEvent
@static
@param {Object} obj DOM element to remove event listener(s) from.
@param {String} name Name of event listener to remove.
@param {Function|String} [callback] might be a callback or unique key to match.
*/
var removeEvent = function(obj, name, callback) {
var type, undef;
name = name.toLowerCase();
if (obj[uid] && eventhash[obj[uid]] && eventhash[obj[uid]][name]) {
type = eventhash[obj[uid]][name];
} else {
return;
}
for (var i = type.length - 1; i >= 0; i--) {
// undefined or not, key should match
if (type[i].orig === callback || type[i].key === callback) {
if (obj.removeEventListener) {
obj.removeEventListener(name, type[i].func, false);
} else if (obj.detachEvent) {
obj.detachEvent('on'+name, type[i].func);
}
type[i].orig = null;
type[i].func = null;
type.splice(i, 1);
// If callback was passed we are done here, otherwise proceed
if (callback !== undef) {
break;
}
}
}
// If event array got empty, remove it
if (!type.length) {
delete eventhash[obj[uid]][name];
}
// If mOxie registry has become empty, remove it
if (Basic.isEmptyObj(eventhash[obj[uid]])) {
delete eventhash[obj[uid]];
// IE doesn't let you remove DOM object property with - delete
try {
delete obj[uid];
} catch(e) {
obj[uid] = undef;
}
}
};
/**
Remove all kind of events from the specified object
@method removeAllEvents
@static
@param {Object} obj DOM element to remove event listeners from.
@param {String} [key] unique key to match, when removing events.
*/
var removeAllEvents = function(obj, key) {
if (!obj || !obj[uid]) {
return;
}
Basic.each(eventhash[obj[uid]], function(events, name) {
removeEvent(obj, name, key);
});
};
return {
addEvent: addEvent,
removeEvent: removeEvent,
removeAllEvents: removeAllEvents
};
});
// Included from: src/javascript/runtime/html5/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/file/FileInput
@private
*/
define("moxie/runtime/html5/file/FileInput", [
"moxie/runtime/html5/Runtime",
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/utils/Events",
"moxie/core/utils/Mime",
"moxie/core/utils/Env"
], function(extensions, Basic, Dom, Events, Mime, Env) {
function FileInput() {
var _files = [], _options;
Basic.extend(this, {
init: function(options) {
var comp = this, I = comp.getRuntime(), input, shimContainer, mimes, browseButton, zIndex, top;
_options = options;
_files = [];
// figure out accept string
mimes = _options.accept.mimes || Mime.extList2mimes(_options.accept, I.can('filter_by_extension'));
shimContainer = I.getShimContainer();
shimContainer.innerHTML = '<input id="' + I.uid +'" type="file" style="font-size:999px;opacity:0;"' +
(_options.multiple && I.can('select_multiple') ? 'multiple' : '') +
(_options.directory && I.can('select_folder') ? 'webkitdirectory directory' : '') + // Chrome 11+
(mimes ? ' accept="' + mimes.join(',') + '"' : '') + ' />';
input = Dom.get(I.uid);
// prepare file input to be placed underneath the browse_button element
Basic.extend(input.style, {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%'
});
browseButton = Dom.get(_options.browse_button);
// Route click event to the input[type=file] element for browsers that support such behavior
if (I.can('summon_file_dialog')) {
if (Dom.getStyle(browseButton, 'position') === 'static') {
browseButton.style.position = 'relative';
}
zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 1;
browseButton.style.zIndex = zIndex;
shimContainer.style.zIndex = zIndex - 1;
Events.addEvent(browseButton, 'click', function(e) {
var input = Dom.get(I.uid);
if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file]
input.click();
}
e.preventDefault();
}, comp.uid);
}
/* Since we have to place input[type=file] on top of the browse_button for some browsers,
browse_button loses interactivity, so we restore it here */
top = I.can('summon_file_dialog') ? browseButton : shimContainer;
Events.addEvent(top, 'mouseover', function() {
comp.trigger('mouseenter');
}, comp.uid);
Events.addEvent(top, 'mouseout', function() {
comp.trigger('mouseleave');
}, comp.uid);
Events.addEvent(top, 'mousedown', function() {
comp.trigger('mousedown');
}, comp.uid);
Events.addEvent(Dom.get(_options.container), 'mouseup', function() {
comp.trigger('mouseup');
}, comp.uid);
input.onchange = function onChange() { // there should be only one handler for this
_files = [];
if (_options.directory) {
// folders are represented by dots, filter them out (Chrome 11+)
Basic.each(this.files, function(file) {
if (file.name !== ".") { // if it doesn't looks like a folder
_files.push(file);
}
});
} else {
_files = [].slice.call(this.files);
}
// clearing the value enables the user to select the same file again if they want to
if (Env.browser !== 'IE') {
this.value = '';
} else {
// in IE input[type="file"] is read-only so the only way to reset it is to re-insert it
var clone = this.cloneNode(true);
this.parentNode.replaceChild(clone, this);
clone.onchange = onChange;
}
comp.trigger('change');
};
// ready event is perfectly asynchronous
comp.trigger({
type: 'ready',
async: true
});
shimContainer = null;
},
getFiles: function() {
return _files;
},
disable: function(state) {
var I = this.getRuntime(), input;
if ((input = Dom.get(I.uid))) {
input.disabled = !!state;
}
},
destroy: function() {
var I = this.getRuntime()
, shim = I.getShim()
, shimContainer = I.getShimContainer()
;
Events.removeAllEvents(shimContainer, this.uid);
Events.removeAllEvents(_options && Dom.get(_options.container), this.uid);
Events.removeAllEvents(_options && Dom.get(_options.browse_button), this.uid);
if (shimContainer) {
shimContainer.innerHTML = '';
}
shim.removeInstance(this.uid);
_files = _options = shimContainer = shim = null;
}
});
}
return (extensions.FileInput = FileInput);
});
// Included from: src/javascript/runtime/html5/file/FileDrop.js
/**
* FileDrop.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/file/FileDrop
@private
*/
define("moxie/runtime/html5/file/FileDrop", [
"moxie/runtime/html5/Runtime",
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/utils/Events",
"moxie/core/utils/Mime"
], function(extensions, Basic, Dom, Events, Mime) {
function FileDrop() {
var _files = [], _allowedExts = [], _options;
Basic.extend(this, {
init: function(options) {
var comp = this, dropZone;
_options = options;
_allowedExts = _extractExts(_options.accept);
dropZone = _options.container;
Events.addEvent(dropZone, 'dragover', function(e) {
e.preventDefault();
e.stopPropagation();
e.dataTransfer.dropEffect = 'copy';
}, comp.uid);
Events.addEvent(dropZone, 'drop', function(e) {
e.preventDefault();
e.stopPropagation();
_files = [];
// Chrome 21+ accepts folders via Drag'n'Drop
if (e.dataTransfer.items && e.dataTransfer.items[0].webkitGetAsEntry) {
_readItems(e.dataTransfer.items, function() {
comp.trigger("drop");
});
} else {
Basic.each(e.dataTransfer.files, function(file) {
if (_isAcceptable(file)) {
_files.push(file);
}
});
comp.trigger("drop");
}
}, comp.uid);
Events.addEvent(dropZone, 'dragenter', function(e) {
e.preventDefault();
e.stopPropagation();
comp.trigger("dragenter");
}, comp.uid);
Events.addEvent(dropZone, 'dragleave', function(e) {
e.preventDefault();
e.stopPropagation();
comp.trigger("dragleave");
}, comp.uid);
},
getFiles: function() {
return _files;
},
destroy: function() {
Events.removeAllEvents(_options && Dom.get(_options.container), this.uid);
_files = _allowedExts = _options = null;
}
});
function _extractExts(accept) {
var exts = [];
for (var i = 0; i < accept.length; i++) {
[].push.apply(exts, accept[i].extensions.split(/\s*,\s*/));
}
return Basic.inArray('*', exts) === -1 ? exts : [];
}
function _isAcceptable(file) {
var ext = Mime.getFileExtension(file.name);
return !ext || !_allowedExts.length || Basic.inArray(ext, _allowedExts) !== -1;
}
function _readItems(items, cb) {
var entries = [];
Basic.each(items, function(item) {
var entry = item.webkitGetAsEntry();
// Address #998 (https://code.google.com/p/chromium/issues/detail?id=332579)
if (entry) {
// file() fails on OSX when the filename contains a special character (e.g. umlaut): see #61
if (entry.isFile) {
var file = item.getAsFile();
if (_isAcceptable(file)) {
_files.push(file);
}
} else {
entries.push(entry);
}
}
});
if (entries.length) {
_readEntries(entries, cb);
} else {
cb();
}
}
function _readEntries(entries, cb) {
var queue = [];
Basic.each(entries, function(entry) {
queue.push(function(cbcb) {
_readEntry(entry, cbcb);
});
});
Basic.inSeries(queue, function() {
cb();
});
}
function _readEntry(entry, cb) {
if (entry.isFile) {
entry.file(function(file) {
if (_isAcceptable(file)) {
_files.push(file);
}
cb();
}, function() {
// fire an error event maybe
cb();
});
} else if (entry.isDirectory) {
_readDirEntry(entry, cb);
} else {
cb(); // not file, not directory? what then?..
}
}
function _readDirEntry(dirEntry, cb) {
var entries = [], dirReader = dirEntry.createReader();
// keep quering recursively till no more entries
function getEntries(cbcb) {
dirReader.readEntries(function(moreEntries) {
if (moreEntries.length) {
[].push.apply(entries, moreEntries);
getEntries(cbcb);
} else {
cbcb();
}
}, cbcb);
}
// ...and you thought FileReader was crazy...
getEntries(function() {
_readEntries(entries, cb);
});
}
}
return (extensions.FileDrop = FileDrop);
});
// Included from: src/javascript/runtime/html5/file/FileReader.js
/**
* FileReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/file/FileReader
@private
*/
define("moxie/runtime/html5/file/FileReader", [
"moxie/runtime/html5/Runtime",
"moxie/core/utils/Encode",
"moxie/core/utils/Basic"
], function(extensions, Encode, Basic) {
function FileReader() {
var _fr, _convertToBinary = false;
Basic.extend(this, {
read: function(op, blob) {
var target = this;
_fr = new window.FileReader();
_fr.addEventListener('progress', function(e) {
target.trigger(e);
});
_fr.addEventListener('load', function(e) {
target.trigger(e);
});
_fr.addEventListener('error', function(e) {
target.trigger(e, _fr.error);
});
_fr.addEventListener('loadend', function() {
_fr = null;
});
if (Basic.typeOf(_fr[op]) === 'function') {
_convertToBinary = false;
_fr[op](blob.getSource());
} else if (op === 'readAsBinaryString') { // readAsBinaryString is depricated in general and never existed in IE10+
_convertToBinary = true;
_fr.readAsDataURL(blob.getSource());
}
},
getResult: function() {
return _fr && _fr.result ? (_convertToBinary ? _toBinary(_fr.result) : _fr.result) : null;
},
abort: function() {
if (_fr) {
_fr.abort();
}
},
destroy: function() {
_fr = null;
}
});
function _toBinary(str) {
return Encode.atob(str.substring(str.indexOf('base64,') + 7));
}
}
return (extensions.FileReader = FileReader);
});
// Included from: src/javascript/runtime/html5/xhr/XMLHttpRequest.js
/**
* XMLHttpRequest.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global ActiveXObject:true */
/**
@class moxie/runtime/html5/xhr/XMLHttpRequest
@private
*/
define("moxie/runtime/html5/xhr/XMLHttpRequest", [
"moxie/runtime/html5/Runtime",
"moxie/core/utils/Basic",
"moxie/core/utils/Mime",
"moxie/core/utils/Url",
"moxie/file/File",
"moxie/file/Blob",
"moxie/xhr/FormData",
"moxie/core/Exceptions",
"moxie/core/utils/Env"
], function(extensions, Basic, Mime, Url, File, Blob, FormData, x, Env) {
function XMLHttpRequest() {
var self = this
, _xhr
, _filename
;
Basic.extend(this, {
send: function(meta, data) {
var target = this
, isGecko2_5_6 = (Env.browser === 'Mozilla' && Env.version >= 4 && Env.version < 7)
, isAndroidBrowser = Env.browser === 'Android Browser'
, mustSendAsBinary = false
;
// extract file name
_filename = meta.url.replace(/^.+?\/([\w\-\.]+)$/, '$1').toLowerCase();
_xhr = _getNativeXHR();
_xhr.open(meta.method, meta.url, meta.async, meta.user, meta.password);
// prepare data to be sent
if (data instanceof Blob) {
if (data.isDetached()) {
mustSendAsBinary = true;
}
data = data.getSource();
} else if (data instanceof FormData) {
if (data.hasBlob()) {
if (data.getBlob().isDetached()) {
data = _prepareMultipart.call(target, data); // _xhr must be instantiated and be in OPENED state
mustSendAsBinary = true;
} else if ((isGecko2_5_6 || isAndroidBrowser) && Basic.typeOf(data.getBlob().getSource()) === 'blob' && window.FileReader) {
// Gecko 2/5/6 can't send blob in FormData: https://bugzilla.mozilla.org/show_bug.cgi?id=649150
// Android browsers (default one and Dolphin) seem to have the same issue, see: #613
_preloadAndSend.call(target, meta, data);
return; // _preloadAndSend will reinvoke send() with transmutated FormData =%D
}
}
// transfer fields to real FormData
if (data instanceof FormData) { // if still a FormData, e.g. not mangled by _prepareMultipart()
var fd = new window.FormData();
data.each(function(value, name) {
if (value instanceof Blob) {
fd.append(name, value.getSource());
} else {
fd.append(name, value);
}
});
data = fd;
}
}
// if XHR L2
if (_xhr.upload) {
if (meta.withCredentials) {
_xhr.withCredentials = true;
}
_xhr.addEventListener('load', function(e) {
target.trigger(e);
});
_xhr.addEventListener('error', function(e) {
target.trigger(e);
});
// additionally listen to progress events
_xhr.addEventListener('progress', function(e) {
target.trigger(e);
});
_xhr.upload.addEventListener('progress', function(e) {
target.trigger({
type: 'UploadProgress',
loaded: e.loaded,
total: e.total
});
});
// ... otherwise simulate XHR L2
} else {
_xhr.onreadystatechange = function onReadyStateChange() {
// fake Level 2 events
switch (_xhr.readyState) {
case 1: // XMLHttpRequest.OPENED
// readystatechanged is fired twice for OPENED state (in IE and Mozilla) - neu
break;
// looks like HEADERS_RECEIVED (state 2) is not reported in Opera (or it's old versions) - neu
case 2: // XMLHttpRequest.HEADERS_RECEIVED
break;
case 3: // XMLHttpRequest.LOADING
// try to fire progress event for not XHR L2
var total, loaded;
try {
if (Url.hasSameOrigin(meta.url)) { // Content-Length not accessible for cross-domain on some browsers
total = _xhr.getResponseHeader('Content-Length') || 0; // old Safari throws an exception here
}
if (_xhr.responseText) { // responseText was introduced in IE7
loaded = _xhr.responseText.length;
}
} catch(ex) {
total = loaded = 0;
}
target.trigger({
type: 'progress',
lengthComputable: !!total,
total: parseInt(total, 10),
loaded: loaded
});
break;
case 4: // XMLHttpRequest.DONE
// release readystatechange handler (mostly for IE)
_xhr.onreadystatechange = function() {};
// usually status 0 is returned when server is unreachable, but FF also fails to status 0 for 408 timeout
if (_xhr.status === 0) {
target.trigger('error');
} else {
target.trigger('load');
}
break;
}
};
}
// set request headers
if (!Basic.isEmptyObj(meta.headers)) {
Basic.each(meta.headers, function(value, header) {
_xhr.setRequestHeader(header, value);
});
}
// request response type
if ("" !== meta.responseType && 'responseType' in _xhr) {
if ('json' === meta.responseType && !Env.can('return_response_type', 'json')) { // we can fake this one
_xhr.responseType = 'text';
} else {
_xhr.responseType = meta.responseType;
}
}
// send ...
if (!mustSendAsBinary) {
_xhr.send(data);
} else {
if (_xhr.sendAsBinary) { // Gecko
_xhr.sendAsBinary(data);
} else { // other browsers having support for typed arrays
(function() {
// mimic Gecko's sendAsBinary
var ui8a = new Uint8Array(data.length);
for (var i = 0; i < data.length; i++) {
ui8a[i] = (data.charCodeAt(i) & 0xff);
}
_xhr.send(ui8a.buffer);
}());
}
}
target.trigger('loadstart');
},
getStatus: function() {
// according to W3C spec it should return 0 for readyState < 3, but instead it throws an exception
try {
if (_xhr) {
return _xhr.status;
}
} catch(ex) {}
return 0;
},
getResponse: function(responseType) {
var I = this.getRuntime();
try {
switch (responseType) {
case 'blob':
var file = new File(I.uid, _xhr.response);
// try to extract file name from content-disposition if possible (might be - not, if CORS for example)
var disposition = _xhr.getResponseHeader('Content-Disposition');
if (disposition) {
// extract filename from response header if available
var match = disposition.match(/filename=([\'\"'])([^\1]+)\1/);
if (match) {
_filename = match[2];
}
}
file.name = _filename;
// pre-webkit Opera doesn't set type property on the blob response
if (!file.type) {
file.type = Mime.getFileMime(_filename);
}
return file;
case 'json':
if (!Env.can('return_response_type', 'json')) {
return _xhr.status === 200 && !!window.JSON ? JSON.parse(_xhr.responseText) : null;
}
return _xhr.response;
case 'document':
return _getDocument(_xhr);
default:
return _xhr.responseText !== '' ? _xhr.responseText : null; // against the specs, but for consistency across the runtimes
}
} catch(ex) {
return null;
}
},
getAllResponseHeaders: function() {
try {
return _xhr.getAllResponseHeaders();
} catch(ex) {}
return '';
},
abort: function() {
if (_xhr) {
_xhr.abort();
}
},
destroy: function() {
self = _filename = null;
}
});
// here we go... ugly fix for ugly bug
function _preloadAndSend(meta, data) {
var target = this, blob, fr;
// get original blob
blob = data.getBlob().getSource();
// preload blob in memory to be sent as binary string
fr = new window.FileReader();
fr.onload = function() {
// overwrite original blob
data.append(data.getBlobName(), new Blob(null, {
type: blob.type,
data: fr.result
}));
// invoke send operation again
self.send.call(target, meta, data);
};
fr.readAsBinaryString(blob);
}
function _getNativeXHR() {
if (window.XMLHttpRequest && !(Env.browser === 'IE' && Env.version < 8)) { // IE7 has native XHR but it's buggy
return new window.XMLHttpRequest();
} else {
return (function() {
var progIDs = ['Msxml2.XMLHTTP.6.0', 'Microsoft.XMLHTTP']; // if 6.0 available, use it, otherwise failback to default 3.0
for (var i = 0; i < progIDs.length; i++) {
try {
return new ActiveXObject(progIDs[i]);
} catch (ex) {}
}
})();
}
}
// @credits Sergey Ilinsky (http://www.ilinsky.com/)
function _getDocument(xhr) {
var rXML = xhr.responseXML;
var rText = xhr.responseText;
// Try parsing responseText (@see: http://www.ilinsky.com/articles/XMLHttpRequest/#bugs-ie-responseXML-content-type)
if (Env.browser === 'IE' && rText && rXML && !rXML.documentElement && /[^\/]+\/[^\+]+\+xml/.test(xhr.getResponseHeader("Content-Type"))) {
rXML = new window.ActiveXObject("Microsoft.XMLDOM");
rXML.async = false;
rXML.validateOnParse = false;
rXML.loadXML(rText);
}
// Check if there is no error in document
if (rXML) {
if ((Env.browser === 'IE' && rXML.parseError !== 0) || !rXML.documentElement || rXML.documentElement.tagName === "parsererror") {
return null;
}
}
return rXML;
}
function _prepareMultipart(fd) {
var boundary = '----moxieboundary' + new Date().getTime()
, dashdash = '--'
, crlf = '\r\n'
, multipart = ''
, I = this.getRuntime()
;
if (!I.can('send_binary_string')) {
throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR);
}
_xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + boundary);
// append multipart parameters
fd.each(function(value, name) {
// Firefox 3.6 failed to convert multibyte characters to UTF-8 in sendAsBinary(),
// so we try it here ourselves with: unescape(encodeURIComponent(value))
if (value instanceof Blob) {
// Build RFC2388 blob
multipart += dashdash + boundary + crlf +
'Content-Disposition: form-data; name="' + name + '"; filename="' + unescape(encodeURIComponent(value.name || 'blob')) + '"' + crlf +
'Content-Type: ' + (value.type || 'application/octet-stream') + crlf + crlf +
value.getSource() + crlf;
} else {
multipart += dashdash + boundary + crlf +
'Content-Disposition: form-data; name="' + name + '"' + crlf + crlf +
unescape(encodeURIComponent(value)) + crlf;
}
});
multipart += dashdash + boundary + dashdash + crlf;
return multipart;
}
}
return (extensions.XMLHttpRequest = XMLHttpRequest);
});
// Included from: src/javascript/runtime/html5/utils/BinaryReader.js
/**
* BinaryReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/utils/BinaryReader
@private
*/
define("moxie/runtime/html5/utils/BinaryReader", [], function() {
return function() {
var II = false, bin;
// Private functions
function read(idx, size) {
var mv = II ? 0 : -8 * (size - 1), sum = 0, i;
for (i = 0; i < size; i++) {
sum |= (bin.charCodeAt(idx + i) << Math.abs(mv + i*8));
}
return sum;
}
function putstr(segment, idx, length) {
length = arguments.length === 3 ? length : bin.length - idx - 1;
bin = bin.substr(0, idx) + segment + bin.substr(length + idx);
}
function write(idx, num, size) {
var str = '', mv = II ? 0 : -8 * (size - 1), i;
for (i = 0; i < size; i++) {
str += String.fromCharCode((num >> Math.abs(mv + i*8)) & 255);
}
putstr(str, idx, size);
}
// Public functions
return {
II: function(order) {
if (order === undefined) {
return II;
} else {
II = order;
}
},
init: function(binData) {
II = false;
bin = binData;
},
SEGMENT: function(idx, length, segment) {
switch (arguments.length) {
case 1:
return bin.substr(idx, bin.length - idx - 1);
case 2:
return bin.substr(idx, length);
case 3:
putstr(segment, idx, length);
break;
default: return bin;
}
},
BYTE: function(idx) {
return read(idx, 1);
},
SHORT: function(idx) {
return read(idx, 2);
},
LONG: function(idx, num) {
if (num === undefined) {
return read(idx, 4);
} else {
write(idx, num, 4);
}
},
SLONG: function(idx) { // 2's complement notation
var num = read(idx, 4);
return (num > 2147483647 ? num - 4294967296 : num);
},
STRING: function(idx, size) {
var str = '';
for (size += idx; idx < size; idx++) {
str += String.fromCharCode(read(idx, 1));
}
return str;
}
};
};
});
// Included from: src/javascript/runtime/html5/image/JPEGHeaders.js
/**
* JPEGHeaders.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/JPEGHeaders
@private
*/
define("moxie/runtime/html5/image/JPEGHeaders", [
"moxie/runtime/html5/utils/BinaryReader"
], function(BinaryReader) {
return function JPEGHeaders(data) {
var headers = [], read, idx, marker, length = 0;
read = new BinaryReader();
read.init(data);
// Check if data is jpeg
if (read.SHORT(0) !== 0xFFD8) {
return;
}
idx = 2;
while (idx <= data.length) {
marker = read.SHORT(idx);
// omit RST (restart) markers
if (marker >= 0xFFD0 && marker <= 0xFFD7) {
idx += 2;
continue;
}
// no headers allowed after SOS marker
if (marker === 0xFFDA || marker === 0xFFD9) {
break;
}
length = read.SHORT(idx + 2) + 2;
// APPn marker detected
if (marker >= 0xFFE1 && marker <= 0xFFEF) {
headers.push({
hex: marker,
name: 'APP' + (marker & 0x000F),
start: idx,
length: length,
segment: read.SEGMENT(idx, length)
});
}
idx += length;
}
read.init(null); // free memory
return {
headers: headers,
restore: function(data) {
var max, i;
read.init(data);
idx = read.SHORT(2) == 0xFFE0 ? 4 + read.SHORT(4) : 2;
for (i = 0, max = headers.length; i < max; i++) {
read.SEGMENT(idx, 0, headers[i].segment);
idx += headers[i].length;
}
data = read.SEGMENT();
read.init(null);
return data;
},
strip: function(data) {
var headers, jpegHeaders, i;
jpegHeaders = new JPEGHeaders(data);
headers = jpegHeaders.headers;
jpegHeaders.purge();
read.init(data);
i = headers.length;
while (i--) {
read.SEGMENT(headers[i].start, headers[i].length, '');
}
data = read.SEGMENT();
read.init(null);
return data;
},
get: function(name) {
var array = [];
for (var i = 0, max = headers.length; i < max; i++) {
if (headers[i].name === name.toUpperCase()) {
array.push(headers[i].segment);
}
}
return array;
},
set: function(name, segment) {
var array = [], i, ii, max;
if (typeof(segment) === 'string') {
array.push(segment);
} else {
array = segment;
}
for (i = ii = 0, max = headers.length; i < max; i++) {
if (headers[i].name === name.toUpperCase()) {
headers[i].segment = array[ii];
headers[i].length = array[ii].length;
ii++;
}
if (ii >= array.length) {
break;
}
}
},
purge: function() {
headers = [];
read.init(null);
read = null;
}
};
};
});
// Included from: src/javascript/runtime/html5/image/ExifParser.js
/**
* ExifParser.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/ExifParser
@private
*/
define("moxie/runtime/html5/image/ExifParser", [
"moxie/core/utils/Basic",
"moxie/runtime/html5/utils/BinaryReader"
], function(Basic, BinaryReader) {
return function ExifParser() {
// Private ExifParser fields
var data, tags, Tiff, offsets = {}, tagDescs;
data = new BinaryReader();
tags = {
tiff : {
/*
The image orientation viewed in terms of rows and columns.
1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.
2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.
3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.
4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.
5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.
6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.
7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.
8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.
*/
0x0112: 'Orientation',
0x010E: 'ImageDescription',
0x010F: 'Make',
0x0110: 'Model',
0x0131: 'Software',
0x8769: 'ExifIFDPointer',
0x8825: 'GPSInfoIFDPointer'
},
exif : {
0x9000: 'ExifVersion',
0xA001: 'ColorSpace',
0xA002: 'PixelXDimension',
0xA003: 'PixelYDimension',
0x9003: 'DateTimeOriginal',
0x829A: 'ExposureTime',
0x829D: 'FNumber',
0x8827: 'ISOSpeedRatings',
0x9201: 'ShutterSpeedValue',
0x9202: 'ApertureValue' ,
0x9207: 'MeteringMode',
0x9208: 'LightSource',
0x9209: 'Flash',
0x920A: 'FocalLength',
0xA402: 'ExposureMode',
0xA403: 'WhiteBalance',
0xA406: 'SceneCaptureType',
0xA404: 'DigitalZoomRatio',
0xA408: 'Contrast',
0xA409: 'Saturation',
0xA40A: 'Sharpness'
},
gps : {
0x0000: 'GPSVersionID',
0x0001: 'GPSLatitudeRef',
0x0002: 'GPSLatitude',
0x0003: 'GPSLongitudeRef',
0x0004: 'GPSLongitude'
}
};
tagDescs = {
'ColorSpace': {
1: 'sRGB',
0: 'Uncalibrated'
},
'MeteringMode': {
0: 'Unknown',
1: 'Average',
2: 'CenterWeightedAverage',
3: 'Spot',
4: 'MultiSpot',
5: 'Pattern',
6: 'Partial',
255: 'Other'
},
'LightSource': {
1: 'Daylight',
2: 'Fliorescent',
3: 'Tungsten',
4: 'Flash',
9: 'Fine weather',
10: 'Cloudy weather',
11: 'Shade',
12: 'Daylight fluorescent (D 5700 - 7100K)',
13: 'Day white fluorescent (N 4600 -5400K)',
14: 'Cool white fluorescent (W 3900 - 4500K)',
15: 'White fluorescent (WW 3200 - 3700K)',
17: 'Standard light A',
18: 'Standard light B',
19: 'Standard light C',
20: 'D55',
21: 'D65',
22: 'D75',
23: 'D50',
24: 'ISO studio tungsten',
255: 'Other'
},
'Flash': {
0x0000: 'Flash did not fire.',
0x0001: 'Flash fired.',
0x0005: 'Strobe return light not detected.',
0x0007: 'Strobe return light detected.',
0x0009: 'Flash fired, compulsory flash mode',
0x000D: 'Flash fired, compulsory flash mode, return light not detected',
0x000F: 'Flash fired, compulsory flash mode, return light detected',
0x0010: 'Flash did not fire, compulsory flash mode',
0x0018: 'Flash did not fire, auto mode',
0x0019: 'Flash fired, auto mode',
0x001D: 'Flash fired, auto mode, return light not detected',
0x001F: 'Flash fired, auto mode, return light detected',
0x0020: 'No flash function',
0x0041: 'Flash fired, red-eye reduction mode',
0x0045: 'Flash fired, red-eye reduction mode, return light not detected',
0x0047: 'Flash fired, red-eye reduction mode, return light detected',
0x0049: 'Flash fired, compulsory flash mode, red-eye reduction mode',
0x004D: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected',
0x004F: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected',
0x0059: 'Flash fired, auto mode, red-eye reduction mode',
0x005D: 'Flash fired, auto mode, return light not detected, red-eye reduction mode',
0x005F: 'Flash fired, auto mode, return light detected, red-eye reduction mode'
},
'ExposureMode': {
0: 'Auto exposure',
1: 'Manual exposure',
2: 'Auto bracket'
},
'WhiteBalance': {
0: 'Auto white balance',
1: 'Manual white balance'
},
'SceneCaptureType': {
0: 'Standard',
1: 'Landscape',
2: 'Portrait',
3: 'Night scene'
},
'Contrast': {
0: 'Normal',
1: 'Soft',
2: 'Hard'
},
'Saturation': {
0: 'Normal',
1: 'Low saturation',
2: 'High saturation'
},
'Sharpness': {
0: 'Normal',
1: 'Soft',
2: 'Hard'
},
// GPS related
'GPSLatitudeRef': {
N: 'North latitude',
S: 'South latitude'
},
'GPSLongitudeRef': {
E: 'East longitude',
W: 'West longitude'
}
};
function extractTags(IFD_offset, tags2extract) {
var length = data.SHORT(IFD_offset), i, ii,
tag, type, count, tagOffset, offset, value, values = [], hash = {};
for (i = 0; i < length; i++) {
// Set binary reader pointer to beginning of the next tag
offset = tagOffset = IFD_offset + 12 * i + 2;
tag = tags2extract[data.SHORT(offset)];
if (tag === undefined) {
continue; // Not the tag we requested
}
type = data.SHORT(offset+=2);
count = data.LONG(offset+=2);
offset += 4;
values = [];
switch (type) {
case 1: // BYTE
case 7: // UNDEFINED
if (count > 4) {
offset = data.LONG(offset) + offsets.tiffHeader;
}
for (ii = 0; ii < count; ii++) {
values[ii] = data.BYTE(offset + ii);
}
break;
case 2: // STRING
if (count > 4) {
offset = data.LONG(offset) + offsets.tiffHeader;
}
hash[tag] = data.STRING(offset, count - 1);
continue;
case 3: // SHORT
if (count > 2) {
offset = data.LONG(offset) + offsets.tiffHeader;
}
for (ii = 0; ii < count; ii++) {
values[ii] = data.SHORT(offset + ii*2);
}
break;
case 4: // LONG
if (count > 1) {
offset = data.LONG(offset) + offsets.tiffHeader;
}
for (ii = 0; ii < count; ii++) {
values[ii] = data.LONG(offset + ii*4);
}
break;
case 5: // RATIONAL
offset = data.LONG(offset) + offsets.tiffHeader;
for (ii = 0; ii < count; ii++) {
values[ii] = data.LONG(offset + ii*4) / data.LONG(offset + ii*4 + 4);
}
break;
case 9: // SLONG
offset = data.LONG(offset) + offsets.tiffHeader;
for (ii = 0; ii < count; ii++) {
values[ii] = data.SLONG(offset + ii*4);
}
break;
case 10: // SRATIONAL
offset = data.LONG(offset) + offsets.tiffHeader;
for (ii = 0; ii < count; ii++) {
values[ii] = data.SLONG(offset + ii*4) / data.SLONG(offset + ii*4 + 4);
}
break;
default:
continue;
}
value = (count == 1 ? values[0] : values);
if (tagDescs.hasOwnProperty(tag) && typeof value != 'object') {
hash[tag] = tagDescs[tag][value];
} else {
hash[tag] = value;
}
}
return hash;
}
function getIFDOffsets() {
var idx = offsets.tiffHeader;
// Set read order of multi-byte data
data.II(data.SHORT(idx) == 0x4949);
// Check if always present bytes are indeed present
if (data.SHORT(idx+=2) !== 0x002A) {
return false;
}
offsets.IFD0 = offsets.tiffHeader + data.LONG(idx += 2);
Tiff = extractTags(offsets.IFD0, tags.tiff);
if ('ExifIFDPointer' in Tiff) {
offsets.exifIFD = offsets.tiffHeader + Tiff.ExifIFDPointer;
delete Tiff.ExifIFDPointer;
}
if ('GPSInfoIFDPointer' in Tiff) {
offsets.gpsIFD = offsets.tiffHeader + Tiff.GPSInfoIFDPointer;
delete Tiff.GPSInfoIFDPointer;
}
return true;
}
// At the moment only setting of simple (LONG) values, that do not require offset recalculation, is supported
function setTag(ifd, tag, value) {
var offset, length, tagOffset, valueOffset = 0;
// If tag name passed translate into hex key
if (typeof(tag) === 'string') {
var tmpTags = tags[ifd.toLowerCase()];
for (var hex in tmpTags) {
if (tmpTags[hex] === tag) {
tag = hex;
break;
}
}
}
offset = offsets[ifd.toLowerCase() + 'IFD'];
length = data.SHORT(offset);
for (var i = 0; i < length; i++) {
tagOffset = offset + 12 * i + 2;
if (data.SHORT(tagOffset) == tag) {
valueOffset = tagOffset + 8;
break;
}
}
if (!valueOffset) {
return false;
}
data.LONG(valueOffset, value);
return true;
}
// Public functions
return {
init: function(segment) {
// Reset internal data
offsets = {
tiffHeader: 10
};
if (segment === undefined || !segment.length) {
return false;
}
data.init(segment);
// Check if that's APP1 and that it has EXIF
if (data.SHORT(0) === 0xFFE1 && data.STRING(4, 5).toUpperCase() === "EXIF\0") {
return getIFDOffsets();
}
return false;
},
TIFF: function() {
return Tiff;
},
EXIF: function() {
var Exif;
// Populate EXIF hash
Exif = extractTags(offsets.exifIFD, tags.exif);
// Fix formatting of some tags
if (Exif.ExifVersion && Basic.typeOf(Exif.ExifVersion) === 'array') {
for (var i = 0, exifVersion = ''; i < Exif.ExifVersion.length; i++) {
exifVersion += String.fromCharCode(Exif.ExifVersion[i]);
}
Exif.ExifVersion = exifVersion;
}
return Exif;
},
GPS: function() {
var GPS;
GPS = extractTags(offsets.gpsIFD, tags.gps);
// iOS devices (and probably some others) do not put in GPSVersionID tag (why?..)
if (GPS.GPSVersionID && Basic.typeOf(GPS.GPSVersionID) === 'array') {
GPS.GPSVersionID = GPS.GPSVersionID.join('.');
}
return GPS;
},
setExif: function(tag, value) {
// Right now only setting of width/height is possible
if (tag !== 'PixelXDimension' && tag !== 'PixelYDimension') {return false;}
return setTag('exif', tag, value);
},
getBinary: function() {
return data.SEGMENT();
},
purge: function() {
data.init(null);
data = Tiff = null;
offsets = {};
}
};
};
});
// Included from: src/javascript/runtime/html5/image/JPEG.js
/**
* JPEG.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/JPEG
@private
*/
define("moxie/runtime/html5/image/JPEG", [
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/runtime/html5/image/JPEGHeaders",
"moxie/runtime/html5/utils/BinaryReader",
"moxie/runtime/html5/image/ExifParser"
], function(Basic, x, JPEGHeaders, BinaryReader, ExifParser) {
function JPEG(binstr) {
var _binstr, _br, _hm, _ep, _info, hasExif;
function _getDimensions() {
var idx = 0, marker, length;
// examine all through the end, since some images might have very large APP segments
while (idx <= _binstr.length) {
marker = _br.SHORT(idx += 2);
if (marker >= 0xFFC0 && marker <= 0xFFC3) { // SOFn
idx += 5; // marker (2 bytes) + length (2 bytes) + Sample precision (1 byte)
return {
height: _br.SHORT(idx),
width: _br.SHORT(idx += 2)
};
}
length = _br.SHORT(idx += 2);
idx += length - 2;
}
return null;
}
_binstr = binstr;
_br = new BinaryReader();
_br.init(_binstr);
// check if it is jpeg
if (_br.SHORT(0) !== 0xFFD8) {
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
}
// backup headers
_hm = new JPEGHeaders(binstr);
// extract exif info
_ep = new ExifParser();
hasExif = !!_ep.init(_hm.get('app1')[0]);
// get dimensions
_info = _getDimensions.call(this);
Basic.extend(this, {
type: 'image/jpeg',
size: _binstr.length,
width: _info && _info.width || 0,
height: _info && _info.height || 0,
setExif: function(tag, value) {
if (!hasExif) {
return false; // or throw an exception
}
if (Basic.typeOf(tag) === 'object') {
Basic.each(tag, function(value, tag) {
_ep.setExif(tag, value);
});
} else {
_ep.setExif(tag, value);
}
// update internal headers
_hm.set('app1', _ep.getBinary());
},
writeHeaders: function() {
if (!arguments.length) {
// if no arguments passed, update headers internally
return (_binstr = _hm.restore(_binstr));
}
return _hm.restore(arguments[0]);
},
stripHeaders: function(binstr) {
return _hm.strip(binstr);
},
purge: function() {
_purge.call(this);
}
});
if (hasExif) {
this.meta = {
tiff: _ep.TIFF(),
exif: _ep.EXIF(),
gps: _ep.GPS()
};
}
function _purge() {
if (!_ep || !_hm || !_br) {
return; // ignore any repeating purge requests
}
_ep.purge();
_hm.purge();
_br.init(null);
_binstr = _info = _hm = _ep = _br = null;
}
}
return JPEG;
});
// Included from: src/javascript/runtime/html5/image/PNG.js
/**
* PNG.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/PNG
@private
*/
define("moxie/runtime/html5/image/PNG", [
"moxie/core/Exceptions",
"moxie/core/utils/Basic",
"moxie/runtime/html5/utils/BinaryReader"
], function(x, Basic, BinaryReader) {
function PNG(binstr) {
var _binstr, _br, _hm, _ep, _info;
_binstr = binstr;
_br = new BinaryReader();
_br.init(_binstr);
// check if it's png
(function() {
var idx = 0, i = 0
, signature = [0x8950, 0x4E47, 0x0D0A, 0x1A0A]
;
for (i = 0; i < signature.length; i++, idx += 2) {
if (signature[i] != _br.SHORT(idx)) {
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
}
}
}());
function _getDimensions() {
var chunk, idx;
chunk = _getChunkAt.call(this, 8);
if (chunk.type == 'IHDR') {
idx = chunk.start;
return {
width: _br.LONG(idx),
height: _br.LONG(idx += 4)
};
}
return null;
}
function _purge() {
if (!_br) {
return; // ignore any repeating purge requests
}
_br.init(null);
_binstr = _info = _hm = _ep = _br = null;
}
_info = _getDimensions.call(this);
Basic.extend(this, {
type: 'image/png',
size: _binstr.length,
width: _info.width,
height: _info.height,
purge: function() {
_purge.call(this);
}
});
// for PNG we can safely trigger purge automatically, as we do not keep any data for later
_purge.call(this);
function _getChunkAt(idx) {
var length, type, start, CRC;
length = _br.LONG(idx);
type = _br.STRING(idx += 4, 4);
start = idx += 4;
CRC = _br.LONG(idx + length);
return {
length: length,
type: type,
start: start,
CRC: CRC
};
}
}
return PNG;
});
// Included from: src/javascript/runtime/html5/image/ImageInfo.js
/**
* ImageInfo.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/ImageInfo
@private
*/
define("moxie/runtime/html5/image/ImageInfo", [
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/runtime/html5/image/JPEG",
"moxie/runtime/html5/image/PNG"
], function(Basic, x, JPEG, PNG) {
/**
Optional image investigation tool for HTML5 runtime. Provides the following features:
- ability to distinguish image type (JPEG or PNG) by signature
- ability to extract image width/height directly from it's internals, without preloading in memory (fast)
- ability to extract APP headers from JPEGs (Exif, GPS, etc)
- ability to replace width/height tags in extracted JPEG headers
- ability to restore APP headers, that were for example stripped during image manipulation
@class ImageInfo
@constructor
@param {String} binstr Image source as binary string
*/
return function(binstr) {
var _cs = [JPEG, PNG], _img;
// figure out the format, throw: ImageError.WRONG_FORMAT if not supported
_img = (function() {
for (var i = 0; i < _cs.length; i++) {
try {
return new _cs[i](binstr);
} catch (ex) {
// console.info(ex);
}
}
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
}());
Basic.extend(this, {
/**
Image Mime Type extracted from it's depths
@property type
@type {String}
@default ''
*/
type: '',
/**
Image size in bytes
@property size
@type {Number}
@default 0
*/
size: 0,
/**
Image width extracted from image source
@property width
@type {Number}
@default 0
*/
width: 0,
/**
Image height extracted from image source
@property height
@type {Number}
@default 0
*/
height: 0,
/**
Sets Exif tag. Currently applicable only for width and height tags. Obviously works only with JPEGs.
@method setExif
@param {String} tag Tag to set
@param {Mixed} value Value to assign to the tag
*/
setExif: function() {},
/**
Restores headers to the source.
@method writeHeaders
@param {String} data Image source as binary string
@return {String} Updated binary string
*/
writeHeaders: function(data) {
return data;
},
/**
Strip all headers from the source.
@method stripHeaders
@param {String} data Image source as binary string
@return {String} Updated binary string
*/
stripHeaders: function(data) {
return data;
},
/**
Dispose resources.
@method purge
*/
purge: function() {}
});
Basic.extend(this, _img);
this.purge = function() {
_img.purge();
_img = null;
};
};
});
// Included from: src/javascript/runtime/html5/image/MegaPixel.js
/**
(The MIT License)
Copyright (c) 2012 Shinichi Tomita <[email protected]>;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* Mega pixel image rendering library for iOS6 Safari
*
* Fixes iOS6 Safari's image file rendering issue for large size image (over mega-pixel),
* which causes unexpected subsampling when drawing it in canvas.
* By using this library, you can safely render the image with proper stretching.
*
* Copyright (c) 2012 Shinichi Tomita <[email protected]>
* Released under the MIT license
*/
/**
@class moxie/runtime/html5/image/MegaPixel
@private
*/
define("moxie/runtime/html5/image/MegaPixel", [], function() {
/**
* Rendering image element (with resizing) into the canvas element
*/
function renderImageToCanvas(img, canvas, options) {
var iw = img.naturalWidth, ih = img.naturalHeight;
var width = options.width, height = options.height;
var x = options.x || 0, y = options.y || 0;
var ctx = canvas.getContext('2d');
if (detectSubsampling(img)) {
iw /= 2;
ih /= 2;
}
var d = 1024; // size of tiling canvas
var tmpCanvas = document.createElement('canvas');
tmpCanvas.width = tmpCanvas.height = d;
var tmpCtx = tmpCanvas.getContext('2d');
var vertSquashRatio = detectVerticalSquash(img, iw, ih);
var sy = 0;
while (sy < ih) {
var sh = sy + d > ih ? ih - sy : d;
var sx = 0;
while (sx < iw) {
var sw = sx + d > iw ? iw - sx : d;
tmpCtx.clearRect(0, 0, d, d);
tmpCtx.drawImage(img, -sx, -sy);
var dx = (sx * width / iw + x) << 0;
var dw = Math.ceil(sw * width / iw);
var dy = (sy * height / ih / vertSquashRatio + y) << 0;
var dh = Math.ceil(sh * height / ih / vertSquashRatio);
ctx.drawImage(tmpCanvas, 0, 0, sw, sh, dx, dy, dw, dh);
sx += d;
}
sy += d;
}
tmpCanvas = tmpCtx = null;
}
/**
* Detect subsampling in loaded image.
* In iOS, larger images than 2M pixels may be subsampled in rendering.
*/
function detectSubsampling(img) {
var iw = img.naturalWidth, ih = img.naturalHeight;
if (iw * ih > 1024 * 1024) { // subsampling may happen over megapixel image
var canvas = document.createElement('canvas');
canvas.width = canvas.height = 1;
var ctx = canvas.getContext('2d');
ctx.drawImage(img, -iw + 1, 0);
// subsampled image becomes half smaller in rendering size.
// check alpha channel value to confirm image is covering edge pixel or not.
// if alpha value is 0 image is not covering, hence subsampled.
return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
} else {
return false;
}
}
/**
* Detecting vertical squash in loaded image.
* Fixes a bug which squash image vertically while drawing into canvas for some images.
*/
function detectVerticalSquash(img, iw, ih) {
var canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = ih;
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
var data = ctx.getImageData(0, 0, 1, ih).data;
// search image edge pixel position in case it is squashed vertically.
var sy = 0;
var ey = ih;
var py = ih;
while (py > sy) {
var alpha = data[(py - 1) * 4 + 3];
if (alpha === 0) {
ey = py;
} else {
sy = py;
}
py = (ey + sy) >> 1;
}
canvas = null;
var ratio = (py / ih);
return (ratio === 0) ? 1 : ratio;
}
return {
isSubsampled: detectSubsampling,
renderTo: renderImageToCanvas
};
});
// Included from: src/javascript/runtime/html5/image/Image.js
/**
* Image.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/Image
@private
*/
define("moxie/runtime/html5/image/Image", [
"moxie/runtime/html5/Runtime",
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/core/utils/Encode",
"moxie/file/File",
"moxie/runtime/html5/image/ImageInfo",
"moxie/runtime/html5/image/MegaPixel",
"moxie/core/utils/Mime",
"moxie/core/utils/Env"
], function(extensions, Basic, x, Encode, File, ImageInfo, MegaPixel, Mime, Env) {
function HTML5Image() {
var me = this
, _img, _imgInfo, _canvas, _binStr, _blob
, _modified = false // is set true whenever image is modified
, _preserveHeaders = true
;
Basic.extend(this, {
loadFromBlob: function(blob) {
var comp = this, I = comp.getRuntime()
, asBinary = arguments.length > 1 ? arguments[1] : true
;
if (!I.can('access_binary')) {
throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR);
}
_blob = blob;
if (blob.isDetached()) {
_binStr = blob.getSource();
_preload.call(this, _binStr);
return;
} else {
_readAsDataUrl.call(this, blob.getSource(), function(dataUrl) {
if (asBinary) {
_binStr = _toBinary(dataUrl);
}
_preload.call(comp, dataUrl);
});
}
},
loadFromImage: function(img, exact) {
this.meta = img.meta;
_blob = new File(null, {
name: img.name,
size: img.size,
type: img.type
});
_preload.call(this, exact ? (_binStr = img.getAsBinaryString()) : img.getAsDataURL());
},
getInfo: function() {
var I = this.getRuntime(), info;
if (!_imgInfo && _binStr && I.can('access_image_binary')) {
_imgInfo = new ImageInfo(_binStr);
}
info = {
width: _getImg().width || 0,
height: _getImg().height || 0,
type: _blob.type || Mime.getFileMime(_blob.name),
size: _binStr && _binStr.length || _blob.size || 0,
name: _blob.name || '',
meta: _imgInfo && _imgInfo.meta || this.meta || {}
};
return info;
},
downsize: function() {
_downsize.apply(this, arguments);
},
getAsCanvas: function() {
if (_canvas) {
_canvas.id = this.uid + '_canvas';
}
return _canvas;
},
getAsBlob: function(type, quality) {
if (type !== this.type) {
// if different mime type requested prepare image for conversion
_downsize.call(this, this.width, this.height, false);
}
return new File(null, {
name: _blob.name || '',
type: type,
data: me.getAsBinaryString.call(this, type, quality)
});
},
getAsDataURL: function(type) {
var quality = arguments[1] || 90;
// if image has not been modified, return the source right away
if (!_modified) {
return _img.src;
}
if ('image/jpeg' !== type) {
return _canvas.toDataURL('image/png');
} else {
try {
// older Geckos used to result in an exception on quality argument
return _canvas.toDataURL('image/jpeg', quality/100);
} catch (ex) {
return _canvas.toDataURL('image/jpeg');
}
}
},
getAsBinaryString: function(type, quality) {
// if image has not been modified, return the source right away
if (!_modified) {
// if image was not loaded from binary string
if (!_binStr) {
_binStr = _toBinary(me.getAsDataURL(type, quality));
}
return _binStr;
}
if ('image/jpeg' !== type) {
_binStr = _toBinary(me.getAsDataURL(type, quality));
} else {
var dataUrl;
// if jpeg
if (!quality) {
quality = 90;
}
try {
// older Geckos used to result in an exception on quality argument
dataUrl = _canvas.toDataURL('image/jpeg', quality/100);
} catch (ex) {
dataUrl = _canvas.toDataURL('image/jpeg');
}
_binStr = _toBinary(dataUrl);
if (_imgInfo) {
_binStr = _imgInfo.stripHeaders(_binStr);
if (_preserveHeaders) {
// update dimensions info in exif
if (_imgInfo.meta && _imgInfo.meta.exif) {
_imgInfo.setExif({
PixelXDimension: this.width,
PixelYDimension: this.height
});
}
// re-inject the headers
_binStr = _imgInfo.writeHeaders(_binStr);
}
// will be re-created from fresh on next getInfo call
_imgInfo.purge();
_imgInfo = null;
}
}
_modified = false;
return _binStr;
},
destroy: function() {
me = null;
_purge.call(this);
this.getRuntime().getShim().removeInstance(this.uid);
}
});
function _getImg() {
if (!_canvas && !_img) {
throw new x.ImageError(x.DOMException.INVALID_STATE_ERR);
}
return _canvas || _img;
}
function _toBinary(str) {
return Encode.atob(str.substring(str.indexOf('base64,') + 7));
}
function _toDataUrl(str, type) {
return 'data:' + (type || '') + ';base64,' + Encode.btoa(str);
}
function _preload(str) {
var comp = this;
_img = new Image();
_img.onerror = function() {
_purge.call(this);
comp.trigger('error', new x.ImageError(x.ImageError.WRONG_FORMAT));
};
_img.onload = function() {
comp.trigger('load');
};
_img.src = /^data:[^;]*;base64,/.test(str) ? str : _toDataUrl(str, _blob.type);
}
function _readAsDataUrl(file, callback) {
var comp = this, fr;
// use FileReader if it's available
if (window.FileReader) {
fr = new FileReader();
fr.onload = function() {
callback(this.result);
};
fr.onerror = function() {
comp.trigger('error', new x.FileException(x.FileException.NOT_READABLE_ERR));
};
fr.readAsDataURL(file);
} else {
return callback(file.getAsDataURL());
}
}
function _downsize(width, height, crop, preserveHeaders) {
var self = this
, scale
, mathFn
, x = 0
, y = 0
, img
, destWidth
, destHeight
, orientation
;
_preserveHeaders = preserveHeaders; // we will need to check this on export (see getAsBinaryString())
// take into account orientation tag
orientation = (this.meta && this.meta.tiff && this.meta.tiff.Orientation) || 1;
if (Basic.inArray(orientation, [5,6,7,8]) !== -1) { // values that require 90 degree rotation
// swap dimensions
var tmp = width;
width = height;
height = tmp;
}
img = _getImg();
// unify dimensions
mathFn = !crop ? Math.min : Math.max;
scale = mathFn(width/img.width, height/img.height);
// we only downsize here
if (scale > 1 && (!crop || preserveHeaders)) { // when cropping one of dimensions may still exceed max, so process it anyway
this.trigger('Resize');
return;
}
// prepare canvas if necessary
if (!_canvas) {
_canvas = document.createElement("canvas");
}
// calculate dimensions of proportionally resized image
destWidth = Math.round(img.width * scale);
destHeight = Math.round(img.height * scale);
// scale image and canvas
if (crop) {
_canvas.width = width;
_canvas.height = height;
// if dimensions of the resulting image still larger than canvas, center it
if (destWidth > width) {
x = Math.round((destWidth - width) / 2);
}
if (destHeight > height) {
y = Math.round((destHeight - height) / 2);
}
} else {
_canvas.width = destWidth;
_canvas.height = destHeight;
}
// rotate if required, according to orientation tag
if (!_preserveHeaders) {
_rotateToOrientaion(_canvas.width, _canvas.height, orientation);
}
_drawToCanvas.call(this, img, _canvas, -x, -y, destWidth, destHeight);
this.width = _canvas.width;
this.height = _canvas.height;
_modified = true;
self.trigger('Resize');
}
function _drawToCanvas(img, canvas, x, y, w, h) {
if (Env.OS === 'iOS') {
// avoid squish bug in iOS6
MegaPixel.renderTo(img, canvas, { width: w, height: h, x: x, y: y });
} else {
var ctx = canvas.getContext('2d');
ctx.drawImage(img, x, y, w, h);
}
}
/**
* Transform canvas coordination according to specified frame size and orientation
* Orientation value is from EXIF tag
* @author Shinichi Tomita <[email protected]>
*/
function _rotateToOrientaion(width, height, orientation) {
switch (orientation) {
case 5:
case 6:
case 7:
case 8:
_canvas.width = height;
_canvas.height = width;
break;
default:
_canvas.width = width;
_canvas.height = height;
}
/**
1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.
2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.
3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.
4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.
5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.
6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.
7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.
8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.
*/
var ctx = _canvas.getContext('2d');
switch (orientation) {
case 2:
// horizontal flip
ctx.translate(width, 0);
ctx.scale(-1, 1);
break;
case 3:
// 180 rotate left
ctx.translate(width, height);
ctx.rotate(Math.PI);
break;
case 4:
// vertical flip
ctx.translate(0, height);
ctx.scale(1, -1);
break;
case 5:
// vertical flip + 90 rotate right
ctx.rotate(0.5 * Math.PI);
ctx.scale(1, -1);
break;
case 6:
// 90 rotate right
ctx.rotate(0.5 * Math.PI);
ctx.translate(0, -height);
break;
case 7:
// horizontal flip + 90 rotate right
ctx.rotate(0.5 * Math.PI);
ctx.translate(width, -height);
ctx.scale(-1, 1);
break;
case 8:
// 90 rotate left
ctx.rotate(-0.5 * Math.PI);
ctx.translate(-width, 0);
break;
}
}
function _purge() {
if (_imgInfo) {
_imgInfo.purge();
_imgInfo = null;
}
_binStr = _img = _canvas = _blob = null;
_modified = false;
}
}
return (extensions.Image = HTML5Image);
});
// Included from: src/javascript/runtime/flash/Runtime.js
/**
* Runtime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global ActiveXObject:true */
/**
Defines constructor for Flash runtime.
@class moxie/runtime/flash/Runtime
@private
*/
define("moxie/runtime/flash/Runtime", [
"moxie/core/utils/Basic",
"moxie/core/utils/Env",
"moxie/core/utils/Dom",
"moxie/core/Exceptions",
"moxie/runtime/Runtime"
], function(Basic, Env, Dom, x, Runtime) {
var type = 'flash', extensions = {};
/**
Get the version of the Flash Player
@method getShimVersion
@private
@return {Number} Flash Player version
*/
function getShimVersion() {
var version;
try {
version = navigator.plugins['Shockwave Flash'];
version = version.description;
} catch (e1) {
try {
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
} catch (e2) {
version = '0.0';
}
}
version = version.match(/\d+/g);
return parseFloat(version[0] + '.' + version[1]);
}
/**
Constructor for the Flash Runtime
@class FlashRuntime
@extends Runtime
*/
function FlashRuntime(options) {
var I = this, initTimer;
options = Basic.extend({ swf_url: Env.swf_url }, options);
Runtime.call(this, options, type, {
access_binary: function(value) {
return value && I.mode === 'browser';
},
access_image_binary: function(value) {
return value && I.mode === 'browser';
},
display_media: Runtime.capTrue,
do_cors: Runtime.capTrue,
drag_and_drop: false,
report_upload_progress: function() {
return I.mode === 'client';
},
resize_image: Runtime.capTrue,
return_response_headers: false,
return_response_type: function(responseType) {
if (responseType === 'json' && !!window.JSON) {
return true;
}
return !Basic.arrayDiff(responseType, ['', 'text', 'document']) || I.mode === 'browser';
},
return_status_code: function(code) {
return I.mode === 'browser' || !Basic.arrayDiff(code, [200, 404]);
},
select_file: Runtime.capTrue,
select_multiple: Runtime.capTrue,
send_binary_string: function(value) {
return value && I.mode === 'browser';
},
send_browser_cookies: function(value) {
return value && I.mode === 'browser';
},
send_custom_headers: function(value) {
return value && I.mode === 'browser';
},
send_multipart: Runtime.capTrue,
slice_blob: Runtime.capTrue,
stream_upload: function(value) {
return value && I.mode === 'browser';
},
summon_file_dialog: false,
upload_filesize: function(size) {
return Basic.parseSizeStr(size) <= 2097152 || I.mode === 'client';
},
use_http_method: function(methods) {
return !Basic.arrayDiff(methods, ['GET', 'POST']);
}
}, {
// capabilities that require specific mode
access_binary: function(value) {
return value ? 'browser' : 'client';
},
access_image_binary: function(value) {
return value ? 'browser' : 'client';
},
report_upload_progress: function(value) {
return value ? 'browser' : 'client';
},
return_response_type: function(responseType) {
return Basic.arrayDiff(responseType, ['', 'text', 'json', 'document']) ? 'browser' : ['client', 'browser'];
},
return_status_code: function(code) {
return Basic.arrayDiff(code, [200, 404]) ? 'browser' : ['client', 'browser'];
},
send_binary_string: function(value) {
return value ? 'browser' : 'client';
},
send_browser_cookies: function(value) {
return value ? 'browser' : 'client';
},
send_custom_headers: function(value) {
return value ? 'browser' : 'client';
},
stream_upload: function(value) {
return value ? 'client' : 'browser';
},
upload_filesize: function(size) {
return Basic.parseSizeStr(size) >= 2097152 ? 'client' : 'browser';
}
}, 'client');
// minimal requirement for Flash Player version
if (getShimVersion() < 10) {
this.mode = false; // with falsy mode, runtime won't operable, no matter what the mode was before
}
Basic.extend(this, {
getShim: function() {
return Dom.get(this.uid);
},
shimExec: function(component, action) {
var args = [].slice.call(arguments, 2);
return I.getShim().exec(this.uid, component, action, args);
},
init: function() {
var html, el, container;
container = this.getShimContainer();
// if not the minimal height, shims are not initialized in older browsers (e.g FF3.6, IE6,7,8, Safari 4.0,5.0, etc)
Basic.extend(container.style, {
position: 'absolute',
top: '-8px',
left: '-8px',
width: '9px',
height: '9px',
overflow: 'hidden'
});
// insert flash object
html = '<object id="' + this.uid + '" type="application/x-shockwave-flash" data="' + options.swf_url + '" ';
if (Env.browser === 'IE') {
html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
}
html += 'width="100%" height="100%" style="outline:0">' +
'<param name="movie" value="' + options.swf_url + '" />' +
'<param name="flashvars" value="uid=' + escape(this.uid) + '&target=' + Env.global_event_dispatcher + '" />' +
'<param name="wmode" value="transparent" />' +
'<param name="allowscriptaccess" value="always" />' +
'</object>';
if (Env.browser === 'IE') {
el = document.createElement('div');
container.appendChild(el);
el.outerHTML = html;
el = container = null; // just in case
} else {
container.innerHTML = html;
}
// Init is dispatched by the shim
initTimer = setTimeout(function() {
if (I && !I.initialized) { // runtime might be already destroyed by this moment
I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR));
}
}, 5000);
},
destroy: (function(destroy) { // extend default destroy method
return function() {
destroy.call(I);
clearTimeout(initTimer); // initialization check might be still onwait
options = initTimer = destroy = I = null;
};
}(this.destroy))
}, extensions);
}
Runtime.addConstructor(type, FlashRuntime);
return extensions;
});
// Included from: src/javascript/runtime/flash/file/Blob.js
/**
* Blob.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/file/Blob
@private
*/
define("moxie/runtime/flash/file/Blob", [
"moxie/runtime/flash/Runtime",
"moxie/file/Blob"
], function(extensions, Blob) {
var FlashBlob = {
slice: function(blob, start, end, type) {
var self = this.getRuntime();
if (start < 0) {
start = Math.max(blob.size + start, 0);
} else if (start > 0) {
start = Math.min(start, blob.size);
}
if (end < 0) {
end = Math.max(blob.size + end, 0);
} else if (end > 0) {
end = Math.min(end, blob.size);
}
blob = self.shimExec.call(this, 'Blob', 'slice', start, end, type || '');
if (blob) {
blob = new Blob(self.uid, blob);
}
return blob;
}
};
return (extensions.Blob = FlashBlob);
});
// Included from: src/javascript/runtime/flash/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/file/FileInput
@private
*/
define("moxie/runtime/flash/file/FileInput", [
"moxie/runtime/flash/Runtime"
], function(extensions) {
var FileInput = {
init: function(options) {
this.getRuntime().shimExec.call(this, 'FileInput', 'init', {
name: options.name,
accept: options.accept,
multiple: options.multiple
});
this.trigger('ready');
}
};
return (extensions.FileInput = FileInput);
});
// Included from: src/javascript/runtime/flash/file/FileReader.js
/**
* FileReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/file/FileReader
@private
*/
define("moxie/runtime/flash/file/FileReader", [
"moxie/runtime/flash/Runtime",
"moxie/core/utils/Encode"
], function(extensions, Encode) {
var _result = '';
function _formatData(data, op) {
switch (op) {
case 'readAsText':
return Encode.atob(data, 'utf8');
case 'readAsBinaryString':
return Encode.atob(data);
case 'readAsDataURL':
return data;
}
return null;
}
var FileReader = {
read: function(op, blob) {
var target = this, self = target.getRuntime();
// special prefix for DataURL read mode
if (op === 'readAsDataURL') {
_result = 'data:' + (blob.type || '') + ';base64,';
}
target.bind('Progress', function(e, data) {
if (data) {
_result += _formatData(data, op);
}
});
return self.shimExec.call(this, 'FileReader', 'readAsBase64', blob.uid);
},
getResult: function() {
return _result;
},
destroy: function() {
_result = null;
}
};
return (extensions.FileReader = FileReader);
});
// Included from: src/javascript/runtime/flash/file/FileReaderSync.js
/**
* FileReaderSync.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/file/FileReaderSync
@private
*/
define("moxie/runtime/flash/file/FileReaderSync", [
"moxie/runtime/flash/Runtime",
"moxie/core/utils/Encode"
], function(extensions, Encode) {
function _formatData(data, op) {
switch (op) {
case 'readAsText':
return Encode.atob(data, 'utf8');
case 'readAsBinaryString':
return Encode.atob(data);
case 'readAsDataURL':
return data;
}
return null;
}
var FileReaderSync = {
read: function(op, blob) {
var result, self = this.getRuntime();
result = self.shimExec.call(this, 'FileReaderSync', 'readAsBase64', blob.uid);
if (!result) {
return null; // or throw ex
}
// special prefix for DataURL read mode
if (op === 'readAsDataURL') {
result = 'data:' + (blob.type || '') + ';base64,' + result;
}
return _formatData(result, op, blob.type);
}
};
return (extensions.FileReaderSync = FileReaderSync);
});
// Included from: src/javascript/runtime/flash/xhr/XMLHttpRequest.js
/**
* XMLHttpRequest.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/xhr/XMLHttpRequest
@private
*/
define("moxie/runtime/flash/xhr/XMLHttpRequest", [
"moxie/runtime/flash/Runtime",
"moxie/core/utils/Basic",
"moxie/file/Blob",
"moxie/file/File",
"moxie/file/FileReaderSync",
"moxie/xhr/FormData",
"moxie/runtime/Transporter"
], function(extensions, Basic, Blob, File, FileReaderSync, FormData, Transporter) {
var XMLHttpRequest = {
send: function(meta, data) {
var target = this, self = target.getRuntime();
function send() {
meta.transport = self.mode;
self.shimExec.call(target, 'XMLHttpRequest', 'send', meta, data);
}
function appendBlob(name, blob) {
self.shimExec.call(target, 'XMLHttpRequest', 'appendBlob', name, blob.uid);
data = null;
send();
}
function attachBlob(blob, cb) {
var tr = new Transporter();
tr.bind("TransportingComplete", function() {
cb(this.result);
});
tr.transport(blob.getSource(), blob.type, {
ruid: self.uid
});
}
// copy over the headers if any
if (!Basic.isEmptyObj(meta.headers)) {
Basic.each(meta.headers, function(value, header) {
self.shimExec.call(target, 'XMLHttpRequest', 'setRequestHeader', header, value.toString()); // Silverlight doesn't accept integers into the arguments of type object
});
}
// transfer over multipart params and blob itself
if (data instanceof FormData) {
var blobField;
data.each(function(value, name) {
if (value instanceof Blob) {
blobField = name;
} else {
self.shimExec.call(target, 'XMLHttpRequest', 'append', name, value);
}
});
if (!data.hasBlob()) {
data = null;
send();
} else {
var blob = data.getBlob();
if (blob.isDetached()) {
attachBlob(blob, function(attachedBlob) {
blob.destroy();
appendBlob(blobField, attachedBlob);
});
} else {
appendBlob(blobField, blob);
}
}
} else if (data instanceof Blob) {
if (data.isDetached()) {
attachBlob(data, function(attachedBlob) {
data.destroy();
data = attachedBlob.uid;
send();
});
} else {
data = data.uid;
send();
}
} else {
send();
}
},
getResponse: function(responseType) {
var frs, blob, self = this.getRuntime();
blob = self.shimExec.call(this, 'XMLHttpRequest', 'getResponseAsBlob');
if (blob) {
blob = new File(self.uid, blob);
if ('blob' === responseType) {
return blob;
}
try {
frs = new FileReaderSync();
if (!!~Basic.inArray(responseType, ["", "text"])) {
return frs.readAsText(blob);
} else if ('json' === responseType && !!window.JSON) {
return JSON.parse(frs.readAsText(blob));
}
} finally {
blob.destroy();
}
}
return null;
},
abort: function(upload_complete_flag) {
var self = this.getRuntime();
self.shimExec.call(this, 'XMLHttpRequest', 'abort');
this.dispatchEvent('readystatechange');
// this.dispatchEvent('progress');
this.dispatchEvent('abort');
//if (!upload_complete_flag) {
// this.dispatchEvent('uploadprogress');
//}
}
};
return (extensions.XMLHttpRequest = XMLHttpRequest);
});
// Included from: src/javascript/runtime/flash/runtime/Transporter.js
/**
* Transporter.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/runtime/Transporter
@private
*/
define("moxie/runtime/flash/runtime/Transporter", [
"moxie/runtime/flash/Runtime",
"moxie/file/Blob"
], function(extensions, Blob) {
var Transporter = {
getAsBlob: function(type) {
var self = this.getRuntime()
, blob = self.shimExec.call(this, 'Transporter', 'getAsBlob', type)
;
if (blob) {
return new Blob(self.uid, blob);
}
return null;
}
};
return (extensions.Transporter = Transporter);
});
// Included from: src/javascript/runtime/flash/image/Image.js
/**
* Image.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/image/Image
@private
*/
define("moxie/runtime/flash/image/Image", [
"moxie/runtime/flash/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/Transporter",
"moxie/file/Blob",
"moxie/file/FileReaderSync"
], function(extensions, Basic, Transporter, Blob, FileReaderSync) {
var Image = {
loadFromBlob: function(blob) {
var comp = this, self = comp.getRuntime();
function exec(srcBlob) {
self.shimExec.call(comp, 'Image', 'loadFromBlob', srcBlob.uid);
comp = self = null;
}
if (blob.isDetached()) { // binary string
var tr = new Transporter();
tr.bind("TransportingComplete", function() {
exec(tr.result.getSource());
});
tr.transport(blob.getSource(), blob.type, { ruid: self.uid });
} else {
exec(blob.getSource());
}
},
loadFromImage: function(img) {
var self = this.getRuntime();
return self.shimExec.call(this, 'Image', 'loadFromImage', img.uid);
},
getAsBlob: function(type, quality) {
var self = this.getRuntime()
, blob = self.shimExec.call(this, 'Image', 'getAsBlob', type, quality)
;
if (blob) {
return new Blob(self.uid, blob);
}
return null;
},
getAsDataURL: function() {
var self = this.getRuntime()
, blob = self.Image.getAsBlob.apply(this, arguments)
, frs
;
if (!blob) {
return null;
}
frs = new FileReaderSync();
return frs.readAsDataURL(blob);
}
};
return (extensions.Image = Image);
});
// Included from: src/javascript/runtime/silverlight/Runtime.js
/**
* RunTime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global ActiveXObject:true */
/**
Defines constructor for Silverlight runtime.
@class moxie/runtime/silverlight/Runtime
@private
*/
define("moxie/runtime/silverlight/Runtime", [
"moxie/core/utils/Basic",
"moxie/core/utils/Env",
"moxie/core/utils/Dom",
"moxie/core/Exceptions",
"moxie/runtime/Runtime"
], function(Basic, Env, Dom, x, Runtime) {
var type = "silverlight", extensions = {};
function isInstalled(version) {
var isVersionSupported = false, control = null, actualVer,
actualVerArray, reqVerArray, requiredVersionPart, actualVersionPart, index = 0;
try {
try {
control = new ActiveXObject('AgControl.AgControl');
if (control.IsVersionSupported(version)) {
isVersionSupported = true;
}
control = null;
} catch (e) {
var plugin = navigator.plugins["Silverlight Plug-In"];
if (plugin) {
actualVer = plugin.description;
if (actualVer === "1.0.30226.2") {
actualVer = "2.0.30226.2";
}
actualVerArray = actualVer.split(".");
while (actualVerArray.length > 3) {
actualVerArray.pop();
}
while ( actualVerArray.length < 4) {
actualVerArray.push(0);
}
reqVerArray = version.split(".");
while (reqVerArray.length > 4) {
reqVerArray.pop();
}
do {
requiredVersionPart = parseInt(reqVerArray[index], 10);
actualVersionPart = parseInt(actualVerArray[index], 10);
index++;
} while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);
if (requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart)) {
isVersionSupported = true;
}
}
}
} catch (e2) {
isVersionSupported = false;
}
return isVersionSupported;
}
/**
Constructor for the Silverlight Runtime
@class SilverlightRuntime
@extends Runtime
*/
function SilverlightRuntime(options) {
var I = this, initTimer;
options = Basic.extend({ xap_url: Env.xap_url }, options);
Runtime.call(this, options, type, {
access_binary: Runtime.capTrue,
access_image_binary: Runtime.capTrue,
display_media: Runtime.capTrue,
do_cors: Runtime.capTrue,
drag_and_drop: false,
report_upload_progress: Runtime.capTrue,
resize_image: Runtime.capTrue,
return_response_headers: function(value) {
return value && I.mode === 'client';
},
return_response_type: function(responseType) {
if (responseType !== 'json') {
return true;
} else {
return !!window.JSON;
}
},
return_status_code: function(code) {
return I.mode === 'client' || !Basic.arrayDiff(code, [200, 404]);
},
select_file: Runtime.capTrue,
select_multiple: Runtime.capTrue,
send_binary_string: Runtime.capTrue,
send_browser_cookies: function(value) {
return value && I.mode === 'browser';
},
send_custom_headers: function(value) {
return value && I.mode === 'client';
},
send_multipart: Runtime.capTrue,
slice_blob: Runtime.capTrue,
stream_upload: true,
summon_file_dialog: false,
upload_filesize: Runtime.capTrue,
use_http_method: function(methods) {
return I.mode === 'client' || !Basic.arrayDiff(methods, ['GET', 'POST']);
}
}, {
// capabilities that require specific mode
return_response_headers: function(value) {
return value ? 'client' : 'browser';
},
return_status_code: function(code) {
return Basic.arrayDiff(code, [200, 404]) ? 'client' : ['client', 'browser'];
},
send_browser_cookies: function(value) {
return value ? 'browser' : 'client';
},
send_custom_headers: function(value) {
return value ? 'client' : 'browser';
},
use_http_method: function(methods) {
return Basic.arrayDiff(methods, ['GET', 'POST']) ? 'client' : ['client', 'browser'];
}
});
// minimal requirement
if (!isInstalled('2.0.31005.0') || Env.browser === 'Opera') {
this.mode = false;
}
Basic.extend(this, {
getShim: function() {
return Dom.get(this.uid).content.Moxie;
},
shimExec: function(component, action) {
var args = [].slice.call(arguments, 2);
return I.getShim().exec(this.uid, component, action, args);
},
init : function() {
var container;
container = this.getShimContainer();
container.innerHTML = '<object id="' + this.uid + '" data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%" style="outline:none;">' +
'<param name="source" value="' + options.xap_url + '"/>' +
'<param name="background" value="Transparent"/>' +
'<param name="windowless" value="true"/>' +
'<param name="enablehtmlaccess" value="true"/>' +
'<param name="initParams" value="uid=' + this.uid + ',target=' + Env.global_event_dispatcher + '"/>' +
'</object>';
// Init is dispatched by the shim
initTimer = setTimeout(function() {
if (I && !I.initialized) { // runtime might be already destroyed by this moment
I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR));
}
}, Env.OS !== 'Windows'? 10000 : 5000); // give it more time to initialize in non Windows OS (like Mac)
},
destroy: (function(destroy) { // extend default destroy method
return function() {
destroy.call(I);
clearTimeout(initTimer); // initialization check might be still onwait
options = initTimer = destroy = I = null;
};
}(this.destroy))
}, extensions);
}
Runtime.addConstructor(type, SilverlightRuntime);
return extensions;
});
// Included from: src/javascript/runtime/silverlight/file/Blob.js
/**
* Blob.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/file/Blob
@private
*/
define("moxie/runtime/silverlight/file/Blob", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/file/Blob"
], function(extensions, Basic, Blob) {
return (extensions.Blob = Basic.extend({}, Blob));
});
// Included from: src/javascript/runtime/silverlight/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/file/FileInput
@private
*/
define("moxie/runtime/silverlight/file/FileInput", [
"moxie/runtime/silverlight/Runtime"
], function(extensions) {
var FileInput = {
init: function(options) {
function toFilters(accept) {
var filter = '';
for (var i = 0; i < accept.length; i++) {
filter += (filter !== '' ? '|' : '') + accept[i].title + " | *." + accept[i].extensions.replace(/,/g, ';*.');
}
return filter;
}
this.getRuntime().shimExec.call(this, 'FileInput', 'init', toFilters(options.accept), options.name, options.multiple);
this.trigger('ready');
}
};
return (extensions.FileInput = FileInput);
});
// Included from: src/javascript/runtime/silverlight/file/FileDrop.js
/**
* FileDrop.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/file/FileDrop
@private
*/
define("moxie/runtime/silverlight/file/FileDrop", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Dom",
"moxie/core/utils/Events"
], function(extensions, Dom, Events) {
// not exactly useful, since works only in safari (...crickets...)
var FileDrop = {
init: function() {
var comp = this, self = comp.getRuntime(), dropZone;
dropZone = self.getShimContainer();
Events.addEvent(dropZone, 'dragover', function(e) {
e.preventDefault();
e.stopPropagation();
e.dataTransfer.dropEffect = 'copy';
}, comp.uid);
Events.addEvent(dropZone, 'dragenter', function(e) {
e.preventDefault();
var flag = Dom.get(self.uid).dragEnter(e);
// If handled, then stop propagation of event in DOM
if (flag) {
e.stopPropagation();
}
}, comp.uid);
Events.addEvent(dropZone, 'drop', function(e) {
e.preventDefault();
var flag = Dom.get(self.uid).dragDrop(e);
// If handled, then stop propagation of event in DOM
if (flag) {
e.stopPropagation();
}
}, comp.uid);
return self.shimExec.call(this, 'FileDrop', 'init');
}
};
return (extensions.FileDrop = FileDrop);
});
// Included from: src/javascript/runtime/silverlight/file/FileReader.js
/**
* FileReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/file/FileReader
@private
*/
define("moxie/runtime/silverlight/file/FileReader", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/file/FileReader"
], function(extensions, Basic, FileReader) {
return (extensions.FileReader = Basic.extend({}, FileReader));
});
// Included from: src/javascript/runtime/silverlight/file/FileReaderSync.js
/**
* FileReaderSync.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/file/FileReaderSync
@private
*/
define("moxie/runtime/silverlight/file/FileReaderSync", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/file/FileReaderSync"
], function(extensions, Basic, FileReaderSync) {
return (extensions.FileReaderSync = Basic.extend({}, FileReaderSync));
});
// Included from: src/javascript/runtime/silverlight/xhr/XMLHttpRequest.js
/**
* XMLHttpRequest.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/xhr/XMLHttpRequest
@private
*/
define("moxie/runtime/silverlight/xhr/XMLHttpRequest", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/xhr/XMLHttpRequest"
], function(extensions, Basic, XMLHttpRequest) {
return (extensions.XMLHttpRequest = Basic.extend({}, XMLHttpRequest));
});
// Included from: src/javascript/runtime/silverlight/runtime/Transporter.js
/**
* Transporter.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/runtime/Transporter
@private
*/
define("moxie/runtime/silverlight/runtime/Transporter", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/runtime/Transporter"
], function(extensions, Basic, Transporter) {
return (extensions.Transporter = Basic.extend({}, Transporter));
});
// Included from: src/javascript/runtime/silverlight/image/Image.js
/**
* Image.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/image/Image
@private
*/
define("moxie/runtime/silverlight/image/Image", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/image/Image"
], function(extensions, Basic, Image) {
return (extensions.Image = Basic.extend({}, Image, {
getInfo: function() {
var self = this.getRuntime()
, grps = ['tiff', 'exif', 'gps']
, info = { meta: {} }
, rawInfo = self.shimExec.call(this, 'Image', 'getInfo')
;
if (rawInfo.meta) {
Basic.each(grps, function(grp) {
var meta = rawInfo.meta[grp]
, tag
, i
, length
, value
;
if (meta && meta.keys) {
info.meta[grp] = {};
for (i = 0, length = meta.keys.length; i < length; i++) {
tag = meta.keys[i];
value = meta[tag];
if (value) {
// convert numbers
if (/^(\d|[1-9]\d+)$/.test(value)) { // integer (make sure doesn't start with zero)
value = parseInt(value, 10);
} else if (/^\d*\.\d+$/.test(value)) { // double
value = parseFloat(value);
}
info.meta[grp][tag] = value;
}
}
}
});
}
info.width = parseInt(rawInfo.width, 10);
info.height = parseInt(rawInfo.height, 10);
info.size = parseInt(rawInfo.size, 10);
info.type = rawInfo.type;
info.name = rawInfo.name;
return info;
}
}));
});
// Included from: src/javascript/runtime/html4/Runtime.js
/**
* Runtime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global File:true */
/**
Defines constructor for HTML4 runtime.
@class moxie/runtime/html4/Runtime
@private
*/
define("moxie/runtime/html4/Runtime", [
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/runtime/Runtime",
"moxie/core/utils/Env"
], function(Basic, x, Runtime, Env) {
var type = 'html4', extensions = {};
function Html4Runtime(options) {
var I = this
, Test = Runtime.capTest
, True = Runtime.capTrue
;
Runtime.call(this, options, type, {
access_binary: Test(window.FileReader || window.File && File.getAsDataURL),
access_image_binary: false,
display_media: Test(extensions.Image && (Env.can('create_canvas') || Env.can('use_data_uri_over32kb'))),
do_cors: false,
drag_and_drop: false,
filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest
return (Env.browser === 'Chrome' && Env.version >= 28) || (Env.browser === 'IE' && Env.version >= 10);
}()),
resize_image: function() {
return extensions.Image && I.can('access_binary') && Env.can('create_canvas');
},
report_upload_progress: false,
return_response_headers: false,
return_response_type: function(responseType) {
if (responseType === 'json' && !!window.JSON) {
return true;
}
return !!~Basic.inArray(responseType, ['text', 'document', '']);
},
return_status_code: function(code) {
return !Basic.arrayDiff(code, [200, 404]);
},
select_file: function() {
return Env.can('use_fileinput');
},
select_multiple: false,
send_binary_string: false,
send_custom_headers: false,
send_multipart: true,
slice_blob: false,
stream_upload: function() {
return I.can('select_file');
},
summon_file_dialog: Test(function() { // yeah... some dirty sniffing here...
return (Env.browser === 'Firefox' && Env.version >= 4) ||
(Env.browser === 'Opera' && Env.version >= 12) ||
!!~Basic.inArray(Env.browser, ['Chrome', 'Safari']);
}()),
upload_filesize: True,
use_http_method: function(methods) {
return !Basic.arrayDiff(methods, ['GET', 'POST']);
}
});
Basic.extend(this, {
init : function() {
this.trigger("Init");
},
destroy: (function(destroy) { // extend default destroy method
return function() {
destroy.call(I);
destroy = I = null;
};
}(this.destroy))
});
Basic.extend(this.getShim(), extensions);
}
Runtime.addConstructor(type, Html4Runtime);
return extensions;
});
// Included from: src/javascript/runtime/html4/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html4/file/FileInput
@private
*/
define("moxie/runtime/html4/file/FileInput", [
"moxie/runtime/html4/Runtime",
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/utils/Events",
"moxie/core/utils/Mime",
"moxie/core/utils/Env"
], function(extensions, Basic, Dom, Events, Mime, Env) {
function FileInput() {
var _uid, _files = [], _mimes = [], _options;
function addInput() {
var comp = this, I = comp.getRuntime(), shimContainer, browseButton, currForm, form, input, uid;
uid = Basic.guid('uid_');
shimContainer = I.getShimContainer(); // we get new ref everytime to avoid memory leaks in IE
if (_uid) { // move previous form out of the view
currForm = Dom.get(_uid + '_form');
if (currForm) {
Basic.extend(currForm.style, { top: '100%' });
}
}
// build form in DOM, since innerHTML version not able to submit file for some reason
form = document.createElement('form');
form.setAttribute('id', uid + '_form');
form.setAttribute('method', 'post');
form.setAttribute('enctype', 'multipart/form-data');
form.setAttribute('encoding', 'multipart/form-data');
Basic.extend(form.style, {
overflow: 'hidden',
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%'
});
input = document.createElement('input');
input.setAttribute('id', uid);
input.setAttribute('type', 'file');
input.setAttribute('name', _options.name || 'Filedata');
input.setAttribute('accept', _mimes.join(','));
Basic.extend(input.style, {
fontSize: '999px',
opacity: 0
});
form.appendChild(input);
shimContainer.appendChild(form);
// prepare file input to be placed underneath the browse_button element
Basic.extend(input.style, {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%'
});
if (Env.browser === 'IE' && Env.version < 10) {
Basic.extend(input.style, {
filter : "progid:DXImageTransform.Microsoft.Alpha(opacity=0)"
});
}
input.onchange = function() { // there should be only one handler for this
var file;
if (!this.value) {
return;
}
if (this.files) {
file = this.files[0];
} else {
file = {
name: this.value
};
}
_files = [file];
this.onchange = function() {}; // clear event handler
addInput.call(comp);
// after file is initialized as o.File, we need to update form and input ids
comp.bind('change', function onChange() {
var input = Dom.get(uid), form = Dom.get(uid + '_form'), file;
comp.unbind('change', onChange);
if (comp.files.length && input && form) {
file = comp.files[0];
input.setAttribute('id', file.uid);
form.setAttribute('id', file.uid + '_form');
// set upload target
form.setAttribute('target', file.uid + '_iframe');
}
input = form = null;
}, 998);
input = form = null;
comp.trigger('change');
};
// route click event to the input
if (I.can('summon_file_dialog')) {
browseButton = Dom.get(_options.browse_button);
Events.removeEvent(browseButton, 'click', comp.uid);
Events.addEvent(browseButton, 'click', function(e) {
if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file]
input.click();
}
e.preventDefault();
}, comp.uid);
}
_uid = uid;
shimContainer = currForm = browseButton = null;
}
Basic.extend(this, {
init: function(options) {
var comp = this, I = comp.getRuntime(), shimContainer;
// figure out accept string
_options = options;
_mimes = options.accept.mimes || Mime.extList2mimes(options.accept, I.can('filter_by_extension'));
shimContainer = I.getShimContainer();
(function() {
var browseButton, zIndex, top;
browseButton = Dom.get(options.browse_button);
// Route click event to the input[type=file] element for browsers that support such behavior
if (I.can('summon_file_dialog')) {
if (Dom.getStyle(browseButton, 'position') === 'static') {
browseButton.style.position = 'relative';
}
zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 1;
browseButton.style.zIndex = zIndex;
shimContainer.style.zIndex = zIndex - 1;
}
/* Since we have to place input[type=file] on top of the browse_button for some browsers,
browse_button loses interactivity, so we restore it here */
top = I.can('summon_file_dialog') ? browseButton : shimContainer;
Events.addEvent(top, 'mouseover', function() {
comp.trigger('mouseenter');
}, comp.uid);
Events.addEvent(top, 'mouseout', function() {
comp.trigger('mouseleave');
}, comp.uid);
Events.addEvent(top, 'mousedown', function() {
comp.trigger('mousedown');
}, comp.uid);
Events.addEvent(Dom.get(options.container), 'mouseup', function() {
comp.trigger('mouseup');
}, comp.uid);
browseButton = null;
}());
addInput.call(this);
shimContainer = null;
// trigger ready event asynchronously
comp.trigger({
type: 'ready',
async: true
});
},
getFiles: function() {
return _files;
},
disable: function(state) {
var input;
if ((input = Dom.get(_uid))) {
input.disabled = !!state;
}
},
destroy: function() {
var I = this.getRuntime()
, shim = I.getShim()
, shimContainer = I.getShimContainer()
;
Events.removeAllEvents(shimContainer, this.uid);
Events.removeAllEvents(_options && Dom.get(_options.container), this.uid);
Events.removeAllEvents(_options && Dom.get(_options.browse_button), this.uid);
if (shimContainer) {
shimContainer.innerHTML = '';
}
shim.removeInstance(this.uid);
_uid = _files = _mimes = _options = shimContainer = shim = null;
}
});
}
return (extensions.FileInput = FileInput);
});
// Included from: src/javascript/runtime/html4/file/FileReader.js
/**
* FileReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html4/file/FileReader
@private
*/
define("moxie/runtime/html4/file/FileReader", [
"moxie/runtime/html4/Runtime",
"moxie/runtime/html5/file/FileReader"
], function(extensions, FileReader) {
return (extensions.FileReader = FileReader);
});
// Included from: src/javascript/runtime/html4/xhr/XMLHttpRequest.js
/**
* XMLHttpRequest.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html4/xhr/XMLHttpRequest
@private
*/
define("moxie/runtime/html4/xhr/XMLHttpRequest", [
"moxie/runtime/html4/Runtime",
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/utils/Url",
"moxie/core/Exceptions",
"moxie/core/utils/Events",
"moxie/file/Blob",
"moxie/xhr/FormData"
], function(extensions, Basic, Dom, Url, x, Events, Blob, FormData) {
function XMLHttpRequest() {
var _status, _response, _iframe;
function cleanup(cb) {
var target = this, uid, form, inputs, i, hasFile = false;
if (!_iframe) {
return;
}
uid = _iframe.id.replace(/_iframe$/, '');
form = Dom.get(uid + '_form');
if (form) {
inputs = form.getElementsByTagName('input');
i = inputs.length;
while (i--) {
switch (inputs[i].getAttribute('type')) {
case 'hidden':
inputs[i].parentNode.removeChild(inputs[i]);
break;
case 'file':
hasFile = true; // flag the case for later
break;
}
}
inputs = [];
if (!hasFile) { // we need to keep the form for sake of possible retries
form.parentNode.removeChild(form);
}
form = null;
}
// without timeout, request is marked as canceled (in console)
setTimeout(function() {
Events.removeEvent(_iframe, 'load', target.uid);
if (_iframe.parentNode) { // #382
_iframe.parentNode.removeChild(_iframe);
}
// check if shim container has any other children, if - not, remove it as well
var shimContainer = target.getRuntime().getShimContainer();
if (!shimContainer.children.length) {
shimContainer.parentNode.removeChild(shimContainer);
}
shimContainer = _iframe = null;
cb();
}, 1);
}
Basic.extend(this, {
send: function(meta, data) {
var target = this, I = target.getRuntime(), uid, form, input, blob;
_status = _response = null;
function createIframe() {
var container = I.getShimContainer() || document.body
, temp = document.createElement('div')
;
// IE 6 won't be able to set the name using setAttribute or iframe.name
temp.innerHTML = '<iframe id="' + uid + '_iframe" name="' + uid + '_iframe" src="javascript:&quot;&quot;" style="display:none"></iframe>';
_iframe = temp.firstChild;
container.appendChild(_iframe);
/* _iframe.onreadystatechange = function() {
console.info(_iframe.readyState);
};*/
Events.addEvent(_iframe, 'load', function() { // _iframe.onload doesn't work in IE lte 8
var el;
try {
el = _iframe.contentWindow.document || _iframe.contentDocument || window.frames[_iframe.id].document;
// try to detect some standard error pages
if (/^4(0[0-9]|1[0-7]|2[2346])\s/.test(el.title)) { // test if title starts with 4xx HTTP error
_status = el.title.replace(/^(\d+).*$/, '$1');
} else {
_status = 200;
// get result
_response = Basic.trim(el.body.innerHTML);
// we need to fire these at least once
target.trigger({
type: 'progress',
loaded: _response.length,
total: _response.length
});
if (blob) { // if we were uploading a file
target.trigger({
type: 'uploadprogress',
loaded: blob.size || 1025,
total: blob.size || 1025
});
}
}
} catch (ex) {
if (Url.hasSameOrigin(meta.url)) {
// if response is sent with error code, iframe in IE gets redirected to res://ieframe.dll/http_x.htm
// which obviously results to cross domain error (wtf?)
_status = 404;
} else {
cleanup.call(target, function() {
target.trigger('error');
});
return;
}
}
cleanup.call(target, function() {
target.trigger('load');
});
}, target.uid);
} // end createIframe
// prepare data to be sent and convert if required
if (data instanceof FormData && data.hasBlob()) {
blob = data.getBlob();
uid = blob.uid;
input = Dom.get(uid);
form = Dom.get(uid + '_form');
if (!form) {
throw new x.DOMException(x.DOMException.NOT_FOUND_ERR);
}
} else {
uid = Basic.guid('uid_');
form = document.createElement('form');
form.setAttribute('id', uid + '_form');
form.setAttribute('method', meta.method);
form.setAttribute('enctype', 'multipart/form-data');
form.setAttribute('encoding', 'multipart/form-data');
form.setAttribute('target', uid + '_iframe');
I.getShimContainer().appendChild(form);
}
if (data instanceof FormData) {
data.each(function(value, name) {
if (value instanceof Blob) {
if (input) {
input.setAttribute('name', name);
}
} else {
var hidden = document.createElement('input');
Basic.extend(hidden, {
type : 'hidden',
name : name,
value : value
});
// make sure that input[type="file"], if it's there, comes last
if (input) {
form.insertBefore(hidden, input);
} else {
form.appendChild(hidden);
}
}
});
}
// set destination url
form.setAttribute("action", meta.url);
createIframe();
form.submit();
target.trigger('loadstart');
},
getStatus: function() {
return _status;
},
getResponse: function(responseType) {
if ('json' === responseType) {
// strip off <pre>..</pre> tags that might be enclosing the response
if (Basic.typeOf(_response) === 'string' && !!window.JSON) {
try {
return JSON.parse(_response.replace(/^\s*<pre[^>]*>/, '').replace(/<\/pre>\s*$/, ''));
} catch (ex) {
return null;
}
}
} else if ('document' === responseType) {
}
return _response;
},
abort: function() {
var target = this;
if (_iframe && _iframe.contentWindow) {
if (_iframe.contentWindow.stop) { // FireFox/Safari/Chrome
_iframe.contentWindow.stop();
} else if (_iframe.contentWindow.document.execCommand) { // IE
_iframe.contentWindow.document.execCommand('Stop');
} else {
_iframe.src = "about:blank";
}
}
cleanup.call(this, function() {
// target.dispatchEvent('readystatechange');
target.dispatchEvent('abort');
});
}
});
}
return (extensions.XMLHttpRequest = XMLHttpRequest);
});
// Included from: src/javascript/runtime/html4/image/Image.js
/**
* Image.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html4/image/Image
@private
*/
define("moxie/runtime/html4/image/Image", [
"moxie/runtime/html4/Runtime",
"moxie/runtime/html5/image/Image"
], function(extensions, Image) {
return (extensions.Image = Image);
});
expose(["moxie/core/utils/Basic","moxie/core/I18n","moxie/core/utils/Mime","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/utils/Encode","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/file/File","moxie/file/FileInput","moxie/file/FileDrop","moxie/runtime/RuntimeTarget","moxie/file/FileReader","moxie/core/utils/Url","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/runtime/Transporter","moxie/image/Image","moxie/core/utils/Events"]);
})(this);/**
* o.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global moxie:true */
/**
Globally exposed namespace with the most frequently used public classes and handy methods.
@class o
@static
@private
*/
(function() {
"use strict";
var o = {}, inArray = moxie.core.utils.Basic.inArray;
// directly add some public classes
// (we do it dynamically here, since for custom builds we cannot know beforehand what modules were included)
(function addAlias(ns) {
var name, itemType;
for (name in ns) {
itemType = typeof(ns[name]);
if (itemType === 'object' && !~inArray(name, ['Exceptions', 'Env', 'Mime'])) {
addAlias(ns[name]);
} else if (itemType === 'function') {
o[name] = ns[name];
}
}
})(window.moxie);
// add some manually
o.Env = window.moxie.core.utils.Env;
o.Mime = window.moxie.core.utils.Mime;
o.Exceptions = window.moxie.core.Exceptions;
// expose globally
window.mOxie = o;
if (!window.o) {
window.o = o;
}
return o;
})();
Location: https://s.fl-ads.com/js/serve/main/parent/adq.js
Referrer: https://www.freemarket.com/sites/
Content-Type: application/javascript
!function(){var e,t,r;!function(n){function o(e,t){return b.call(e,t)}function i(e,t){var r,n,o,i,a,s,c,u,l,f,p,d=t&&t.split("/"),h=v.map,m=h&&h["*"]||{};if(e&&"."===e.charAt(0))if(t){for(d=d.slice(0,d.length-1),e=e.split("/"),a=e.length-1,v.nodeIdCompat&&k.test(e[a])&&(e[a]=e[a].replace(k,"")),e=d.concat(e),l=0;l<e.length;l+=1)if(p=e[l],"."===p)e.splice(l,1),l-=1;else if(".."===p){if(1===l&&(".."===e[2]||".."===e[0]))break;l>0&&(e.splice(l-1,2),l-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((d||m)&&h){for(r=e.split("/"),l=r.length;l>0;l-=1){if(n=r.slice(0,l).join("/"),d)for(f=d.length;f>0;f-=1)if(o=h[d.slice(0,f).join("/")],o&&(o=o[n])){i=o,s=l;break}if(i)break;!c&&m&&m[n]&&(c=m[n],u=l)}!i&&c&&(i=c,s=u),i&&(r.splice(0,s,i),e=r.join("/"))}return e}function a(e,t){return function(){return d.apply(n,O.call(arguments,0).concat([e,t]))}}function s(e){return function(t){return i(t,e)}}function c(e){return function(t){g[e]=t}}function u(e){if(o(y,e)){var t=y[e];delete y[e],w[e]=!0,p.apply(n,t)}if(!o(g,e)&&!o(w,e))throw new Error("No "+e);return g[e]}function l(e){var t,r=e?e.indexOf("!"):-1;return r>-1&&(t=e.substring(0,r),e=e.substring(r+1,e.length)),[t,e]}function f(e){return function(){return v&&v.config&&v.config[e]||{}}}var p,d,h,m,g={},y={},v={},w={},b=Object.prototype.hasOwnProperty,O=[].slice,k=/\.js$/;h=function(e,t){var r,n=l(e),o=n[0];return e=n[1],o&&(o=i(o,t),r=u(o)),o?e=r&&r.normalize?r.normalize(e,s(t)):i(e,t):(e=i(e,t),n=l(e),o=n[0],e=n[1],o&&(r=u(o))),{f:o?o+"!"+e:e,n:e,pr:o,p:r}},m={require:function(e){return a(e)},exports:function(e){var t=g[e];return"undefined"!=typeof t?t:g[e]={}},module:function(e){return{id:e,uri:"",exports:g[e],config:f(e)}}},p=function(e,t,r,i){var s,l,f,p,d,v,b=[],O=typeof r;if(i=i||e,"undefined"===O||"function"===O){for(t=!t.length&&r.length?["require","exports","module"]:t,d=0;d<t.length;d+=1)if(p=h(t[d],i),l=p.f,"require"===l)b[d]=m.require(e);else if("exports"===l)b[d]=m.exports(e),v=!0;else if("module"===l)s=b[d]=m.module(e);else if(o(g,l)||o(y,l)||o(w,l))b[d]=u(l);else{if(!p.p)throw new Error(e+" missing "+l);p.p.load(p.n,a(i,!0),c(l),{}),b[d]=g[l]}f=r?r.apply(g[e],b):void 0,e&&(s&&s.exports!==n&&s.exports!==g[e]?g[e]=s.exports:f===n&&v||(g[e]=f))}else e&&(g[e]=r)},e=t=d=function(e,t,r,o,i){if("string"==typeof e)return m[e]?m[e](t):u(h(e,t).f);if(!e.splice){if(v=e,v.deps&&d(v.deps,v.callback),!t)return;t.splice?(e=t,t=r,r=null):e=n}return t=t||function(){},"function"==typeof r&&(r=o,o=i),o?p(n,e,t,r):setTimeout(function(){p(n,e,t,r)},4),d},d.config=function(e){return d(e)},e._defined=g,r=function(e,t,r){t.splice||(r=t,t=[]),o(g,e)||o(y,e)||(y[e]=[e,t,r])},r.amd={jQuery:!0}}(),r("almond",function(){}),r("utility/is",[],function(){"use strict";return{Arguments:function(e){return"[object Arguments]"===Object.prototype.toString.call(e)},Array:Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Boolean:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},Function:function(e){return"[object Function]"===Object.prototype.toString.call(e)},Number:function(e){return"[object Number]"===Object.prototype.toString.call(e)},Object:function(e){return e===Object(e)},PlainObject:function(e){return!(!e||!e.constructor||e.constructor!==Object)},RegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},String:function(e){return"[object String]"===Object.prototype.toString.call(e)}}}),r("serve/environments",["require","../utility/is"],function(e){"use strict";var t=e("../utility/is"),r={DEVELOPMENT:"development",PRODUCTION:"production"};return r.is=function(){var e=Object.keys(this).filter(function(e){return t.String(e)&&t.String(this[e])},this),r=e.map(function(e){return this[e]},this);return function(e){return r.indexOf(e)>=0}}.call(r),Object.freeze(r)}),r("utility/object",["require","./is"],function(e){"use strict";var t=e("./is");return{extend:function r(){var e,n,o;for(t.Boolean(arguments[0])?(e=!!arguments[0],n=arguments[1]||{},o=2):(e=!1,n=arguments[0]||{},o=1),t.Object(n)||t.Function(n)||(n={});o<arguments.length;o++){var i=arguments[o];if(null!=i)for(var a in i)if(i.hasOwnProperty(a)){var s=i[a],c=n[a];if(s===n)continue;if(e&&s&&(t.PlainObject(s)||t.Array(s))){var u;t.Array(s)?u=c&&t.Array(c)?c:[]:t.PlainObject(s)&&(u=c&&t.PlainObject(c)?c:{}),n[a]=r(e,u,s)}else void 0!==s&&(n[a]=s)}}return n}}}),r("utility/number",["require","./is"],function(e){"use strict";var t=e("./is");return{isArrayOfPositiveInteger:function(e){if(!t.Array(e))return!1;for(var r=0;r<e.length;r++)if(!this.isPositiveInteger(e[r]))return!1;return!0},isInteger:function(e){return!this.isNaN(this.parseInt(e))&&this.parseFloat(e)===this.parseInt(e)},isNaN:Number.isNaN||function(e){return"number"==typeof e&&isNaN(e)},isPositiveInteger:function(e){return this.isInteger(e)&&this.parseInt(e)>0},parseInt:function(e){return parseInt(e,10)},parseFloat:parseFloat}}),r("utility/uri",["require","./is"],function(e){"use strict";var t=e("./is");return{buildQuery:function(e,r){var n="";for(var o in e)if(e.hasOwnProperty(o)&&o)if(t.Array(e[o]))for(var i={},a=0,s=e[o].length;s>a;a++)void 0!==e[o][a]&&void 0===i[e[o][a]+""]&&(n+="&"+this.buildQueryParameter(o,e[o][a]),r&&(i[e[o][a]+""]=!0));else void 0!==e[o]&&(n+="&"+this.buildQueryParameter(o,e[o]));return n.substring(1)},buildQueryParameter:function(e,t){return this.encode(e)+(null!==t?"="+this.encode(t):"")},decode:decodeURIComponent,encode:encodeURIComponent,getFragmentParameter:function(e){return this.parseFragment(window.location.hash)[e]},getQueryParameter:function(e){return this.parseQuery(window.location.search)[e]},parseFragment:function(e){return this.parseQuery(e.replace(/^#/,"?"))},parseQuery:function(e){if(!t.String(e))return{};e=e.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");for(var r={},n=e.split("&"),o=n.length,i=0;o>i;i++){var a=n[i].split("="),s=this.decode(a.shift()),c=a.length?this.decode(a.join("=")):null;r[s]?(t.String(r[s])&&(r[s]=[r[s]]),r[s].push(c)):r[s]=c}return r}}}),r("serve/global",["require","./environments","../utility/object","../utility/number","../utility/uri"],function(e){"use strict";function t(e){var t=i.getQueryParameter(e);if(void 0!==t&&(t=parseInt(t,10),!o.isPositiveInteger(t)))throw new TypeError(e+" must be a positive integer");return t}var r=e("./environments"),n=e("../utility/object").extend,o=e("../utility/number"),i=e("../utility/uri");window.Ads=window.Ads||{};var a=Object.create({});return function(){var e={get:function(){return e.value},set:function(r){e.value=n(!0,{adzerk:{network_id:t("network_id"),site_id:t("site_id")},easyXDM:{}},r)},value:{}};try{return Object.defineProperty(a,"config",{enumerable:!0,get:e.get,set:e.set})}catch(r){}try{return Object.defineProperty(a,"config",{enumerable:!0,value:e.value,writable:!0})}catch(r){}}(),a.config=window.Ads.config||{},function(){var e={get:function(){var t=i.getFragmentParameter("env");return void 0!==t&&r.is(t)?t:e.value},set:function(t){if(!r.is(t))throw new TypeError("Invalid environment: "+t);e.value=t},value:r.PRODUCTION};try{return Object.defineProperty(a,"env",{enumerable:!0,get:e.get,set:e.set})}catch(t){}try{return Object.defineProperty(a,"env",{enumerable:!0,value:e.value,writable:!0})}catch(t){}}(),a.env=window.Ads.env,function(){try{return Object.defineProperty(a,"queue",{get:function(){return window._adq}})}catch(e){}}(),a=Object.freeze(a),window.Ads=a,a}),r("serve/console",["require","./environments","./global","../utility/is"],function(e){"use strict";var t=e("./environments"),r=e("./global"),n=e("../utility/is"),o=function(){var e=function(){var e=Object.getPrototypeOf(this);return null===e?this:n.PlainObject(e)?this:e}.call(this);if(!n.Object(this)||!n.Object(e))return function(){return null};var t=function(t){if(Object.prototype.hasOwnProperty.call(e,t)){if(n.Function(e[t]))return e[t].bind(this);if(n.Object(e[t])){try{return Function.prototype.bind.call(e[t],this)}catch(r){}try{return Function.prototype.call.bind(e[t],this)}catch(r){}}}return null}.bind(this);return/\bTrident\b/.test(navigator.userAgent)?function(e){var r=t(e);return n.Function(r)&&["error","info","log","warn"].indexOf(e)>=0?function(){return r.call(this,Array.prototype.slice.call(arguments).join(" "))}:n.Function(r)&&["assert"].indexOf(e)>=0?function(e){return r.call(this,e,Array.prototype.slice.call(arguments,1).join(" "))}:null}.bind(this):t}.call(window.console);return{assert:function(){var e=o("assert")||function(){var e=o("error")||o("warn")||o("log")||function(){};return function(t){return t?void 0:e.call(console,"Assertion failed:",Array.prototype.slice.call(arguments,1))}}();return function(){return r.env!==t.PRODUCTION?e.apply(console,arguments):void 0}}(),clear:o("clear")||function(){},debug:function(){var e=o("debug")||o("log")||function(){};return function(){return r.env!==t.PRODUCTION?e.apply(console,arguments):void 0}}(),dir:o("dir")||o("log")||function(){},dirxml:o("dirxml")||o("dir")||o("log")||function(){},error:o("error")||o("warn")||o("log")||function(){},info:o("info")||o("log")||function(){},log:o("log")||function(){},stacktrace:o("trace")||function(){},trace:function(){var e=o("log")||function(){};return function(){return r.env!==t.PRODUCTION?e.apply(console,arguments):void 0}}(),warn:o("warn")||o("log")||function(){}}}),r("utility/string",[],function(){"use strict";return{camelCase:function(e){return e=e.toString(),e=e.replace(/[^\w\-\s]/g,""),e=e.replace(/^[^a-zA-Z]+/,""),e=e.trim(),e=e.toLowerCase(),e=e.replace(/([\-_\s]+)([a-zA-Z\d])/g,function(e,t,r){return r.toUpperCase()}),e=e.replace(/(\d+)([a-zA-Z])/g,function(e,t,r){return t+r.toUpperCase()})}}}),r("serve/errors/base",["require","../../utility/is"],function(e){"use strict";function t(e){Error.call(this),this.message=e||"",r.Function(Error.captureStackTrace)&&Error.captureStackTrace(this,this.constructor)}var r=e("../../utility/is");return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t.prototype.name="Error",t}),r("serve/errors/dom",["require","./base"],function(e){"use strict";function t(e){r.call(this,"DOM element not found: "+e)}var r=e("./base");return t.prototype=Object.create(r.prototype),t.prototype.constructor=t,t.prototype.name="DOMError",t}),r("serve/frame/child/base",["require","../../../utility/string","../../console","../../errors/dom","../../../utility/object","../../global","../../../utility/number","../../../utility/is","../../../utility/uri"],function(e){"use strict";function t(e,t){if(null==e)throw new TypeError("Target div for ad placement must be specified");if(!document.getElementById(e))throw new o(e);this.config=Object.freeze(i(!0,{size:JSON.parse(u.getQueryParameter("size"))},a.config,t,{div:e})),function(e){if(null==e.adzerk.network_id)throw new TypeError("Adzerk network ID must be specified");if(!s.isPositiveInteger(e.adzerk.network_id))throw new TypeError("Adzerk network ID must be a positive integer");if(null==e.adzerk.site_id)throw new TypeError("Adzerk site ID must be specified");if(!s.isPositiveInteger(e.adzerk.site_id))throw new TypeError("Adzerk site ID must be a positive integer");if(null==e.size)throw new TypeError("Ad size must be specified");if(!s.isPositiveInteger(e.size))throw new TypeError("Ad size must be a positive integer")}(this.config),n.trace("Creating ad placement");try{this.placement=ados_add_placement(this.config.adzerk.network_id,this.config.adzerk.site_id,this.config.div,this.config.size)}catch(r){if(r instanceof ReferenceError)return;throw r}this.params=Object.freeze(function(){var e={},t=u.getQueryParameter("keywords");if(void 0!==t)try{if(t=JSON.parse(t),!c.Array(t))throw new TypeError("Keywords must be an array");e.keywords=t}catch(r){n.warn(r.toString())}var o=u.getQueryParameter("properties");if(void 0!==o)try{if(o=JSON.parse(o),!c.PlainObject(o)||c.Array(o))throw new TypeError("Properties must be an object");e.properties=o}catch(r){n.warn(r.toString())}var i=u.getQueryParameter("refresh");if(void 0!==i)try{if(i=parseInt(i,10),!s.isPositiveInteger(i))throw new TypeError("Refresh interval must be a positive integer");e.refresh=i}catch(r){n.warn(r.toString())}var a=u.getQueryParameter("zone");if(void 0!==a)try{if(a=parseInt(a,10),!s.isPositiveInteger(a))throw new TypeError("Zone ID must be a positive integer");e.zone=a}catch(r){n.warn(r.toString())}return e}()),function(e){try{e.hasOwnProperty("refresh")&&this.setRefreshInterval(e.refresh)}catch(t){n.warn("Unable to set refresh interval",t.toString())}try{e.hasOwnProperty("zone")&&this.setZone(e.zone)}catch(t){n.warn("Unable to set zone",t.toString())}try{e.hasOwnProperty("keywords")&&this.setKeywords(e.keywords)}catch(t){n.warn("Unable to set ad targeting keywords",t.toString())}try{e.hasOwnProperty("properties")&&this.setProperties(e.properties)}catch(t){n.warn("Unable to set ad targeting properties",t.toString())}}.call(this,this.params),n.debug("ChildFrame",this)}var r=e("../../../utility/string").camelCase,n=e("../../console"),o=e("../../errors/dom"),i=e("../../../utility/object").extend,a=e("../../global"),s=e("../../../utility/number"),c=e("../../../utility/is"),u=e("../../../utility/uri");return t.prototype={addKeywords:function(){for(var e=this.getKeywords(),t=function(t){try{if(!c.String(t))throw new TypeError("Keyword must be a string");e.indexOf(t)<0&&(n.trace("Adding keyword",t),e.push(t))}catch(r){n.warn("Unable to add keyword",r.toString())}},r=0;r<arguments.length;r++)if(c.Array(arguments[r]))for(var o=0;o<arguments[r].length;o++)t(arguments[r][o]);else t(arguments[r]);this.setKeywords(e)},getKeywords:function(){return window.ados.keywords?window.ados.keywords.split(","):[]},getProperties:function(){return this.placement.Properties||{}},info:function(){n.info(this)},load:function(){n.trace("Loading the ad placement"),ados_load()},refresh:function(){n.trace("Refreshing ad placement"),ados_refresh(this.placement)},removeKeywords:function(){for(var e=this.getKeywords(),t=0;t<e.length;t++){var r=e[t];Array.prototype.indexOf.call(arguments,r)>=0&&(n.trace("Removing keyword",r),e.splice(t,1))}this.setKeywords(e)},resetKeywords:function(){n.trace("Resetting keywords"),this.setKeywords([])},resetProperties:function(){n.trace("Resetting properties"),this.placement.Properties={}},resetProperty:function(e){n.trace("Resetting property",e),delete this.placement.Properties[e]},setKeywords:function(e){if(!c.Array(e))throw new TypeError("Keywords must be specified as an array");n.trace("Setting keywords",e),ados_setKeywords(e.join(","))},setProperties:function(e){if(!c.PlainObject(e)||c.Array(e))throw new TypeError("Properties must be specified as an object");for(var t in e)e.hasOwnProperty(t)&&this.setProperty(t,e[t])},setProperty:function(e,t){var o=function(e,t){e=r(e),n.trace("Setting property",e,"=>",t),this.placement.setProperty(e,t)}.bind(this);for(var i in this.config.rewrites)if(this.config.rewrites.hasOwnProperty(i)){var a=this.config.rewrites[i];if(i=new RegExp(i),i.test(e)){var s=i.exec(e)[1],u=a(t);if(!c.Object(u))throw new TypeError(a);for(var l in u)if(u.hasOwnProperty(l)){var f=u[l];"keywords"===l?this.addKeywords(f):o((s||"")+l,f)}return}}"keywords"===e?this.addKeywords(t):o(e,t)},setRefreshInterval:function(){function e(){null!==r&&(clearInterval(r),r=null)}var r=null;return function(o){var i=function(n){e(),r=setInterval(t.prototype.refresh.bind(this),1e3*n)}.bind(this);if(null==o||s.isInteger(o)&&!s.isPositiveInteger(o))n.trace("Disabling refresh"),e();else{if(!s.isPositiveInteger(o))throw new TypeError("Refresh interval must be a positive integer");o=parseInt(o,10),n.trace("Enabling ad refresh with interval:",o+" seconds"),i(o)}}}.call(this),setZone:function(e){if(!s.isPositiveInteger(e))throw new TypeError("Zone ID must be a positive integer");e=parseInt(e,10),n.trace("Setting zone",e),this.placement.setZone(e)}},t.prototype.constructor=t,t}),r("serve/operation",["require","./frame/child/base","./errors/base","../utility/is"],function(e){"use strict";function t(e){if(void 0===typeof e)throw new TypeError("Operation not specified");if(!o.String(e))throw new TypeError("Operation must be a string");if(0!==e.lastIndexOf("_",0))throw new TypeError("Operation must be prefixed with an underscore");if(this.method=e.slice(1),!r.hasOwnProperty(this.method)||r[this.method]===r.constructor)throw new n("No method corresponding to '"+e+"' operation");this.params=Array.prototype.slice.call(arguments,1),this.timestamp=(new Date).getTime(),this.errors=[]}var r=e("./frame/child/base").prototype,n=e("./errors/base"),o=e("../utility/is");return t.prototype={apply:function(e){o.Array(e)||(e=[e]);for(var t=0;t<e.length;t++){var r=e[t];try{r[this.method].apply(r,this.params)}catch(n){this.errors.push(n)}}}},t.prototype.constructor=t,t}),function(e,t,r,n,o,i){function a(e,t){var r=typeof e[t];return"function"==r||!("object"!=r||!e[t])||"unknown"==r}function s(e,t){return!("object"!=typeof e[t]||!e[t])}function c(e){return"[object Array]"===Object.prototype.toString.call(e)}function u(){var e="Shockwave Flash",t="application/x-shockwave-flash";if(!w(navigator.plugins)&&"object"==typeof navigator.plugins[e]){var r=navigator.plugins[e].description;r&&!w(navigator.mimeTypes)&&navigator.mimeTypes[t]&&navigator.mimeTypes[t].enabledPlugin&&(T=r.match(/\d+/g))}if(!T){var n;try{n=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"),T=Array.prototype.slice.call(n.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/),1),n=null}catch(o){}}if(!T)return!1;var i=parseInt(T[0],10),a=parseInt(T[1],10);return S=i>9&&a>0,!0}function l(){if(!B){B=!0;for(var e=0;e<Q.length;e++)Q[e]();Q.length=0}}function f(e,t){return B?void e.call(t):void Q.push(function(){e.call(t)})}function p(){var e=parent;if(""!==C)for(var t=0,r=C.split(".");t<r.length;t++)e=e[r[t]];return e.easyXDM}function d(t){return e.easyXDM=U,C=t,C&&(X="easyXDM_"+C.replace(".","_")+"_"),L}function h(e){return e.match(A)[3]}function m(e){return e.match(A)[4]||""}function g(e){var t=e.toLowerCase().match(A),r=t[2],n=t[3],o=t[4]||"";return("http:"==r&&":80"==o||"https:"==r&&":443"==o)&&(o=""),r+"//"+n+o}function y(e){if(e=e.replace(N,"$1/"),!e.match(/^(http||https):\/\//)){var t="/"===e.substring(0,1)?"":r.pathname;"/"!==t.substring(t.length-1)&&(t=t.substring(0,t.lastIndexOf("/")+1)),e=r.protocol+"//"+r.host+t+e}for(;z.test(e);)e=e.replace(z,"");return e}function v(e,t){var r="",n=e.indexOf("#");-1!==n&&(r=e.substring(n),e=e.substring(0,n));var o=[];for(var a in t)t.hasOwnProperty(a)&&o.push(a+"="+i(t[a]));return e+(q?"#":-1==e.indexOf("?")?"?":"&")+o.join("&")+r}function w(e){return"undefined"==typeof e}function b(e,t,r){var n;for(var o in t)t.hasOwnProperty(o)&&(o in e?(n=t[o],"object"==typeof n?b(e[o],n,r):r||(e[o]=t[o])):e[o]=t[o]);return e}function O(){var e=t.body.appendChild(t.createElement("form")),r=e.appendChild(t.createElement("input"));r.name=X+"TEST"+I,E=r!==e.elements[r.name],t.body.removeChild(e)}function k(e){w(E)&&O();var r;E?r=t.createElement('<iframe name="'+e.props.name+'"/>'):(r=t.createElement("IFRAME"),r.name=e.props.name),r.id=r.name=e.props.name,delete e.props.name,"string"==typeof e.container&&(e.container=t.getElementById(e.container)),e.container||(b(r.style,{position:"absolute",top:"-2000px",left:"0px"}),e.container=t.body);var n=e.props.src;if(e.props.src="javascript:false",b(r,e.props),r.border=r.frameBorder=0,r.allowTransparency=!0,e.container.appendChild(r),e.onLoad&&R(r,"load",e.onLoad),e.usePost){var o,i=e.container.appendChild(t.createElement("form"));if(i.target=r.name,i.action=n,i.method="POST","object"==typeof e.usePost)for(var a in e.usePost)e.usePost.hasOwnProperty(a)&&(E?o=t.createElement('<input name="'+a+'"/>'):(o=t.createElement("INPUT"),o.name=a),o.value=e.usePost[a],i.appendChild(o));i.submit(),i.parentNode.removeChild(i)}else r.src=n;return e.props.src=n,r}function P(e,t){"string"==typeof e&&(e=[e]);for(var r,n=e.length;n--;)if(r=e[n],r=new RegExp("^"==r.substr(0,1)?r:"^"+r.replace(/(\*)/g,".$1").replace(/\?/g,".")+"$"),r.test(t))return!0;return!1}function _(n){var o,i=n.protocol;if(n.isHost=n.isHost||w(J.xdm_p),q=n.hash||!1,n.props||(n.props={}),n.isHost)n.remote=y(n.remote),n.channel=n.channel||"default"+I++,n.secret=Math.random().toString(16).substring(2),w(i)&&(i=g(r.href)==g(n.remote)?"4":a(e,"postMessage")||a(t,"postMessage")?"1":n.swf&&a(e,"ActiveXObject")&&u()?"6":"Gecko"===navigator.product&&"frameElement"in e&&-1==navigator.userAgent.indexOf("WebKit")?"5":n.remoteHelper?"2":"0");else if(n.channel=J.xdm_c.replace(/["'<>\\]/g,""),n.secret=J.xdm_s,n.remote=J.xdm_e.replace(/["'<>\\]/g,""),i=J.xdm_p,n.acl&&!P(n.acl,n.remote))throw new Error("Access denied for "+n.remote);switch(n.protocol=i,i){case"0":if(b(n,{interval:100,delay:2e3,useResize:!0,useParent:!1,usePolling:!1},!0),n.isHost){if(!n.local){for(var s,c=r.protocol+"//"+r.host,l=t.body.getElementsByTagName("img"),f=l.length;f--;)if(s=l[f],s.src.substring(0,c.length)===c){n.local=s.src;break}n.local||(n.local=e)}var p={xdm_c:n.channel,xdm_p:0};n.local===e?(n.usePolling=!0,n.useParent=!0,n.local=r.protocol+"//"+r.host+r.pathname+r.search,p.xdm_e=n.local,p.xdm_pa=1):p.xdm_e=y(n.local),n.container&&(n.useResize=!1,p.xdm_po=1),n.remote=v(n.remote,p)}else b(n,{channel:J.xdm_c,remote:J.xdm_e,useParent:!w(J.xdm_pa),usePolling:!w(J.xdm_po),useResize:n.useParent?!1:n.useResize});o=[new L.stack.HashTransport(n),new L.stack.ReliableBehavior({}),new L.stack.QueueBehavior({encode:!0,maxLength:4e3-n.remote.length}),new L.stack.VerifyBehavior({initiate:n.isHost})];break;case"1":o=[new L.stack.PostMessageTransport(n)];break;case"2":n.isHost&&(n.remoteHelper=y(n.remoteHelper)),o=[new L.stack.NameTransport(n),new L.stack.QueueBehavior,new L.stack.VerifyBehavior({initiate:n.isHost})];break;case"3":o=[new L.stack.NixTransport(n)];break;case"4":o=[new L.stack.SameOriginTransport(n)];break;case"5":o=[new L.stack.FrameElementTransport(n)];break;case"6":T||u(),o=[new L.stack.FlashTransport(n)]}return o.push(new L.stack.QueueBehavior({lazy:n.lazy,remove:!0})),o}function j(e){for(var t,r={incoming:function(e,t){this.up.incoming(e,t)},outgoing:function(e,t){this.down.outgoing(e,t)},callback:function(e){this.up.callback(e)},init:function(){this.down.init()},destroy:function(){this.down.destroy()}},n=0,o=e.length;o>n;n++)t=e[n],b(t,r,!0),0!==n&&(t.down=e[n-1]),n!==o-1&&(t.up=e[n+1]);return t}function x(e){e.up.down=e.down,e.down.up=e.up,e.up=e.down=null}var E,T,S,R,M,D=this,I=Math.floor(1e4*Math.random()),F=Function.prototype,A=/^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/,z=/[\-\w]+\/\.\.\//,N=/([^:])\/\//g,C="",L={},U=e.easyXDM,X="easyXDM_",q=!1;if(a(e,"addEventListener"))R=function(e,t,r){e.addEventListener(t,r,!1)},M=function(e,t,r){e.removeEventListener(t,r,!1)};else{if(!a(e,"attachEvent"))throw new Error("Browser not supported");R=function(e,t,r){e.attachEvent("on"+t,r)},M=function(e,t,r){e.detachEvent("on"+t,r)}}var H,B=!1,Q=[];if("readyState"in t?(H=t.readyState,B="complete"==H||~navigator.userAgent.indexOf("AppleWebKit/")&&("loaded"==H||"interactive"==H)):B=!!t.body,!B){if(a(e,"addEventListener"))R(t,"DOMContentLoaded",l);else if(R(t,"readystatechange",function(){"complete"==t.readyState&&l()}),t.documentElement.doScroll&&e===top){var K=function(){if(!B){try{t.documentElement.doScroll("left")}catch(e){return void n(K,1)}l()}};K()}R(e,"load",l)}var J=function(e){e=e.substring(1).split("&");for(var t,r={},n=e.length;n--;)t=e[n].split("="),r[t[0]]=o(t[1]);return r}(/xdm_e=/.test(r.search)?r.search:r.hash),W=function(){var e={},t={a:[1,2,3]},r='{"a":[1,2,3]}';return"undefined"!=typeof JSON&&"function"==typeof JSON.stringify&&JSON.stringify(t).replace(/\s/g,"")===r?JSON:(Object.toJSON&&Object.toJSON(t).replace(/\s/g,"")===r&&(e.stringify=Object.toJSON),"function"==typeof String.prototype.evalJSON&&(t=r.evalJSON(),t.a&&3===t.a.length&&3===t.a[2]&&(e.parse=function(e){return e.evalJSON()})),e.stringify&&e.parse?(W=function(){return e},e):null)};b(L,{version:"2.4.19.3",query:J,stack:{},apply:b,getJSONObject:W,whenReady:f,noConflict:d}),L.DomHelper={on:R,un:M,requiresJSON:function(r){s(e,"JSON")||t.write('<script type="text/javascript" src="'+r+'"></script>')}},function(){var e={};L.Fn={set:function(t,r){e[t]=r},get:function(t,r){if(e.hasOwnProperty(t)){var n=e[t];return r&&delete e[t],n}}}}(),L.Socket=function(e){var t=j(_(e).concat([{incoming:function(t,r){e.onMessage(t,r)},callback:function(t){e.onReady&&e.onReady(t)}}])),r=g(e.remote);this.origin=g(e.remote),this.destroy=function(){t.destroy()},this.postMessage=function(e){t.outgoing(e,r)},t.init()},L.Rpc=function(e,t){if(t.local)for(var r in t.local)if(t.local.hasOwnProperty(r)){var n=t.local[r];"function"==typeof n&&(t.local[r]={method:n})}var o=j(_(e).concat([new L.stack.RpcBehavior(this,t),{callback:function(t){e.onReady&&e.onReady(t)}}]));this.origin=g(e.remote),this.destroy=function(){o.destroy()},o.init()},L.stack.SameOriginTransport=function(e){var t,o,i,a;return t={outgoing:function(e,t,r){i(e),r&&r()},destroy:function(){o&&(o.parentNode.removeChild(o),o=null)},onDOMReady:function(){a=g(e.remote),e.isHost?(b(e.props,{src:v(e.remote,{xdm_e:r.protocol+"//"+r.host+r.pathname,xdm_c:e.channel,xdm_p:4}),name:X+e.channel+"_provider"}),o=k(e),L.Fn.set(e.channel,function(e){return i=e,n(function(){t.up.callback(!0)},0),function(e){t.up.incoming(e,a)}})):(i=p().Fn.get(e.channel,!0)(function(e){t.up.incoming(e,a)}),n(function(){t.up.callback(!0)},0))},init:function(){f(t.onDOMReady,t)}}},L.stack.FlashTransport=function(e){function o(e){n(function(){s.up.incoming(e,u)},0)}function a(r){var n=e.swf+"?host="+e.isHost,o="easyXDM_swf_"+Math.floor(1e4*Math.random());L.Fn.set("flash_loaded"+r.replace(/[\-.]/g,"_"),function(){L.stack.FlashTransport[r].swf=l=p.firstChild;for(var e=L.stack.FlashTransport[r].queue,t=0;t<e.length;t++)e[t]();e.length=0}),e.swfContainer?p="string"==typeof e.swfContainer?t.getElementById(e.swfContainer):e.swfContainer:(p=t.createElement("div"),b(p.style,S&&e.swfNoThrottle?{height:"20px",width:"20px",position:"fixed",right:0,top:0}:{height:"1px",width:"1px",position:"absolute",overflow:"hidden",right:0,top:0}),t.body.appendChild(p));var a="callback=flash_loaded"+i(r.replace(/[\-.]/g,"_"))+"&proto="+D.location.protocol+"&domain="+i(h(D.location.href))+"&port="+i(m(D.location.href))+"&ns="+i(C);p.innerHTML="<object height='20' width='20' type='application/x-shockwave-flash' id='"+o+"' data='"+n+"'><param name='allowScriptAccess' value='always'></param><param name='wmode' value='transparent'><param name='movie' value='"+n+"'></param><param name='flashvars' value='"+a+"'></param><embed type='application/x-shockwave-flash' FlashVars='"+a+"' allowScriptAccess='always' wmode='transparent' src='"+n+"' height='1' width='1'></embed></object>"}var s,c,u,l,p;return s={outgoing:function(t,r,n){l.postMessage(e.channel,t.toString()),n&&n()},destroy:function(){try{l.destroyChannel(e.channel)}catch(t){}l=null,c&&(c.parentNode.removeChild(c),c=null)},onDOMReady:function(){u=e.remote,L.Fn.set("flash_"+e.channel+"_init",function(){n(function(){s.up.callback(!0)})}),L.Fn.set("flash_"+e.channel+"_onMessage",o),e.swf=y(e.swf);var t=h(e.swf),i=function(){L.stack.FlashTransport[t].init=!0,l=L.stack.FlashTransport[t].swf,l.createChannel(e.channel,e.secret,g(e.remote),e.isHost),e.isHost&&(S&&e.swfNoThrottle&&b(e.props,{position:"fixed",right:0,top:0,height:"20px",width:"20px"}),b(e.props,{src:v(e.remote,{xdm_e:g(r.href),xdm_c:e.channel,xdm_p:6,xdm_s:e.secret}),name:X+e.channel+"_provider"}),c=k(e))};L.stack.FlashTransport[t]&&L.stack.FlashTransport[t].init?i():L.stack.FlashTransport[t]?L.stack.FlashTransport[t].queue.push(i):(L.stack.FlashTransport[t]={queue:[i]},a(t))},init:function(){f(s.onDOMReady,s)}}},L.stack.PostMessageTransport=function(t){function o(e){if(e.origin)return g(e.origin);if(e.uri)return g(e.uri);if(e.domain)return r.protocol+"//"+e.domain;throw"Unable to retrieve the origin of the event"}function i(e){var r=o(e);r==u&&e.data.substring(0,t.channel.length+1)==t.channel+" "&&a.up.incoming(e.data.substring(t.channel.length+1),r)}var a,s,c,u;return a={outgoing:function(e,r,n){c.postMessage(t.channel+" "+e,r||u),n&&n()},destroy:function(){M(e,"message",i),s&&(c=null,s.parentNode.removeChild(s),s=null)},onDOMReady:function(){if(u=g(t.remote),t.isHost){var o=function(r){r.data==t.channel+"-ready"&&(c="postMessage"in s.contentWindow?s.contentWindow:s.contentWindow.document,M(e,"message",o),R(e,"message",i),n(function(){a.up.callback(!0)},0))};R(e,"message",o),b(t.props,{src:v(t.remote,{xdm_e:g(r.href),xdm_c:t.channel,xdm_p:1}),name:X+t.channel+"_provider"}),s=k(t)}else R(e,"message",i),c="postMessage"in e.parent?e.parent:e.parent.document,c.postMessage(t.channel+"-ready",u),n(function(){a.up.callback(!0)},0)},init:function(){f(a.onDOMReady,a)}}},L.stack.FrameElementTransport=function(o){var i,a,s,c;return i={outgoing:function(e,t,r){s.call(this,e),r&&r()},destroy:function(){a&&(a.parentNode.removeChild(a),a=null)},onDOMReady:function(){c=g(o.remote),o.isHost?(b(o.props,{src:v(o.remote,{xdm_e:g(r.href),xdm_c:o.channel,xdm_p:5}),name:X+o.channel+"_provider"}),a=k(o),a.fn=function(e){return delete a.fn,s=e,n(function(){i.up.callback(!0)},0),function(e){i.up.incoming(e,c)}}):(t.referrer&&g(t.referrer)!=J.xdm_e&&(e.top.location=J.xdm_e),s=e.frameElement.fn(function(e){i.up.incoming(e,c)}),i.up.callback(!0))},init:function(){f(i.onDOMReady,i)}}},L.stack.NameTransport=function(e){function t(t){var r=e.remoteHelper+(s?"#_3":"#_2")+e.channel;c.contentWindow.sendMessage(t,r)}function r(){s?2!==++l&&s||a.up.callback(!0):(t("ready"),a.up.callback(!0))}function o(e){a.up.incoming(e,d)}function i(){p&&n(function(){p(!0)},0)}var a,s,c,u,l,p,d,h;return a={outgoing:function(e,r,n){p=n,t(e)},destroy:function(){c.parentNode.removeChild(c),c=null,s&&(u.parentNode.removeChild(u),u=null)},onDOMReady:function(){s=e.isHost,l=0,d=g(e.remote),e.local=y(e.local),s?(L.Fn.set(e.channel,function(t){s&&"ready"===t&&(L.Fn.set(e.channel,o),r())}),h=v(e.remote,{xdm_e:e.local,xdm_c:e.channel,xdm_p:2}),b(e.props,{src:h+"#"+e.channel,name:X+e.channel+"_provider"}),u=k(e)):(e.remoteHelper=e.remote,L.Fn.set(e.channel,o));var t=function(){var o=c||this;M(o,"load",t),L.Fn.set(e.channel+"_load",i),function a(){"function"==typeof o.contentWindow.sendMessage?r():n(a,50)}()};c=k({props:{src:e.local+"#_4"+e.channel},onLoad:t})},init:function(){f(a.onDOMReady,a)}}},L.stack.HashTransport=function(t){function r(e){if(m){var r=t.remote+"#"+d++ +"_"+e;(c||!y?m.contentWindow:m).location=r}}function o(e){p=e,s.up.incoming(p.substring(p.indexOf("_")+1),v)}function i(){if(h){var e=h.location.href,t="",r=e.indexOf("#");-1!=r&&(t=e.substring(r)),t&&t!=p&&o(t)}}function a(){u=setInterval(i,l)}var s,c,u,l,p,d,h,m,y,v;return s={outgoing:function(e){r(e)},destroy:function(){e.clearInterval(u),(c||!y)&&m.parentNode.removeChild(m),m=null},onDOMReady:function(){if(c=t.isHost,l=t.interval,p="#"+t.channel,d=0,y=t.useParent,v=g(t.remote),c){if(b(t.props,{src:t.remote,name:X+t.channel+"_provider"}),y)t.onLoad=function(){h=e,a(),s.up.callback(!0)};else{var r=0,o=t.delay/50;!function i(){if(++r>o)throw new Error("Unable to reference listenerwindow");try{h=m.contentWindow.frames[X+t.channel+"_consumer"]}catch(e){}h?(a(),s.up.callback(!0)):n(i,50)}()}m=k(t)}else h=e,a(),y?(m=parent,s.up.callback(!0)):(b(t,{props:{src:t.remote+"#"+t.channel+new Date,name:X+t.channel+"_consumer"},onLoad:function(){s.up.callback(!0)}}),m=k(t))},init:function(){f(s.onDOMReady,s)}}},L.stack.ReliableBehavior=function(){var e,t,r=0,n=0,o="";return e={incoming:function(i,a){var s=i.indexOf("_"),c=i.substring(0,s).split(",");i=i.substring(s+1),c[0]==r&&(o="",t&&t(!0)),i.length>0&&(e.down.outgoing(c[1]+","+r+"_"+o,a),n!=c[1]&&(n=c[1],e.up.incoming(i,a)))},outgoing:function(i,a,s){o=i,t=s,e.down.outgoing(n+","+ ++r+"_"+i,a)}}},L.stack.QueueBehavior=function(e){function t(){if(e.remove&&0===s.length)return void x(r);if(!c&&0!==s.length&&!a){c=!0;var o=s.shift();r.down.outgoing(o.data,o.origin,function(e){c=!1,o.callback&&n(function(){o.callback(e)
},0),t()})}}var r,a,s=[],c=!0,u="",l=0,f=!1,p=!1;return r={init:function(){w(e)&&(e={}),e.maxLength&&(l=e.maxLength,p=!0),e.lazy?f=!0:r.down.init()},callback:function(e){c=!1;var n=r.up;t(),n.callback(e)},incoming:function(t,n){if(p){var i=t.indexOf("_"),a=parseInt(t.substring(0,i),10);u+=t.substring(i+1),0===a&&(e.encode&&(u=o(u)),r.up.incoming(u,n),u="")}else r.up.incoming(t,n)},outgoing:function(n,o,a){e.encode&&(n=i(n));var c,u=[];if(p){for(;0!==n.length;)c=n.substring(0,l),n=n.substring(c.length),u.push(c);for(;c=u.shift();)s.push({data:u.length+"_"+c,origin:o,callback:0===u.length?a:null})}else s.push({data:n,origin:o,callback:a});f?r.down.init():t()},destroy:function(){a=!0,r.down.destroy()}}},L.stack.VerifyBehavior=function(e){function t(){n=Math.random().toString(16).substring(2),r.down.outgoing(n)}var r,n,o;return r={incoming:function(i,a){var s=i.indexOf("_");-1===s?i===n?r.up.callback(!0):o||(o=i,e.initiate||t(),r.down.outgoing(i)):i.substring(0,s)===o&&r.up.incoming(i.substring(s+1),a)},outgoing:function(e,t,o){r.down.outgoing(n+"_"+e,t,o)},callback:function(){e.initiate&&t()}}},L.stack.RpcBehavior=function(e,t){function r(e){e.jsonrpc="2.0",i.down.outgoing(a.stringify(e))}function n(e,t){var n=Array.prototype.slice;return function(){var o,i=arguments.length,a={method:t};i>0&&"function"==typeof arguments[i-1]?(i>1&&"function"==typeof arguments[i-2]?(o={success:arguments[i-2],error:arguments[i-1]},a.params=n.call(arguments,0,i-2)):(o={success:arguments[i-1]},a.params=n.call(arguments,0,i-1)),u[""+ ++s]=o,a.id=s):a.params=n.call(arguments,0),e.namedParams&&1===a.params.length&&(a.params=a.params[0]),r(a)}}function o(e,t,n,o){if(!n)return void(t&&r({id:t,error:{code:-32601,message:"Procedure not found."}}));var i,a;t?(i=function(e){i=F,r({id:t,result:e})},a=function(e,n){a=F;var o={id:t,error:{code:-32099,message:e}};n&&(o.error.data=n),r(o)}):i=a=F,c(o)||(o=[o]);try{var s=n.method.apply(n.scope,o.concat([i,a]));w(s)||i(s)}catch(u){a(u.message)}}var i,a=t.serializer||W(),s=0,u={};return i={incoming:function(e){var n=a.parse(e);if(n.method)t.handle?t.handle(n,r):o(n.method,n.id,t.local[n.method],n.params);else{var i=u[n.id];n.error?i.error&&i.error(n.error):i.success&&i.success(n.result),delete u[n.id]}},init:function(){if(t.remote)for(var r in t.remote)t.remote.hasOwnProperty(r)&&(e[r]=n(t.remote[r],r));i.down.init()},destroy:function(){for(var r in t.remote)t.remote.hasOwnProperty(r)&&e.hasOwnProperty(r)&&delete e[r];i.down.destroy()}}},D.easyXDM=L}(window,document,location,window.setTimeout,decodeURIComponent,encodeURIComponent),r("easyXDM",function(e){return function(){var t;return t||e.easyXDM}}(this)),r("serve/frame/parent/base",["require","../../console","../../errors/dom","../../../utility/number","../../../utility/is"],function(e){"use strict";function t(e,t){if(this.div=e.div,void 0===this.div)throw new TypeError("ParentFrame div must be specified");if(!i.String(this.div))throw new TypeError("ParentFrame div must be a string");if(!document.getElementById(this.div))throw new n(this.div);if(this.onLoad=e.onLoad,function(e){if(void 0!==e&&!i.Function(e))throw new TypeError("ParentFrame onLoad callback must be a function")}(this.onLoad),this.onReady=e.onReady,void 0!==this.onReady&&!i.Function(this.onReady))throw new TypeError("ParentFrame onReady callback must be a function");this.params=Object.freeze({keywords:e.keywords,properties:e.properties,refresh:e.refresh,size:JSON.stringify(e.size),zone:e.zone,network_id:t.network_id,site_id:t.site_id}),function(e){if(void 0===e.network_id)throw new TypeError("ParentFrame Network ID must be specified");if(!o.isPositiveInteger(e.network_id))throw new TypeError("ParentFrame Network ID must be a positive integer");if(void 0===e.site_id)throw new TypeError("ParentFrame Site ID must be specified");if(!o.isPositiveInteger(e.site_id))throw new TypeError("ParentFrame Site ID must be a positive integer")}(this.params),r.debug("ParentFrame",this)}var r=e("../../console"),n=e("../../errors/dom"),o=e("../../../utility/number"),i=e("../../../utility/is");return t.prototype=Object.create({}),t.prototype.constructor=t,t}),r("serve/frame/parent/rpc",["require","../child/base","../../console","easyXDM","../../../utility/object","../../global","../../../utility/is","./base","../../../utility/uri"],function(e){"use strict";function t(e){c.call(this,e,a.config.adzerk),this.easyXDM=function(t){return i(!0,{},a.config.easyXDM,e.easyXDM,{container:this.div,remote:f.requestUrl+"?"+u.buildQuery(t),remoteHelper:f.helperUrl,onLoad:this.onLoad,onReady:this.onReady})}.call(this,this.params),function(e){if(void 0===e.remote)throw new TypeError("easyXDM remote URL must be specified");if(!s.String(e.remote))throw new TypeError("easyXDM remote URL must be a string");if(void 0===e.local)n.warn("Recommended configuration is undefined: easyXDM.local");else if(!s.String(e.local))throw new TypeError("easyXDM local URL must be a string");if(void 0===e.remoteHelper)n.warn("Recommended configuration is undefined: easyXDM.remoteHelper");else if(!s.String(e.remoteHelper))throw new TypeError("easyXDM remote helper URL must be a string");if(void 0===e.swf)n.warn("Recommended configuration is undefined: easyXDM.swf");else if(!s.String(e.swf))throw new TypeError("easyXDM swf URL must be a string");if(void 0!==e.hash&&!s.Boolean(e.hash))throw new TypeError("easyXDM hash option must be a boolean");if(void 0!==e.lazy&&!s.Boolean(e.lazy))throw new TypeError("easyXDM lazy option must be a boolean");if(void 0!==e.onLoad&&!s.Function(e.onLoad))throw new TypeError("easyXDM onLoad option must be a function");if(void 0!==e.onReady&&!s.Function(e.onReady))throw new TypeError("easyXDM onReady option must be a function");var t=["container","hash","lazy","local","onLoad","onReady","remote","remoteHelper","swf"];for(var r in e)e.hasOwnProperty(r)&&t.indexOf(r)<0&&n.warn("Unrecognized easyXDM configuration option: '"+r+"'")}(this.easyXDM),o.Rpc.call(this,this.easyXDM,{remote:l}),n.debug("ParentFrameRpc",this)}var r=e("../child/base"),n=e("../../console"),o=e("easyXDM"),i=e("../../../utility/object").extend,a=e("../../global"),s=e("../../../utility/is"),c=e("./base"),u=e("../../../utility/uri"),l=Object.freeze(function(){var e={};for(var t in r.prototype)r.prototype.hasOwnProperty(t)&&r.prototype[t]!==r.prototype.constructor&&(e[t]={});return e}()),f=Object.freeze(function(){if(void 0===a.config.base_url)throw new TypeError("Base URL is not defined");if(!s.String(a.config.base_url))throw new TypeError("Base URL must be a string");var e=window.location.protocol+a.config.base_url.replace(/^https?:/,"").replace(/\/?$/,"/");return{helperUrl:e+"name.html",requestUrl:e+"iframe.html"}}());return t.prototype=Object.create(c.prototype),t.prototype.constructor=t,t}),r("serve/queue",["require","./console","./environments","./global","../utility/is","./operation","./frame/parent/rpc"],function(e){"use strict";function t(){this.errors=[],this.frames=[],this.history=[],this.loaded=!1,this.loading=!1}var r=e("./console"),n=e("./environments"),o=e("./global"),i=e("../utility/is"),a=e("./operation"),s=e("./frame/parent/rpc");return t.prototype={init:function(e){for(var t=new s(e),r=0;r<this.history.length;r++){var n=this.history[r];n.apply(t)}this.loaded&&t.load(),this.frames.push(t)},push:function(){for(var e=0;e<arguments.length;e++){var t=arguments[e];try{if(i.Array(t)||i.String(t)){var s=Object.create(a.prototype);if(i.Array(t)?s.constructor.apply(s,t):i.String(t)&&s.constructor.call(s,t),"load"===s.method){if(this.loading&&(this.loading=!1),this.loaded)continue;this.loaded=!0}else if("refresh"===s.method&&!this.loaded)continue;s.apply(this.frames),this.history.push(s)}else{if(!i.Object(t))throw new TypeError("Argument must be an array, a string or an object");this.init(t)}}catch(c){this.errors.push(c),o.env!==n.PRODUCTION&&r.error(c.toString())}}this.loaded||this.loading||(this.loading=!0,this.push("_load"))}},t.prototype.constructor=t,t}),function(e){"use strict";t(["serve/queue"],function(t){e._adq=function(e){var r=new t;return r.push.apply(r,e||[]),r}(e._adq)})}(window),r("serve/main/parent/adq",function(){})}();
//# sourceMappingURL=adq.js.map
Location: http://ilmanifesto.info/wordpress/wp-content/plugins/boxit/js/plupload/moxie.js?ver=3.9.1
Referrer: http://ilmanifesto.info/
Content-Type: application/javascript
/**
* mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill
* v1.2.0
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*
* Date: 2014-01-16
*/
/**
* Compiled inline version. (Library mode)
*/
/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */
/*globals $code */
(function(exports, undefined) {
"use strict";
var modules = {};
function require(ids, callback) {
var module, defs = [];
for (var i = 0; i < ids.length; ++i) {
module = modules[ids[i]] || resolve(ids[i]);
if (!module) {
throw 'module definition dependecy not found: ' + ids[i];
}
defs.push(module);
}
callback.apply(null, defs);
}
function define(id, dependencies, definition) {
if (typeof id !== 'string') {
throw 'invalid module definition, module id must be defined and be a string';
}
if (dependencies === undefined) {
throw 'invalid module definition, dependencies must be specified';
}
if (definition === undefined) {
throw 'invalid module definition, definition function must be specified';
}
require(dependencies, function() {
modules[id] = definition.apply(null, arguments);
});
}
function defined(id) {
return !!modules[id];
}
function resolve(id) {
var target = exports;
var fragments = id.split(/[.\/]/);
for (var fi = 0; fi < fragments.length; ++fi) {
if (!target[fragments[fi]]) {
return;
}
target = target[fragments[fi]];
}
return target;
}
function expose(ids) {
for (var i = 0; i < ids.length; i++) {
var target = exports;
var id = ids[i];
var fragments = id.split(/[.\/]/);
for (var fi = 0; fi < fragments.length - 1; ++fi) {
if (target[fragments[fi]] === undefined) {
target[fragments[fi]] = {};
}
target = target[fragments[fi]];
}
target[fragments[fragments.length - 1]] = modules[id];
}
}
// Included from: src/javascript/core/utils/Basic.js
/**
* Basic.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Basic', [], function() {
/**
Gets the true type of the built-in object (better version of typeof).
@author Angus Croll (http://javascriptweblog.wordpress.com/)
@method typeOf
@for Utils
@static
@param {Object} o Object to check.
@return {String} Object [[Class]]
*/
var typeOf = function(o) {
var undef;
if (o === undef) {
return 'undefined';
} else if (o === null) {
return 'null';
} else if (o.nodeType) {
return 'node';
}
// the snippet below is awesome, however it fails to detect null, undefined and arguments types in IE lte 8
return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
};
/**
Extends the specified object with another object.
@method extend
@static
@param {Object} target Object to extend.
@param {Object} [obj]* Multiple objects to extend with.
@return {Object} Same as target, the extended object.
*/
var extend = function(target) {
var undef;
each(arguments, function(arg, i) {
if (i > 0) {
each(arg, function(value, key) {
if (value !== undef) {
if (typeOf(target[key]) === typeOf(value) && !!~inArray(typeOf(value), ['array', 'object'])) {
extend(target[key], value);
} else {
target[key] = value;
}
}
});
}
});
return target;
};
/**
Executes the callback function for each item in array/object. If you return false in the
callback it will break the loop.
@method each
@static
@param {Object} obj Object to iterate.
@param {function} callback Callback function to execute for each item.
*/
var each = function(obj, callback) {
var length, key, i, undef;
if (obj) {
try {
length = obj.length;
} catch(ex) {
length = undef;
}
if (length === undef) {
// Loop object items
for (key in obj) {
if (obj.hasOwnProperty(key)) {
if (callback(obj[key], key) === false) {
return;
}
}
}
} else {
// Loop array items
for (i = 0; i < length; i++) {
if (callback(obj[i], i) === false) {
return;
}
}
}
}
};
/**
Checks if object is empty.
@method isEmptyObj
@static
@param {Object} o Object to check.
@return {Boolean}
*/
var isEmptyObj = function(obj) {
var prop;
if (!obj || typeOf(obj) !== 'object') {
return true;
}
for (prop in obj) {
return false;
}
return true;
};
/**
Recieve an array of functions (usually async) to call in sequence, each function
receives a callback as first argument that it should call, when it completes. Finally,
after everything is complete, main callback is called. Passing truthy value to the
callback as a first argument will interrupt the sequence and invoke main callback
immediately.
@method inSeries
@static
@param {Array} queue Array of functions to call in sequence
@param {Function} cb Main callback that is called in the end, or in case of erro
*/
var inSeries = function(queue, cb) {
var i = 0, length = queue.length;
if (typeOf(cb) !== 'function') {
cb = function() {};
}
if (!queue || !queue.length) {
cb();
}
function callNext(i) {
if (typeOf(queue[i]) === 'function') {
queue[i](function(error) {
/*jshint expr:true */
++i < length && !error ? callNext(i) : cb(error);
});
}
}
callNext(i);
};
/**
Recieve an array of functions (usually async) to call in parallel, each function
receives a callback as first argument that it should call, when it completes. After
everything is complete, main callback is called. Passing truthy value to the
callback as a first argument will interrupt the process and invoke main callback
immediately.
@method inParallel
@static
@param {Array} queue Array of functions to call in sequence
@param {Function} cb Main callback that is called in the end, or in case of erro
*/
var inParallel = function(queue, cb) {
var count = 0, num = queue.length, cbArgs = new Array(num);
each(queue, function(fn, i) {
fn(function(error) {
if (error) {
return cb(error);
}
var args = [].slice.call(arguments);
args.shift(); // strip error - undefined or not
cbArgs[i] = args;
count++;
if (count === num) {
cbArgs.unshift(null);
cb.apply(this, cbArgs);
}
});
});
};
/**
Find an element in array and return it's index if present, otherwise return -1.
@method inArray
@static
@param {Mixed} needle Element to find
@param {Array} array
@return {Int} Index of the element, or -1 if not found
*/
var inArray = function(needle, array) {
if (array) {
if (Array.prototype.indexOf) {
return Array.prototype.indexOf.call(array, needle);
}
for (var i = 0, length = array.length; i < length; i++) {
if (array[i] === needle) {
return i;
}
}
}
return -1;
};
/**
Returns elements of first array if they are not present in second. And false - otherwise.
@private
@method arrayDiff
@param {Array} needles
@param {Array} array
@return {Array|Boolean}
*/
var arrayDiff = function(needles, array) {
var diff = [];
if (typeOf(needles) !== 'array') {
needles = [needles];
}
if (typeOf(array) !== 'array') {
array = [array];
}
for (var i in needles) {
if (inArray(needles[i], array) === -1) {
diff.push(needles[i]);
}
}
return diff.length ? diff : false;
};
/**
Find intersection of two arrays.
@private
@method arrayIntersect
@param {Array} array1
@param {Array} array2
@return {Array} Intersection of two arrays or null if there is none
*/
var arrayIntersect = function(array1, array2) {
var result = [];
each(array1, function(item) {
if (inArray(item, array2) !== -1) {
result.push(item);
}
});
return result.length ? result : null;
};
/**
Forces anything into an array.
@method toArray
@static
@param {Object} obj Object with length field.
@return {Array} Array object containing all items.
*/
var toArray = function(obj) {
var i, arr = [];
for (i = 0; i < obj.length; i++) {
arr[i] = obj[i];
}
return arr;
};
/**
Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers.
The only way a user would be able to get the same ID is if the two persons at the same exact milisecond manages
to get 5 the same random numbers between 0-65535 it also uses a counter so each call will be guaranteed to be page unique.
It's more probable for the earth to be hit with an ansteriod. Y
@method guid
@static
@param {String} prefix to prepend (by default 'o' will be prepended).
@method guid
@return {String} Virtually unique id.
*/
var guid = (function() {
var counter = 0;
return function(prefix) {
var guid = new Date().getTime().toString(32), i;
for (i = 0; i < 5; i++) {
guid += Math.floor(Math.random() * 65535).toString(32);
}
return (prefix || 'o_') + guid + (counter++).toString(32);
};
}());
/**
Trims white spaces around the string
@method trim
@static
@param {String} str
@return {String}
*/
var trim = function(str) {
if (!str) {
return str;
}
return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, '');
};
/**
Parses the specified size string into a byte value. For example 10kb becomes 10240.
@method parseSizeStr
@static
@param {String/Number} size String to parse or number to just pass through.
@return {Number} Size in bytes.
*/
var parseSizeStr = function(size) {
if (typeof(size) !== 'string') {
return size;
}
var muls = {
t: 1099511627776,
g: 1073741824,
m: 1048576,
k: 1024
},
mul;
size = /^([0-9]+)([mgk]?)$/.exec(size.toLowerCase().replace(/[^0-9mkg]/g, ''));
mul = size[2];
size = +size[1];
if (muls.hasOwnProperty(mul)) {
size *= muls[mul];
}
return size;
};
return {
guid: guid,
typeOf: typeOf,
extend: extend,
each: each,
isEmptyObj: isEmptyObj,
inSeries: inSeries,
inParallel: inParallel,
inArray: inArray,
arrayDiff: arrayDiff,
arrayIntersect: arrayIntersect,
toArray: toArray,
trim: trim,
parseSizeStr: parseSizeStr
};
});
// Included from: src/javascript/core/I18n.js
/**
* I18n.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/core/I18n", [
"moxie/core/utils/Basic"
], function(Basic) {
var i18n = {};
return {
/**
* Extends the language pack object with new items.
*
* @param {Object} pack Language pack items to add.
* @return {Object} Extended language pack object.
*/
addI18n: function(pack) {
return Basic.extend(i18n, pack);
},
/**
* Translates the specified string by checking for the english string in the language pack lookup.
*
* @param {String} str String to look for.
* @return {String} Translated string or the input string if it wasn't found.
*/
translate: function(str) {
return i18n[str] || str;
},
/**
* Shortcut for translate function
*
* @param {String} str String to look for.
* @return {String} Translated string or the input string if it wasn't found.
*/
_: function(str) {
return this.translate(str);
},
/**
* Pseudo sprintf implementation - simple way to replace tokens with specified values.
*
* @param {String} str String with tokens
* @return {String} String with replaced tokens
*/
sprintf: function(str) {
var args = [].slice.call(arguments, 1);
return str.replace(/%[a-z]/g, function() {
var value = args.shift();
return Basic.typeOf(value) !== 'undefined' ? value : '';
});
}
};
});
// Included from: src/javascript/core/utils/Mime.js
/**
* Mime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/core/utils/Mime", [
"moxie/core/utils/Basic",
"moxie/core/I18n"
], function(Basic, I18n) {
var mimeData = "" +
"application/msword,doc dot," +
"application/pdf,pdf," +
"application/pgp-signature,pgp," +
"application/postscript,ps ai eps," +
"application/rtf,rtf," +
"application/vnd.ms-excel,xls xlb," +
"application/vnd.ms-powerpoint,ppt pps pot," +
"application/zip,zip," +
"application/x-shockwave-flash,swf swfl," +
"application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," +
"application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," +
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," +
"application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," +
"application/vnd.openxmlformats-officedocument.presentationml.template,potx," +
"application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," +
"application/x-javascript,js," +
"application/json,json," +
"audio/mpeg,mp3 mpga mpega mp2," +
"audio/x-wav,wav," +
"audio/x-m4a,m4a," +
"audio/ogg,oga ogg," +
"audio/aiff,aiff aif," +
"audio/flac,flac," +
"audio/aac,aac," +
"audio/ac3,ac3," +
"audio/x-ms-wma,wma," +
"image/bmp,bmp," +
"image/gif,gif," +
"image/jpeg,jpg jpeg jpe," +
"image/photoshop,psd," +
"image/png,png," +
"image/svg+xml,svg svgz," +
"image/tiff,tiff tif," +
"text/plain,asc txt text diff log," +
"text/html,htm html xhtml," +
"text/css,css," +
"text/csv,csv," +
"text/rtf,rtf," +
"video/mpeg,mpeg mpg mpe m2v," +
"video/quicktime,qt mov," +
"video/mp4,mp4," +
"video/x-m4v,m4v," +
"video/x-flv,flv," +
"video/x-ms-wmv,wmv," +
"video/avi,avi," +
"video/webm,webm," +
"video/3gpp,3gpp 3gp," +
"video/3gpp2,3g2," +
"video/vnd.rn-realvideo,rv," +
"video/ogg,ogv," +
"video/x-matroska,mkv," +
"application/vnd.oasis.opendocument.formula-template,otf," +
"application/octet-stream,exe";
var Mime = {
mimes: {},
extensions: {},
// Parses the default mime types string into a mimes and extensions lookup maps
addMimeType: function (mimeData) {
var items = mimeData.split(/,/), i, ii, ext;
for (i = 0; i < items.length; i += 2) {
ext = items[i + 1].split(/ /);
// extension to mime lookup
for (ii = 0; ii < ext.length; ii++) {
this.mimes[ext[ii]] = items[i];
}
// mime to extension lookup
this.extensions[items[i]] = ext;
}
},
extList2mimes: function (filters, addMissingExtensions) {
var self = this, ext, i, ii, type, mimes = [];
// convert extensions to mime types list
for (i = 0; i < filters.length; i++) {
ext = filters[i].extensions.split(/\s*,\s*/);
for (ii = 0; ii < ext.length; ii++) {
// if there's an asterisk in the list, then accept attribute is not required
if (ext[ii] === '*') {
return [];
}
type = self.mimes[ext[ii]];
if (!type) {
if (addMissingExtensions && /^\w+$/.test(ext[ii])) {
mimes.push('.' + ext[ii]);
} else {
return []; // accept all
}
} else if (Basic.inArray(type, mimes) === -1) {
mimes.push(type);
}
}
}
return mimes;
},
mimes2exts: function(mimes) {
var self = this, exts = [];
Basic.each(mimes, function(mime) {
if (mime === '*') {
exts = [];
return false;
}
// check if this thing looks like mime type
var m = mime.match(/^(\w+)\/(\*|\w+)$/);
if (m) {
if (m[2] === '*') {
// wildcard mime type detected
Basic.each(self.extensions, function(arr, mime) {
if ((new RegExp('^' + m[1] + '/')).test(mime)) {
[].push.apply(exts, self.extensions[mime]);
}
});
} else if (self.extensions[mime]) {
[].push.apply(exts, self.extensions[mime]);
}
}
});
return exts;
},
mimes2extList: function(mimes) {
var accept = [], exts = [];
if (Basic.typeOf(mimes) === 'string') {
mimes = Basic.trim(mimes).split(/\s*,\s*/);
}
exts = this.mimes2exts(mimes);
accept.push({
title: I18n.translate('Files'),
extensions: exts.length ? exts.join(',') : '*'
});
// save original mimes string
accept.mimes = mimes;
return accept;
},
getFileExtension: function(fileName) {
var matches = fileName && fileName.match(/\.([^.]+)$/);
if (matches) {
return matches[1].toLowerCase();
}
return '';
},
getFileMime: function(fileName) {
return this.mimes[this.getFileExtension(fileName)] || '';
}
};
Mime.addMimeType(mimeData);
return Mime;
});
// Included from: src/javascript/core/utils/Env.js
/**
* Env.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/core/utils/Env", [
"moxie/core/utils/Basic"
], function(Basic) {
// UAParser.js v0.6.2
// Lightweight JavaScript-based User-Agent string parser
// https://github.com/faisalman/ua-parser-js
//
// Copyright © 2012-2013 Faisalman <[email protected]>
// Dual licensed under GPLv2 & MIT
var UAParser = (function (undefined) {
//////////////
// Constants
/////////////
var EMPTY = '',
UNKNOWN = '?',
FUNC_TYPE = 'function',
UNDEF_TYPE = 'undefined',
OBJ_TYPE = 'object',
MAJOR = 'major',
MODEL = 'model',
NAME = 'name',
TYPE = 'type',
VENDOR = 'vendor',
VERSION = 'version',
ARCHITECTURE= 'architecture',
CONSOLE = 'console',
MOBILE = 'mobile',
TABLET = 'tablet';
///////////
// Helper
//////////
var util = {
has : function (str1, str2) {
return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1;
},
lowerize : function (str) {
return str.toLowerCase();
}
};
///////////////
// Map helper
//////////////
var mapper = {
rgx : function () {
// loop through all regexes maps
for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) {
var regex = args[i], // even sequence (0,2,4,..)
props = args[i + 1]; // odd sequence (1,3,5,..)
// construct object barebones
if (typeof(result) === UNDEF_TYPE) {
result = {};
for (p in props) {
q = props[p];
if (typeof(q) === OBJ_TYPE) {
result[q[0]] = undefined;
} else {
result[q] = undefined;
}
}
}
// try matching uastring with regexes
for (j = k = 0; j < regex.length; j++) {
matches = regex[j].exec(this.getUA());
if (!!matches) {
for (p = 0; p < props.length; p++) {
match = matches[++k];
q = props[p];
// check if given property is actually array
if (typeof(q) === OBJ_TYPE && q.length > 0) {
if (q.length == 2) {
if (typeof(q[1]) == FUNC_TYPE) {
// assign modified match
result[q[0]] = q[1].call(this, match);
} else {
// assign given value, ignore regex match
result[q[0]] = q[1];
}
} else if (q.length == 3) {
// check whether function or regex
if (typeof(q[1]) === FUNC_TYPE && !(q[1].exec && q[1].test)) {
// call function (usually string mapper)
result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
} else {
// sanitize match using given regex
result[q[0]] = match ? match.replace(q[1], q[2]) : undefined;
}
} else if (q.length == 4) {
result[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined;
}
} else {
result[q] = match ? match : undefined;
}
}
break;
}
}
if(!!matches) break; // break the loop immediately if match found
}
return result;
},
str : function (str, map) {
for (var i in map) {
// check if array
if (typeof(map[i]) === OBJ_TYPE && map[i].length > 0) {
for (var j = 0; j < map[i].length; j++) {
if (util.has(map[i][j], str)) {
return (i === UNKNOWN) ? undefined : i;
}
}
} else if (util.has(map[i], str)) {
return (i === UNKNOWN) ? undefined : i;
}
}
return str;
}
};
///////////////
// String map
//////////////
var maps = {
browser : {
oldsafari : {
major : {
'1' : ['/8', '/1', '/3'],
'2' : '/4',
'?' : '/'
},
version : {
'1.0' : '/8',
'1.2' : '/1',
'1.3' : '/3',
'2.0' : '/412',
'2.0.2' : '/416',
'2.0.3' : '/417',
'2.0.4' : '/419',
'?' : '/'
}
}
},
device : {
sprint : {
model : {
'Evo Shift 4G' : '7373KT'
},
vendor : {
'HTC' : 'APA',
'Sprint' : 'Sprint'
}
}
},
os : {
windows : {
version : {
'ME' : '4.90',
'NT 3.11' : 'NT3.51',
'NT 4.0' : 'NT4.0',
'2000' : 'NT 5.0',
'XP' : ['NT 5.1', 'NT 5.2'],
'Vista' : 'NT 6.0',
'7' : 'NT 6.1',
'8' : 'NT 6.2',
'8.1' : 'NT 6.3',
'RT' : 'ARM'
}
}
}
};
//////////////
// Regex map
/////////////
var regexes = {
browser : [[
// Presto based
/(opera\smini)\/((\d+)?[\w\.-]+)/i, // Opera Mini
/(opera\s[mobiletab]+).+version\/((\d+)?[\w\.-]+)/i, // Opera Mobi/Tablet
/(opera).+version\/((\d+)?[\w\.]+)/i, // Opera > 9.80
/(opera)[\/\s]+((\d+)?[\w\.]+)/i // Opera < 9.80
], [NAME, VERSION, MAJOR], [
/\s(opr)\/((\d+)?[\w\.]+)/i // Opera Webkit
], [[NAME, 'Opera'], VERSION, MAJOR], [
// Mixed
/(kindle)\/((\d+)?[\w\.]+)/i, // Kindle
/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?((\d+)?[\w\.]+)*/i,
// Lunascape/Maxthon/Netfront/Jasmine/Blazer
// Trident based
/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?((\d+)?[\w\.]*)/i,
// Avant/IEMobile/SlimBrowser/Baidu
/(?:ms|\()(ie)\s((\d+)?[\w\.]+)/i, // Internet Explorer
// Webkit/KHTML based
/(rekonq)((?:\/)[\w\.]+)*/i, // Rekonq
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron)\/((\d+)?[\w\.-]+)/i
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron
], [NAME, VERSION, MAJOR], [
/(trident).+rv[:\s]((\d+)?[\w\.]+).+like\sgecko/i // IE11
], [[NAME, 'IE'], VERSION, MAJOR], [
/(yabrowser)\/((\d+)?[\w\.]+)/i // Yandex
], [[NAME, 'Yandex'], VERSION, MAJOR], [
/(comodo_dragon)\/((\d+)?[\w\.]+)/i // Comodo Dragon
], [[NAME, /_/g, ' '], VERSION, MAJOR], [
/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?((\d+)?[\w\.]+)/i
// Chrome/OmniWeb/Arora/Tizen/Nokia
], [NAME, VERSION, MAJOR], [
/(dolfin)\/((\d+)?[\w\.]+)/i // Dolphin
], [[NAME, 'Dolphin'], VERSION, MAJOR], [
/((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i // Chrome for Android/iOS
], [[NAME, 'Chrome'], VERSION, MAJOR], [
/((?:android.+))version\/((\d+)?[\w\.]+)\smobile\ssafari/i // Android Browser
], [[NAME, 'Android Browser'], VERSION, MAJOR], [
/version\/((\d+)?[\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
], [VERSION, MAJOR, [NAME, 'Mobile Safari']], [
/version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
], [VERSION, MAJOR, NAME], [
/webkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i // Safari < 3.0
], [NAME, [MAJOR, mapper.str, maps.browser.oldsafari.major], [VERSION, mapper.str, maps.browser.oldsafari.version]], [
/(konqueror)\/((\d+)?[\w\.]+)/i, // Konqueror
/(webkit|khtml)\/((\d+)?[\w\.]+)/i
], [NAME, VERSION, MAJOR], [
// Gecko based
/(navigator|netscape)\/((\d+)?[\w\.-]+)/i // Netscape
], [[NAME, 'Netscape'], VERSION, MAJOR], [
/(swiftfox)/i, // Swiftfox
/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,
// IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i,
// Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
// Other
/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|qqbrowser)[\/\s]?((\d+)?[\w\.]+)/i,
// UCBrowser/Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/QQBrowser
/(links)\s\(((\d+)?[\w\.]+)/i, // Links
/(gobrowser)\/?((\d+)?[\w\.]+)*/i, // GoBrowser
/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i, // ICE Browser
/(mosaic)[\/\s]((\d+)?[\w\.]+)/i // Mosaic
], [NAME, VERSION, MAJOR]
],
engine : [[
/(presto)\/([\w\.]+)/i, // Presto
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m
/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
/(icab)[\/\s]([23]\.[\d\.]+)/i // iCab
], [NAME, VERSION], [
/rv\:([\w\.]+).*(gecko)/i // Gecko
], [VERSION, NAME]
],
os : [[
// Windows based
/(windows)\snt\s6\.2;\s(arm)/i, // Windows RT
/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i
], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [
/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i
], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [
// Mobile/Embedded OS
/\((bb)(10);/i // BlackBerry 10
], [[NAME, 'BlackBerry'], VERSION], [
/(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry
/(tizen)\/([\w\.]+)/i, // Tizen
/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego)[\/\s-]?([\w\.]+)*/i
// Android/WebOS/Palm/QNX/Bada/RIM/MeeGo
], [NAME, VERSION], [
/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian
], [[NAME, 'Symbian'], VERSION],[
/mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS
], [[NAME, 'Firefox OS'], VERSION], [
// Console
/(nintendo|playstation)\s([wids3portablevu]+)/i, // Nintendo/Playstation
// GNU/Linux based
/(mint)[\/\s\(]?(\w+)*/i, // Mint
/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk)[\/\s-]?([\w\.-]+)*/i,
// Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
// Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk
/(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux
/(gnu)\s?([\w\.]+)*/i // GNU
], [NAME, VERSION], [
/(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS
], [[NAME, 'Chromium OS'], VERSION],[
// Solaris
/(sunos)\s?([\w\.]+\d)*/i // Solaris
], [[NAME, 'Solaris'], VERSION], [
// BSD based
/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly
], [NAME, VERSION],[
/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i // iOS
], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [
/(mac\sos\sx)\s?([\w\s\.]+\w)*/i // Mac OS
], [NAME, [VERSION, /_/g, '.']], [
// Other
/(haiku)\s(\w+)/i, // Haiku
/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, // AIX
/(macintosh|mac(?=_powerpc)|plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos)/i,
// Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS
/(unix)\s?([\w\.]+)*/i // UNIX
], [NAME, VERSION]
]
};
/////////////////
// Constructor
////////////////
var UAParser = function (uastring) {
var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
this.getBrowser = function () {
return mapper.rgx.apply(this, regexes.browser);
};
this.getEngine = function () {
return mapper.rgx.apply(this, regexes.engine);
};
this.getOS = function () {
return mapper.rgx.apply(this, regexes.os);
};
this.getResult = function() {
return {
ua : this.getUA(),
browser : this.getBrowser(),
engine : this.getEngine(),
os : this.getOS()
};
};
this.getUA = function () {
return ua;
};
this.setUA = function (uastring) {
ua = uastring;
return this;
};
this.setUA(ua);
};
return new UAParser().getResult();
})();
function version_compare(v1, v2, operator) {
// From: http://phpjs.org/functions
// + original by: Philippe Jausions (http://pear.php.net/user/jausions)
// + original by: Aidan Lister (http://aidanlister.com/)
// + reimplemented by: Kankrelune (http://www.webfaktory.info/)
// + improved by: Brett Zamir (http://brett-zamir.me)
// + improved by: Scott Baker
// + improved by: Theriault
// * example 1: version_compare('8.2.5rc', '8.2.5a');
// * returns 1: 1
// * example 2: version_compare('8.2.50', '8.2.52', '<');
// * returns 2: true
// * example 3: version_compare('5.3.0-dev', '5.3.0');
// * returns 3: -1
// * example 4: version_compare('4.1.0.52','4.01.0.51');
// * returns 4: 1
// Important: compare must be initialized at 0.
var i = 0,
x = 0,
compare = 0,
// vm maps textual PHP versions to negatives so they're less than 0.
// PHP currently defines these as CASE-SENSITIVE. It is important to
// leave these as negatives so that they can come before numerical versions
// and as if no letters were there to begin with.
// (1alpha is < 1 and < 1.1 but > 1dev1)
// If a non-numerical value can't be mapped to this table, it receives
// -7 as its value.
vm = {
'dev': -6,
'alpha': -5,
'a': -5,
'beta': -4,
'b': -4,
'RC': -3,
'rc': -3,
'#': -2,
'p': 1,
'pl': 1
},
// This function will be called to prepare each version argument.
// It replaces every _, -, and + with a dot.
// It surrounds any nonsequence of numbers/dots with dots.
// It replaces sequences of dots with a single dot.
// version_compare('4..0', '4.0') == 0
// Important: A string of 0 length needs to be converted into a value
// even less than an unexisting value in vm (-7), hence [-8].
// It's also important to not strip spaces because of this.
// version_compare('', ' ') == 1
prepVersion = function (v) {
v = ('' + v).replace(/[_\-+]/g, '.');
v = v.replace(/([^.\d]+)/g, '.$1.').replace(/\.{2,}/g, '.');
return (!v.length ? [-8] : v.split('.'));
},
// This converts a version component to a number.
// Empty component becomes 0.
// Non-numerical component becomes a negative number.
// Numerical component becomes itself as an integer.
numVersion = function (v) {
return !v ? 0 : (isNaN(v) ? vm[v] || -7 : parseInt(v, 10));
};
v1 = prepVersion(v1);
v2 = prepVersion(v2);
x = Math.max(v1.length, v2.length);
for (i = 0; i < x; i++) {
if (v1[i] == v2[i]) {
continue;
}
v1[i] = numVersion(v1[i]);
v2[i] = numVersion(v2[i]);
if (v1[i] < v2[i]) {
compare = -1;
break;
} else if (v1[i] > v2[i]) {
compare = 1;
break;
}
}
if (!operator) {
return compare;
}
// Important: operator is CASE-SENSITIVE.
// "No operator" seems to be treated as "<."
// Any other values seem to make the function return null.
switch (operator) {
case '>':
case 'gt':
return (compare > 0);
case '>=':
case 'ge':
return (compare >= 0);
case '<=':
case 'le':
return (compare <= 0);
case '==':
case '=':
case 'eq':
return (compare === 0);
case '<>':
case '!=':
case 'ne':
return (compare !== 0);
case '':
case '<':
case 'lt':
return (compare < 0);
default:
return null;
}
}
var can = (function() {
var caps = {
define_property: (function() {
/* // currently too much extra code required, not exactly worth it
try { // as of IE8, getters/setters are supported only on DOM elements
var obj = {};
if (Object.defineProperty) {
Object.defineProperty(obj, 'prop', {
enumerable: true,
configurable: true
});
return true;
}
} catch(ex) {}
if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) {
return true;
}*/
return false;
}()),
create_canvas: (function() {
// On the S60 and BB Storm, getContext exists, but always returns undefined
// so we actually have to call getContext() to verify
// github.com/Modernizr/Modernizr/issues/issue/97/
var el = document.createElement('canvas');
return !!(el.getContext && el.getContext('2d'));
}()),
return_response_type: function(responseType) {
try {
if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) {
return true;
} else if (window.XMLHttpRequest) {
var xhr = new XMLHttpRequest();
xhr.open('get', '/'); // otherwise Gecko throws an exception
if ('responseType' in xhr) {
xhr.responseType = responseType;
// as of 23.0.1271.64, Chrome switched from throwing exception to merely logging it to the console (why? o why?)
if (xhr.responseType !== responseType) {
return false;
}
return true;
}
}
} catch (ex) {}
return false;
},
// ideas for this heavily come from Modernizr (http://modernizr.com/)
use_data_uri: (function() {
var du = new Image();
du.onload = function() {
caps.use_data_uri = (du.width === 1 && du.height === 1);
};
setTimeout(function() {
du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==";
}, 1);
return false;
}()),
use_data_uri_over32kb: function() { // IE8
return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9);
},
use_data_uri_of: function(bytes) {
return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb());
},
use_fileinput: function() {
var el = document.createElement('input');
el.setAttribute('type', 'file');
return !el.disabled;
}
};
return function(cap) {
var args = [].slice.call(arguments);
args.shift(); // shift of cap
return Basic.typeOf(caps[cap]) === 'function' ? caps[cap].apply(this, args) : !!caps[cap];
};
}());
var Env = {
can: can,
browser: UAParser.browser.name,
version: parseFloat(UAParser.browser.major),
os: UAParser.os.name, // everybody intuitively types it in a lowercase for some reason
osVersion: UAParser.os.version,
verComp: version_compare,
swf_url: "../flash/Moxie.swf",
xap_url: "../silverlight/Moxie.xap",
global_event_dispatcher: "moxie.core.EventTarget.instance.dispatchEvent"
};
// for backward compatibility
// @deprecated Use `Env.os` instead
Env.OS = Env.os;
return Env;
});
// Included from: src/javascript/core/utils/Dom.js
/**
* Dom.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Dom', ['moxie/core/utils/Env'], function(Env) {
/**
Get DOM Element by it's id.
@method get
@for Utils
@param {String} id Identifier of the DOM Element
@return {DOMElement}
*/
var get = function(id) {
if (typeof id !== 'string') {
return id;
}
return document.getElementById(id);
};
/**
Checks if specified DOM element has specified class.
@method hasClass
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Class name
*/
var hasClass = function(obj, name) {
if (!obj.className) {
return false;
}
var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)");
return regExp.test(obj.className);
};
/**
Adds specified className to specified DOM element.
@method addClass
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Class name
*/
var addClass = function(obj, name) {
if (!hasClass(obj, name)) {
obj.className = !obj.className ? name : obj.className.replace(/\s+$/, '') + ' ' + name;
}
};
/**
Removes specified className from specified DOM element.
@method removeClass
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Class name
*/
var removeClass = function(obj, name) {
if (obj.className) {
var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)");
obj.className = obj.className.replace(regExp, function($0, $1, $2) {
return $1 === ' ' && $2 === ' ' ? ' ' : '';
});
}
};
/**
Returns a given computed style of a DOM element.
@method getStyle
@static
@param {Object} obj DOM element like object.
@param {String} name Style you want to get from the DOM element
*/
var getStyle = function(obj, name) {
if (obj.currentStyle) {
return obj.currentStyle[name];
} else if (window.getComputedStyle) {
return window.getComputedStyle(obj, null)[name];
}
};
/**
Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields.
@method getPos
@static
@param {Element} node HTML element or element id to get x, y position from.
@param {Element} root Optional root element to stop calculations at.
@return {object} Absolute position of the specified element object with x, y fields.
*/
var getPos = function(node, root) {
var x = 0, y = 0, parent, doc = document, nodeRect, rootRect;
node = node;
root = root || doc.body;
// Returns the x, y cordinate for an element on IE 6 and IE 7
function getIEPos(node) {
var bodyElm, rect, x = 0, y = 0;
if (node) {
rect = node.getBoundingClientRect();
bodyElm = doc.compatMode === "CSS1Compat" ? doc.documentElement : doc.body;
x = rect.left + bodyElm.scrollLeft;
y = rect.top + bodyElm.scrollTop;
}
return {
x : x,
y : y
};
}
// Use getBoundingClientRect on IE 6 and IE 7 but not on IE 8 in standards mode
if (node && node.getBoundingClientRect && Env.browser === 'IE' && (!doc.documentMode || doc.documentMode < 8)) {
nodeRect = getIEPos(node);
rootRect = getIEPos(root);
return {
x : nodeRect.x - rootRect.x,
y : nodeRect.y - rootRect.y
};
}
parent = node;
while (parent && parent != root && parent.nodeType) {
x += parent.offsetLeft || 0;
y += parent.offsetTop || 0;
parent = parent.offsetParent;
}
parent = node.parentNode;
while (parent && parent != root && parent.nodeType) {
x -= parent.scrollLeft || 0;
y -= parent.scrollTop || 0;
parent = parent.parentNode;
}
return {
x : x,
y : y
};
};
/**
Returns the size of the specified node in pixels.
@method getSize
@static
@param {Node} node Node to get the size of.
@return {Object} Object with a w and h property.
*/
var getSize = function(node) {
return {
w : node.offsetWidth || node.clientWidth,
h : node.offsetHeight || node.clientHeight
};
};
return {
get: get,
hasClass: hasClass,
addClass: addClass,
removeClass: removeClass,
getStyle: getStyle,
getPos: getPos,
getSize: getSize
};
});
// Included from: src/javascript/core/Exceptions.js
/**
* Exceptions.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/Exceptions', [
'moxie/core/utils/Basic'
], function(Basic) {
function _findKey(obj, value) {
var key;
for (key in obj) {
if (obj[key] === value) {
return key;
}
}
return null;
}
return {
RuntimeError: (function() {
var namecodes = {
NOT_INIT_ERR: 1,
NOT_SUPPORTED_ERR: 9,
JS_ERR: 4
};
function RuntimeError(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": RuntimeError " + this.code;
}
Basic.extend(RuntimeError, namecodes);
RuntimeError.prototype = Error.prototype;
return RuntimeError;
}()),
OperationNotAllowedException: (function() {
function OperationNotAllowedException(code) {
this.code = code;
this.name = 'OperationNotAllowedException';
}
Basic.extend(OperationNotAllowedException, {
NOT_ALLOWED_ERR: 1
});
OperationNotAllowedException.prototype = Error.prototype;
return OperationNotAllowedException;
}()),
ImageError: (function() {
var namecodes = {
WRONG_FORMAT: 1,
MAX_RESOLUTION_ERR: 2
};
function ImageError(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": ImageError " + this.code;
}
Basic.extend(ImageError, namecodes);
ImageError.prototype = Error.prototype;
return ImageError;
}()),
FileException: (function() {
var namecodes = {
NOT_FOUND_ERR: 1,
SECURITY_ERR: 2,
ABORT_ERR: 3,
NOT_READABLE_ERR: 4,
ENCODING_ERR: 5,
NO_MODIFICATION_ALLOWED_ERR: 6,
INVALID_STATE_ERR: 7,
SYNTAX_ERR: 8
};
function FileException(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": FileException " + this.code;
}
Basic.extend(FileException, namecodes);
FileException.prototype = Error.prototype;
return FileException;
}()),
DOMException: (function() {
var namecodes = {
INDEX_SIZE_ERR: 1,
DOMSTRING_SIZE_ERR: 2,
HIERARCHY_REQUEST_ERR: 3,
WRONG_DOCUMENT_ERR: 4,
INVALID_CHARACTER_ERR: 5,
NO_DATA_ALLOWED_ERR: 6,
NO_MODIFICATION_ALLOWED_ERR: 7,
NOT_FOUND_ERR: 8,
NOT_SUPPORTED_ERR: 9,
INUSE_ATTRIBUTE_ERR: 10,
INVALID_STATE_ERR: 11,
SYNTAX_ERR: 12,
INVALID_MODIFICATION_ERR: 13,
NAMESPACE_ERR: 14,
INVALID_ACCESS_ERR: 15,
VALIDATION_ERR: 16,
TYPE_MISMATCH_ERR: 17,
SECURITY_ERR: 18,
NETWORK_ERR: 19,
ABORT_ERR: 20,
URL_MISMATCH_ERR: 21,
QUOTA_EXCEEDED_ERR: 22,
TIMEOUT_ERR: 23,
INVALID_NODE_TYPE_ERR: 24,
DATA_CLONE_ERR: 25
};
function DOMException(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": DOMException " + this.code;
}
Basic.extend(DOMException, namecodes);
DOMException.prototype = Error.prototype;
return DOMException;
}()),
EventException: (function() {
function EventException(code) {
this.code = code;
this.name = 'EventException';
}
Basic.extend(EventException, {
UNSPECIFIED_EVENT_TYPE_ERR: 0
});
EventException.prototype = Error.prototype;
return EventException;
}())
};
});
// Included from: src/javascript/core/EventTarget.js
/**
* EventTarget.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/EventTarget', [
'moxie/core/Exceptions',
'moxie/core/utils/Basic'
], function(x, Basic) {
/**
Parent object for all event dispatching components and objects
@class EventTarget
@constructor EventTarget
*/
function EventTarget() {
// hash of event listeners by object uid
var eventpool = {};
Basic.extend(this, {
/**
Unique id of the event dispatcher, usually overriden by children
@property uid
@type String
*/
uid: null,
/**
Can be called from within a child in order to acquire uniqie id in automated manner
@method init
*/
init: function() {
if (!this.uid) {
this.uid = Basic.guid('uid_');
}
},
/**
Register a handler to a specific event dispatched by the object
@method addEventListener
@param {String} type Type or basically a name of the event to subscribe to
@param {Function} fn Callback function that will be called when event happens
@param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first
@param {Object} [scope=this] A scope to invoke event handler in
*/
addEventListener: function(type, fn, priority, scope) {
var self = this, list;
type = Basic.trim(type);
if (/\s/.test(type)) {
// multiple event types were passed for one handler
Basic.each(type.split(/\s+/), function(type) {
self.addEventListener(type, fn, priority, scope);
});
return;
}
type = type.toLowerCase();
priority = parseInt(priority, 10) || 0;
list = eventpool[this.uid] && eventpool[this.uid][type] || [];
list.push({fn : fn, priority : priority, scope : scope || this});
if (!eventpool[this.uid]) {
eventpool[this.uid] = {};
}
eventpool[this.uid][type] = list;
},
/**
Check if any handlers were registered to the specified event
@method hasEventListener
@param {String} type Type or basically a name of the event to check
@return {Mixed} Returns a handler if it was found and false, if - not
*/
hasEventListener: function(type) {
return type ? !!(eventpool[this.uid] && eventpool[this.uid][type]) : !!eventpool[this.uid];
},
/**
Unregister the handler from the event, or if former was not specified - unregister all handlers
@method removeEventListener
@param {String} type Type or basically a name of the event
@param {Function} [fn] Handler to unregister
*/
removeEventListener: function(type, fn) {
type = type.toLowerCase();
var list = eventpool[this.uid] && eventpool[this.uid][type], i;
if (list) {
if (fn) {
for (i = list.length - 1; i >= 0; i--) {
if (list[i].fn === fn) {
list.splice(i, 1);
break;
}
}
} else {
list = [];
}
// delete event list if it has become empty
if (!list.length) {
delete eventpool[this.uid][type];
// and object specific entry in a hash if it has no more listeners attached
if (Basic.isEmptyObj(eventpool[this.uid])) {
delete eventpool[this.uid];
}
}
}
},
/**
Remove all event handlers from the object
@method removeAllEventListeners
*/
removeAllEventListeners: function() {
if (eventpool[this.uid]) {
delete eventpool[this.uid];
}
},
/**
Dispatch the event
@method dispatchEvent
@param {String/Object} Type of event or event object to dispatch
@param {Mixed} [...] Variable number of arguments to be passed to a handlers
@return {Boolean} true by default and false if any handler returned false
*/
dispatchEvent: function(type) {
var uid, list, args, tmpEvt, evt = {}, result = true, undef;
if (Basic.typeOf(type) !== 'string') {
// we can't use original object directly (because of Silverlight)
tmpEvt = type;
if (Basic.typeOf(tmpEvt.type) === 'string') {
type = tmpEvt.type;
if (tmpEvt.total !== undef && tmpEvt.loaded !== undef) { // progress event
evt.total = tmpEvt.total;
evt.loaded = tmpEvt.loaded;
}
evt.async = tmpEvt.async || false;
} else {
throw new x.EventException(x.EventException.UNSPECIFIED_EVENT_TYPE_ERR);
}
}
// check if event is meant to be dispatched on an object having specific uid
if (type.indexOf('::') !== -1) {
(function(arr) {
uid = arr[0];
type = arr[1];
}(type.split('::')));
} else {
uid = this.uid;
}
type = type.toLowerCase();
list = eventpool[uid] && eventpool[uid][type];
if (list) {
// sort event list by prority
list.sort(function(a, b) { return b.priority - a.priority; });
args = [].slice.call(arguments);
// first argument will be pseudo-event object
args.shift();
evt.type = type;
args.unshift(evt);
// Dispatch event to all listeners
var queue = [];
Basic.each(list, function(handler) {
// explicitly set the target, otherwise events fired from shims do not get it
args[0].target = handler.scope;
// if event is marked as async, detach the handler
if (evt.async) {
queue.push(function(cb) {
setTimeout(function() {
cb(handler.fn.apply(handler.scope, args) === false);
}, 1);
});
} else {
queue.push(function(cb) {
cb(handler.fn.apply(handler.scope, args) === false); // if handler returns false stop propagation
});
}
});
if (queue.length) {
Basic.inSeries(queue, function(err) {
result = !err;
});
}
}
return result;
},
/**
Alias for addEventListener
@method bind
@protected
*/
bind: function() {
this.addEventListener.apply(this, arguments);
},
/**
Alias for removeEventListener
@method unbind
@protected
*/
unbind: function() {
this.removeEventListener.apply(this, arguments);
},
/**
Alias for removeAllEventListeners
@method unbindAll
@protected
*/
unbindAll: function() {
this.removeAllEventListeners.apply(this, arguments);
},
/**
Alias for dispatchEvent
@method trigger
@protected
*/
trigger: function() {
return this.dispatchEvent.apply(this, arguments);
},
/**
Converts properties of on[event] type to corresponding event handlers,
is used to avoid extra hassle around the process of calling them back
@method convertEventPropsToHandlers
@private
*/
convertEventPropsToHandlers: function(handlers) {
var h;
if (Basic.typeOf(handlers) !== 'array') {
handlers = [handlers];
}
for (var i = 0; i < handlers.length; i++) {
h = 'on' + handlers[i];
if (Basic.typeOf(this[h]) === 'function') {
this.addEventListener(handlers[i], this[h]);
} else if (Basic.typeOf(this[h]) === 'undefined') {
this[h] = null; // object must have defined event properties, even if it doesn't make use of them
}
}
}
});
}
EventTarget.instance = new EventTarget();
return EventTarget;
});
// Included from: src/javascript/core/utils/Encode.js
/**
* Encode.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Encode', [], function() {
/**
Encode string with UTF-8
@method utf8_encode
@for Utils
@static
@param {String} str String to encode
@return {String} UTF-8 encoded string
*/
var utf8_encode = function(str) {
return unescape(encodeURIComponent(str));
};
/**
Decode UTF-8 encoded string
@method utf8_decode
@static
@param {String} str String to decode
@return {String} Decoded string
*/
var utf8_decode = function(str_data) {
return decodeURIComponent(escape(str_data));
};
/**
Decode Base64 encoded string (uses browser's default method if available),
from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js
@method atob
@static
@param {String} data String to decode
@return {String} Decoded string
*/
var atob = function(data, utf8) {
if (typeof(window.atob) === 'function') {
return utf8 ? utf8_decode(window.atob(data)) : window.atob(data);
}
// http://kevin.vanzonneveld.net
// + original by: Tyler Akins (http://rumkin.com)
// + improved by: Thunder.m
// + input by: Aman Gupta
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Onno Marsman
// + bugfixed by: Pellentesque Malesuada
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
// * returns 1: 'Kevin van Zonneveld'
// mozilla has this native
// - but breaks in 2.0.0.12!
//if (typeof this.window.atob == 'function') {
// return atob(data);
//}
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
ac = 0,
dec = "",
tmp_arr = [];
if (!data) {
return data;
}
data += '';
do { // unpack four hexets into three octets using index points in b64
h1 = b64.indexOf(data.charAt(i++));
h2 = b64.indexOf(data.charAt(i++));
h3 = b64.indexOf(data.charAt(i++));
h4 = b64.indexOf(data.charAt(i++));
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
o1 = bits >> 16 & 0xff;
o2 = bits >> 8 & 0xff;
o3 = bits & 0xff;
if (h3 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1);
} else if (h4 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1, o2);
} else {
tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
}
} while (i < data.length);
dec = tmp_arr.join('');
return utf8 ? utf8_decode(dec) : dec;
};
/**
Base64 encode string (uses browser's default method if available),
from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js
@method btoa
@static
@param {String} data String to encode
@return {String} Base64 encoded string
*/
var btoa = function(data, utf8) {
if (utf8) {
utf8_encode(data);
}
if (typeof(window.btoa) === 'function') {
return window.btoa(data);
}
// http://kevin.vanzonneveld.net
// + original by: Tyler Akins (http://rumkin.com)
// + improved by: Bayron Guevara
// + improved by: Thunder.m
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Pellentesque Malesuada
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Rafał Kukawski (http://kukawski.pl)
// * example 1: base64_encode('Kevin van Zonneveld');
// * returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
// mozilla has this native
// - but breaks in 2.0.0.12!
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
ac = 0,
enc = "",
tmp_arr = [];
if (!data) {
return data;
}
do { // pack three octets into four hexets
o1 = data.charCodeAt(i++);
o2 = data.charCodeAt(i++);
o3 = data.charCodeAt(i++);
bits = o1 << 16 | o2 << 8 | o3;
h1 = bits >> 18 & 0x3f;
h2 = bits >> 12 & 0x3f;
h3 = bits >> 6 & 0x3f;
h4 = bits & 0x3f;
// use hexets to index into b64, and append result to encoded string
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
} while (i < data.length);
enc = tmp_arr.join('');
var r = data.length % 3;
return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
};
return {
utf8_encode: utf8_encode,
utf8_decode: utf8_decode,
atob: atob,
btoa: btoa
};
});
// Included from: src/javascript/runtime/Runtime.js
/**
* Runtime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/runtime/Runtime', [
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/EventTarget"
], function(Basic, Dom, EventTarget) {
var runtimeConstructors = {}, runtimes = {};
/**
Common set of methods and properties for every runtime instance
@class Runtime
@param {Object} options
@param {String} type Sanitized name of the runtime
@param {Object} [caps] Set of capabilities that differentiate specified runtime
@param {Object} [modeCaps] Set of capabilities that do require specific operational mode
@param {String} [preferredMode='browser'] Preferred operational mode to choose if no required capabilities were requested
*/
function Runtime(options, type, caps, modeCaps, preferredMode) {
/**
Dispatched when runtime is initialized and ready.
Results in RuntimeInit on a connected component.
@event Init
*/
/**
Dispatched when runtime fails to initialize.
Results in RuntimeError on a connected component.
@event Error
*/
var self = this
, _shim
, _uid = Basic.guid(type + '_')
, defaultMode = preferredMode || 'browser'
;
options = options || {};
// register runtime in private hash
runtimes[_uid] = this;
/**
Default set of capabilities, which can be redifined later by specific runtime
@private
@property caps
@type Object
*/
caps = Basic.extend({
// Runtime can:
// provide access to raw binary data of the file
access_binary: false,
// provide access to raw binary data of the image (image extension is optional)
access_image_binary: false,
// display binary data as thumbs for example
display_media: false,
// make cross-domain requests
do_cors: false,
// accept files dragged and dropped from the desktop
drag_and_drop: false,
// filter files in selection dialog by their extensions
filter_by_extension: true,
// resize image (and manipulate it raw data of any file in general)
resize_image: false,
// periodically report how many bytes of total in the file were uploaded (loaded)
report_upload_progress: false,
// provide access to the headers of http response
return_response_headers: false,
// support response of specific type, which should be passed as an argument
// e.g. runtime.can('return_response_type', 'blob')
return_response_type: false,
// return http status code of the response
return_status_code: true,
// send custom http header with the request
send_custom_headers: false,
// pick up the files from a dialog
select_file: false,
// select whole folder in file browse dialog
select_folder: false,
// select multiple files at once in file browse dialog
select_multiple: true,
// send raw binary data, that is generated after image resizing or manipulation of other kind
send_binary_string: false,
// send cookies with http request and therefore retain session
send_browser_cookies: true,
// send data formatted as multipart/form-data
send_multipart: true,
// slice the file or blob to smaller parts
slice_blob: false,
// upload file without preloading it to memory, stream it out directly from disk
stream_upload: false,
// programmatically trigger file browse dialog
summon_file_dialog: false,
// upload file of specific size, size should be passed as argument
// e.g. runtime.can('upload_filesize', '500mb')
upload_filesize: true,
// initiate http request with specific http method, method should be passed as argument
// e.g. runtime.can('use_http_method', 'put')
use_http_method: true
}, caps);
// default to the mode that is compatible with preferred caps
if (options.preferred_caps) {
defaultMode = Runtime.getMode(modeCaps, options.preferred_caps, defaultMode);
}
// small extension factory here (is meant to be extended with actual extensions constructors)
_shim = (function() {
var objpool = {};
return {
exec: function(uid, comp, fn, args) {
if (_shim[comp]) {
if (!objpool[uid]) {
objpool[uid] = {
context: this,
instance: new _shim[comp]()
};
}
if (objpool[uid].instance[fn]) {
return objpool[uid].instance[fn].apply(this, args);
}
}
},
removeInstance: function(uid) {
delete objpool[uid];
},
removeAllInstances: function() {
var self = this;
Basic.each(objpool, function(obj, uid) {
if (Basic.typeOf(obj.instance.destroy) === 'function') {
obj.instance.destroy.call(obj.context);
}
self.removeInstance(uid);
});
}
};
}());
// public methods
Basic.extend(this, {
/**
Specifies whether runtime instance was initialized or not
@property initialized
@type {Boolean}
@default false
*/
initialized: false, // shims require this flag to stop initialization retries
/**
Unique ID of the runtime
@property uid
@type {String}
*/
uid: _uid,
/**
Runtime type (e.g. flash, html5, etc)
@property type
@type {String}
*/
type: type,
/**
Runtime (not native one) may operate in browser or client mode.
@property mode
@private
@type {String|Boolean} current mode or false, if none possible
*/
mode: Runtime.getMode(modeCaps, (options.required_caps), defaultMode),
/**
id of the DOM container for the runtime (if available)
@property shimid
@type {String}
*/
shimid: _uid + '_container',
/**
Number of connected clients. If equal to zero, runtime can be destroyed
@property clients
@type {Number}
*/
clients: 0,
/**
Runtime initialization options
@property options
@type {Object}
*/
options: options,
/**
Checks if the runtime has specific capability
@method can
@param {String} cap Name of capability to check
@param {Mixed} [value] If passed, capability should somehow correlate to the value
@param {Object} [refCaps] Set of capabilities to check the specified cap against (defaults to internal set)
@return {Boolean} true if runtime has such capability and false, if - not
*/
can: function(cap, value) {
var refCaps = arguments[2] || caps;
// if cap var is a comma-separated list of caps, convert it to object (key/value)
if (Basic.typeOf(cap) === 'string' && Basic.typeOf(value) === 'undefined') {
cap = Runtime.parseCaps(cap);
}
if (Basic.typeOf(cap) === 'object') {
for (var key in cap) {
if (!this.can(key, cap[key], refCaps)) {
return false;
}
}
return true;
}
// check the individual cap
if (Basic.typeOf(refCaps[cap]) === 'function') {
return refCaps[cap].call(this, value);
} else {
return (value === refCaps[cap]);
}
},
/**
Returns container for the runtime as DOM element
@method getShimContainer
@return {DOMElement}
*/
getShimContainer: function() {
var container, shimContainer = Dom.get(this.shimid);
// if no container for shim, create one
if (!shimContainer) {
container = this.options.container ? Dom.get(this.options.container) : document.body;
// create shim container and insert it at an absolute position into the outer container
shimContainer = document.createElement('div');
shimContainer.id = this.shimid;
shimContainer.className = 'moxie-shim moxie-shim-' + this.type;
Basic.extend(shimContainer.style, {
position: 'absolute',
top: '0px',
left: '0px',
width: '1px',
height: '1px',
overflow: 'hidden'
});
container.appendChild(shimContainer);
container = null;
}
return shimContainer;
},
/**
Returns runtime as DOM element (if appropriate)
@method getShim
@return {DOMElement}
*/
getShim: function() {
return _shim;
},
/**
Invokes a method within the runtime itself (might differ across the runtimes)
@method shimExec
@param {Mixed} []
@protected
@return {Mixed} Depends on the action and component
*/
shimExec: function(component, action) {
var args = [].slice.call(arguments, 2);
return self.getShim().exec.call(this, this.uid, component, action, args);
},
/**
Operaional interface that is used by components to invoke specific actions on the runtime
(is invoked in the scope of component)
@method exec
@param {Mixed} []*
@protected
@return {Mixed} Depends on the action and component
*/
exec: function(component, action) { // this is called in the context of component, not runtime
var args = [].slice.call(arguments, 2);
if (self[component] && self[component][action]) {
return self[component][action].apply(this, args);
}
return self.shimExec.apply(this, arguments);
},
/**
Destroys the runtime (removes all events and deletes DOM structures)
@method destroy
*/
destroy: function() {
if (!self) {
return; // obviously already destroyed
}
var shimContainer = Dom.get(this.shimid);
if (shimContainer) {
shimContainer.parentNode.removeChild(shimContainer);
}
if (_shim) {
_shim.removeAllInstances();
}
this.unbindAll();
delete runtimes[this.uid];
this.uid = null; // mark this runtime as destroyed
_uid = self = _shim = shimContainer = null;
}
});
// once we got the mode, test against all caps
if (this.mode && options.required_caps && !this.can(options.required_caps)) {
this.mode = false;
}
}
/**
Default order to try different runtime types
@property order
@type String
@static
*/
Runtime.order = 'html5,flash,silverlight,html4';
/**
Retrieves runtime from private hash by it's uid
@method getRuntime
@private
@static
@param {String} uid Unique identifier of the runtime
@return {Runtime|Boolean} Returns runtime, if it exists and false, if - not
*/
Runtime.getRuntime = function(uid) {
return runtimes[uid] ? runtimes[uid] : false;
};
/**
Register constructor for the Runtime of new (or perhaps modified) type
@method addConstructor
@static
@param {String} type Runtime type (e.g. flash, html5, etc)
@param {Function} construct Constructor for the Runtime type
*/
Runtime.addConstructor = function(type, constructor) {
constructor.prototype = EventTarget.instance;
runtimeConstructors[type] = constructor;
};
/**
Get the constructor for the specified type.
method getConstructor
@static
@param {String} type Runtime type (e.g. flash, html5, etc)
@return {Function} Constructor for the Runtime type
*/
Runtime.getConstructor = function(type) {
return runtimeConstructors[type] || null;
};
/**
Get info about the runtime (uid, type, capabilities)
@method getInfo
@static
@param {String} uid Unique identifier of the runtime
@return {Mixed} Info object or null if runtime doesn't exist
*/
Runtime.getInfo = function(uid) {
var runtime = Runtime.getRuntime(uid);
if (runtime) {
return {
uid: runtime.uid,
type: runtime.type,
mode: runtime.mode,
can: function() {
return runtime.can.apply(runtime, arguments);
}
};
}
return null;
};
/**
Convert caps represented by a comma-separated string to the object representation.
@method parseCaps
@static
@param {String} capStr Comma-separated list of capabilities
@return {Object}
*/
Runtime.parseCaps = function(capStr) {
var capObj = {};
if (Basic.typeOf(capStr) !== 'string') {
return capStr || {};
}
Basic.each(capStr.split(','), function(key) {
capObj[key] = true; // we assume it to be - true
});
return capObj;
};
/**
Test the specified runtime for specific capabilities.
@method can
@static
@param {String} type Runtime type (e.g. flash, html5, etc)
@param {String|Object} caps Set of capabilities to check
@return {Boolean} Result of the test
*/
Runtime.can = function(type, caps) {
var runtime
, constructor = Runtime.getConstructor(type)
, mode
;
if (constructor) {
runtime = new constructor({
required_caps: caps
});
mode = runtime.mode;
runtime.destroy();
return !!mode;
}
return false;
};
/**
Figure out a runtime that supports specified capabilities.
@method thatCan
@static
@param {String|Object} caps Set of capabilities to check
@param {String} [runtimeOrder] Comma-separated list of runtimes to check against
@return {String} Usable runtime identifier or null
*/
Runtime.thatCan = function(caps, runtimeOrder) {
var types = (runtimeOrder || Runtime.order).split(/\s*,\s*/);
for (var i in types) {
if (Runtime.can(types[i], caps)) {
return types[i];
}
}
return null;
};
/**
Figure out an operational mode for the specified set of capabilities.
@method getMode
@static
@param {Object} modeCaps Set of capabilities that depend on particular runtime mode
@param {Object} [requiredCaps] Supplied set of capabilities to find operational mode for
@param {String|Boolean} [defaultMode='browser'] Default mode to use
@return {String|Boolean} Compatible operational mode
*/
Runtime.getMode = function(modeCaps, requiredCaps, defaultMode) {
var mode = null;
if (Basic.typeOf(defaultMode) === 'undefined') { // only if not specified
defaultMode = 'browser';
}
if (requiredCaps && !Basic.isEmptyObj(modeCaps)) {
// loop over required caps and check if they do require the same mode
Basic.each(requiredCaps, function(value, cap) {
if (modeCaps.hasOwnProperty(cap)) {
var capMode = modeCaps[cap](value);
// make sure we always have an array
if (typeof(capMode) === 'string') {
capMode = [capMode];
}
if (!mode) {
mode = capMode;
} else if (!(mode = Basic.arrayIntersect(mode, capMode))) {
// if cap requires conflicting mode - runtime cannot fulfill required caps
return (mode = false);
}
}
});
if (mode) {
return Basic.inArray(defaultMode, mode) !== -1 ? defaultMode : mode[0];
} else if (mode === false) {
return false;
}
}
return defaultMode;
};
/**
Capability check that always returns true
@private
@static
@return {True}
*/
Runtime.capTrue = function() {
return true;
};
/**
Capability check that always returns false
@private
@static
@return {False}
*/
Runtime.capFalse = function() {
return false;
};
/**
Evaluate the expression to boolean value and create a function that always returns it.
@private
@static
@param {Mixed} expr Expression to evaluate
@return {Function} Function returning the result of evaluation
*/
Runtime.capTest = function(expr) {
return function() {
return !!expr;
};
};
return Runtime;
});
// Included from: src/javascript/runtime/RuntimeClient.js
/**
* RuntimeClient.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/runtime/RuntimeClient', [
'moxie/core/Exceptions',
'moxie/core/utils/Basic',
'moxie/runtime/Runtime'
], function(x, Basic, Runtime) {
/**
Set of methods and properties, required by a component to acquire ability to connect to a runtime
@class RuntimeClient
*/
return function RuntimeClient() {
var runtime;
Basic.extend(this, {
/**
Connects to the runtime specified by the options. Will either connect to existing runtime or create a new one.
Increments number of clients connected to the specified runtime.
@method connectRuntime
@param {Mixed} options Can be a runtme uid or a set of key-value pairs defining requirements and pre-requisites
*/
connectRuntime: function(options) {
var comp = this, ruid;
function initialize(items) {
var type, constructor;
// if we ran out of runtimes
if (!items.length) {
comp.trigger('RuntimeError', new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR));
runtime = null;
return;
}
type = items.shift();
constructor = Runtime.getConstructor(type);
if (!constructor) {
initialize(items);
return;
}
// try initializing the runtime
runtime = new constructor(options);
runtime.bind('Init', function() {
// mark runtime as initialized
runtime.initialized = true;
// jailbreak ...
setTimeout(function() {
runtime.clients++;
// this will be triggered on component
comp.trigger('RuntimeInit', runtime);
}, 1);
});
runtime.bind('Error', function() {
runtime.destroy(); // runtime cannot destroy itself from inside at a right moment, thus we do it here
initialize(items);
});
/*runtime.bind('Exception', function() { });*/
// check if runtime managed to pick-up operational mode
if (!runtime.mode) {
runtime.trigger('Error');
return;
}
runtime.init();
}
// check if a particular runtime was requested
if (Basic.typeOf(options) === 'string') {
ruid = options;
} else if (Basic.typeOf(options.ruid) === 'string') {
ruid = options.ruid;
}
if (ruid) {
runtime = Runtime.getRuntime(ruid);
if (runtime) {
runtime.clients++;
return runtime;
} else {
// there should be a runtime and there's none - weird case
throw new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR);
}
}
// initialize a fresh one, that fits runtime list and required features best
initialize((options.runtime_order || Runtime.order).split(/\s*,\s*/));
},
/**
Returns the runtime to which the client is currently connected.
@method getRuntime
@return {Runtime} Runtime or null if client is not connected
*/
getRuntime: function() {
if (runtime && runtime.uid) {
return runtime;
}
runtime = null; // make sure we do not leave zombies rambling around
return null;
},
/**
Disconnects from the runtime. Decrements number of clients connected to the specified runtime.
@method disconnectRuntime
*/
disconnectRuntime: function() {
if (runtime && --runtime.clients <= 0) {
runtime.destroy();
runtime = null;
}
}
});
};
});
// Included from: src/javascript/file/Blob.js
/**
* Blob.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/Blob', [
'moxie/core/utils/Basic',
'moxie/core/utils/Encode',
'moxie/runtime/RuntimeClient'
], function(Basic, Encode, RuntimeClient) {
var blobpool = {};
/**
@class Blob
@constructor
@param {String} ruid Unique id of the runtime, to which this blob belongs to
@param {Object} blob Object "Native" blob object, as it is represented in the runtime
*/
function Blob(ruid, blob) {
function _sliceDetached(start, end, type) {
var blob, data = blobpool[this.uid];
if (Basic.typeOf(data) !== 'string' || !data.length) {
return null; // or throw exception
}
blob = new Blob(null, {
type: type,
size: end - start
});
blob.detach(data.substr(start, blob.size));
return blob;
}
RuntimeClient.call(this);
if (ruid) {
this.connectRuntime(ruid);
}
if (!blob) {
blob = {};
} else if (Basic.typeOf(blob) === 'string') { // dataUrl or binary string
blob = { data: blob };
}
Basic.extend(this, {
/**
Unique id of the component
@property uid
@type {String}
*/
uid: blob.uid || Basic.guid('uid_'),
/**
Unique id of the connected runtime, if falsy, then runtime will have to be initialized
before this Blob can be used, modified or sent
@property ruid
@type {String}
*/
ruid: ruid,
/**
Size of blob
@property size
@type {Number}
@default 0
*/
size: blob.size || 0,
/**
Mime type of blob
@property type
@type {String}
@default ''
*/
type: blob.type || '',
/**
@method slice
@param {Number} [start=0]
*/
slice: function(start, end, type) {
if (this.isDetached()) {
return _sliceDetached.apply(this, arguments);
}
return this.getRuntime().exec.call(this, 'Blob', 'slice', this.getSource(), start, end, type);
},
/**
Returns "native" blob object (as it is represented in connected runtime) or null if not found
@method getSource
@return {Blob} Returns "native" blob object or null if not found
*/
getSource: function() {
if (!blobpool[this.uid]) {
return null;
}
return blobpool[this.uid];
},
/**
Detaches blob from any runtime that it depends on and initialize with standalone value
@method detach
@protected
@param {DOMString} [data=''] Standalone value
*/
detach: function(data) {
if (this.ruid) {
this.getRuntime().exec.call(this, 'Blob', 'destroy', blobpool[this.uid]);
this.disconnectRuntime();
this.ruid = null;
}
data = data || '';
// if dataUrl, convert to binary string
var matches = data.match(/^data:([^;]*);base64,/);
if (matches) {
this.type = matches[1];
data = Encode.atob(data.substring(data.indexOf('base64,') + 7));
}
this.size = data.length;
blobpool[this.uid] = data;
},
/**
Checks if blob is standalone (detached of any runtime)
@method isDetached
@protected
@return {Boolean}
*/
isDetached: function() {
return !this.ruid && Basic.typeOf(blobpool[this.uid]) === 'string';
},
/**
Destroy Blob and free any resources it was using
@method destroy
*/
destroy: function() {
this.detach();
delete blobpool[this.uid];
}
});
if (blob.data) {
this.detach(blob.data); // auto-detach if payload has been passed
} else {
blobpool[this.uid] = blob;
}
}
return Blob;
});
// Included from: src/javascript/file/File.js
/**
* File.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/File', [
'moxie/core/utils/Basic',
'moxie/core/utils/Mime',
'moxie/file/Blob'
], function(Basic, Mime, Blob) {
/**
@class File
@extends Blob
@constructor
@param {String} ruid Unique id of the runtime, to which this blob belongs to
@param {Object} file Object "Native" file object, as it is represented in the runtime
*/
function File(ruid, file) {
var name, type;
if (!file) { // avoid extra errors in case we overlooked something
file = {};
}
// figure out the type
if (file.type && file.type !== '') {
type = file.type;
} else {
type = Mime.getFileMime(file.name);
}
// sanitize file name or generate new one
if (file.name) {
name = file.name.replace(/\\/g, '/');
name = name.substr(name.lastIndexOf('/') + 1);
} else {
var prefix = type.split('/')[0];
name = Basic.guid((prefix !== '' ? prefix : 'file') + '_');
if (Mime.extensions[type]) {
name += '.' + Mime.extensions[type][0]; // append proper extension if possible
}
}
Blob.apply(this, arguments);
Basic.extend(this, {
/**
File mime type
@property type
@type {String}
@default ''
*/
type: type || '',
/**
File name
@property name
@type {String}
@default UID
*/
name: name || Basic.guid('file_'),
/**
Date of last modification
@property lastModifiedDate
@type {String}
@default now
*/
lastModifiedDate: file.lastModifiedDate || (new Date()).toLocaleString() // Thu Aug 23 2012 19:40:00 GMT+0400 (GET)
});
}
File.prototype = Blob.prototype;
return File;
});
// Included from: src/javascript/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/FileInput', [
'moxie/core/utils/Basic',
'moxie/core/utils/Mime',
'moxie/core/utils/Dom',
'moxie/core/Exceptions',
'moxie/core/EventTarget',
'moxie/core/I18n',
'moxie/file/File',
'moxie/runtime/Runtime',
'moxie/runtime/RuntimeClient'
], function(Basic, Mime, Dom, x, EventTarget, I18n, File, Runtime, RuntimeClient) {
/**
Provides a convenient way to create cross-browser file-picker. Generates file selection dialog on click,
converts selected files to _File_ objects, to be used in conjunction with _Image_, preloaded in memory
with _FileReader_ or uploaded to a server through _XMLHttpRequest_.
@class FileInput
@constructor
@extends EventTarget
@uses RuntimeClient
@param {Object|String|DOMElement} options If options is string or node, argument is considered as _browse\_button_.
@param {String|DOMElement} options.browse_button DOM Element to turn into file picker.
@param {Array} [options.accept] Array of mime types to accept. By default accepts all.
@param {String} [options.file='file'] Name of the file field (not the filename).
@param {Boolean} [options.multiple=false] Enable selection of multiple files.
@param {Boolean} [options.directory=false] Turn file input into the folder input (cannot be both at the same time).
@param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode
for _browse\_button_.
@param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support.
@example
<div id="container">
<a id="file-picker" href="javascript:;">Browse...</a>
</div>
<script>
var fileInput = new mOxie.FileInput({
browse_button: 'file-picker', // or document.getElementById('file-picker')
container: 'container',
accept: [
{title: "Image files", extensions: "jpg,gif,png"} // accept only images
],
multiple: true // allow multiple file selection
});
fileInput.onchange = function(e) {
// do something to files array
console.info(e.target.files); // or this.files or fileInput.files
};
fileInput.init(); // initialize
</script>
*/
var dispatches = [
/**
Dispatched when runtime is connected and file-picker is ready to be used.
@event ready
@param {Object} event
*/
'ready',
/**
Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked.
Check [corresponding documentation entry](#method_refresh) for more info.
@event refresh
@param {Object} event
*/
/**
Dispatched when selection of files in the dialog is complete.
@event change
@param {Object} event
*/
'change',
'cancel', // TODO: might be useful
/**
Dispatched when mouse cursor enters file-picker area. Can be used to style element
accordingly.
@event mouseenter
@param {Object} event
*/
'mouseenter',
/**
Dispatched when mouse cursor leaves file-picker area. Can be used to style element
accordingly.
@event mouseleave
@param {Object} event
*/
'mouseleave',
/**
Dispatched when functional mouse button is pressed on top of file-picker area.
@event mousedown
@param {Object} event
*/
'mousedown',
/**
Dispatched when functional mouse button is released on top of file-picker area.
@event mouseup
@param {Object} event
*/
'mouseup'
];
function FileInput(options) {
var self = this,
container, browseButton, defaults;
// if flat argument passed it should be browse_button id
if (Basic.inArray(Basic.typeOf(options), ['string', 'node']) !== -1) {
options = { browse_button : options };
}
// this will help us to find proper default container
browseButton = Dom.get(options.browse_button);
if (!browseButton) {
// browse button is required
throw new x.DOMException(x.DOMException.NOT_FOUND_ERR);
}
// figure out the options
defaults = {
accept: [{
title: I18n.translate('All Files'),
extensions: '*'
}],
name: 'file',
multiple: false,
required_caps: false,
container: browseButton.parentNode || document.body
};
options = Basic.extend({}, defaults, options);
// convert to object representation
if (typeof(options.required_caps) === 'string') {
options.required_caps = Runtime.parseCaps(options.required_caps);
}
// normalize accept option (could be list of mime types or array of title/extensions pairs)
if (typeof(options.accept) === 'string') {
options.accept = Mime.mimes2extList(options.accept);
}
container = Dom.get(options.container);
// make sure we have container
if (!container) {
container = document.body;
}
// make container relative, if it's not
if (Dom.getStyle(container, 'position') === 'static') {
container.style.position = 'relative';
}
container = browseButton = null; // IE
RuntimeClient.call(self);
Basic.extend(self, {
/**
Unique id of the component
@property uid
@protected
@readOnly
@type {String}
@default UID
*/
uid: Basic.guid('uid_'),
/**
Unique id of the connected runtime, if any.
@property ruid
@protected
@type {String}
*/
ruid: null,
/**
Unique id of the runtime container. Useful to get hold of it for various manipulations.
@property shimid
@protected
@type {String}
*/
shimid: null,
/**
Array of selected mOxie.File objects
@property files
@type {Array}
@default null
*/
files: null,
/**
Initializes the file-picker, connects it to runtime and dispatches event ready when done.
@method init
*/
init: function() {
self.convertEventPropsToHandlers(dispatches);
self.bind('RuntimeInit', function(e, runtime) {
self.ruid = runtime.uid;
self.shimid = runtime.shimid;
self.bind("Ready", function() {
self.trigger("Refresh");
}, 999);
self.bind("Change", function() {
var files = runtime.exec.call(self, 'FileInput', 'getFiles');
self.files = [];
Basic.each(files, function(file) {
// ignore empty files (IE10 for example hangs if you try to send them via XHR)
if (file.size === 0) {
return true;
}
self.files.push(new File(self.ruid, file));
});
}, 999);
// re-position and resize shim container
self.bind('Refresh', function() {
var pos, size, browseButton, shimContainer;
browseButton = Dom.get(options.browse_button);
shimContainer = Dom.get(runtime.shimid); // do not use runtime.getShimContainer(), since it will create container if it doesn't exist
if (browseButton) {
pos = Dom.getPos(browseButton, Dom.get(options.container));
size = Dom.getSize(browseButton);
if (shimContainer) {
Basic.extend(shimContainer.style, {
top : pos.y + 'px',
left : pos.x + 'px',
width : size.w + 'px',
height : size.h + 'px'
});
}
}
shimContainer = browseButton = null;
});
runtime.exec.call(self, 'FileInput', 'init', options);
});
// runtime needs: options.required_features, options.runtime_order and options.container
self.connectRuntime(Basic.extend({}, options, {
required_caps: {
select_file: true
}
}));
},
/**
Disables file-picker element, so that it doesn't react to mouse clicks.
@method disable
@param {Boolean} [state=true] Disable component if - true, enable if - false
*/
disable: function(state) {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state);
}
},
/**
Reposition and resize dialog trigger to match the position and size of browse_button element.
@method refresh
*/
refresh: function() {
self.trigger("Refresh");
},
/**
Destroy component.
@method destroy
*/
destroy: function() {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileInput', 'destroy');
this.disconnectRuntime();
}
if (Basic.typeOf(this.files) === 'array') {
// no sense in leaving associated files behind
Basic.each(this.files, function(file) {
file.destroy();
});
}
this.files = null;
}
});
}
FileInput.prototype = EventTarget.instance;
return FileInput;
});
// Included from: src/javascript/file/FileDrop.js
/**
* FileDrop.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/FileDrop', [
'moxie/core/I18n',
'moxie/core/utils/Dom',
'moxie/core/Exceptions',
'moxie/core/utils/Basic',
'moxie/file/File',
'moxie/runtime/RuntimeClient',
'moxie/core/EventTarget',
'moxie/core/utils/Mime'
], function(I18n, Dom, x, Basic, File, RuntimeClient, EventTarget, Mime) {
/**
Turn arbitrary DOM element to a drop zone accepting files. Converts selected files to _File_ objects, to be used
in conjunction with _Image_, preloaded in memory with _FileReader_ or uploaded to a server through
_XMLHttpRequest_.
@example
<div id="drop_zone">
Drop files here
</div>
<br />
<div id="filelist"></div>
<script type="text/javascript">
var fileDrop = new mOxie.FileDrop('drop_zone'), fileList = mOxie.get('filelist');
fileDrop.ondrop = function() {
mOxie.each(this.files, function(file) {
fileList.innerHTML += '<div>' + file.name + '</div>';
});
};
fileDrop.init();
</script>
@class FileDrop
@constructor
@extends EventTarget
@uses RuntimeClient
@param {Object|String} options If options has typeof string, argument is considered as options.drop_zone
@param {String|DOMElement} options.drop_zone DOM Element to turn into a drop zone
@param {Array} [options.accept] Array of mime types to accept. By default accepts all
@param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support
*/
var dispatches = [
/**
Dispatched when runtime is connected and drop zone is ready to accept files.
@event ready
@param {Object} event
*/
'ready',
/**
Dispatched when dragging cursor enters the drop zone.
@event dragenter
@param {Object} event
*/
'dragenter',
/**
Dispatched when dragging cursor leaves the drop zone.
@event dragleave
@param {Object} event
*/
'dragleave',
/**
Dispatched when file is dropped onto the drop zone.
@event drop
@param {Object} event
*/
'drop',
/**
Dispatched if error occurs.
@event error
@param {Object} event
*/
'error'
];
function FileDrop(options) {
var self = this, defaults;
// if flat argument passed it should be drop_zone id
if (typeof(options) === 'string') {
options = { drop_zone : options };
}
// figure out the options
defaults = {
accept: [{
title: I18n.translate('All Files'),
extensions: '*'
}],
required_caps: {
drag_and_drop: true
}
};
options = typeof(options) === 'object' ? Basic.extend({}, defaults, options) : defaults;
// this will help us to find proper default container
options.container = Dom.get(options.drop_zone) || document.body;
// make container relative, if it is not
if (Dom.getStyle(options.container, 'position') === 'static') {
options.container.style.position = 'relative';
}
// normalize accept option (could be list of mime types or array of title/extensions pairs)
if (typeof(options.accept) === 'string') {
options.accept = Mime.mimes2extList(options.accept);
}
RuntimeClient.call(self);
Basic.extend(self, {
uid: Basic.guid('uid_'),
ruid: null,
files: null,
init: function() {
self.convertEventPropsToHandlers(dispatches);
self.bind('RuntimeInit', function(e, runtime) {
self.ruid = runtime.uid;
self.bind("Drop", function() {
var files = runtime.exec.call(self, 'FileDrop', 'getFiles');
self.files = [];
Basic.each(files, function(file) {
self.files.push(new File(self.ruid, file));
});
}, 999);
runtime.exec.call(self, 'FileDrop', 'init', options);
self.dispatchEvent('ready');
});
// runtime needs: options.required_features, options.runtime_order and options.container
self.connectRuntime(options); // throws RuntimeError
},
destroy: function() {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileDrop', 'destroy');
this.disconnectRuntime();
}
this.files = null;
}
});
}
FileDrop.prototype = EventTarget.instance;
return FileDrop;
});
// Included from: src/javascript/runtime/RuntimeTarget.js
/**
* RuntimeTarget.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/runtime/RuntimeTarget', [
'moxie/core/utils/Basic',
'moxie/runtime/RuntimeClient',
"moxie/core/EventTarget"
], function(Basic, RuntimeClient, EventTarget) {
/**
Instance of this class can be used as a target for the events dispatched by shims,
when allowing them onto components is for either reason inappropriate
@class RuntimeTarget
@constructor
@protected
@extends EventTarget
*/
function RuntimeTarget() {
this.uid = Basic.guid('uid_');
RuntimeClient.call(this);
this.destroy = function() {
this.disconnectRuntime();
this.unbindAll();
};
}
RuntimeTarget.prototype = EventTarget.instance;
return RuntimeTarget;
});
// Included from: src/javascript/file/FileReader.js
/**
* FileReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/FileReader', [
'moxie/core/utils/Basic',
'moxie/core/utils/Encode',
'moxie/core/Exceptions',
'moxie/core/EventTarget',
'moxie/file/Blob',
'moxie/file/File',
'moxie/runtime/RuntimeTarget'
], function(Basic, Encode, x, EventTarget, Blob, File, RuntimeTarget) {
/**
Utility for preloading o.Blob/o.File objects in memory. By design closely follows [W3C FileReader](http://www.w3.org/TR/FileAPI/#dfn-filereader)
interface. Where possible uses native FileReader, where - not falls back to shims.
@class FileReader
@constructor FileReader
@extends EventTarget
@uses RuntimeClient
*/
var dispatches = [
/**
Dispatched when the read starts.
@event loadstart
@param {Object} event
*/
'loadstart',
/**
Dispatched while reading (and decoding) blob, and reporting partial Blob data (progess.loaded/progress.total).
@event progress
@param {Object} event
*/
'progress',
/**
Dispatched when the read has successfully completed.
@event load
@param {Object} event
*/
'load',
/**
Dispatched when the read has been aborted. For instance, by invoking the abort() method.
@event abort
@param {Object} event
*/
'abort',
/**
Dispatched when the read has failed.
@event error
@param {Object} event
*/
'error',
/**
Dispatched when the request has completed (either in success or failure).
@event loadend
@param {Object} event
*/
'loadend'
];
function FileReader() {
var self = this, _fr;
Basic.extend(this, {
/**
UID of the component instance.
@property uid
@type {String}
*/
uid: Basic.guid('uid_'),
/**
Contains current state of FileReader object. Can take values of FileReader.EMPTY, FileReader.LOADING
and FileReader.DONE.
@property readyState
@type {Number}
@default FileReader.EMPTY
*/
readyState: FileReader.EMPTY,
/**
Result of the successful read operation.
@property result
@type {String}
*/
result: null,
/**
Stores the error of failed asynchronous read operation.
@property error
@type {DOMError}
*/
error: null,
/**
Initiates reading of File/Blob object contents to binary string.
@method readAsBinaryString
@param {Blob|File} blob Object to preload
*/
readAsBinaryString: function(blob) {
_read.call(this, 'readAsBinaryString', blob);
},
/**
Initiates reading of File/Blob object contents to dataURL string.
@method readAsDataURL
@param {Blob|File} blob Object to preload
*/
readAsDataURL: function(blob) {
_read.call(this, 'readAsDataURL', blob);
},
/**
Initiates reading of File/Blob object contents to string.
@method readAsText
@param {Blob|File} blob Object to preload
*/
readAsText: function(blob) {
_read.call(this, 'readAsText', blob);
},
/**
Aborts preloading process.
@method abort
*/
abort: function() {
this.result = null;
if (Basic.inArray(this.readyState, [FileReader.EMPTY, FileReader.DONE]) !== -1) {
return;
} else if (this.readyState === FileReader.LOADING) {
this.readyState = FileReader.DONE;
}
if (_fr) {
_fr.getRuntime().exec.call(this, 'FileReader', 'abort');
}
this.trigger('abort');
this.trigger('loadend');
},
/**
Destroy component and release resources.
@method destroy
*/
destroy: function() {
this.abort();
if (_fr) {
_fr.getRuntime().exec.call(this, 'FileReader', 'destroy');
_fr.disconnectRuntime();
}
self = _fr = null;
}
});
function _read(op, blob) {
_fr = new RuntimeTarget();
function error(err) {
self.readyState = FileReader.DONE;
self.error = err;
self.trigger('error');
loadEnd();
}
function loadEnd() {
_fr.destroy();
_fr = null;
self.trigger('loadend');
}
function exec(runtime) {
_fr.bind('Error', function(e, err) {
error(err);
});
_fr.bind('Progress', function(e) {
self.result = runtime.exec.call(_fr, 'FileReader', 'getResult');
self.trigger(e);
});
_fr.bind('Load', function(e) {
self.readyState = FileReader.DONE;
self.result = runtime.exec.call(_fr, 'FileReader', 'getResult');
self.trigger(e);
loadEnd();
});
runtime.exec.call(_fr, 'FileReader', 'read', op, blob);
}
this.convertEventPropsToHandlers(dispatches);
if (this.readyState === FileReader.LOADING) {
return error(new x.DOMException(x.DOMException.INVALID_STATE_ERR));
}
this.readyState = FileReader.LOADING;
this.trigger('loadstart');
// if source is o.Blob/o.File
if (blob instanceof Blob) {
if (blob.isDetached()) {
var src = blob.getSource();
switch (op) {
case 'readAsText':
case 'readAsBinaryString':
this.result = src;
break;
case 'readAsDataURL':
this.result = 'data:' + blob.type + ';base64,' + Encode.btoa(src);
break;
}
this.readyState = FileReader.DONE;
this.trigger('load');
loadEnd();
} else {
exec(_fr.connectRuntime(blob.ruid));
}
} else {
error(new x.DOMException(x.DOMException.NOT_FOUND_ERR));
}
}
}
/**
Initial FileReader state
@property EMPTY
@type {Number}
@final
@static
@default 0
*/
FileReader.EMPTY = 0;
/**
FileReader switches to this state when it is preloading the source
@property LOADING
@type {Number}
@final
@static
@default 1
*/
FileReader.LOADING = 1;
/**
Preloading is complete, this is a final state
@property DONE
@type {Number}
@final
@static
@default 2
*/
FileReader.DONE = 2;
FileReader.prototype = EventTarget.instance;
return FileReader;
});
// Included from: src/javascript/core/utils/Url.js
/**
* Url.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Url', [], function() {
/**
Parse url into separate components and fill in absent parts with parts from current url,
based on https://raw.github.com/kvz/phpjs/master/functions/url/parse_url.js
@method parseUrl
@for Utils
@static
@param {String} url Url to parse (defaults to empty string if undefined)
@return {Object} Hash containing extracted uri components
*/
var parseUrl = function(url, currentUrl) {
var key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'fragment']
, i = key.length
, ports = {
http: 80,
https: 443
}
, uri = {}
, regex = /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/
, m = regex.exec(url || '')
;
while (i--) {
if (m[i]) {
uri[key[i]] = m[i];
}
}
// when url is relative, we set the origin and the path ourselves
if (!uri.scheme) {
// come up with defaults
if (!currentUrl || typeof(currentUrl) === 'string') {
currentUrl = parseUrl(currentUrl || document.location.href);
}
uri.scheme = currentUrl.scheme;
uri.host = currentUrl.host;
uri.port = currentUrl.port;
var path = '';
// for urls without trailing slash we need to figure out the path
if (/^[^\/]/.test(uri.path)) {
path = currentUrl.path;
// if path ends with a filename, strip it
if (!/(\/|\/[^\.]+)$/.test(path)) {
path = path.replace(/\/[^\/]+$/, '/');
} else {
path += '/';
}
}
uri.path = path + (uri.path || ''); // site may reside at domain.com or domain.com/subdir
}
if (!uri.port) {
uri.port = ports[uri.scheme] || 80;
}
uri.port = parseInt(uri.port, 10);
if (!uri.path) {
uri.path = "/";
}
delete uri.source;
return uri;
};
/**
Resolve url - among other things will turn relative url to absolute
@method resolveUrl
@static
@param {String} url Either absolute or relative
@return {String} Resolved, absolute url
*/
var resolveUrl = function(url) {
var ports = { // we ignore default ports
http: 80,
https: 443
}
, urlp = parseUrl(url)
;
return urlp.scheme + '://' + urlp.host + (urlp.port !== ports[urlp.scheme] ? ':' + urlp.port : '') + urlp.path + (urlp.query ? urlp.query : '');
};
/**
Check if specified url has the same origin as the current document
@method hasSameOrigin
@param {String|Object} url
@return {Boolean}
*/
var hasSameOrigin = function(url) {
function origin(url) {
return [url.scheme, url.host, url.port].join('/');
}
if (typeof url === 'string') {
url = parseUrl(url);
}
return origin(parseUrl()) === origin(url);
};
return {
parseUrl: parseUrl,
resolveUrl: resolveUrl,
hasSameOrigin: hasSameOrigin
};
});
// Included from: src/javascript/file/FileReaderSync.js
/**
* FileReaderSync.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/FileReaderSync', [
'moxie/core/utils/Basic',
'moxie/runtime/RuntimeClient',
'moxie/core/utils/Encode'
], function(Basic, RuntimeClient, Encode) {
/**
Synchronous FileReader implementation. Something like this is available in WebWorkers environment, here
it can be used to read only preloaded blobs/files and only below certain size (not yet sure what that'd be,
but probably < 1mb). Not meant to be used directly by user.
@class FileReaderSync
@private
@constructor
*/
return function() {
RuntimeClient.call(this);
Basic.extend(this, {
uid: Basic.guid('uid_'),
readAsBinaryString: function(blob) {
return _read.call(this, 'readAsBinaryString', blob);
},
readAsDataURL: function(blob) {
return _read.call(this, 'readAsDataURL', blob);
},
/*readAsArrayBuffer: function(blob) {
return _read.call(this, 'readAsArrayBuffer', blob);
},*/
readAsText: function(blob) {
return _read.call(this, 'readAsText', blob);
}
});
function _read(op, blob) {
if (blob.isDetached()) {
var src = blob.getSource();
switch (op) {
case 'readAsBinaryString':
return src;
case 'readAsDataURL':
return 'data:' + blob.type + ';base64,' + Encode.btoa(src);
case 'readAsText':
var txt = '';
for (var i = 0, length = src.length; i < length; i++) {
txt += String.fromCharCode(src[i]);
}
return txt;
}
} else {
var result = this.connectRuntime(blob.ruid).exec.call(this, 'FileReaderSync', 'read', op, blob);
this.disconnectRuntime();
return result;
}
}
};
});
// Included from: src/javascript/xhr/FormData.js
/**
* FormData.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/xhr/FormData", [
"moxie/core/Exceptions",
"moxie/core/utils/Basic",
"moxie/file/Blob"
], function(x, Basic, Blob) {
/**
FormData
@class FormData
@constructor
*/
function FormData() {
var _blob, _fields = [];
Basic.extend(this, {
/**
Append another key-value pair to the FormData object
@method append
@param {String} name Name for the new field
@param {String|Blob|Array|Object} value Value for the field
*/
append: function(name, value) {
var self = this, valueType = Basic.typeOf(value);
// according to specs value might be either Blob or String
if (value instanceof Blob) {
_blob = {
name: name,
value: value // unfortunately we can only send single Blob in one FormData
};
} else if ('array' === valueType) {
name += '[]';
Basic.each(value, function(value) {
self.append(name, value);
});
} else if ('object' === valueType) {
Basic.each(value, function(value, key) {
self.append(name + '[' + key + ']', value);
});
} else if ('null' === valueType || 'undefined' === valueType || 'number' === valueType && isNaN(value)) {
self.append(name, "false");
} else {
_fields.push({
name: name,
value: value.toString()
});
}
},
/**
Checks if FormData contains Blob.
@method hasBlob
@return {Boolean}
*/
hasBlob: function() {
return !!this.getBlob();
},
/**
Retrieves blob.
@method getBlob
@return {Object} Either Blob if found or null
*/
getBlob: function() {
return _blob && _blob.value || null;
},
/**
Retrieves blob field name.
@method getBlobName
@return {String} Either Blob field name or null
*/
getBlobName: function() {
return _blob && _blob.name || null;
},
/**
Loop over the fields in FormData and invoke the callback for each of them.
@method each
@param {Function} cb Callback to call for each field
*/
each: function(cb) {
Basic.each(_fields, function(field) {
cb(field.value, field.name);
});
if (_blob) {
cb(_blob.value, _blob.name);
}
},
destroy: function() {
_blob = null;
_fields = [];
}
});
}
return FormData;
});
// Included from: src/javascript/xhr/XMLHttpRequest.js
/**
* XMLHttpRequest.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/xhr/XMLHttpRequest", [
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/core/EventTarget",
"moxie/core/utils/Encode",
"moxie/core/utils/Url",
"moxie/runtime/Runtime",
"moxie/runtime/RuntimeTarget",
"moxie/file/Blob",
"moxie/file/FileReaderSync",
"moxie/xhr/FormData",
"moxie/core/utils/Env",
"moxie/core/utils/Mime"
], function(Basic, x, EventTarget, Encode, Url, Runtime, RuntimeTarget, Blob, FileReaderSync, FormData, Env, Mime) {
var httpCode = {
100: 'Continue',
101: 'Switching Protocols',
102: 'Processing',
200: 'OK',
201: 'Created',
202: 'Accepted',
203: 'Non-Authoritative Information',
204: 'No Content',
205: 'Reset Content',
206: 'Partial Content',
207: 'Multi-Status',
226: 'IM Used',
300: 'Multiple Choices',
301: 'Moved Permanently',
302: 'Found',
303: 'See Other',
304: 'Not Modified',
305: 'Use Proxy',
306: 'Reserved',
307: 'Temporary Redirect',
400: 'Bad Request',
401: 'Unauthorized',
402: 'Payment Required',
403: 'Forbidden',
404: 'Not Found',
405: 'Method Not Allowed',
406: 'Not Acceptable',
407: 'Proxy Authentication Required',
408: 'Request Timeout',
409: 'Conflict',
410: 'Gone',
411: 'Length Required',
412: 'Precondition Failed',
413: 'Request Entity Too Large',
414: 'Request-URI Too Long',
415: 'Unsupported Media Type',
416: 'Requested Range Not Satisfiable',
417: 'Expectation Failed',
422: 'Unprocessable Entity',
423: 'Locked',
424: 'Failed Dependency',
426: 'Upgrade Required',
500: 'Internal Server Error',
501: 'Not Implemented',
502: 'Bad Gateway',
503: 'Service Unavailable',
504: 'Gateway Timeout',
505: 'HTTP Version Not Supported',
506: 'Variant Also Negotiates',
507: 'Insufficient Storage',
510: 'Not Extended'
};
function XMLHttpRequestUpload() {
this.uid = Basic.guid('uid_');
}
XMLHttpRequestUpload.prototype = EventTarget.instance;
/**
Implementation of XMLHttpRequest
@class XMLHttpRequest
@constructor
@uses RuntimeClient
@extends EventTarget
*/
var dispatches = ['loadstart', 'progress', 'abort', 'error', 'load', 'timeout', 'loadend']; // & readystatechange (for historical reasons)
var NATIVE = 1, RUNTIME = 2;
function XMLHttpRequest() {
var self = this,
// this (together with _p() @see below) is here to gracefully upgrade to setter/getter syntax where possible
props = {
/**
The amount of milliseconds a request can take before being terminated. Initially zero. Zero means there is no timeout.
@property timeout
@type Number
@default 0
*/
timeout: 0,
/**
Current state, can take following values:
UNSENT (numeric value 0)
The object has been constructed.
OPENED (numeric value 1)
The open() method has been successfully invoked. During this state request headers can be set using setRequestHeader() and the request can be made using the send() method.
HEADERS_RECEIVED (numeric value 2)
All redirects (if any) have been followed and all HTTP headers of the final response have been received. Several response members of the object are now available.
LOADING (numeric value 3)
The response entity body is being received.
DONE (numeric value 4)
@property readyState
@type Number
@default 0 (UNSENT)
*/
readyState: XMLHttpRequest.UNSENT,
/**
True when user credentials are to be included in a cross-origin request. False when they are to be excluded
in a cross-origin request and when cookies are to be ignored in its response. Initially false.
@property withCredentials
@type Boolean
@default false
*/
withCredentials: false,
/**
Returns the HTTP status code.
@property status
@type Number
@default 0
*/
status: 0,
/**
Returns the HTTP status text.
@property statusText
@type String
*/
statusText: "",
/**
Returns the response type. Can be set to change the response type. Values are:
the empty string (default), "arraybuffer", "blob", "document", "json", and "text".
@property responseType
@type String
*/
responseType: "",
/**
Returns the document response entity body.
Throws an "InvalidStateError" exception if responseType is not the empty string or "document".
@property responseXML
@type Document
*/
responseXML: null,
/**
Returns the text response entity body.
Throws an "InvalidStateError" exception if responseType is not the empty string or "text".
@property responseText
@type String
*/
responseText: null,
/**
Returns the response entity body (http://www.w3.org/TR/XMLHttpRequest/#response-entity-body).
Can become: ArrayBuffer, Blob, Document, JSON, Text
@property response
@type Mixed
*/
response: null
},
_async = true,
_url,
_method,
_headers = {},
_user,
_password,
_encoding = null,
_mimeType = null,
// flags
_sync_flag = false,
_send_flag = false,
_upload_events_flag = false,
_upload_complete_flag = false,
_error_flag = false,
_same_origin_flag = false,
// times
_start_time,
_timeoutset_time,
_finalMime = null,
_finalCharset = null,
_options = {},
_xhr,
_responseHeaders = '',
_responseHeadersBag
;
Basic.extend(this, props, {
/**
Unique id of the component
@property uid
@type String
*/
uid: Basic.guid('uid_'),
/**
Target for Upload events
@property upload
@type XMLHttpRequestUpload
*/
upload: new XMLHttpRequestUpload(),
/**
Sets the request method, request URL, synchronous flag, request username, and request password.
Throws a "SyntaxError" exception if one of the following is true:
method is not a valid HTTP method.
url cannot be resolved.
url contains the "user:password" format in the userinfo production.
Throws a "SecurityError" exception if method is a case-insensitive match for CONNECT, TRACE or TRACK.
Throws an "InvalidAccessError" exception if one of the following is true:
Either user or password is passed as argument and the origin of url does not match the XMLHttpRequest origin.
There is an associated XMLHttpRequest document and either the timeout attribute is not zero,
the withCredentials attribute is true, or the responseType attribute is not the empty string.
@method open
@param {String} method HTTP method to use on request
@param {String} url URL to request
@param {Boolean} [async=true] If false request will be done in synchronous manner. Asynchronous by default.
@param {String} [user] Username to use in HTTP authentication process on server-side
@param {String} [password] Password to use in HTTP authentication process on server-side
*/
open: function(method, url, async, user, password) {
var urlp;
// first two arguments are required
if (!method || !url) {
throw new x.DOMException(x.DOMException.SYNTAX_ERR);
}
// 2 - check if any code point in method is higher than U+00FF or after deflating method it does not match the method
if (/[\u0100-\uffff]/.test(method) || Encode.utf8_encode(method) !== method) {
throw new x.DOMException(x.DOMException.SYNTAX_ERR);
}
// 3
if (!!~Basic.inArray(method.toUpperCase(), ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'TRACE', 'TRACK'])) {
_method = method.toUpperCase();
}
// 4 - allowing these methods poses a security risk
if (!!~Basic.inArray(_method, ['CONNECT', 'TRACE', 'TRACK'])) {
throw new x.DOMException(x.DOMException.SECURITY_ERR);
}
// 5
url = Encode.utf8_encode(url);
// 6 - Resolve url relative to the XMLHttpRequest base URL. If the algorithm returns an error, throw a "SyntaxError".
urlp = Url.parseUrl(url);
_same_origin_flag = Url.hasSameOrigin(urlp);
// 7 - manually build up absolute url
_url = Url.resolveUrl(url);
// 9-10, 12-13
if ((user || password) && !_same_origin_flag) {
throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR);
}
_user = user || urlp.user;
_password = password || urlp.pass;
// 11
_async = async || true;
if (_async === false && (_p('timeout') || _p('withCredentials') || _p('responseType') !== "")) {
throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR);
}
// 14 - terminate abort()
// 15 - terminate send()
// 18
_sync_flag = !_async;
_send_flag = false;
_headers = {};
_reset.call(this);
// 19
_p('readyState', XMLHttpRequest.OPENED);
// 20
this.convertEventPropsToHandlers(['readystatechange']); // unify event handlers
this.dispatchEvent('readystatechange');
},
/**
Appends an header to the list of author request headers, or if header is already
in the list of author request headers, combines its value with value.
Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set.
Throws a "SyntaxError" exception if header is not a valid HTTP header field name or if value
is not a valid HTTP header field value.
@method setRequestHeader
@param {String} header
@param {String|Number} value
*/
setRequestHeader: function(header, value) {
var uaHeaders = [ // these headers are controlled by the user agent
"accept-charset",
"accept-encoding",
"access-control-request-headers",
"access-control-request-method",
"connection",
"content-length",
"cookie",
"cookie2",
"content-transfer-encoding",
"date",
"expect",
"host",
"keep-alive",
"origin",
"referer",
"te",
"trailer",
"transfer-encoding",
"upgrade",
"user-agent",
"via"
];
// 1-2
if (_p('readyState') !== XMLHttpRequest.OPENED || _send_flag) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 3
if (/[\u0100-\uffff]/.test(header) || Encode.utf8_encode(header) !== header) {
throw new x.DOMException(x.DOMException.SYNTAX_ERR);
}
// 4
/* this step is seemingly bypassed in browsers, probably to allow various unicode characters in header values
if (/[\u0100-\uffff]/.test(value) || Encode.utf8_encode(value) !== value) {
throw new x.DOMException(x.DOMException.SYNTAX_ERR);
}*/
header = Basic.trim(header).toLowerCase();
// setting of proxy-* and sec-* headers is prohibited by spec
if (!!~Basic.inArray(header, uaHeaders) || /^(proxy\-|sec\-)/.test(header)) {
return false;
}
// camelize
// browsers lowercase header names (at least for custom ones)
// header = header.replace(/\b\w/g, function($1) { return $1.toUpperCase(); });
if (!_headers[header]) {
_headers[header] = value;
} else {
// http://tools.ietf.org/html/rfc2616#section-4.2 (last paragraph)
_headers[header] += ', ' + value;
}
return true;
},
/**
Returns all headers from the response, with the exception of those whose field name is Set-Cookie or Set-Cookie2.
@method getAllResponseHeaders
@return {String} reponse headers or empty string
*/
getAllResponseHeaders: function() {
return _responseHeaders || '';
},
/**
Returns the header field value from the response of which the field name matches header,
unless the field name is Set-Cookie or Set-Cookie2.
@method getResponseHeader
@param {String} header
@return {String} value(s) for the specified header or null
*/
getResponseHeader: function(header) {
header = header.toLowerCase();
if (_error_flag || !!~Basic.inArray(header, ['set-cookie', 'set-cookie2'])) {
return null;
}
if (_responseHeaders && _responseHeaders !== '') {
// if we didn't parse response headers until now, do it and keep for later
if (!_responseHeadersBag) {
_responseHeadersBag = {};
Basic.each(_responseHeaders.split(/\r\n/), function(line) {
var pair = line.split(/:\s+/);
if (pair.length === 2) { // last line might be empty, omit
pair[0] = Basic.trim(pair[0]); // just in case
_responseHeadersBag[pair[0].toLowerCase()] = { // simply to retain header name in original form
header: pair[0],
value: Basic.trim(pair[1])
};
}
});
}
if (_responseHeadersBag.hasOwnProperty(header)) {
return _responseHeadersBag[header].header + ': ' + _responseHeadersBag[header].value;
}
}
return null;
},
/**
Sets the Content-Type header for the response to mime.
Throws an "InvalidStateError" exception if the state is LOADING or DONE.
Throws a "SyntaxError" exception if mime is not a valid media type.
@method overrideMimeType
@param String mime Mime type to set
*/
overrideMimeType: function(mime) {
var matches, charset;
// 1
if (!!~Basic.inArray(_p('readyState'), [XMLHttpRequest.LOADING, XMLHttpRequest.DONE])) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 2
mime = Basic.trim(mime.toLowerCase());
if (/;/.test(mime) && (matches = mime.match(/^([^;]+)(?:;\scharset\=)?(.*)$/))) {
mime = matches[1];
if (matches[2]) {
charset = matches[2];
}
}
if (!Mime.mimes[mime]) {
throw new x.DOMException(x.DOMException.SYNTAX_ERR);
}
// 3-4
_finalMime = mime;
_finalCharset = charset;
},
/**
Initiates the request. The optional argument provides the request entity body.
The argument is ignored if request method is GET or HEAD.
Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set.
@method send
@param {Blob|Document|String|FormData} [data] Request entity body
@param {Object} [options] Set of requirements and pre-requisities for runtime initialization
*/
send: function(data, options) {
if (Basic.typeOf(options) === 'string') {
_options = { ruid: options };
} else if (!options) {
_options = {};
} else {
_options = options;
}
this.convertEventPropsToHandlers(dispatches);
this.upload.convertEventPropsToHandlers(dispatches);
// 1-2
if (this.readyState !== XMLHttpRequest.OPENED || _send_flag) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 3
// sending Blob
if (data instanceof Blob) {
_options.ruid = data.ruid;
_mimeType = data.type || 'application/octet-stream';
}
// FormData
else if (data instanceof FormData) {
if (data.hasBlob()) {
var blob = data.getBlob();
_options.ruid = blob.ruid;
_mimeType = blob.type || 'application/octet-stream';
}
}
// DOMString
else if (typeof data === 'string') {
_encoding = 'UTF-8';
_mimeType = 'text/plain;charset=UTF-8';
// data should be converted to Unicode and encoded as UTF-8
data = Encode.utf8_encode(data);
}
// if withCredentials not set, but requested, set it automatically
if (!this.withCredentials) {
this.withCredentials = (_options.required_caps && _options.required_caps.send_browser_cookies) && !_same_origin_flag;
}
// 4 - storage mutex
// 5
_upload_events_flag = (!_sync_flag && this.upload.hasEventListener()); // DSAP
// 6
_error_flag = false;
// 7
_upload_complete_flag = !data;
// 8 - Asynchronous steps
if (!_sync_flag) {
// 8.1
_send_flag = true;
// 8.2
// this.dispatchEvent('loadstart'); // will be dispatched either by native or runtime xhr
// 8.3
//if (!_upload_complete_flag) {
// this.upload.dispatchEvent('loadstart'); // will be dispatched either by native or runtime xhr
//}
}
// 8.5 - Return the send() method call, but continue running the steps in this algorithm.
_doXHR.call(this, data);
},
/**
Cancels any network activity.
@method abort
*/
abort: function() {
_error_flag = true;
_sync_flag = false;
if (!~Basic.inArray(_p('readyState'), [XMLHttpRequest.UNSENT, XMLHttpRequest.OPENED, XMLHttpRequest.DONE])) {
_p('readyState', XMLHttpRequest.DONE);
_send_flag = false;
if (_xhr) {
_xhr.getRuntime().exec.call(_xhr, 'XMLHttpRequest', 'abort', _upload_complete_flag);
} else {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
_upload_complete_flag = true;
} else {
_p('readyState', XMLHttpRequest.UNSENT);
}
},
destroy: function() {
if (_xhr) {
if (Basic.typeOf(_xhr.destroy) === 'function') {
_xhr.destroy();
}
_xhr = null;
}
this.unbindAll();
if (this.upload) {
this.upload.unbindAll();
this.upload = null;
}
}
});
/* this is nice, but maybe too lengthy
// if supported by JS version, set getters/setters for specific properties
o.defineProperty(this, 'readyState', {
configurable: false,
get: function() {
return _p('readyState');
}
});
o.defineProperty(this, 'timeout', {
configurable: false,
get: function() {
return _p('timeout');
},
set: function(value) {
if (_sync_flag) {
throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR);
}
// timeout still should be measured relative to the start time of request
_timeoutset_time = (new Date).getTime();
_p('timeout', value);
}
});
// the withCredentials attribute has no effect when fetching same-origin resources
o.defineProperty(this, 'withCredentials', {
configurable: false,
get: function() {
return _p('withCredentials');
},
set: function(value) {
// 1-2
if (!~o.inArray(_p('readyState'), [XMLHttpRequest.UNSENT, XMLHttpRequest.OPENED]) || _send_flag) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 3-4
if (_anonymous_flag || _sync_flag) {
throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR);
}
// 5
_p('withCredentials', value);
}
});
o.defineProperty(this, 'status', {
configurable: false,
get: function() {
return _p('status');
}
});
o.defineProperty(this, 'statusText', {
configurable: false,
get: function() {
return _p('statusText');
}
});
o.defineProperty(this, 'responseType', {
configurable: false,
get: function() {
return _p('responseType');
},
set: function(value) {
// 1
if (!!~o.inArray(_p('readyState'), [XMLHttpRequest.LOADING, XMLHttpRequest.DONE])) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 2
if (_sync_flag) {
throw new x.DOMException(x.DOMException.INVALID_ACCESS_ERR);
}
// 3
_p('responseType', value.toLowerCase());
}
});
o.defineProperty(this, 'responseText', {
configurable: false,
get: function() {
// 1
if (!~o.inArray(_p('responseType'), ['', 'text'])) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 2-3
if (_p('readyState') !== XMLHttpRequest.DONE && _p('readyState') !== XMLHttpRequest.LOADING || _error_flag) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
return _p('responseText');
}
});
o.defineProperty(this, 'responseXML', {
configurable: false,
get: function() {
// 1
if (!~o.inArray(_p('responseType'), ['', 'document'])) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// 2-3
if (_p('readyState') !== XMLHttpRequest.DONE || _error_flag) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
return _p('responseXML');
}
});
o.defineProperty(this, 'response', {
configurable: false,
get: function() {
if (!!~o.inArray(_p('responseType'), ['', 'text'])) {
if (_p('readyState') !== XMLHttpRequest.DONE && _p('readyState') !== XMLHttpRequest.LOADING || _error_flag) {
return '';
}
}
if (_p('readyState') !== XMLHttpRequest.DONE || _error_flag) {
return null;
}
return _p('response');
}
});
*/
function _p(prop, value) {
if (!props.hasOwnProperty(prop)) {
return;
}
if (arguments.length === 1) { // get
return Env.can('define_property') ? props[prop] : self[prop];
} else { // set
if (Env.can('define_property')) {
props[prop] = value;
} else {
self[prop] = value;
}
}
}
/*
function _toASCII(str, AllowUnassigned, UseSTD3ASCIIRules) {
// TODO: http://tools.ietf.org/html/rfc3490#section-4.1
return str.toLowerCase();
}
*/
function _doXHR(data) {
var self = this;
_start_time = new Date().getTime();
_xhr = new RuntimeTarget();
function loadEnd() {
_xhr.destroy();
_xhr = null;
self.dispatchEvent('loadend');
self = null;
}
function exec(runtime) {
_xhr.bind('LoadStart', function(e) {
_p('readyState', XMLHttpRequest.LOADING);
self.dispatchEvent('readystatechange');
self.dispatchEvent(e);
if (_upload_events_flag) {
self.upload.dispatchEvent(e);
}
});
_xhr.bind('Progress', function(e) {
if (_p('readyState') !== XMLHttpRequest.LOADING) {
_p('readyState', XMLHttpRequest.LOADING); // LoadStart unreliable (in Flash for example)
self.dispatchEvent('readystatechange');
}
self.dispatchEvent(e);
});
_xhr.bind('UploadProgress', function(e) {
if (_upload_events_flag) {
self.upload.dispatchEvent({
type: 'progress',
lengthComputable: false,
total: e.total,
loaded: e.loaded
});
}
});
_xhr.bind('Load', function(e) {
_p('readyState', XMLHttpRequest.DONE);
_p('status', Number(runtime.exec.call(_xhr, 'XMLHttpRequest', 'getStatus') || 0));
_p('statusText', httpCode[_p('status')] || "");
_p('response', runtime.exec.call(_xhr, 'XMLHttpRequest', 'getResponse', _p('responseType')));
if (!!~Basic.inArray(_p('responseType'), ['text', ''])) {
_p('responseText', _p('response'));
} else if (_p('responseType') === 'document') {
_p('responseXML', _p('response'));
}
_responseHeaders = runtime.exec.call(_xhr, 'XMLHttpRequest', 'getAllResponseHeaders');
self.dispatchEvent('readystatechange');
if (_p('status') > 0) { // status 0 usually means that server is unreachable
if (_upload_events_flag) {
self.upload.dispatchEvent(e);
}
self.dispatchEvent(e);
} else {
_error_flag = true;
self.dispatchEvent('error');
}
loadEnd();
});
_xhr.bind('Abort', function(e) {
self.dispatchEvent(e);
loadEnd();
});
_xhr.bind('Error', function(e) {
_error_flag = true;
_p('readyState', XMLHttpRequest.DONE);
self.dispatchEvent('readystatechange');
_upload_complete_flag = true;
self.dispatchEvent(e);
loadEnd();
});
runtime.exec.call(_xhr, 'XMLHttpRequest', 'send', {
url: _url,
method: _method,
async: _async,
user: _user,
password: _password,
headers: _headers,
mimeType: _mimeType,
encoding: _encoding,
responseType: self.responseType,
withCredentials: self.withCredentials,
options: _options
}, data);
}
// clarify our requirements
if (typeof(_options.required_caps) === 'string') {
_options.required_caps = Runtime.parseCaps(_options.required_caps);
}
_options.required_caps = Basic.extend({}, _options.required_caps, {
return_response_type: self.responseType
});
if (data instanceof FormData) {
_options.required_caps.send_multipart = true;
}
if (!_same_origin_flag) {
_options.required_caps.do_cors = true;
}
if (_options.ruid) { // we do not need to wait if we can connect directly
exec(_xhr.connectRuntime(_options));
} else {
_xhr.bind('RuntimeInit', function(e, runtime) {
exec(runtime);
});
_xhr.bind('RuntimeError', function(e, err) {
self.dispatchEvent('RuntimeError', err);
});
_xhr.connectRuntime(_options);
}
}
function _reset() {
_p('responseText', "");
_p('responseXML', null);
_p('response', null);
_p('status', 0);
_p('statusText', "");
_start_time = _timeoutset_time = null;
}
}
XMLHttpRequest.UNSENT = 0;
XMLHttpRequest.OPENED = 1;
XMLHttpRequest.HEADERS_RECEIVED = 2;
XMLHttpRequest.LOADING = 3;
XMLHttpRequest.DONE = 4;
XMLHttpRequest.prototype = EventTarget.instance;
return XMLHttpRequest;
});
// Included from: src/javascript/runtime/Transporter.js
/**
* Transporter.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/runtime/Transporter", [
"moxie/core/utils/Basic",
"moxie/core/utils/Encode",
"moxie/runtime/RuntimeClient",
"moxie/core/EventTarget"
], function(Basic, Encode, RuntimeClient, EventTarget) {
function Transporter() {
var mod, _runtime, _data, _size, _pos, _chunk_size;
RuntimeClient.call(this);
Basic.extend(this, {
uid: Basic.guid('uid_'),
state: Transporter.IDLE,
result: null,
transport: function(data, type, options) {
var self = this;
options = Basic.extend({
chunk_size: 204798
}, options);
// should divide by three, base64 requires this
if ((mod = options.chunk_size % 3)) {
options.chunk_size += 3 - mod;
}
_chunk_size = options.chunk_size;
_reset.call(this);
_data = data;
_size = data.length;
if (Basic.typeOf(options) === 'string' || options.ruid) {
_run.call(self, type, this.connectRuntime(options));
} else {
// we require this to run only once
var cb = function(e, runtime) {
self.unbind("RuntimeInit", cb);
_run.call(self, type, runtime);
};
this.bind("RuntimeInit", cb);
this.connectRuntime(options);
}
},
abort: function() {
var self = this;
self.state = Transporter.IDLE;
if (_runtime) {
_runtime.exec.call(self, 'Transporter', 'clear');
self.trigger("TransportingAborted");
}
_reset.call(self);
},
destroy: function() {
this.unbindAll();
_runtime = null;
this.disconnectRuntime();
_reset.call(this);
}
});
function _reset() {
_size = _pos = 0;
_data = this.result = null;
}
function _run(type, runtime) {
var self = this;
_runtime = runtime;
//self.unbind("RuntimeInit");
self.bind("TransportingProgress", function(e) {
_pos = e.loaded;
if (_pos < _size && Basic.inArray(self.state, [Transporter.IDLE, Transporter.DONE]) === -1) {
_transport.call(self);
}
}, 999);
self.bind("TransportingComplete", function() {
_pos = _size;
self.state = Transporter.DONE;
_data = null; // clean a bit
self.result = _runtime.exec.call(self, 'Transporter', 'getAsBlob', type || '');
}, 999);
self.state = Transporter.BUSY;
self.trigger("TransportingStarted");
_transport.call(self);
}
function _transport() {
var self = this,
chunk,
bytesLeft = _size - _pos;
if (_chunk_size > bytesLeft) {
_chunk_size = bytesLeft;
}
chunk = Encode.btoa(_data.substr(_pos, _chunk_size));
_runtime.exec.call(self, 'Transporter', 'receive', chunk, _size);
}
}
Transporter.IDLE = 0;
Transporter.BUSY = 1;
Transporter.DONE = 2;
Transporter.prototype = EventTarget.instance;
return Transporter;
});
// Included from: src/javascript/image/Image.js
/**
* Image.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/image/Image", [
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/Exceptions",
"moxie/file/FileReaderSync",
"moxie/xhr/XMLHttpRequest",
"moxie/runtime/Runtime",
"moxie/runtime/RuntimeClient",
"moxie/runtime/Transporter",
"moxie/core/utils/Env",
"moxie/core/EventTarget",
"moxie/file/Blob",
"moxie/file/File",
"moxie/core/utils/Encode"
], function(Basic, Dom, x, FileReaderSync, XMLHttpRequest, Runtime, RuntimeClient, Transporter, Env, EventTarget, Blob, File, Encode) {
/**
Image preloading and manipulation utility. Additionally it provides access to image meta info (Exif, GPS) and raw binary data.
@class Image
@constructor
@extends EventTarget
*/
var dispatches = [
'progress',
/**
Dispatched when loading is complete.
@event load
@param {Object} event
*/
'load',
'error',
/**
Dispatched when resize operation is complete.
@event resize
@param {Object} event
*/
'resize',
/**
Dispatched when visual representation of the image is successfully embedded
into the corresponsing container.
@event embedded
@param {Object} event
*/
'embedded'
];
function Image() {
RuntimeClient.call(this);
Basic.extend(this, {
/**
Unique id of the component
@property uid
@type {String}
*/
uid: Basic.guid('uid_'),
/**
Unique id of the connected runtime, if any.
@property ruid
@type {String}
*/
ruid: null,
/**
Name of the file, that was used to create an image, if available. If not equals to empty string.
@property name
@type {String}
@default ""
*/
name: "",
/**
Size of the image in bytes. Actual value is set only after image is preloaded.
@property size
@type {Number}
@default 0
*/
size: 0,
/**
Width of the image. Actual value is set only after image is preloaded.
@property width
@type {Number}
@default 0
*/
width: 0,
/**
Height of the image. Actual value is set only after image is preloaded.
@property height
@type {Number}
@default 0
*/
height: 0,
/**
Mime type of the image. Currently only image/jpeg and image/png are supported. Actual value is set only after image is preloaded.
@property type
@type {String}
@default ""
*/
type: "",
/**
Holds meta info (Exif, GPS). Is populated only for image/jpeg. Actual value is set only after image is preloaded.
@property meta
@type {Object}
@default {}
*/
meta: {},
/**
Alias for load method, that takes another mOxie.Image object as a source (see load).
@method clone
@param {Image} src Source for the image
@param {Boolean} [exact=false] Whether to activate in-depth clone mode
*/
clone: function() {
this.load.apply(this, arguments);
},
/**
Loads image from various sources. Currently the source for new image can be: mOxie.Image, mOxie.Blob/mOxie.File,
native Blob/File, dataUrl or URL. Depending on the type of the source, arguments - differ. When source is URL,
Image will be downloaded from remote destination and loaded in memory.
@example
var img = new mOxie.Image();
img.onload = function() {
var blob = img.getAsBlob();
var formData = new mOxie.FormData();
formData.append('file', blob);
var xhr = new mOxie.XMLHttpRequest();
xhr.onload = function() {
// upload complete
};
xhr.open('post', 'upload.php');
xhr.send(formData);
};
img.load("http://www.moxiecode.com/images/mox-logo.jpg"); // notice file extension (.jpg)
@method load
@param {Image|Blob|File|String} src Source for the image
@param {Boolean|Object} [mixed]
*/
load: function() {
// this is here because to bind properly we need an uid first, which is created above
this.bind('Load Resize', function() {
_updateInfo.call(this);
}, 999);
this.convertEventPropsToHandlers(dispatches);
_load.apply(this, arguments);
},
/**
Downsizes the image to fit the specified width/height. If crop is supplied, image will be cropped to exact dimensions.
@method downsize
@param {Number} width Resulting width
@param {Number} [height=width] Resulting height (optional, if not supplied will default to width)
@param {Boolean} [crop=false] Whether to crop the image to exact dimensions
@param {Boolean} [preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize)
*/
downsize: function(width, height, crop, preserveHeaders) {
try {
if (!this.size) { // only preloaded image objects can be used as source
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
// no way to reliably intercept the crash due to high resolution, so we simply avoid it
if (this.width > Image.MAX_RESIZE_WIDTH || this.height > Image.MAX_RESIZE_HEIGHT) {
throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR);
}
if (!width && !height || Basic.typeOf(crop) === 'undefined') {
crop = false;
}
width = width || this.width;
height = height || this.height;
preserveHeaders = (Basic.typeOf(preserveHeaders) === 'undefined' ? true : !!preserveHeaders);
this.getRuntime().exec.call(this, 'Image', 'downsize', width, height, crop, preserveHeaders);
} catch(ex) {
// for now simply trigger error event
this.trigger('error', ex);
}
},
/**
Alias for downsize(width, height, true). (see downsize)
@method crop
@param {Number} width Resulting width
@param {Number} [height=width] Resulting height (optional, if not supplied will default to width)
@param {Boolean} [preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize)
*/
crop: function(width, height, preserveHeaders) {
this.downsize(width, height, true, preserveHeaders);
},
getAsCanvas: function() {
if (!Env.can('create_canvas')) {
throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR);
}
var runtime = this.connectRuntime(this.ruid);
return runtime.exec.call(this, 'Image', 'getAsCanvas');
},
/**
Retrieves image in it's current state as mOxie.Blob object. Cannot be run on empty or image in progress (throws
DOMException.INVALID_STATE_ERR).
@method getAsBlob
@param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png
@param {Number} [quality=90] Applicable only together with mime type image/jpeg
@return {Blob} Image as Blob
*/
getAsBlob: function(type, quality) {
if (!this.size) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
if (!type) {
type = 'image/jpeg';
}
if (type === 'image/jpeg' && !quality) {
quality = 90;
}
return this.getRuntime().exec.call(this, 'Image', 'getAsBlob', type, quality);
},
/**
Retrieves image in it's current state as dataURL string. Cannot be run on empty or image in progress (throws
DOMException.INVALID_STATE_ERR).
@method getAsDataURL
@param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png
@param {Number} [quality=90] Applicable only together with mime type image/jpeg
@return {String} Image as dataURL string
*/
getAsDataURL: function(type, quality) {
if (!this.size) {
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
return this.getRuntime().exec.call(this, 'Image', 'getAsDataURL', type, quality);
},
/**
Retrieves image in it's current state as binary string. Cannot be run on empty or image in progress (throws
DOMException.INVALID_STATE_ERR).
@method getAsBinaryString
@param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png
@param {Number} [quality=90] Applicable only together with mime type image/jpeg
@return {String} Image as binary string
*/
getAsBinaryString: function(type, quality) {
var dataUrl = this.getAsDataURL(type, quality);
return Encode.atob(dataUrl.substring(dataUrl.indexOf('base64,') + 7));
},
/**
Embeds the image, or better to say, it's visual representation into the specified node. Depending on the runtime
in use, might be a canvas, or image (actual ) element or shim object (Flash or SilverLight - very rare, used for
legacy browsers that do not have canvas or proper dataURI support).
@method embed
@param {DOMElement} el DOM element to insert the image object into
@param {Object} options Set of key/value pairs controlling the mime type, dimensions and cropping factor of resulting
representation
*/
embed: function(el) {
var self = this
, imgCopy
, type, quality, crop
, options = arguments[1] || {}
, width = this.width
, height = this.height
, runtime // this has to be outside of all the closures to contain proper runtime
;
function onResize() {
// if possible, embed a canvas element directly
if (Env.can('create_canvas')) {
var canvas = imgCopy.getAsCanvas();
if (canvas) {
el.appendChild(canvas);
canvas = null;
imgCopy.destroy();
self.trigger('embedded');
return;
}
}
var dataUrl = imgCopy.getAsDataURL(type, quality);
if (!dataUrl) {
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
}
if (Env.can('use_data_uri_of', dataUrl.length)) {
el.innerHTML = '<img src="' + dataUrl + '" width="' + imgCopy.width + '" height="' + imgCopy.height + '" />';
imgCopy.destroy();
self.trigger('embedded');
} else {
var tr = new Transporter();
tr.bind("TransportingComplete", function() {
runtime = self.connectRuntime(this.result.ruid);
self.bind("Embedded", function() {
// position and size properly
Basic.extend(runtime.getShimContainer().style, {
//position: 'relative',
top: '0px',
left: '0px',
width: imgCopy.width + 'px',
height: imgCopy.height + 'px'
});
// some shims (Flash/SilverLight) reinitialize, if parent element is hidden, reordered or it's
// position type changes (in Gecko), but since we basically need this only in IEs 6/7 and
// sometimes 8 and they do not have this problem, we can comment this for now
/*tr.bind("RuntimeInit", function(e, runtime) {
tr.destroy();
runtime.destroy();
onResize.call(self); // re-feed our image data
});*/
runtime = null;
}, 999);
runtime.exec.call(self, "ImageView", "display", this.result.uid, width, height);
imgCopy.destroy();
});
tr.transport(Encode.atob(dataUrl.substring(dataUrl.indexOf('base64,') + 7)), type, Basic.extend({}, options, {
required_caps: {
display_media: true
},
runtime_order: 'flash,silverlight',
container: el
}));
}
}
try {
if (!(el = Dom.get(el))) {
throw new x.DOMException(x.DOMException.INVALID_NODE_TYPE_ERR);
}
if (!this.size) { // only preloaded image objects can be used as source
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
if (this.width > Image.MAX_RESIZE_WIDTH || this.height > Image.MAX_RESIZE_HEIGHT) {
throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR);
}
type = options.type || this.type || 'image/jpeg';
quality = options.quality || 90;
crop = Basic.typeOf(options.crop) !== 'undefined' ? options.crop : false;
// figure out dimensions for the thumb
if (options.width) {
width = options.width;
height = options.height || width;
} else {
// if container element has > 0 dimensions, take them
var dimensions = Dom.getSize(el);
if (dimensions.w && dimensions.h) { // both should be > 0
width = dimensions.w;
height = dimensions.h;
}
}
imgCopy = new Image();
imgCopy.bind("Resize", function() {
onResize.call(self);
});
imgCopy.bind("Load", function() {
imgCopy.downsize(width, height, crop, false);
});
imgCopy.clone(this, false);
return imgCopy;
} catch(ex) {
// for now simply trigger error event
this.trigger('error', ex);
}
},
/**
Properly destroys the image and frees resources in use. If any. Recommended way to dispose mOxie.Image object.
@method destroy
*/
destroy: function() {
if (this.ruid) {
this.getRuntime().exec.call(this, 'Image', 'destroy');
this.disconnectRuntime();
}
this.unbindAll();
}
});
function _updateInfo(info) {
if (!info) {
info = this.getRuntime().exec.call(this, 'Image', 'getInfo');
}
this.size = info.size;
this.width = info.width;
this.height = info.height;
this.type = info.type;
this.meta = info.meta;
// update file name, only if empty
if (this.name === '') {
this.name = info.name;
}
}
function _load(src) {
var srcType = Basic.typeOf(src);
try {
// if source is Image
if (src instanceof Image) {
if (!src.size) { // only preloaded image objects can be used as source
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
}
_loadFromImage.apply(this, arguments);
}
// if source is o.Blob/o.File
else if (src instanceof Blob) {
if (!~Basic.inArray(src.type, ['image/jpeg', 'image/png'])) {
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
}
_loadFromBlob.apply(this, arguments);
}
// if native blob/file
else if (Basic.inArray(srcType, ['blob', 'file']) !== -1) {
_load.call(this, new File(null, src), arguments[1]);
}
// if String
else if (srcType === 'string') {
// if dataUrl String
if (/^data:[^;]*;base64,/.test(src)) {
_load.call(this, new Blob(null, { data: src }), arguments[1]);
}
// else assume Url, either relative or absolute
else {
_loadFromUrl.apply(this, arguments);
}
}
// if source seems to be an img node
else if (srcType === 'node' && src.nodeName.toLowerCase() === 'img') {
_load.call(this, src.src, arguments[1]);
}
else {
throw new x.DOMException(x.DOMException.TYPE_MISMATCH_ERR);
}
} catch(ex) {
// for now simply trigger error event
this.trigger('error', ex);
}
}
function _loadFromImage(img, exact) {
var runtime = this.connectRuntime(img.ruid);
this.ruid = runtime.uid;
runtime.exec.call(this, 'Image', 'loadFromImage', img, (Basic.typeOf(exact) === 'undefined' ? true : exact));
}
function _loadFromBlob(blob, options) {
var self = this;
self.name = blob.name || '';
function exec(runtime) {
self.ruid = runtime.uid;
runtime.exec.call(self, 'Image', 'loadFromBlob', blob);
}
if (blob.isDetached()) {
this.bind('RuntimeInit', function(e, runtime) {
exec(runtime);
});
// convert to object representation
if (options && typeof(options.required_caps) === 'string') {
options.required_caps = Runtime.parseCaps(options.required_caps);
}
this.connectRuntime(Basic.extend({
required_caps: {
access_image_binary: true,
resize_image: true
}
}, options));
} else {
exec(this.connectRuntime(blob.ruid));
}
}
function _loadFromUrl(url, options) {
var self = this, xhr;
xhr = new XMLHttpRequest();
xhr.open('get', url);
xhr.responseType = 'blob';
xhr.onprogress = function(e) {
self.trigger(e);
};
xhr.onload = function() {
_loadFromBlob.call(self, xhr.response, true);
};
xhr.onerror = function(e) {
self.trigger(e);
};
xhr.onloadend = function() {
xhr.destroy();
};
xhr.bind('RuntimeError', function(e, err) {
self.trigger('RuntimeError', err);
});
xhr.send(null, options);
}
}
// virtual world will crash on you if image has a resolution higher than this:
Image.MAX_RESIZE_WIDTH = 6500;
Image.MAX_RESIZE_HEIGHT = 6500;
Image.prototype = EventTarget.instance;
return Image;
});
// Included from: src/javascript/runtime/html5/Runtime.js
/**
* Runtime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global File:true */
/**
Defines constructor for HTML5 runtime.
@class moxie/runtime/html5/Runtime
@private
*/
define("moxie/runtime/html5/Runtime", [
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/runtime/Runtime",
"moxie/core/utils/Env"
], function(Basic, x, Runtime, Env) {
var type = "html5", extensions = {};
function Html5Runtime(options) {
var I = this
, Test = Runtime.capTest
, True = Runtime.capTrue
;
var caps = Basic.extend({
access_binary: Test(window.FileReader || window.File && window.File.getAsDataURL),
access_image_binary: function() {
return I.can('access_binary') && !!extensions.Image;
},
display_media: Test(Env.can('create_canvas') || Env.can('use_data_uri_over32kb')),
do_cors: Test(window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()),
drag_and_drop: Test(function() {
// this comes directly from Modernizr: http://www.modernizr.com/
var div = document.createElement('div');
// IE has support for drag and drop since version 5, but doesn't support dropping files from desktop
return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && (Env.browser !== 'IE' || Env.version > 9);
}()),
filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest
return (Env.browser === 'Chrome' && Env.version >= 28) || (Env.browser === 'IE' && Env.version >= 10);
}()),
return_response_headers: True,
return_response_type: function(responseType) {
if (responseType === 'json' && !!window.JSON) { // we can fake this one even if it's not supported
return true;
}
return Env.can('return_response_type', responseType);
},
return_status_code: True,
report_upload_progress: Test(window.XMLHttpRequest && new XMLHttpRequest().upload),
resize_image: function() {
return I.can('access_binary') && Env.can('create_canvas');
},
select_file: function() {
return Env.can('use_fileinput') && window.File;
},
select_folder: function() {
return I.can('select_file') && Env.browser === 'Chrome' && Env.version >= 21;
},
select_multiple: function() {
// it is buggy on Safari Windows and iOS
return I.can('select_file') &&
!(Env.browser === 'Safari' && Env.os === 'Windows') &&
!(Env.os === 'iOS' && Env.verComp(Env.osVersion, "7.0.4", '<'));
},
send_binary_string: Test(window.XMLHttpRequest && (new XMLHttpRequest().sendAsBinary || (window.Uint8Array && window.ArrayBuffer))),
send_custom_headers: Test(window.XMLHttpRequest),
send_multipart: function() {
return !!(window.XMLHttpRequest && new XMLHttpRequest().upload && window.FormData) || I.can('send_binary_string');
},
slice_blob: Test(window.File && (File.prototype.mozSlice || File.prototype.webkitSlice || File.prototype.slice)),
stream_upload: function(){
return I.can('slice_blob') && I.can('send_multipart');
},
summon_file_dialog: Test(function() { // yeah... some dirty sniffing here...
return (Env.browser === 'Firefox' && Env.version >= 4) ||
(Env.browser === 'Opera' && Env.version >= 12) ||
(Env.browser === 'IE' && Env.version >= 10) ||
!!~Basic.inArray(Env.browser, ['Chrome', 'Safari']);
}()),
upload_filesize: True
},
arguments[2]
);
Runtime.call(this, options, (arguments[1] || type), caps);
Basic.extend(this, {
init : function() {
this.trigger("Init");
},
destroy: (function(destroy) { // extend default destroy method
return function() {
destroy.call(I);
destroy = I = null;
};
}(this.destroy))
});
Basic.extend(this.getShim(), extensions);
}
Runtime.addConstructor(type, Html5Runtime);
return extensions;
});
// Included from: src/javascript/runtime/html5/file/Blob.js
/**
* Blob.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/file/Blob
@private
*/
define("moxie/runtime/html5/file/Blob", [
"moxie/runtime/html5/Runtime",
"moxie/file/Blob"
], function(extensions, Blob) {
function HTML5Blob() {
function w3cBlobSlice(blob, start, end) {
var blobSlice;
if (window.File.prototype.slice) {
try {
blob.slice(); // depricated version will throw WRONG_ARGUMENTS_ERR exception
return blob.slice(start, end);
} catch (e) {
// depricated slice method
return blob.slice(start, end - start);
}
// slice method got prefixed: https://bugzilla.mozilla.org/show_bug.cgi?id=649672
} else if ((blobSlice = window.File.prototype.webkitSlice || window.File.prototype.mozSlice)) {
return blobSlice.call(blob, start, end);
} else {
return null; // or throw some exception
}
}
this.slice = function() {
return new Blob(this.getRuntime().uid, w3cBlobSlice.apply(this, arguments));
};
}
return (extensions.Blob = HTML5Blob);
});
// Included from: src/javascript/core/utils/Events.js
/**
* Events.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Events', [
'moxie/core/utils/Basic'
], function(Basic) {
var eventhash = {}, uid = 'moxie_' + Basic.guid();
// IE W3C like event funcs
function preventDefault() {
this.returnValue = false;
}
function stopPropagation() {
this.cancelBubble = true;
}
/**
Adds an event handler to the specified object and store reference to the handler
in objects internal Plupload registry (@see removeEvent).
@method addEvent
@for Utils
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Name to add event listener to.
@param {Function} callback Function to call when event occurs.
@param {String} [key] that might be used to add specifity to the event record.
*/
var addEvent = function(obj, name, callback, key) {
var func, events;
name = name.toLowerCase();
// Add event listener
if (obj.addEventListener) {
func = callback;
obj.addEventListener(name, func, false);
} else if (obj.attachEvent) {
func = function() {
var evt = window.event;
if (!evt.target) {
evt.target = evt.srcElement;
}
evt.preventDefault = preventDefault;
evt.stopPropagation = stopPropagation;
callback(evt);
};
obj.attachEvent('on' + name, func);
}
// Log event handler to objects internal mOxie registry
if (!obj[uid]) {
obj[uid] = Basic.guid();
}
if (!eventhash.hasOwnProperty(obj[uid])) {
eventhash[obj[uid]] = {};
}
events = eventhash[obj[uid]];
if (!events.hasOwnProperty(name)) {
events[name] = [];
}
events[name].push({
func: func,
orig: callback, // store original callback for IE
key: key
});
};
/**
Remove event handler from the specified object. If third argument (callback)
is not specified remove all events with the specified name.
@method removeEvent
@static
@param {Object} obj DOM element to remove event listener(s) from.
@param {String} name Name of event listener to remove.
@param {Function|String} [callback] might be a callback or unique key to match.
*/
var removeEvent = function(obj, name, callback) {
var type, undef;
name = name.toLowerCase();
if (obj[uid] && eventhash[obj[uid]] && eventhash[obj[uid]][name]) {
type = eventhash[obj[uid]][name];
} else {
return;
}
for (var i = type.length - 1; i >= 0; i--) {
// undefined or not, key should match
if (type[i].orig === callback || type[i].key === callback) {
if (obj.removeEventListener) {
obj.removeEventListener(name, type[i].func, false);
} else if (obj.detachEvent) {
obj.detachEvent('on'+name, type[i].func);
}
type[i].orig = null;
type[i].func = null;
type.splice(i, 1);
// If callback was passed we are done here, otherwise proceed
if (callback !== undef) {
break;
}
}
}
// If event array got empty, remove it
if (!type.length) {
delete eventhash[obj[uid]][name];
}
// If mOxie registry has become empty, remove it
if (Basic.isEmptyObj(eventhash[obj[uid]])) {
delete eventhash[obj[uid]];
// IE doesn't let you remove DOM object property with - delete
try {
delete obj[uid];
} catch(e) {
obj[uid] = undef;
}
}
};
/**
Remove all kind of events from the specified object
@method removeAllEvents
@static
@param {Object} obj DOM element to remove event listeners from.
@param {String} [key] unique key to match, when removing events.
*/
var removeAllEvents = function(obj, key) {
if (!obj || !obj[uid]) {
return;
}
Basic.each(eventhash[obj[uid]], function(events, name) {
removeEvent(obj, name, key);
});
};
return {
addEvent: addEvent,
removeEvent: removeEvent,
removeAllEvents: removeAllEvents
};
});
// Included from: src/javascript/runtime/html5/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/file/FileInput
@private
*/
define("moxie/runtime/html5/file/FileInput", [
"moxie/runtime/html5/Runtime",
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/utils/Events",
"moxie/core/utils/Mime",
"moxie/core/utils/Env"
], function(extensions, Basic, Dom, Events, Mime, Env) {
function FileInput() {
var _files = [], _options;
Basic.extend(this, {
init: function(options) {
var comp = this, I = comp.getRuntime(), input, shimContainer, mimes, browseButton, zIndex, top;
_options = options;
_files = [];
// figure out accept string
mimes = _options.accept.mimes || Mime.extList2mimes(_options.accept, I.can('filter_by_extension'));
shimContainer = I.getShimContainer();
shimContainer.innerHTML = '<input id="' + I.uid +'" type="file" style="font-size:999px;opacity:0;"' +
(_options.multiple && I.can('select_multiple') ? 'multiple' : '') +
(_options.directory && I.can('select_folder') ? 'webkitdirectory directory' : '') + // Chrome 11+
(mimes ? ' accept="' + mimes.join(',') + '"' : '') + ' />';
input = Dom.get(I.uid);
// prepare file input to be placed underneath the browse_button element
Basic.extend(input.style, {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%'
});
browseButton = Dom.get(_options.browse_button);
// Route click event to the input[type=file] element for browsers that support such behavior
if (I.can('summon_file_dialog')) {
if (Dom.getStyle(browseButton, 'position') === 'static') {
browseButton.style.position = 'relative';
}
zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 1;
browseButton.style.zIndex = zIndex;
shimContainer.style.zIndex = zIndex - 1;
Events.addEvent(browseButton, 'click', function(e) {
var input = Dom.get(I.uid);
if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file]
input.click();
}
e.preventDefault();
}, comp.uid);
}
/* Since we have to place input[type=file] on top of the browse_button for some browsers,
browse_button loses interactivity, so we restore it here */
top = I.can('summon_file_dialog') ? browseButton : shimContainer;
Events.addEvent(top, 'mouseover', function() {
comp.trigger('mouseenter');
}, comp.uid);
Events.addEvent(top, 'mouseout', function() {
comp.trigger('mouseleave');
}, comp.uid);
Events.addEvent(top, 'mousedown', function() {
comp.trigger('mousedown');
}, comp.uid);
Events.addEvent(Dom.get(_options.container), 'mouseup', function() {
comp.trigger('mouseup');
}, comp.uid);
input.onchange = function onChange() { // there should be only one handler for this
_files = [];
if (_options.directory) {
// folders are represented by dots, filter them out (Chrome 11+)
Basic.each(this.files, function(file) {
if (file.name !== ".") { // if it doesn't looks like a folder
_files.push(file);
}
});
} else {
_files = [].slice.call(this.files);
}
// clearing the value enables the user to select the same file again if they want to
if (Env.browser !== 'IE') {
this.value = '';
} else {
// in IE input[type="file"] is read-only so the only way to reset it is to re-insert it
var clone = this.cloneNode(true);
this.parentNode.replaceChild(clone, this);
clone.onchange = onChange;
}
comp.trigger('change');
};
// ready event is perfectly asynchronous
comp.trigger({
type: 'ready',
async: true
});
shimContainer = null;
},
getFiles: function() {
return _files;
},
disable: function(state) {
var I = this.getRuntime(), input;
if ((input = Dom.get(I.uid))) {
input.disabled = !!state;
}
},
destroy: function() {
var I = this.getRuntime()
, shim = I.getShim()
, shimContainer = I.getShimContainer()
;
Events.removeAllEvents(shimContainer, this.uid);
Events.removeAllEvents(_options && Dom.get(_options.container), this.uid);
Events.removeAllEvents(_options && Dom.get(_options.browse_button), this.uid);
if (shimContainer) {
shimContainer.innerHTML = '';
}
shim.removeInstance(this.uid);
_files = _options = shimContainer = shim = null;
}
});
}
return (extensions.FileInput = FileInput);
});
// Included from: src/javascript/runtime/html5/file/FileDrop.js
/**
* FileDrop.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/file/FileDrop
@private
*/
define("moxie/runtime/html5/file/FileDrop", [
"moxie/runtime/html5/Runtime",
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/utils/Events",
"moxie/core/utils/Mime"
], function(extensions, Basic, Dom, Events, Mime) {
function FileDrop() {
var _files = [], _allowedExts = [], _options;
Basic.extend(this, {
init: function(options) {
var comp = this, dropZone;
_options = options;
_allowedExts = _extractExts(_options.accept);
dropZone = _options.container;
Events.addEvent(dropZone, 'dragover', function(e) {
e.preventDefault();
e.stopPropagation();
e.dataTransfer.dropEffect = 'copy';
}, comp.uid);
Events.addEvent(dropZone, 'drop', function(e) {
e.preventDefault();
e.stopPropagation();
_files = [];
// Chrome 21+ accepts folders via Drag'n'Drop
if (e.dataTransfer.items && e.dataTransfer.items[0].webkitGetAsEntry) {
_readItems(e.dataTransfer.items, function() {
comp.trigger("drop");
});
} else {
Basic.each(e.dataTransfer.files, function(file) {
if (_isAcceptable(file)) {
_files.push(file);
}
});
comp.trigger("drop");
}
}, comp.uid);
Events.addEvent(dropZone, 'dragenter', function(e) {
e.preventDefault();
e.stopPropagation();
comp.trigger("dragenter");
}, comp.uid);
Events.addEvent(dropZone, 'dragleave', function(e) {
e.preventDefault();
e.stopPropagation();
comp.trigger("dragleave");
}, comp.uid);
},
getFiles: function() {
return _files;
},
destroy: function() {
Events.removeAllEvents(_options && Dom.get(_options.container), this.uid);
_files = _allowedExts = _options = null;
}
});
function _extractExts(accept) {
var exts = [];
for (var i = 0; i < accept.length; i++) {
[].push.apply(exts, accept[i].extensions.split(/\s*,\s*/));
}
return Basic.inArray('*', exts) === -1 ? exts : [];
}
function _isAcceptable(file) {
var ext = Mime.getFileExtension(file.name);
return !ext || !_allowedExts.length || Basic.inArray(ext, _allowedExts) !== -1;
}
function _readItems(items, cb) {
var entries = [];
Basic.each(items, function(item) {
var entry = item.webkitGetAsEntry();
// Address #998 (https://code.google.com/p/chromium/issues/detail?id=332579)
if (entry) {
// file() fails on OSX when the filename contains a special character (e.g. umlaut): see #61
if (entry.isFile) {
var file = item.getAsFile();
if (_isAcceptable(file)) {
_files.push(file);
}
} else {
entries.push(entry);
}
}
});
if (entries.length) {
_readEntries(entries, cb);
} else {
cb();
}
}
function _readEntries(entries, cb) {
var queue = [];
Basic.each(entries, function(entry) {
queue.push(function(cbcb) {
_readEntry(entry, cbcb);
});
});
Basic.inSeries(queue, function() {
cb();
});
}
function _readEntry(entry, cb) {
if (entry.isFile) {
entry.file(function(file) {
if (_isAcceptable(file)) {
_files.push(file);
}
cb();
}, function() {
// fire an error event maybe
cb();
});
} else if (entry.isDirectory) {
_readDirEntry(entry, cb);
} else {
cb(); // not file, not directory? what then?..
}
}
function _readDirEntry(dirEntry, cb) {
var entries = [], dirReader = dirEntry.createReader();
// keep quering recursively till no more entries
function getEntries(cbcb) {
dirReader.readEntries(function(moreEntries) {
if (moreEntries.length) {
[].push.apply(entries, moreEntries);
getEntries(cbcb);
} else {
cbcb();
}
}, cbcb);
}
// ...and you thought FileReader was crazy...
getEntries(function() {
_readEntries(entries, cb);
});
}
}
return (extensions.FileDrop = FileDrop);
});
// Included from: src/javascript/runtime/html5/file/FileReader.js
/**
* FileReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/file/FileReader
@private
*/
define("moxie/runtime/html5/file/FileReader", [
"moxie/runtime/html5/Runtime",
"moxie/core/utils/Encode",
"moxie/core/utils/Basic"
], function(extensions, Encode, Basic) {
function FileReader() {
var _fr, _convertToBinary = false;
Basic.extend(this, {
read: function(op, blob) {
var target = this;
_fr = new window.FileReader();
_fr.addEventListener('progress', function(e) {
target.trigger(e);
});
_fr.addEventListener('load', function(e) {
target.trigger(e);
});
_fr.addEventListener('error', function(e) {
target.trigger(e, _fr.error);
});
_fr.addEventListener('loadend', function() {
_fr = null;
});
if (Basic.typeOf(_fr[op]) === 'function') {
_convertToBinary = false;
_fr[op](blob.getSource());
} else if (op === 'readAsBinaryString') { // readAsBinaryString is depricated in general and never existed in IE10+
_convertToBinary = true;
_fr.readAsDataURL(blob.getSource());
}
},
getResult: function() {
return _fr && _fr.result ? (_convertToBinary ? _toBinary(_fr.result) : _fr.result) : null;
},
abort: function() {
if (_fr) {
_fr.abort();
}
},
destroy: function() {
_fr = null;
}
});
function _toBinary(str) {
return Encode.atob(str.substring(str.indexOf('base64,') + 7));
}
}
return (extensions.FileReader = FileReader);
});
// Included from: src/javascript/runtime/html5/xhr/XMLHttpRequest.js
/**
* XMLHttpRequest.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global ActiveXObject:true */
/**
@class moxie/runtime/html5/xhr/XMLHttpRequest
@private
*/
define("moxie/runtime/html5/xhr/XMLHttpRequest", [
"moxie/runtime/html5/Runtime",
"moxie/core/utils/Basic",
"moxie/core/utils/Mime",
"moxie/core/utils/Url",
"moxie/file/File",
"moxie/file/Blob",
"moxie/xhr/FormData",
"moxie/core/Exceptions",
"moxie/core/utils/Env"
], function(extensions, Basic, Mime, Url, File, Blob, FormData, x, Env) {
function XMLHttpRequest() {
var self = this
, _xhr
, _filename
;
Basic.extend(this, {
send: function(meta, data) {
var target = this
, isGecko2_5_6 = (Env.browser === 'Mozilla' && Env.version >= 4 && Env.version < 7)
, isAndroidBrowser = Env.browser === 'Android Browser'
, mustSendAsBinary = false
;
// extract file name
_filename = meta.url.replace(/^.+?\/([\w\-\.]+)$/, '$1').toLowerCase();
_xhr = _getNativeXHR();
_xhr.open(meta.method, meta.url, meta.async, meta.user, meta.password);
// prepare data to be sent
if (data instanceof Blob) {
if (data.isDetached()) {
mustSendAsBinary = true;
}
data = data.getSource();
} else if (data instanceof FormData) {
if (data.hasBlob()) {
if (data.getBlob().isDetached()) {
data = _prepareMultipart.call(target, data); // _xhr must be instantiated and be in OPENED state
mustSendAsBinary = true;
} else if ((isGecko2_5_6 || isAndroidBrowser) && Basic.typeOf(data.getBlob().getSource()) === 'blob' && window.FileReader) {
// Gecko 2/5/6 can't send blob in FormData: https://bugzilla.mozilla.org/show_bug.cgi?id=649150
// Android browsers (default one and Dolphin) seem to have the same issue, see: #613
_preloadAndSend.call(target, meta, data);
return; // _preloadAndSend will reinvoke send() with transmutated FormData =%D
}
}
// transfer fields to real FormData
if (data instanceof FormData) { // if still a FormData, e.g. not mangled by _prepareMultipart()
var fd = new window.FormData();
data.each(function(value, name) {
if (value instanceof Blob) {
fd.append(name, value.getSource());
} else {
fd.append(name, value);
}
});
data = fd;
}
}
// if XHR L2
if (_xhr.upload) {
if (meta.withCredentials) {
_xhr.withCredentials = true;
}
_xhr.addEventListener('load', function(e) {
target.trigger(e);
});
_xhr.addEventListener('error', function(e) {
target.trigger(e);
});
// additionally listen to progress events
_xhr.addEventListener('progress', function(e) {
target.trigger(e);
});
_xhr.upload.addEventListener('progress', function(e) {
target.trigger({
type: 'UploadProgress',
loaded: e.loaded,
total: e.total
});
});
// ... otherwise simulate XHR L2
} else {
_xhr.onreadystatechange = function onReadyStateChange() {
// fake Level 2 events
switch (_xhr.readyState) {
case 1: // XMLHttpRequest.OPENED
// readystatechanged is fired twice for OPENED state (in IE and Mozilla) - neu
break;
// looks like HEADERS_RECEIVED (state 2) is not reported in Opera (or it's old versions) - neu
case 2: // XMLHttpRequest.HEADERS_RECEIVED
break;
case 3: // XMLHttpRequest.LOADING
// try to fire progress event for not XHR L2
var total, loaded;
try {
if (Url.hasSameOrigin(meta.url)) { // Content-Length not accessible for cross-domain on some browsers
total = _xhr.getResponseHeader('Content-Length') || 0; // old Safari throws an exception here
}
if (_xhr.responseText) { // responseText was introduced in IE7
loaded = _xhr.responseText.length;
}
} catch(ex) {
total = loaded = 0;
}
target.trigger({
type: 'progress',
lengthComputable: !!total,
total: parseInt(total, 10),
loaded: loaded
});
break;
case 4: // XMLHttpRequest.DONE
// release readystatechange handler (mostly for IE)
_xhr.onreadystatechange = function() {};
// usually status 0 is returned when server is unreachable, but FF also fails to status 0 for 408 timeout
if (_xhr.status === 0) {
target.trigger('error');
} else {
target.trigger('load');
}
break;
}
};
}
// set request headers
if (!Basic.isEmptyObj(meta.headers)) {
Basic.each(meta.headers, function(value, header) {
_xhr.setRequestHeader(header, value);
});
}
// request response type
if ("" !== meta.responseType && 'responseType' in _xhr) {
if ('json' === meta.responseType && !Env.can('return_response_type', 'json')) { // we can fake this one
_xhr.responseType = 'text';
} else {
_xhr.responseType = meta.responseType;
}
}
// send ...
if (!mustSendAsBinary) {
_xhr.send(data);
} else {
if (_xhr.sendAsBinary) { // Gecko
_xhr.sendAsBinary(data);
} else { // other browsers having support for typed arrays
(function() {
// mimic Gecko's sendAsBinary
var ui8a = new Uint8Array(data.length);
for (var i = 0; i < data.length; i++) {
ui8a[i] = (data.charCodeAt(i) & 0xff);
}
_xhr.send(ui8a.buffer);
}());
}
}
target.trigger('loadstart');
},
getStatus: function() {
// according to W3C spec it should return 0 for readyState < 3, but instead it throws an exception
try {
if (_xhr) {
return _xhr.status;
}
} catch(ex) {}
return 0;
},
getResponse: function(responseType) {
var I = this.getRuntime();
try {
switch (responseType) {
case 'blob':
var file = new File(I.uid, _xhr.response);
// try to extract file name from content-disposition if possible (might be - not, if CORS for example)
var disposition = _xhr.getResponseHeader('Content-Disposition');
if (disposition) {
// extract filename from response header if available
var match = disposition.match(/filename=([\'\"'])([^\1]+)\1/);
if (match) {
_filename = match[2];
}
}
file.name = _filename;
// pre-webkit Opera doesn't set type property on the blob response
if (!file.type) {
file.type = Mime.getFileMime(_filename);
}
return file;
case 'json':
if (!Env.can('return_response_type', 'json')) {
return _xhr.status === 200 && !!window.JSON ? JSON.parse(_xhr.responseText) : null;
}
return _xhr.response;
case 'document':
return _getDocument(_xhr);
default:
return _xhr.responseText !== '' ? _xhr.responseText : null; // against the specs, but for consistency across the runtimes
}
} catch(ex) {
return null;
}
},
getAllResponseHeaders: function() {
try {
return _xhr.getAllResponseHeaders();
} catch(ex) {}
return '';
},
abort: function() {
if (_xhr) {
_xhr.abort();
}
},
destroy: function() {
self = _filename = null;
}
});
// here we go... ugly fix for ugly bug
function _preloadAndSend(meta, data) {
var target = this, blob, fr;
// get original blob
blob = data.getBlob().getSource();
// preload blob in memory to be sent as binary string
fr = new window.FileReader();
fr.onload = function() {
// overwrite original blob
data.append(data.getBlobName(), new Blob(null, {
type: blob.type,
data: fr.result
}));
// invoke send operation again
self.send.call(target, meta, data);
};
fr.readAsBinaryString(blob);
}
function _getNativeXHR() {
if (window.XMLHttpRequest && !(Env.browser === 'IE' && Env.version < 8)) { // IE7 has native XHR but it's buggy
return new window.XMLHttpRequest();
} else {
return (function() {
var progIDs = ['Msxml2.XMLHTTP.6.0', 'Microsoft.XMLHTTP']; // if 6.0 available, use it, otherwise failback to default 3.0
for (var i = 0; i < progIDs.length; i++) {
try {
return new ActiveXObject(progIDs[i]);
} catch (ex) {}
}
})();
}
}
// @credits Sergey Ilinsky (http://www.ilinsky.com/)
function _getDocument(xhr) {
var rXML = xhr.responseXML;
var rText = xhr.responseText;
// Try parsing responseText (@see: http://www.ilinsky.com/articles/XMLHttpRequest/#bugs-ie-responseXML-content-type)
if (Env.browser === 'IE' && rText && rXML && !rXML.documentElement && /[^\/]+\/[^\+]+\+xml/.test(xhr.getResponseHeader("Content-Type"))) {
rXML = new window.ActiveXObject("Microsoft.XMLDOM");
rXML.async = false;
rXML.validateOnParse = false;
rXML.loadXML(rText);
}
// Check if there is no error in document
if (rXML) {
if ((Env.browser === 'IE' && rXML.parseError !== 0) || !rXML.documentElement || rXML.documentElement.tagName === "parsererror") {
return null;
}
}
return rXML;
}
function _prepareMultipart(fd) {
var boundary = '----moxieboundary' + new Date().getTime()
, dashdash = '--'
, crlf = '\r\n'
, multipart = ''
, I = this.getRuntime()
;
if (!I.can('send_binary_string')) {
throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR);
}
_xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + boundary);
// append multipart parameters
fd.each(function(value, name) {
// Firefox 3.6 failed to convert multibyte characters to UTF-8 in sendAsBinary(),
// so we try it here ourselves with: unescape(encodeURIComponent(value))
if (value instanceof Blob) {
// Build RFC2388 blob
multipart += dashdash + boundary + crlf +
'Content-Disposition: form-data; name="' + name + '"; filename="' + unescape(encodeURIComponent(value.name || 'blob')) + '"' + crlf +
'Content-Type: ' + (value.type || 'application/octet-stream') + crlf + crlf +
value.getSource() + crlf;
} else {
multipart += dashdash + boundary + crlf +
'Content-Disposition: form-data; name="' + name + '"' + crlf + crlf +
unescape(encodeURIComponent(value)) + crlf;
}
});
multipart += dashdash + boundary + dashdash + crlf;
return multipart;
}
}
return (extensions.XMLHttpRequest = XMLHttpRequest);
});
// Included from: src/javascript/runtime/html5/utils/BinaryReader.js
/**
* BinaryReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/utils/BinaryReader
@private
*/
define("moxie/runtime/html5/utils/BinaryReader", [], function() {
return function() {
var II = false, bin;
// Private functions
function read(idx, size) {
var mv = II ? 0 : -8 * (size - 1), sum = 0, i;
for (i = 0; i < size; i++) {
sum |= (bin.charCodeAt(idx + i) << Math.abs(mv + i*8));
}
return sum;
}
function putstr(segment, idx, length) {
length = arguments.length === 3 ? length : bin.length - idx - 1;
bin = bin.substr(0, idx) + segment + bin.substr(length + idx);
}
function write(idx, num, size) {
var str = '', mv = II ? 0 : -8 * (size - 1), i;
for (i = 0; i < size; i++) {
str += String.fromCharCode((num >> Math.abs(mv + i*8)) & 255);
}
putstr(str, idx, size);
}
// Public functions
return {
II: function(order) {
if (order === undefined) {
return II;
} else {
II = order;
}
},
init: function(binData) {
II = false;
bin = binData;
},
SEGMENT: function(idx, length, segment) {
switch (arguments.length) {
case 1:
return bin.substr(idx, bin.length - idx - 1);
case 2:
return bin.substr(idx, length);
case 3:
putstr(segment, idx, length);
break;
default: return bin;
}
},
BYTE: function(idx) {
return read(idx, 1);
},
SHORT: function(idx) {
return read(idx, 2);
},
LONG: function(idx, num) {
if (num === undefined) {
return read(idx, 4);
} else {
write(idx, num, 4);
}
},
SLONG: function(idx) { // 2's complement notation
var num = read(idx, 4);
return (num > 2147483647 ? num - 4294967296 : num);
},
STRING: function(idx, size) {
var str = '';
for (size += idx; idx < size; idx++) {
str += String.fromCharCode(read(idx, 1));
}
return str;
}
};
};
});
// Included from: src/javascript/runtime/html5/image/JPEGHeaders.js
/**
* JPEGHeaders.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/JPEGHeaders
@private
*/
define("moxie/runtime/html5/image/JPEGHeaders", [
"moxie/runtime/html5/utils/BinaryReader"
], function(BinaryReader) {
return function JPEGHeaders(data) {
var headers = [], read, idx, marker, length = 0;
read = new BinaryReader();
read.init(data);
// Check if data is jpeg
if (read.SHORT(0) !== 0xFFD8) {
return;
}
idx = 2;
while (idx <= data.length) {
marker = read.SHORT(idx);
// omit RST (restart) markers
if (marker >= 0xFFD0 && marker <= 0xFFD7) {
idx += 2;
continue;
}
// no headers allowed after SOS marker
if (marker === 0xFFDA || marker === 0xFFD9) {
break;
}
length = read.SHORT(idx + 2) + 2;
// APPn marker detected
if (marker >= 0xFFE1 && marker <= 0xFFEF) {
headers.push({
hex: marker,
name: 'APP' + (marker & 0x000F),
start: idx,
length: length,
segment: read.SEGMENT(idx, length)
});
}
idx += length;
}
read.init(null); // free memory
return {
headers: headers,
restore: function(data) {
var max, i;
read.init(data);
idx = read.SHORT(2) == 0xFFE0 ? 4 + read.SHORT(4) : 2;
for (i = 0, max = headers.length; i < max; i++) {
read.SEGMENT(idx, 0, headers[i].segment);
idx += headers[i].length;
}
data = read.SEGMENT();
read.init(null);
return data;
},
strip: function(data) {
var headers, jpegHeaders, i;
jpegHeaders = new JPEGHeaders(data);
headers = jpegHeaders.headers;
jpegHeaders.purge();
read.init(data);
i = headers.length;
while (i--) {
read.SEGMENT(headers[i].start, headers[i].length, '');
}
data = read.SEGMENT();
read.init(null);
return data;
},
get: function(name) {
var array = [];
for (var i = 0, max = headers.length; i < max; i++) {
if (headers[i].name === name.toUpperCase()) {
array.push(headers[i].segment);
}
}
return array;
},
set: function(name, segment) {
var array = [], i, ii, max;
if (typeof(segment) === 'string') {
array.push(segment);
} else {
array = segment;
}
for (i = ii = 0, max = headers.length; i < max; i++) {
if (headers[i].name === name.toUpperCase()) {
headers[i].segment = array[ii];
headers[i].length = array[ii].length;
ii++;
}
if (ii >= array.length) {
break;
}
}
},
purge: function() {
headers = [];
read.init(null);
read = null;
}
};
};
});
// Included from: src/javascript/runtime/html5/image/ExifParser.js
/**
* ExifParser.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/ExifParser
@private
*/
define("moxie/runtime/html5/image/ExifParser", [
"moxie/core/utils/Basic",
"moxie/runtime/html5/utils/BinaryReader"
], function(Basic, BinaryReader) {
return function ExifParser() {
// Private ExifParser fields
var data, tags, Tiff, offsets = {}, tagDescs;
data = new BinaryReader();
tags = {
tiff : {
/*
The image orientation viewed in terms of rows and columns.
1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.
2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.
3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.
4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.
5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.
6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.
7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.
8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.
*/
0x0112: 'Orientation',
0x010E: 'ImageDescription',
0x010F: 'Make',
0x0110: 'Model',
0x0131: 'Software',
0x8769: 'ExifIFDPointer',
0x8825: 'GPSInfoIFDPointer'
},
exif : {
0x9000: 'ExifVersion',
0xA001: 'ColorSpace',
0xA002: 'PixelXDimension',
0xA003: 'PixelYDimension',
0x9003: 'DateTimeOriginal',
0x829A: 'ExposureTime',
0x829D: 'FNumber',
0x8827: 'ISOSpeedRatings',
0x9201: 'ShutterSpeedValue',
0x9202: 'ApertureValue' ,
0x9207: 'MeteringMode',
0x9208: 'LightSource',
0x9209: 'Flash',
0x920A: 'FocalLength',
0xA402: 'ExposureMode',
0xA403: 'WhiteBalance',
0xA406: 'SceneCaptureType',
0xA404: 'DigitalZoomRatio',
0xA408: 'Contrast',
0xA409: 'Saturation',
0xA40A: 'Sharpness'
},
gps : {
0x0000: 'GPSVersionID',
0x0001: 'GPSLatitudeRef',
0x0002: 'GPSLatitude',
0x0003: 'GPSLongitudeRef',
0x0004: 'GPSLongitude'
}
};
tagDescs = {
'ColorSpace': {
1: 'sRGB',
0: 'Uncalibrated'
},
'MeteringMode': {
0: 'Unknown',
1: 'Average',
2: 'CenterWeightedAverage',
3: 'Spot',
4: 'MultiSpot',
5: 'Pattern',
6: 'Partial',
255: 'Other'
},
'LightSource': {
1: 'Daylight',
2: 'Fliorescent',
3: 'Tungsten',
4: 'Flash',
9: 'Fine weather',
10: 'Cloudy weather',
11: 'Shade',
12: 'Daylight fluorescent (D 5700 - 7100K)',
13: 'Day white fluorescent (N 4600 -5400K)',
14: 'Cool white fluorescent (W 3900 - 4500K)',
15: 'White fluorescent (WW 3200 - 3700K)',
17: 'Standard light A',
18: 'Standard light B',
19: 'Standard light C',
20: 'D55',
21: 'D65',
22: 'D75',
23: 'D50',
24: 'ISO studio tungsten',
255: 'Other'
},
'Flash': {
0x0000: 'Flash did not fire.',
0x0001: 'Flash fired.',
0x0005: 'Strobe return light not detected.',
0x0007: 'Strobe return light detected.',
0x0009: 'Flash fired, compulsory flash mode',
0x000D: 'Flash fired, compulsory flash mode, return light not detected',
0x000F: 'Flash fired, compulsory flash mode, return light detected',
0x0010: 'Flash did not fire, compulsory flash mode',
0x0018: 'Flash did not fire, auto mode',
0x0019: 'Flash fired, auto mode',
0x001D: 'Flash fired, auto mode, return light not detected',
0x001F: 'Flash fired, auto mode, return light detected',
0x0020: 'No flash function',
0x0041: 'Flash fired, red-eye reduction mode',
0x0045: 'Flash fired, red-eye reduction mode, return light not detected',
0x0047: 'Flash fired, red-eye reduction mode, return light detected',
0x0049: 'Flash fired, compulsory flash mode, red-eye reduction mode',
0x004D: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected',
0x004F: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected',
0x0059: 'Flash fired, auto mode, red-eye reduction mode',
0x005D: 'Flash fired, auto mode, return light not detected, red-eye reduction mode',
0x005F: 'Flash fired, auto mode, return light detected, red-eye reduction mode'
},
'ExposureMode': {
0: 'Auto exposure',
1: 'Manual exposure',
2: 'Auto bracket'
},
'WhiteBalance': {
0: 'Auto white balance',
1: 'Manual white balance'
},
'SceneCaptureType': {
0: 'Standard',
1: 'Landscape',
2: 'Portrait',
3: 'Night scene'
},
'Contrast': {
0: 'Normal',
1: 'Soft',
2: 'Hard'
},
'Saturation': {
0: 'Normal',
1: 'Low saturation',
2: 'High saturation'
},
'Sharpness': {
0: 'Normal',
1: 'Soft',
2: 'Hard'
},
// GPS related
'GPSLatitudeRef': {
N: 'North latitude',
S: 'South latitude'
},
'GPSLongitudeRef': {
E: 'East longitude',
W: 'West longitude'
}
};
function extractTags(IFD_offset, tags2extract) {
var length = data.SHORT(IFD_offset), i, ii,
tag, type, count, tagOffset, offset, value, values = [], hash = {};
for (i = 0; i < length; i++) {
// Set binary reader pointer to beginning of the next tag
offset = tagOffset = IFD_offset + 12 * i + 2;
tag = tags2extract[data.SHORT(offset)];
if (tag === undefined) {
continue; // Not the tag we requested
}
type = data.SHORT(offset+=2);
count = data.LONG(offset+=2);
offset += 4;
values = [];
switch (type) {
case 1: // BYTE
case 7: // UNDEFINED
if (count > 4) {
offset = data.LONG(offset) + offsets.tiffHeader;
}
for (ii = 0; ii < count; ii++) {
values[ii] = data.BYTE(offset + ii);
}
break;
case 2: // STRING
if (count > 4) {
offset = data.LONG(offset) + offsets.tiffHeader;
}
hash[tag] = data.STRING(offset, count - 1);
continue;
case 3: // SHORT
if (count > 2) {
offset = data.LONG(offset) + offsets.tiffHeader;
}
for (ii = 0; ii < count; ii++) {
values[ii] = data.SHORT(offset + ii*2);
}
break;
case 4: // LONG
if (count > 1) {
offset = data.LONG(offset) + offsets.tiffHeader;
}
for (ii = 0; ii < count; ii++) {
values[ii] = data.LONG(offset + ii*4);
}
break;
case 5: // RATIONAL
offset = data.LONG(offset) + offsets.tiffHeader;
for (ii = 0; ii < count; ii++) {
values[ii] = data.LONG(offset + ii*4) / data.LONG(offset + ii*4 + 4);
}
break;
case 9: // SLONG
offset = data.LONG(offset) + offsets.tiffHeader;
for (ii = 0; ii < count; ii++) {
values[ii] = data.SLONG(offset + ii*4);
}
break;
case 10: // SRATIONAL
offset = data.LONG(offset) + offsets.tiffHeader;
for (ii = 0; ii < count; ii++) {
values[ii] = data.SLONG(offset + ii*4) / data.SLONG(offset + ii*4 + 4);
}
break;
default:
continue;
}
value = (count == 1 ? values[0] : values);
if (tagDescs.hasOwnProperty(tag) && typeof value != 'object') {
hash[tag] = tagDescs[tag][value];
} else {
hash[tag] = value;
}
}
return hash;
}
function getIFDOffsets() {
var idx = offsets.tiffHeader;
// Set read order of multi-byte data
data.II(data.SHORT(idx) == 0x4949);
// Check if always present bytes are indeed present
if (data.SHORT(idx+=2) !== 0x002A) {
return false;
}
offsets.IFD0 = offsets.tiffHeader + data.LONG(idx += 2);
Tiff = extractTags(offsets.IFD0, tags.tiff);
if ('ExifIFDPointer' in Tiff) {
offsets.exifIFD = offsets.tiffHeader + Tiff.ExifIFDPointer;
delete Tiff.ExifIFDPointer;
}
if ('GPSInfoIFDPointer' in Tiff) {
offsets.gpsIFD = offsets.tiffHeader + Tiff.GPSInfoIFDPointer;
delete Tiff.GPSInfoIFDPointer;
}
return true;
}
// At the moment only setting of simple (LONG) values, that do not require offset recalculation, is supported
function setTag(ifd, tag, value) {
var offset, length, tagOffset, valueOffset = 0;
// If tag name passed translate into hex key
if (typeof(tag) === 'string') {
var tmpTags = tags[ifd.toLowerCase()];
for (var hex in tmpTags) {
if (tmpTags[hex] === tag) {
tag = hex;
break;
}
}
}
offset = offsets[ifd.toLowerCase() + 'IFD'];
length = data.SHORT(offset);
for (var i = 0; i < length; i++) {
tagOffset = offset + 12 * i + 2;
if (data.SHORT(tagOffset) == tag) {
valueOffset = tagOffset + 8;
break;
}
}
if (!valueOffset) {
return false;
}
data.LONG(valueOffset, value);
return true;
}
// Public functions
return {
init: function(segment) {
// Reset internal data
offsets = {
tiffHeader: 10
};
if (segment === undefined || !segment.length) {
return false;
}
data.init(segment);
// Check if that's APP1 and that it has EXIF
if (data.SHORT(0) === 0xFFE1 && data.STRING(4, 5).toUpperCase() === "EXIF\0") {
return getIFDOffsets();
}
return false;
},
TIFF: function() {
return Tiff;
},
EXIF: function() {
var Exif;
// Populate EXIF hash
Exif = extractTags(offsets.exifIFD, tags.exif);
// Fix formatting of some tags
if (Exif.ExifVersion && Basic.typeOf(Exif.ExifVersion) === 'array') {
for (var i = 0, exifVersion = ''; i < Exif.ExifVersion.length; i++) {
exifVersion += String.fromCharCode(Exif.ExifVersion[i]);
}
Exif.ExifVersion = exifVersion;
}
return Exif;
},
GPS: function() {
var GPS;
GPS = extractTags(offsets.gpsIFD, tags.gps);
// iOS devices (and probably some others) do not put in GPSVersionID tag (why?..)
if (GPS.GPSVersionID && Basic.typeOf(GPS.GPSVersionID) === 'array') {
GPS.GPSVersionID = GPS.GPSVersionID.join('.');
}
return GPS;
},
setExif: function(tag, value) {
// Right now only setting of width/height is possible
if (tag !== 'PixelXDimension' && tag !== 'PixelYDimension') {return false;}
return setTag('exif', tag, value);
},
getBinary: function() {
return data.SEGMENT();
},
purge: function() {
data.init(null);
data = Tiff = null;
offsets = {};
}
};
};
});
// Included from: src/javascript/runtime/html5/image/JPEG.js
/**
* JPEG.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/JPEG
@private
*/
define("moxie/runtime/html5/image/JPEG", [
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/runtime/html5/image/JPEGHeaders",
"moxie/runtime/html5/utils/BinaryReader",
"moxie/runtime/html5/image/ExifParser"
], function(Basic, x, JPEGHeaders, BinaryReader, ExifParser) {
function JPEG(binstr) {
var _binstr, _br, _hm, _ep, _info, hasExif;
function _getDimensions() {
var idx = 0, marker, length;
// examine all through the end, since some images might have very large APP segments
while (idx <= _binstr.length) {
marker = _br.SHORT(idx += 2);
if (marker >= 0xFFC0 && marker <= 0xFFC3) { // SOFn
idx += 5; // marker (2 bytes) + length (2 bytes) + Sample precision (1 byte)
return {
height: _br.SHORT(idx),
width: _br.SHORT(idx += 2)
};
}
length = _br.SHORT(idx += 2);
idx += length - 2;
}
return null;
}
_binstr = binstr;
_br = new BinaryReader();
_br.init(_binstr);
// check if it is jpeg
if (_br.SHORT(0) !== 0xFFD8) {
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
}
// backup headers
_hm = new JPEGHeaders(binstr);
// extract exif info
_ep = new ExifParser();
hasExif = !!_ep.init(_hm.get('app1')[0]);
// get dimensions
_info = _getDimensions.call(this);
Basic.extend(this, {
type: 'image/jpeg',
size: _binstr.length,
width: _info && _info.width || 0,
height: _info && _info.height || 0,
setExif: function(tag, value) {
if (!hasExif) {
return false; // or throw an exception
}
if (Basic.typeOf(tag) === 'object') {
Basic.each(tag, function(value, tag) {
_ep.setExif(tag, value);
});
} else {
_ep.setExif(tag, value);
}
// update internal headers
_hm.set('app1', _ep.getBinary());
},
writeHeaders: function() {
if (!arguments.length) {
// if no arguments passed, update headers internally
return (_binstr = _hm.restore(_binstr));
}
return _hm.restore(arguments[0]);
},
stripHeaders: function(binstr) {
return _hm.strip(binstr);
},
purge: function() {
_purge.call(this);
}
});
if (hasExif) {
this.meta = {
tiff: _ep.TIFF(),
exif: _ep.EXIF(),
gps: _ep.GPS()
};
}
function _purge() {
if (!_ep || !_hm || !_br) {
return; // ignore any repeating purge requests
}
_ep.purge();
_hm.purge();
_br.init(null);
_binstr = _info = _hm = _ep = _br = null;
}
}
return JPEG;
});
// Included from: src/javascript/runtime/html5/image/PNG.js
/**
* PNG.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/PNG
@private
*/
define("moxie/runtime/html5/image/PNG", [
"moxie/core/Exceptions",
"moxie/core/utils/Basic",
"moxie/runtime/html5/utils/BinaryReader"
], function(x, Basic, BinaryReader) {
function PNG(binstr) {
var _binstr, _br, _hm, _ep, _info;
_binstr = binstr;
_br = new BinaryReader();
_br.init(_binstr);
// check if it's png
(function() {
var idx = 0, i = 0
, signature = [0x8950, 0x4E47, 0x0D0A, 0x1A0A]
;
for (i = 0; i < signature.length; i++, idx += 2) {
if (signature[i] != _br.SHORT(idx)) {
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
}
}
}());
function _getDimensions() {
var chunk, idx;
chunk = _getChunkAt.call(this, 8);
if (chunk.type == 'IHDR') {
idx = chunk.start;
return {
width: _br.LONG(idx),
height: _br.LONG(idx += 4)
};
}
return null;
}
function _purge() {
if (!_br) {
return; // ignore any repeating purge requests
}
_br.init(null);
_binstr = _info = _hm = _ep = _br = null;
}
_info = _getDimensions.call(this);
Basic.extend(this, {
type: 'image/png',
size: _binstr.length,
width: _info.width,
height: _info.height,
purge: function() {
_purge.call(this);
}
});
// for PNG we can safely trigger purge automatically, as we do not keep any data for later
_purge.call(this);
function _getChunkAt(idx) {
var length, type, start, CRC;
length = _br.LONG(idx);
type = _br.STRING(idx += 4, 4);
start = idx += 4;
CRC = _br.LONG(idx + length);
return {
length: length,
type: type,
start: start,
CRC: CRC
};
}
}
return PNG;
});
// Included from: src/javascript/runtime/html5/image/ImageInfo.js
/**
* ImageInfo.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/ImageInfo
@private
*/
define("moxie/runtime/html5/image/ImageInfo", [
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/runtime/html5/image/JPEG",
"moxie/runtime/html5/image/PNG"
], function(Basic, x, JPEG, PNG) {
/**
Optional image investigation tool for HTML5 runtime. Provides the following features:
- ability to distinguish image type (JPEG or PNG) by signature
- ability to extract image width/height directly from it's internals, without preloading in memory (fast)
- ability to extract APP headers from JPEGs (Exif, GPS, etc)
- ability to replace width/height tags in extracted JPEG headers
- ability to restore APP headers, that were for example stripped during image manipulation
@class ImageInfo
@constructor
@param {String} binstr Image source as binary string
*/
return function(binstr) {
var _cs = [JPEG, PNG], _img;
// figure out the format, throw: ImageError.WRONG_FORMAT if not supported
_img = (function() {
for (var i = 0; i < _cs.length; i++) {
try {
return new _cs[i](binstr);
} catch (ex) {
// console.info(ex);
}
}
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
}());
Basic.extend(this, {
/**
Image Mime Type extracted from it's depths
@property type
@type {String}
@default ''
*/
type: '',
/**
Image size in bytes
@property size
@type {Number}
@default 0
*/
size: 0,
/**
Image width extracted from image source
@property width
@type {Number}
@default 0
*/
width: 0,
/**
Image height extracted from image source
@property height
@type {Number}
@default 0
*/
height: 0,
/**
Sets Exif tag. Currently applicable only for width and height tags. Obviously works only with JPEGs.
@method setExif
@param {String} tag Tag to set
@param {Mixed} value Value to assign to the tag
*/
setExif: function() {},
/**
Restores headers to the source.
@method writeHeaders
@param {String} data Image source as binary string
@return {String} Updated binary string
*/
writeHeaders: function(data) {
return data;
},
/**
Strip all headers from the source.
@method stripHeaders
@param {String} data Image source as binary string
@return {String} Updated binary string
*/
stripHeaders: function(data) {
return data;
},
/**
Dispose resources.
@method purge
*/
purge: function() {}
});
Basic.extend(this, _img);
this.purge = function() {
_img.purge();
_img = null;
};
};
});
// Included from: src/javascript/runtime/html5/image/MegaPixel.js
/**
(The MIT License)
Copyright (c) 2012 Shinichi Tomita <[email protected]>;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* Mega pixel image rendering library for iOS6 Safari
*
* Fixes iOS6 Safari's image file rendering issue for large size image (over mega-pixel),
* which causes unexpected subsampling when drawing it in canvas.
* By using this library, you can safely render the image with proper stretching.
*
* Copyright (c) 2012 Shinichi Tomita <[email protected]>
* Released under the MIT license
*/
/**
@class moxie/runtime/html5/image/MegaPixel
@private
*/
define("moxie/runtime/html5/image/MegaPixel", [], function() {
/**
* Rendering image element (with resizing) into the canvas element
*/
function renderImageToCanvas(img, canvas, options) {
var iw = img.naturalWidth, ih = img.naturalHeight;
var width = options.width, height = options.height;
var x = options.x || 0, y = options.y || 0;
var ctx = canvas.getContext('2d');
if (detectSubsampling(img)) {
iw /= 2;
ih /= 2;
}
var d = 1024; // size of tiling canvas
var tmpCanvas = document.createElement('canvas');
tmpCanvas.width = tmpCanvas.height = d;
var tmpCtx = tmpCanvas.getContext('2d');
var vertSquashRatio = detectVerticalSquash(img, iw, ih);
var sy = 0;
while (sy < ih) {
var sh = sy + d > ih ? ih - sy : d;
var sx = 0;
while (sx < iw) {
var sw = sx + d > iw ? iw - sx : d;
tmpCtx.clearRect(0, 0, d, d);
tmpCtx.drawImage(img, -sx, -sy);
var dx = (sx * width / iw + x) << 0;
var dw = Math.ceil(sw * width / iw);
var dy = (sy * height / ih / vertSquashRatio + y) << 0;
var dh = Math.ceil(sh * height / ih / vertSquashRatio);
ctx.drawImage(tmpCanvas, 0, 0, sw, sh, dx, dy, dw, dh);
sx += d;
}
sy += d;
}
tmpCanvas = tmpCtx = null;
}
/**
* Detect subsampling in loaded image.
* In iOS, larger images than 2M pixels may be subsampled in rendering.
*/
function detectSubsampling(img) {
var iw = img.naturalWidth, ih = img.naturalHeight;
if (iw * ih > 1024 * 1024) { // subsampling may happen over megapixel image
var canvas = document.createElement('canvas');
canvas.width = canvas.height = 1;
var ctx = canvas.getContext('2d');
ctx.drawImage(img, -iw + 1, 0);
// subsampled image becomes half smaller in rendering size.
// check alpha channel value to confirm image is covering edge pixel or not.
// if alpha value is 0 image is not covering, hence subsampled.
return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
} else {
return false;
}
}
/**
* Detecting vertical squash in loaded image.
* Fixes a bug which squash image vertically while drawing into canvas for some images.
*/
function detectVerticalSquash(img, iw, ih) {
var canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = ih;
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
var data = ctx.getImageData(0, 0, 1, ih).data;
// search image edge pixel position in case it is squashed vertically.
var sy = 0;
var ey = ih;
var py = ih;
while (py > sy) {
var alpha = data[(py - 1) * 4 + 3];
if (alpha === 0) {
ey = py;
} else {
sy = py;
}
py = (ey + sy) >> 1;
}
canvas = null;
var ratio = (py / ih);
return (ratio === 0) ? 1 : ratio;
}
return {
isSubsampled: detectSubsampling,
renderTo: renderImageToCanvas
};
});
// Included from: src/javascript/runtime/html5/image/Image.js
/**
* Image.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html5/image/Image
@private
*/
define("moxie/runtime/html5/image/Image", [
"moxie/runtime/html5/Runtime",
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/core/utils/Encode",
"moxie/file/File",
"moxie/runtime/html5/image/ImageInfo",
"moxie/runtime/html5/image/MegaPixel",
"moxie/core/utils/Mime",
"moxie/core/utils/Env"
], function(extensions, Basic, x, Encode, File, ImageInfo, MegaPixel, Mime, Env) {
function HTML5Image() {
var me = this
, _img, _imgInfo, _canvas, _binStr, _blob
, _modified = false // is set true whenever image is modified
, _preserveHeaders = true
;
Basic.extend(this, {
loadFromBlob: function(blob) {
var comp = this, I = comp.getRuntime()
, asBinary = arguments.length > 1 ? arguments[1] : true
;
if (!I.can('access_binary')) {
throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR);
}
_blob = blob;
if (blob.isDetached()) {
_binStr = blob.getSource();
_preload.call(this, _binStr);
return;
} else {
_readAsDataUrl.call(this, blob.getSource(), function(dataUrl) {
if (asBinary) {
_binStr = _toBinary(dataUrl);
}
_preload.call(comp, dataUrl);
});
}
},
loadFromImage: function(img, exact) {
this.meta = img.meta;
_blob = new File(null, {
name: img.name,
size: img.size,
type: img.type
});
_preload.call(this, exact ? (_binStr = img.getAsBinaryString()) : img.getAsDataURL());
},
getInfo: function() {
var I = this.getRuntime(), info;
if (!_imgInfo && _binStr && I.can('access_image_binary')) {
_imgInfo = new ImageInfo(_binStr);
}
info = {
width: _getImg().width || 0,
height: _getImg().height || 0,
type: _blob.type || Mime.getFileMime(_blob.name),
size: _binStr && _binStr.length || _blob.size || 0,
name: _blob.name || '',
meta: _imgInfo && _imgInfo.meta || this.meta || {}
};
return info;
},
downsize: function() {
_downsize.apply(this, arguments);
},
getAsCanvas: function() {
if (_canvas) {
_canvas.id = this.uid + '_canvas';
}
return _canvas;
},
getAsBlob: function(type, quality) {
if (type !== this.type) {
// if different mime type requested prepare image for conversion
_downsize.call(this, this.width, this.height, false);
}
return new File(null, {
name: _blob.name || '',
type: type,
data: me.getAsBinaryString.call(this, type, quality)
});
},
getAsDataURL: function(type) {
var quality = arguments[1] || 90;
// if image has not been modified, return the source right away
if (!_modified) {
return _img.src;
}
if ('image/jpeg' !== type) {
return _canvas.toDataURL('image/png');
} else {
try {
// older Geckos used to result in an exception on quality argument
return _canvas.toDataURL('image/jpeg', quality/100);
} catch (ex) {
return _canvas.toDataURL('image/jpeg');
}
}
},
getAsBinaryString: function(type, quality) {
// if image has not been modified, return the source right away
if (!_modified) {
// if image was not loaded from binary string
if (!_binStr) {
_binStr = _toBinary(me.getAsDataURL(type, quality));
}
return _binStr;
}
if ('image/jpeg' !== type) {
_binStr = _toBinary(me.getAsDataURL(type, quality));
} else {
var dataUrl;
// if jpeg
if (!quality) {
quality = 90;
}
try {
// older Geckos used to result in an exception on quality argument
dataUrl = _canvas.toDataURL('image/jpeg', quality/100);
} catch (ex) {
dataUrl = _canvas.toDataURL('image/jpeg');
}
_binStr = _toBinary(dataUrl);
if (_imgInfo) {
_binStr = _imgInfo.stripHeaders(_binStr);
if (_preserveHeaders) {
// update dimensions info in exif
if (_imgInfo.meta && _imgInfo.meta.exif) {
_imgInfo.setExif({
PixelXDimension: this.width,
PixelYDimension: this.height
});
}
// re-inject the headers
_binStr = _imgInfo.writeHeaders(_binStr);
}
// will be re-created from fresh on next getInfo call
_imgInfo.purge();
_imgInfo = null;
}
}
_modified = false;
return _binStr;
},
destroy: function() {
me = null;
_purge.call(this);
this.getRuntime().getShim().removeInstance(this.uid);
}
});
function _getImg() {
if (!_canvas && !_img) {
throw new x.ImageError(x.DOMException.INVALID_STATE_ERR);
}
return _canvas || _img;
}
function _toBinary(str) {
return Encode.atob(str.substring(str.indexOf('base64,') + 7));
}
function _toDataUrl(str, type) {
return 'data:' + (type || '') + ';base64,' + Encode.btoa(str);
}
function _preload(str) {
var comp = this;
_img = new Image();
_img.onerror = function() {
_purge.call(this);
comp.trigger('error', new x.ImageError(x.ImageError.WRONG_FORMAT));
};
_img.onload = function() {
comp.trigger('load');
};
_img.src = /^data:[^;]*;base64,/.test(str) ? str : _toDataUrl(str, _blob.type);
}
function _readAsDataUrl(file, callback) {
var comp = this, fr;
// use FileReader if it's available
if (window.FileReader) {
fr = new FileReader();
fr.onload = function() {
callback(this.result);
};
fr.onerror = function() {
comp.trigger('error', new x.FileException(x.FileException.NOT_READABLE_ERR));
};
fr.readAsDataURL(file);
} else {
return callback(file.getAsDataURL());
}
}
function _downsize(width, height, crop, preserveHeaders) {
var self = this
, scale
, mathFn
, x = 0
, y = 0
, img
, destWidth
, destHeight
, orientation
;
_preserveHeaders = preserveHeaders; // we will need to check this on export (see getAsBinaryString())
// take into account orientation tag
orientation = (this.meta && this.meta.tiff && this.meta.tiff.Orientation) || 1;
if (Basic.inArray(orientation, [5,6,7,8]) !== -1) { // values that require 90 degree rotation
// swap dimensions
var tmp = width;
width = height;
height = tmp;
}
img = _getImg();
// unify dimensions
mathFn = !crop ? Math.min : Math.max;
scale = mathFn(width/img.width, height/img.height);
// we only downsize here
if (scale > 1 && (!crop || preserveHeaders)) { // when cropping one of dimensions may still exceed max, so process it anyway
this.trigger('Resize');
return;
}
// prepare canvas if necessary
if (!_canvas) {
_canvas = document.createElement("canvas");
}
// calculate dimensions of proportionally resized image
destWidth = Math.round(img.width * scale);
destHeight = Math.round(img.height * scale);
// scale image and canvas
if (crop) {
_canvas.width = width;
_canvas.height = height;
// if dimensions of the resulting image still larger than canvas, center it
if (destWidth > width) {
x = Math.round((destWidth - width) / 2);
}
if (destHeight > height) {
y = Math.round((destHeight - height) / 2);
}
} else {
_canvas.width = destWidth;
_canvas.height = destHeight;
}
// rotate if required, according to orientation tag
if (!_preserveHeaders) {
_rotateToOrientaion(_canvas.width, _canvas.height, orientation);
}
_drawToCanvas.call(this, img, _canvas, -x, -y, destWidth, destHeight);
this.width = _canvas.width;
this.height = _canvas.height;
_modified = true;
self.trigger('Resize');
}
function _drawToCanvas(img, canvas, x, y, w, h) {
if (Env.OS === 'iOS') {
// avoid squish bug in iOS6
MegaPixel.renderTo(img, canvas, { width: w, height: h, x: x, y: y });
} else {
var ctx = canvas.getContext('2d');
ctx.drawImage(img, x, y, w, h);
}
}
/**
* Transform canvas coordination according to specified frame size and orientation
* Orientation value is from EXIF tag
* @author Shinichi Tomita <[email protected]>
*/
function _rotateToOrientaion(width, height, orientation) {
switch (orientation) {
case 5:
case 6:
case 7:
case 8:
_canvas.width = height;
_canvas.height = width;
break;
default:
_canvas.width = width;
_canvas.height = height;
}
/**
1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.
2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.
3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.
4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.
5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.
6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.
7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.
8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.
*/
var ctx = _canvas.getContext('2d');
switch (orientation) {
case 2:
// horizontal flip
ctx.translate(width, 0);
ctx.scale(-1, 1);
break;
case 3:
// 180 rotate left
ctx.translate(width, height);
ctx.rotate(Math.PI);
break;
case 4:
// vertical flip
ctx.translate(0, height);
ctx.scale(1, -1);
break;
case 5:
// vertical flip + 90 rotate right
ctx.rotate(0.5 * Math.PI);
ctx.scale(1, -1);
break;
case 6:
// 90 rotate right
ctx.rotate(0.5 * Math.PI);
ctx.translate(0, -height);
break;
case 7:
// horizontal flip + 90 rotate right
ctx.rotate(0.5 * Math.PI);
ctx.translate(width, -height);
ctx.scale(-1, 1);
break;
case 8:
// 90 rotate left
ctx.rotate(-0.5 * Math.PI);
ctx.translate(-width, 0);
break;
}
}
function _purge() {
if (_imgInfo) {
_imgInfo.purge();
_imgInfo = null;
}
_binStr = _img = _canvas = _blob = null;
_modified = false;
}
}
return (extensions.Image = HTML5Image);
});
// Included from: src/javascript/runtime/flash/Runtime.js
/**
* Runtime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global ActiveXObject:true */
/**
Defines constructor for Flash runtime.
@class moxie/runtime/flash/Runtime
@private
*/
define("moxie/runtime/flash/Runtime", [
"moxie/core/utils/Basic",
"moxie/core/utils/Env",
"moxie/core/utils/Dom",
"moxie/core/Exceptions",
"moxie/runtime/Runtime"
], function(Basic, Env, Dom, x, Runtime) {
var type = 'flash', extensions = {};
/**
Get the version of the Flash Player
@method getShimVersion
@private
@return {Number} Flash Player version
*/
function getShimVersion() {
var version;
try {
version = navigator.plugins['Shockwave Flash'];
version = version.description;
} catch (e1) {
try {
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
} catch (e2) {
version = '0.0';
}
}
version = version.match(/\d+/g);
return parseFloat(version[0] + '.' + version[1]);
}
/**
Constructor for the Flash Runtime
@class FlashRuntime
@extends Runtime
*/
function FlashRuntime(options) {
var I = this, initTimer;
options = Basic.extend({ swf_url: Env.swf_url }, options);
Runtime.call(this, options, type, {
access_binary: function(value) {
return value && I.mode === 'browser';
},
access_image_binary: function(value) {
return value && I.mode === 'browser';
},
display_media: Runtime.capTrue,
do_cors: Runtime.capTrue,
drag_and_drop: false,
report_upload_progress: function() {
return I.mode === 'client';
},
resize_image: Runtime.capTrue,
return_response_headers: false,
return_response_type: function(responseType) {
if (responseType === 'json' && !!window.JSON) {
return true;
}
return !Basic.arrayDiff(responseType, ['', 'text', 'document']) || I.mode === 'browser';
},
return_status_code: function(code) {
return I.mode === 'browser' || !Basic.arrayDiff(code, [200, 404]);
},
select_file: Runtime.capTrue,
select_multiple: Runtime.capTrue,
send_binary_string: function(value) {
return value && I.mode === 'browser';
},
send_browser_cookies: function(value) {
return value && I.mode === 'browser';
},
send_custom_headers: function(value) {
return value && I.mode === 'browser';
},
send_multipart: Runtime.capTrue,
slice_blob: Runtime.capTrue,
stream_upload: function(value) {
return value && I.mode === 'browser';
},
summon_file_dialog: false,
upload_filesize: function(size) {
return Basic.parseSizeStr(size) <= 2097152 || I.mode === 'client';
},
use_http_method: function(methods) {
return !Basic.arrayDiff(methods, ['GET', 'POST']);
}
}, {
// capabilities that require specific mode
access_binary: function(value) {
return value ? 'browser' : 'client';
},
access_image_binary: function(value) {
return value ? 'browser' : 'client';
},
report_upload_progress: function(value) {
return value ? 'browser' : 'client';
},
return_response_type: function(responseType) {
return Basic.arrayDiff(responseType, ['', 'text', 'json', 'document']) ? 'browser' : ['client', 'browser'];
},
return_status_code: function(code) {
return Basic.arrayDiff(code, [200, 404]) ? 'browser' : ['client', 'browser'];
},
send_binary_string: function(value) {
return value ? 'browser' : 'client';
},
send_browser_cookies: function(value) {
return value ? 'browser' : 'client';
},
send_custom_headers: function(value) {
return value ? 'browser' : 'client';
},
stream_upload: function(value) {
return value ? 'client' : 'browser';
},
upload_filesize: function(size) {
return Basic.parseSizeStr(size) >= 2097152 ? 'client' : 'browser';
}
}, 'client');
// minimal requirement for Flash Player version
if (getShimVersion() < 10) {
this.mode = false; // with falsy mode, runtime won't operable, no matter what the mode was before
}
Basic.extend(this, {
getShim: function() {
return Dom.get(this.uid);
},
shimExec: function(component, action) {
var args = [].slice.call(arguments, 2);
return I.getShim().exec(this.uid, component, action, args);
},
init: function() {
var html, el, container;
container = this.getShimContainer();
// if not the minimal height, shims are not initialized in older browsers (e.g FF3.6, IE6,7,8, Safari 4.0,5.0, etc)
Basic.extend(container.style, {
position: 'absolute',
top: '-8px',
left: '-8px',
width: '9px',
height: '9px',
overflow: 'hidden'
});
// insert flash object
html = '<object id="' + this.uid + '" type="application/x-shockwave-flash" data="' + options.swf_url + '" ';
if (Env.browser === 'IE') {
html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
}
html += 'width="100%" height="100%" style="outline:0">' +
'<param name="movie" value="' + options.swf_url + '" />' +
'<param name="flashvars" value="uid=' + escape(this.uid) + '&target=' + Env.global_event_dispatcher + '" />' +
'<param name="wmode" value="transparent" />' +
'<param name="allowscriptaccess" value="always" />' +
'</object>';
if (Env.browser === 'IE') {
el = document.createElement('div');
container.appendChild(el);
el.outerHTML = html;
el = container = null; // just in case
} else {
container.innerHTML = html;
}
// Init is dispatched by the shim
initTimer = setTimeout(function() {
if (I && !I.initialized) { // runtime might be already destroyed by this moment
I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR));
}
}, 5000);
},
destroy: (function(destroy) { // extend default destroy method
return function() {
destroy.call(I);
clearTimeout(initTimer); // initialization check might be still onwait
options = initTimer = destroy = I = null;
};
}(this.destroy))
}, extensions);
}
Runtime.addConstructor(type, FlashRuntime);
return extensions;
});
// Included from: src/javascript/runtime/flash/file/Blob.js
/**
* Blob.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/file/Blob
@private
*/
define("moxie/runtime/flash/file/Blob", [
"moxie/runtime/flash/Runtime",
"moxie/file/Blob"
], function(extensions, Blob) {
var FlashBlob = {
slice: function(blob, start, end, type) {
var self = this.getRuntime();
if (start < 0) {
start = Math.max(blob.size + start, 0);
} else if (start > 0) {
start = Math.min(start, blob.size);
}
if (end < 0) {
end = Math.max(blob.size + end, 0);
} else if (end > 0) {
end = Math.min(end, blob.size);
}
blob = self.shimExec.call(this, 'Blob', 'slice', start, end, type || '');
if (blob) {
blob = new Blob(self.uid, blob);
}
return blob;
}
};
return (extensions.Blob = FlashBlob);
});
// Included from: src/javascript/runtime/flash/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/file/FileInput
@private
*/
define("moxie/runtime/flash/file/FileInput", [
"moxie/runtime/flash/Runtime"
], function(extensions) {
var FileInput = {
init: function(options) {
this.getRuntime().shimExec.call(this, 'FileInput', 'init', {
name: options.name,
accept: options.accept,
multiple: options.multiple
});
this.trigger('ready');
}
};
return (extensions.FileInput = FileInput);
});
// Included from: src/javascript/runtime/flash/file/FileReader.js
/**
* FileReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/file/FileReader
@private
*/
define("moxie/runtime/flash/file/FileReader", [
"moxie/runtime/flash/Runtime",
"moxie/core/utils/Encode"
], function(extensions, Encode) {
var _result = '';
function _formatData(data, op) {
switch (op) {
case 'readAsText':
return Encode.atob(data, 'utf8');
case 'readAsBinaryString':
return Encode.atob(data);
case 'readAsDataURL':
return data;
}
return null;
}
var FileReader = {
read: function(op, blob) {
var target = this, self = target.getRuntime();
// special prefix for DataURL read mode
if (op === 'readAsDataURL') {
_result = 'data:' + (blob.type || '') + ';base64,';
}
target.bind('Progress', function(e, data) {
if (data) {
_result += _formatData(data, op);
}
});
return self.shimExec.call(this, 'FileReader', 'readAsBase64', blob.uid);
},
getResult: function() {
return _result;
},
destroy: function() {
_result = null;
}
};
return (extensions.FileReader = FileReader);
});
// Included from: src/javascript/runtime/flash/file/FileReaderSync.js
/**
* FileReaderSync.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/file/FileReaderSync
@private
*/
define("moxie/runtime/flash/file/FileReaderSync", [
"moxie/runtime/flash/Runtime",
"moxie/core/utils/Encode"
], function(extensions, Encode) {
function _formatData(data, op) {
switch (op) {
case 'readAsText':
return Encode.atob(data, 'utf8');
case 'readAsBinaryString':
return Encode.atob(data);
case 'readAsDataURL':
return data;
}
return null;
}
var FileReaderSync = {
read: function(op, blob) {
var result, self = this.getRuntime();
result = self.shimExec.call(this, 'FileReaderSync', 'readAsBase64', blob.uid);
if (!result) {
return null; // or throw ex
}
// special prefix for DataURL read mode
if (op === 'readAsDataURL') {
result = 'data:' + (blob.type || '') + ';base64,' + result;
}
return _formatData(result, op, blob.type);
}
};
return (extensions.FileReaderSync = FileReaderSync);
});
// Included from: src/javascript/runtime/flash/xhr/XMLHttpRequest.js
/**
* XMLHttpRequest.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/xhr/XMLHttpRequest
@private
*/
define("moxie/runtime/flash/xhr/XMLHttpRequest", [
"moxie/runtime/flash/Runtime",
"moxie/core/utils/Basic",
"moxie/file/Blob",
"moxie/file/File",
"moxie/file/FileReaderSync",
"moxie/xhr/FormData",
"moxie/runtime/Transporter"
], function(extensions, Basic, Blob, File, FileReaderSync, FormData, Transporter) {
var XMLHttpRequest = {
send: function(meta, data) {
var target = this, self = target.getRuntime();
function send() {
meta.transport = self.mode;
self.shimExec.call(target, 'XMLHttpRequest', 'send', meta, data);
}
function appendBlob(name, blob) {
self.shimExec.call(target, 'XMLHttpRequest', 'appendBlob', name, blob.uid);
data = null;
send();
}
function attachBlob(blob, cb) {
var tr = new Transporter();
tr.bind("TransportingComplete", function() {
cb(this.result);
});
tr.transport(blob.getSource(), blob.type, {
ruid: self.uid
});
}
// copy over the headers if any
if (!Basic.isEmptyObj(meta.headers)) {
Basic.each(meta.headers, function(value, header) {
self.shimExec.call(target, 'XMLHttpRequest', 'setRequestHeader', header, value.toString()); // Silverlight doesn't accept integers into the arguments of type object
});
}
// transfer over multipart params and blob itself
if (data instanceof FormData) {
var blobField;
data.each(function(value, name) {
if (value instanceof Blob) {
blobField = name;
} else {
self.shimExec.call(target, 'XMLHttpRequest', 'append', name, value);
}
});
if (!data.hasBlob()) {
data = null;
send();
} else {
var blob = data.getBlob();
if (blob.isDetached()) {
attachBlob(blob, function(attachedBlob) {
blob.destroy();
appendBlob(blobField, attachedBlob);
});
} else {
appendBlob(blobField, blob);
}
}
} else if (data instanceof Blob) {
if (data.isDetached()) {
attachBlob(data, function(attachedBlob) {
data.destroy();
data = attachedBlob.uid;
send();
});
} else {
data = data.uid;
send();
}
} else {
send();
}
},
getResponse: function(responseType) {
var frs, blob, self = this.getRuntime();
blob = self.shimExec.call(this, 'XMLHttpRequest', 'getResponseAsBlob');
if (blob) {
blob = new File(self.uid, blob);
if ('blob' === responseType) {
return blob;
}
try {
frs = new FileReaderSync();
if (!!~Basic.inArray(responseType, ["", "text"])) {
return frs.readAsText(blob);
} else if ('json' === responseType && !!window.JSON) {
return JSON.parse(frs.readAsText(blob));
}
} finally {
blob.destroy();
}
}
return null;
},
abort: function(upload_complete_flag) {
var self = this.getRuntime();
self.shimExec.call(this, 'XMLHttpRequest', 'abort');
this.dispatchEvent('readystatechange');
// this.dispatchEvent('progress');
this.dispatchEvent('abort');
//if (!upload_complete_flag) {
// this.dispatchEvent('uploadprogress');
//}
}
};
return (extensions.XMLHttpRequest = XMLHttpRequest);
});
// Included from: src/javascript/runtime/flash/runtime/Transporter.js
/**
* Transporter.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/runtime/Transporter
@private
*/
define("moxie/runtime/flash/runtime/Transporter", [
"moxie/runtime/flash/Runtime",
"moxie/file/Blob"
], function(extensions, Blob) {
var Transporter = {
getAsBlob: function(type) {
var self = this.getRuntime()
, blob = self.shimExec.call(this, 'Transporter', 'getAsBlob', type)
;
if (blob) {
return new Blob(self.uid, blob);
}
return null;
}
};
return (extensions.Transporter = Transporter);
});
// Included from: src/javascript/runtime/flash/image/Image.js
/**
* Image.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/flash/image/Image
@private
*/
define("moxie/runtime/flash/image/Image", [
"moxie/runtime/flash/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/Transporter",
"moxie/file/Blob",
"moxie/file/FileReaderSync"
], function(extensions, Basic, Transporter, Blob, FileReaderSync) {
var Image = {
loadFromBlob: function(blob) {
var comp = this, self = comp.getRuntime();
function exec(srcBlob) {
self.shimExec.call(comp, 'Image', 'loadFromBlob', srcBlob.uid);
comp = self = null;
}
if (blob.isDetached()) { // binary string
var tr = new Transporter();
tr.bind("TransportingComplete", function() {
exec(tr.result.getSource());
});
tr.transport(blob.getSource(), blob.type, { ruid: self.uid });
} else {
exec(blob.getSource());
}
},
loadFromImage: function(img) {
var self = this.getRuntime();
return self.shimExec.call(this, 'Image', 'loadFromImage', img.uid);
},
getAsBlob: function(type, quality) {
var self = this.getRuntime()
, blob = self.shimExec.call(this, 'Image', 'getAsBlob', type, quality)
;
if (blob) {
return new Blob(self.uid, blob);
}
return null;
},
getAsDataURL: function() {
var self = this.getRuntime()
, blob = self.Image.getAsBlob.apply(this, arguments)
, frs
;
if (!blob) {
return null;
}
frs = new FileReaderSync();
return frs.readAsDataURL(blob);
}
};
return (extensions.Image = Image);
});
// Included from: src/javascript/runtime/silverlight/Runtime.js
/**
* RunTime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global ActiveXObject:true */
/**
Defines constructor for Silverlight runtime.
@class moxie/runtime/silverlight/Runtime
@private
*/
define("moxie/runtime/silverlight/Runtime", [
"moxie/core/utils/Basic",
"moxie/core/utils/Env",
"moxie/core/utils/Dom",
"moxie/core/Exceptions",
"moxie/runtime/Runtime"
], function(Basic, Env, Dom, x, Runtime) {
var type = "silverlight", extensions = {};
function isInstalled(version) {
var isVersionSupported = false, control = null, actualVer,
actualVerArray, reqVerArray, requiredVersionPart, actualVersionPart, index = 0;
try {
try {
control = new ActiveXObject('AgControl.AgControl');
if (control.IsVersionSupported(version)) {
isVersionSupported = true;
}
control = null;
} catch (e) {
var plugin = navigator.plugins["Silverlight Plug-In"];
if (plugin) {
actualVer = plugin.description;
if (actualVer === "1.0.30226.2") {
actualVer = "2.0.30226.2";
}
actualVerArray = actualVer.split(".");
while (actualVerArray.length > 3) {
actualVerArray.pop();
}
while ( actualVerArray.length < 4) {
actualVerArray.push(0);
}
reqVerArray = version.split(".");
while (reqVerArray.length > 4) {
reqVerArray.pop();
}
do {
requiredVersionPart = parseInt(reqVerArray[index], 10);
actualVersionPart = parseInt(actualVerArray[index], 10);
index++;
} while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);
if (requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart)) {
isVersionSupported = true;
}
}
}
} catch (e2) {
isVersionSupported = false;
}
return isVersionSupported;
}
/**
Constructor for the Silverlight Runtime
@class SilverlightRuntime
@extends Runtime
*/
function SilverlightRuntime(options) {
var I = this, initTimer;
options = Basic.extend({ xap_url: Env.xap_url }, options);
Runtime.call(this, options, type, {
access_binary: Runtime.capTrue,
access_image_binary: Runtime.capTrue,
display_media: Runtime.capTrue,
do_cors: Runtime.capTrue,
drag_and_drop: false,
report_upload_progress: Runtime.capTrue,
resize_image: Runtime.capTrue,
return_response_headers: function(value) {
return value && I.mode === 'client';
},
return_response_type: function(responseType) {
if (responseType !== 'json') {
return true;
} else {
return !!window.JSON;
}
},
return_status_code: function(code) {
return I.mode === 'client' || !Basic.arrayDiff(code, [200, 404]);
},
select_file: Runtime.capTrue,
select_multiple: Runtime.capTrue,
send_binary_string: Runtime.capTrue,
send_browser_cookies: function(value) {
return value && I.mode === 'browser';
},
send_custom_headers: function(value) {
return value && I.mode === 'client';
},
send_multipart: Runtime.capTrue,
slice_blob: Runtime.capTrue,
stream_upload: true,
summon_file_dialog: false,
upload_filesize: Runtime.capTrue,
use_http_method: function(methods) {
return I.mode === 'client' || !Basic.arrayDiff(methods, ['GET', 'POST']);
}
}, {
// capabilities that require specific mode
return_response_headers: function(value) {
return value ? 'client' : 'browser';
},
return_status_code: function(code) {
return Basic.arrayDiff(code, [200, 404]) ? 'client' : ['client', 'browser'];
},
send_browser_cookies: function(value) {
return value ? 'browser' : 'client';
},
send_custom_headers: function(value) {
return value ? 'client' : 'browser';
},
use_http_method: function(methods) {
return Basic.arrayDiff(methods, ['GET', 'POST']) ? 'client' : ['client', 'browser'];
}
});
// minimal requirement
if (!isInstalled('2.0.31005.0') || Env.browser === 'Opera') {
this.mode = false;
}
Basic.extend(this, {
getShim: function() {
return Dom.get(this.uid).content.Moxie;
},
shimExec: function(component, action) {
var args = [].slice.call(arguments, 2);
return I.getShim().exec(this.uid, component, action, args);
},
init : function() {
var container;
container = this.getShimContainer();
container.innerHTML = '<object id="' + this.uid + '" data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%" style="outline:none;">' +
'<param name="source" value="' + options.xap_url + '"/>' +
'<param name="background" value="Transparent"/>' +
'<param name="windowless" value="true"/>' +
'<param name="enablehtmlaccess" value="true"/>' +
'<param name="initParams" value="uid=' + this.uid + ',target=' + Env.global_event_dispatcher + '"/>' +
'</object>';
// Init is dispatched by the shim
initTimer = setTimeout(function() {
if (I && !I.initialized) { // runtime might be already destroyed by this moment
I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR));
}
}, Env.OS !== 'Windows'? 10000 : 5000); // give it more time to initialize in non Windows OS (like Mac)
},
destroy: (function(destroy) { // extend default destroy method
return function() {
destroy.call(I);
clearTimeout(initTimer); // initialization check might be still onwait
options = initTimer = destroy = I = null;
};
}(this.destroy))
}, extensions);
}
Runtime.addConstructor(type, SilverlightRuntime);
return extensions;
});
// Included from: src/javascript/runtime/silverlight/file/Blob.js
/**
* Blob.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/file/Blob
@private
*/
define("moxie/runtime/silverlight/file/Blob", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/file/Blob"
], function(extensions, Basic, Blob) {
return (extensions.Blob = Basic.extend({}, Blob));
});
// Included from: src/javascript/runtime/silverlight/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/file/FileInput
@private
*/
define("moxie/runtime/silverlight/file/FileInput", [
"moxie/runtime/silverlight/Runtime"
], function(extensions) {
var FileInput = {
init: function(options) {
function toFilters(accept) {
var filter = '';
for (var i = 0; i < accept.length; i++) {
filter += (filter !== '' ? '|' : '') + accept[i].title + " | *." + accept[i].extensions.replace(/,/g, ';*.');
}
return filter;
}
this.getRuntime().shimExec.call(this, 'FileInput', 'init', toFilters(options.accept), options.name, options.multiple);
this.trigger('ready');
}
};
return (extensions.FileInput = FileInput);
});
// Included from: src/javascript/runtime/silverlight/file/FileDrop.js
/**
* FileDrop.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/file/FileDrop
@private
*/
define("moxie/runtime/silverlight/file/FileDrop", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Dom",
"moxie/core/utils/Events"
], function(extensions, Dom, Events) {
// not exactly useful, since works only in safari (...crickets...)
var FileDrop = {
init: function() {
var comp = this, self = comp.getRuntime(), dropZone;
dropZone = self.getShimContainer();
Events.addEvent(dropZone, 'dragover', function(e) {
e.preventDefault();
e.stopPropagation();
e.dataTransfer.dropEffect = 'copy';
}, comp.uid);
Events.addEvent(dropZone, 'dragenter', function(e) {
e.preventDefault();
var flag = Dom.get(self.uid).dragEnter(e);
// If handled, then stop propagation of event in DOM
if (flag) {
e.stopPropagation();
}
}, comp.uid);
Events.addEvent(dropZone, 'drop', function(e) {
e.preventDefault();
var flag = Dom.get(self.uid).dragDrop(e);
// If handled, then stop propagation of event in DOM
if (flag) {
e.stopPropagation();
}
}, comp.uid);
return self.shimExec.call(this, 'FileDrop', 'init');
}
};
return (extensions.FileDrop = FileDrop);
});
// Included from: src/javascript/runtime/silverlight/file/FileReader.js
/**
* FileReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/file/FileReader
@private
*/
define("moxie/runtime/silverlight/file/FileReader", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/file/FileReader"
], function(extensions, Basic, FileReader) {
return (extensions.FileReader = Basic.extend({}, FileReader));
});
// Included from: src/javascript/runtime/silverlight/file/FileReaderSync.js
/**
* FileReaderSync.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/file/FileReaderSync
@private
*/
define("moxie/runtime/silverlight/file/FileReaderSync", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/file/FileReaderSync"
], function(extensions, Basic, FileReaderSync) {
return (extensions.FileReaderSync = Basic.extend({}, FileReaderSync));
});
// Included from: src/javascript/runtime/silverlight/xhr/XMLHttpRequest.js
/**
* XMLHttpRequest.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/xhr/XMLHttpRequest
@private
*/
define("moxie/runtime/silverlight/xhr/XMLHttpRequest", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/xhr/XMLHttpRequest"
], function(extensions, Basic, XMLHttpRequest) {
return (extensions.XMLHttpRequest = Basic.extend({}, XMLHttpRequest));
});
// Included from: src/javascript/runtime/silverlight/runtime/Transporter.js
/**
* Transporter.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/runtime/Transporter
@private
*/
define("moxie/runtime/silverlight/runtime/Transporter", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/runtime/Transporter"
], function(extensions, Basic, Transporter) {
return (extensions.Transporter = Basic.extend({}, Transporter));
});
// Included from: src/javascript/runtime/silverlight/image/Image.js
/**
* Image.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/silverlight/image/Image
@private
*/
define("moxie/runtime/silverlight/image/Image", [
"moxie/runtime/silverlight/Runtime",
"moxie/core/utils/Basic",
"moxie/runtime/flash/image/Image"
], function(extensions, Basic, Image) {
return (extensions.Image = Basic.extend({}, Image, {
getInfo: function() {
var self = this.getRuntime()
, grps = ['tiff', 'exif', 'gps']
, info = { meta: {} }
, rawInfo = self.shimExec.call(this, 'Image', 'getInfo')
;
if (rawInfo.meta) {
Basic.each(grps, function(grp) {
var meta = rawInfo.meta[grp]
, tag
, i
, length
, value
;
if (meta && meta.keys) {
info.meta[grp] = {};
for (i = 0, length = meta.keys.length; i < length; i++) {
tag = meta.keys[i];
value = meta[tag];
if (value) {
// convert numbers
if (/^(\d|[1-9]\d+)$/.test(value)) { // integer (make sure doesn't start with zero)
value = parseInt(value, 10);
} else if (/^\d*\.\d+$/.test(value)) { // double
value = parseFloat(value);
}
info.meta[grp][tag] = value;
}
}
}
});
}
info.width = parseInt(rawInfo.width, 10);
info.height = parseInt(rawInfo.height, 10);
info.size = parseInt(rawInfo.size, 10);
info.type = rawInfo.type;
info.name = rawInfo.name;
return info;
}
}));
});
// Included from: src/javascript/runtime/html4/Runtime.js
/**
* Runtime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global File:true */
/**
Defines constructor for HTML4 runtime.
@class moxie/runtime/html4/Runtime
@private
*/
define("moxie/runtime/html4/Runtime", [
"moxie/core/utils/Basic",
"moxie/core/Exceptions",
"moxie/runtime/Runtime",
"moxie/core/utils/Env"
], function(Basic, x, Runtime, Env) {
var type = 'html4', extensions = {};
function Html4Runtime(options) {
var I = this
, Test = Runtime.capTest
, True = Runtime.capTrue
;
Runtime.call(this, options, type, {
access_binary: Test(window.FileReader || window.File && File.getAsDataURL),
access_image_binary: false,
display_media: Test(extensions.Image && (Env.can('create_canvas') || Env.can('use_data_uri_over32kb'))),
do_cors: false,
drag_and_drop: false,
filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest
return (Env.browser === 'Chrome' && Env.version >= 28) || (Env.browser === 'IE' && Env.version >= 10);
}()),
resize_image: function() {
return extensions.Image && I.can('access_binary') && Env.can('create_canvas');
},
report_upload_progress: false,
return_response_headers: false,
return_response_type: function(responseType) {
if (responseType === 'json' && !!window.JSON) {
return true;
}
return !!~Basic.inArray(responseType, ['text', 'document', '']);
},
return_status_code: function(code) {
return !Basic.arrayDiff(code, [200, 404]);
},
select_file: function() {
return Env.can('use_fileinput');
},
select_multiple: false,
send_binary_string: false,
send_custom_headers: false,
send_multipart: true,
slice_blob: false,
stream_upload: function() {
return I.can('select_file');
},
summon_file_dialog: Test(function() { // yeah... some dirty sniffing here...
return (Env.browser === 'Firefox' && Env.version >= 4) ||
(Env.browser === 'Opera' && Env.version >= 12) ||
!!~Basic.inArray(Env.browser, ['Chrome', 'Safari']);
}()),
upload_filesize: True,
use_http_method: function(methods) {
return !Basic.arrayDiff(methods, ['GET', 'POST']);
}
});
Basic.extend(this, {
init : function() {
this.trigger("Init");
},
destroy: (function(destroy) { // extend default destroy method
return function() {
destroy.call(I);
destroy = I = null;
};
}(this.destroy))
});
Basic.extend(this.getShim(), extensions);
}
Runtime.addConstructor(type, Html4Runtime);
return extensions;
});
// Included from: src/javascript/runtime/html4/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html4/file/FileInput
@private
*/
define("moxie/runtime/html4/file/FileInput", [
"moxie/runtime/html4/Runtime",
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/utils/Events",
"moxie/core/utils/Mime",
"moxie/core/utils/Env"
], function(extensions, Basic, Dom, Events, Mime, Env) {
function FileInput() {
var _uid, _files = [], _mimes = [], _options;
function addInput() {
var comp = this, I = comp.getRuntime(), shimContainer, browseButton, currForm, form, input, uid;
uid = Basic.guid('uid_');
shimContainer = I.getShimContainer(); // we get new ref everytime to avoid memory leaks in IE
if (_uid) { // move previous form out of the view
currForm = Dom.get(_uid + '_form');
if (currForm) {
Basic.extend(currForm.style, { top: '100%' });
}
}
// build form in DOM, since innerHTML version not able to submit file for some reason
form = document.createElement('form');
form.setAttribute('id', uid + '_form');
form.setAttribute('method', 'post');
form.setAttribute('enctype', 'multipart/form-data');
form.setAttribute('encoding', 'multipart/form-data');
Basic.extend(form.style, {
overflow: 'hidden',
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%'
});
input = document.createElement('input');
input.setAttribute('id', uid);
input.setAttribute('type', 'file');
input.setAttribute('name', _options.name || 'Filedata');
input.setAttribute('accept', _mimes.join(','));
Basic.extend(input.style, {
fontSize: '999px',
opacity: 0
});
form.appendChild(input);
shimContainer.appendChild(form);
// prepare file input to be placed underneath the browse_button element
Basic.extend(input.style, {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%'
});
if (Env.browser === 'IE' && Env.version < 10) {
Basic.extend(input.style, {
filter : "progid:DXImageTransform.Microsoft.Alpha(opacity=0)"
});
}
input.onchange = function() { // there should be only one handler for this
var file;
if (!this.value) {
return;
}
if (this.files) {
file = this.files[0];
} else {
file = {
name: this.value
};
}
_files = [file];
this.onchange = function() {}; // clear event handler
addInput.call(comp);
// after file is initialized as o.File, we need to update form and input ids
comp.bind('change', function onChange() {
var input = Dom.get(uid), form = Dom.get(uid + '_form'), file;
comp.unbind('change', onChange);
if (comp.files.length && input && form) {
file = comp.files[0];
input.setAttribute('id', file.uid);
form.setAttribute('id', file.uid + '_form');
// set upload target
form.setAttribute('target', file.uid + '_iframe');
}
input = form = null;
}, 998);
input = form = null;
comp.trigger('change');
};
// route click event to the input
if (I.can('summon_file_dialog')) {
browseButton = Dom.get(_options.browse_button);
Events.removeEvent(browseButton, 'click', comp.uid);
Events.addEvent(browseButton, 'click', function(e) {
if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file]
input.click();
}
e.preventDefault();
}, comp.uid);
}
_uid = uid;
shimContainer = currForm = browseButton = null;
}
Basic.extend(this, {
init: function(options) {
var comp = this, I = comp.getRuntime(), shimContainer;
// figure out accept string
_options = options;
_mimes = options.accept.mimes || Mime.extList2mimes(options.accept, I.can('filter_by_extension'));
shimContainer = I.getShimContainer();
(function() {
var browseButton, zIndex, top;
browseButton = Dom.get(options.browse_button);
// Route click event to the input[type=file] element for browsers that support such behavior
if (I.can('summon_file_dialog')) {
if (Dom.getStyle(browseButton, 'position') === 'static') {
browseButton.style.position = 'relative';
}
zIndex = parseInt(Dom.getStyle(browseButton, 'z-index'), 10) || 1;
browseButton.style.zIndex = zIndex;
shimContainer.style.zIndex = zIndex - 1;
}
/* Since we have to place input[type=file] on top of the browse_button for some browsers,
browse_button loses interactivity, so we restore it here */
top = I.can('summon_file_dialog') ? browseButton : shimContainer;
Events.addEvent(top, 'mouseover', function() {
comp.trigger('mouseenter');
}, comp.uid);
Events.addEvent(top, 'mouseout', function() {
comp.trigger('mouseleave');
}, comp.uid);
Events.addEvent(top, 'mousedown', function() {
comp.trigger('mousedown');
}, comp.uid);
Events.addEvent(Dom.get(options.container), 'mouseup', function() {
comp.trigger('mouseup');
}, comp.uid);
browseButton = null;
}());
addInput.call(this);
shimContainer = null;
// trigger ready event asynchronously
comp.trigger({
type: 'ready',
async: true
});
},
getFiles: function() {
return _files;
},
disable: function(state) {
var input;
if ((input = Dom.get(_uid))) {
input.disabled = !!state;
}
},
destroy: function() {
var I = this.getRuntime()
, shim = I.getShim()
, shimContainer = I.getShimContainer()
;
Events.removeAllEvents(shimContainer, this.uid);
Events.removeAllEvents(_options && Dom.get(_options.container), this.uid);
Events.removeAllEvents(_options && Dom.get(_options.browse_button), this.uid);
if (shimContainer) {
shimContainer.innerHTML = '';
}
shim.removeInstance(this.uid);
_uid = _files = _mimes = _options = shimContainer = shim = null;
}
});
}
return (extensions.FileInput = FileInput);
});
// Included from: src/javascript/runtime/html4/file/FileReader.js
/**
* FileReader.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html4/file/FileReader
@private
*/
define("moxie/runtime/html4/file/FileReader", [
"moxie/runtime/html4/Runtime",
"moxie/runtime/html5/file/FileReader"
], function(extensions, FileReader) {
return (extensions.FileReader = FileReader);
});
// Included from: src/javascript/runtime/html4/xhr/XMLHttpRequest.js
/**
* XMLHttpRequest.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html4/xhr/XMLHttpRequest
@private
*/
define("moxie/runtime/html4/xhr/XMLHttpRequest", [
"moxie/runtime/html4/Runtime",
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/utils/Url",
"moxie/core/Exceptions",
"moxie/core/utils/Events",
"moxie/file/Blob",
"moxie/xhr/FormData"
], function(extensions, Basic, Dom, Url, x, Events, Blob, FormData) {
function XMLHttpRequest() {
var _status, _response, _iframe;
function cleanup(cb) {
var target = this, uid, form, inputs, i, hasFile = false;
if (!_iframe) {
return;
}
uid = _iframe.id.replace(/_iframe$/, '');
form = Dom.get(uid + '_form');
if (form) {
inputs = form.getElementsByTagName('input');
i = inputs.length;
while (i--) {
switch (inputs[i].getAttribute('type')) {
case 'hidden':
inputs[i].parentNode.removeChild(inputs[i]);
break;
case 'file':
hasFile = true; // flag the case for later
break;
}
}
inputs = [];
if (!hasFile) { // we need to keep the form for sake of possible retries
form.parentNode.removeChild(form);
}
form = null;
}
// without timeout, request is marked as canceled (in console)
setTimeout(function() {
Events.removeEvent(_iframe, 'load', target.uid);
if (_iframe.parentNode) { // #382
_iframe.parentNode.removeChild(_iframe);
}
// check if shim container has any other children, if - not, remove it as well
var shimContainer = target.getRuntime().getShimContainer();
if (!shimContainer.children.length) {
shimContainer.parentNode.removeChild(shimContainer);
}
shimContainer = _iframe = null;
cb();
}, 1);
}
Basic.extend(this, {
send: function(meta, data) {
var target = this, I = target.getRuntime(), uid, form, input, blob;
_status = _response = null;
function createIframe() {
var container = I.getShimContainer() || document.body
, temp = document.createElement('div')
;
// IE 6 won't be able to set the name using setAttribute or iframe.name
temp.innerHTML = '<iframe id="' + uid + '_iframe" name="' + uid + '_iframe" src="javascript:&quot;&quot;" style="display:none"></iframe>';
_iframe = temp.firstChild;
container.appendChild(_iframe);
/* _iframe.onreadystatechange = function() {
console.info(_iframe.readyState);
};*/
Events.addEvent(_iframe, 'load', function() { // _iframe.onload doesn't work in IE lte 8
var el;
try {
el = _iframe.contentWindow.document || _iframe.contentDocument || window.frames[_iframe.id].document;
// try to detect some standard error pages
if (/^4(0[0-9]|1[0-7]|2[2346])\s/.test(el.title)) { // test if title starts with 4xx HTTP error
_status = el.title.replace(/^(\d+).*$/, '$1');
} else {
_status = 200;
// get result
_response = Basic.trim(el.body.innerHTML);
// we need to fire these at least once
target.trigger({
type: 'progress',
loaded: _response.length,
total: _response.length
});
if (blob) { // if we were uploading a file
target.trigger({
type: 'uploadprogress',
loaded: blob.size || 1025,
total: blob.size || 1025
});
}
}
} catch (ex) {
if (Url.hasSameOrigin(meta.url)) {
// if response is sent with error code, iframe in IE gets redirected to res://ieframe.dll/http_x.htm
// which obviously results to cross domain error (wtf?)
_status = 404;
} else {
cleanup.call(target, function() {
target.trigger('error');
});
return;
}
}
cleanup.call(target, function() {
target.trigger('load');
});
}, target.uid);
} // end createIframe
// prepare data to be sent and convert if required
if (data instanceof FormData && data.hasBlob()) {
blob = data.getBlob();
uid = blob.uid;
input = Dom.get(uid);
form = Dom.get(uid + '_form');
if (!form) {
throw new x.DOMException(x.DOMException.NOT_FOUND_ERR);
}
} else {
uid = Basic.guid('uid_');
form = document.createElement('form');
form.setAttribute('id', uid + '_form');
form.setAttribute('method', meta.method);
form.setAttribute('enctype', 'multipart/form-data');
form.setAttribute('encoding', 'multipart/form-data');
form.setAttribute('target', uid + '_iframe');
I.getShimContainer().appendChild(form);
}
if (data instanceof FormData) {
data.each(function(value, name) {
if (value instanceof Blob) {
if (input) {
input.setAttribute('name', name);
}
} else {
var hidden = document.createElement('input');
Basic.extend(hidden, {
type : 'hidden',
name : name,
value : value
});
// make sure that input[type="file"], if it's there, comes last
if (input) {
form.insertBefore(hidden, input);
} else {
form.appendChild(hidden);
}
}
});
}
// set destination url
form.setAttribute("action", meta.url);
createIframe();
form.submit();
target.trigger('loadstart');
},
getStatus: function() {
return _status;
},
getResponse: function(responseType) {
if ('json' === responseType) {
// strip off <pre>..</pre> tags that might be enclosing the response
if (Basic.typeOf(_response) === 'string' && !!window.JSON) {
try {
return JSON.parse(_response.replace(/^\s*<pre[^>]*>/, '').replace(/<\/pre>\s*$/, ''));
} catch (ex) {
return null;
}
}
} else if ('document' === responseType) {
}
return _response;
},
abort: function() {
var target = this;
if (_iframe && _iframe.contentWindow) {
if (_iframe.contentWindow.stop) { // FireFox/Safari/Chrome
_iframe.contentWindow.stop();
} else if (_iframe.contentWindow.document.execCommand) { // IE
_iframe.contentWindow.document.execCommand('Stop');
} else {
_iframe.src = "about:blank";
}
}
cleanup.call(this, function() {
// target.dispatchEvent('readystatechange');
target.dispatchEvent('abort');
});
}
});
}
return (extensions.XMLHttpRequest = XMLHttpRequest);
});
// Included from: src/javascript/runtime/html4/image/Image.js
/**
* Image.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/**
@class moxie/runtime/html4/image/Image
@private
*/
define("moxie/runtime/html4/image/Image", [
"moxie/runtime/html4/Runtime",
"moxie/runtime/html5/image/Image"
], function(extensions, Image) {
return (extensions.Image = Image);
});
expose(["moxie/core/utils/Basic","moxie/core/I18n","moxie/core/utils/Mime","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/utils/Encode","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/file/File","moxie/file/FileInput","moxie/file/FileDrop","moxie/runtime/RuntimeTarget","moxie/file/FileReader","moxie/core/utils/Url","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/runtime/Transporter","moxie/image/Image","moxie/core/utils/Events"]);
})(this);/**
* o.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
/*global moxie:true */
/**
Globally exposed namespace with the most frequently used public classes and handy methods.
@class o
@static
@private
*/
(function() {
"use strict";
var o = {}, inArray = moxie.core.utils.Basic.inArray;
// directly add some public classes
// (we do it dynamically here, since for custom builds we cannot know beforehand what modules were included)
(function addAlias(ns) {
var name, itemType;
for (name in ns) {
itemType = typeof(ns[name]);
if (itemType === 'object' && !~inArray(name, ['Exceptions', 'Env', 'Mime'])) {
addAlias(ns[name]);
} else if (itemType === 'function') {
o[name] = ns[name];
}
}
})(window.moxie);
// add some manually
o.Env = window.moxie.core.utils.Env;
o.Mime = window.moxie.core.utils.Mime;
o.Exceptions = window.moxie.core.Exceptions;
// expose globally
window.mOxie = o;
if (!window.o) {
window.o = o;
}
return o;
})();
Location: http://az632987.vo.msecnd.net/cdnfiles/js/libs/IndexedDBShim-0.1.2.min.js
Referrer: http://www.ninjamock.com/
Content-Type: text/javascript
/*! IndexedDBShim - v0.1.2 - 2014-06-14 */
"use strict";var idbModules={},cleanInterface=!1;(function(){var e={test:!0};if(Object.defineProperty)try{Object.defineProperty(e,"test",{enumerable:!1}),e.test&&(cleanInterface=!0)}catch(t){}})(),function(e){function t(e,t,n,o){n.target=t,"function"==typeof t[e]&&t[e].apply(t,[n]),"function"==typeof o&&o()}function n(t,n,o){var r=new DOMException.prototype.constructor(0,n);throw r.name=t,r.message=n,e.DEBUG&&(console.log(t,n,o,r),console.trace&&console.trace()),r}var o=function(){this.length=0,this._items=[],cleanInterface&&Object.defineProperty(this,"_items",{enumerable:!1})};if(o.prototype={contains:function(e){return-1!==this._items.indexOf(e)},item:function(e){return this._items[e]},indexOf:function(e){return this._items.indexOf(e)},push:function(e){this._items.push(e),this.length+=1;for(var t=0;this._items.length>t;t++)this[t]=this._items[t]},splice:function(){this._items.splice.apply(this._items,arguments),this.length=this._items.length;for(var e in this)e===parseInt(e,10)+""&&delete this[e];for(e=0;this._items.length>e;e++)this[e]=this._items[e]}},cleanInterface)for(var r in{indexOf:!1,push:!1,splice:!1})Object.defineProperty(o.prototype,r,{enumerable:!1});e.util={throwDOMException:n,callback:t,quote:function(e){return"'"+e+"'"},StringList:o}}(idbModules),function(idbModules){var Sca=function(){return{decycle:function(object,callback){function checkForCompletion(){0===queuedObjects.length&&returnCallback(derezObj)}function readBlobAsDataURL(e,t){var n=new FileReader;n.onloadend=function(e){var n=e.target.result,o="blob";updateEncodedBlob(n,t,o)},n.readAsDataURL(e)}function updateEncodedBlob(dataURL,path,blobtype){var encoded=queuedObjects.indexOf(path);path=path.replace("$","derezObj"),eval(path+'.$enc="'+dataURL+'"'),eval(path+'.$type="'+blobtype+'"'),queuedObjects.splice(encoded,1),checkForCompletion()}function derez(e,t){var n,o,r;if(!("object"!=typeof e||null===e||e instanceof Boolean||e instanceof Date||e instanceof Number||e instanceof RegExp||e instanceof Blob||e instanceof String)){for(n=0;objects.length>n;n+=1)if(objects[n]===e)return{$ref:paths[n]};if(objects.push(e),paths.push(t),"[object Array]"===Object.prototype.toString.apply(e))for(r=[],n=0;e.length>n;n+=1)r[n]=derez(e[n],t+"["+n+"]");else{r={};for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=derez(e[o],t+"["+JSON.stringify(o)+"]"))}return r}return e instanceof Blob?(queuedObjects.push(t),readBlobAsDataURL(e,t)):e instanceof Boolean?e={$type:"bool",$enc:""+e}:e instanceof Date?e={$type:"date",$enc:e.getTime()}:e instanceof Number?e={$type:"num",$enc:""+e}:e instanceof RegExp&&(e={$type:"regex",$enc:""+e}),e}var objects=[],paths=[],queuedObjects=[],returnCallback=callback,derezObj=derez(object,"$");checkForCompletion()},retrocycle:function retrocycle($){function dataURLToBlob(e){var t,n,o,r=";base64,";if(-1===e.indexOf(r))return n=e.split(","),t=n[0].split(":")[1],o=n[1],new Blob([o],{type:t});n=e.split(r),t=n[0].split(":")[1],o=window.atob(n[1]);for(var i=o.length,a=new Uint8Array(i),s=0;i>s;++s)a[s]=o.charCodeAt(s);return new Blob([a.buffer],{type:t})}function rez(value){var i,item,name,path;if(value&&"object"==typeof value)if("[object Array]"===Object.prototype.toString.apply(value))for(i=0;value.length>i;i+=1)item=value[i],item&&"object"==typeof item&&(path=item.$ref,value[i]="string"==typeof path&&px.test(path)?eval(path):rez(item));else if(void 0!==value.$type)switch(value.$type){case"blob":case"file":value=dataURLToBlob(value.$enc);break;case"bool":value=Boolean("true"===value.$enc);break;case"date":value=new Date(value.$enc);break;case"num":value=Number(value.$enc);break;case"regex":value=eval(value.$enc)}else for(name in value)"object"==typeof value[name]&&(item=value[name],item&&(path=item.$ref,value[name]="string"==typeof path&&px.test(path)?eval(path):rez(item)));return value}var px=/^\$(?:\[(?:\d+|\"(?:[^\\\"\u0000-\u001f]|\\([\\\"\/bfnrt]|u[0-9a-zA-Z]{4}))*\")\])*$/;return rez($),$},encode:function(e,t){function n(e){t(JSON.stringify(e))}this.decycle(e,n)},decode:function(e){return this.retrocycle(JSON.parse(e))}}}();idbModules.Sca=Sca}(idbModules),function(e){var t=["","number","string","boolean","object","undefined"],n=function(){return{encode:function(e){return t.indexOf(typeof e)+"-"+JSON.stringify(e)},decode:function(e){return e===void 0?void 0:JSON.parse(e.substring(2))}}},o={number:n("number"),"boolean":n(),object:n(),string:{encode:function(e){return t.indexOf("string")+"-"+e},decode:function(e){return""+e.substring(2)}},undefined:{encode:function(){return t.indexOf("undefined")+"-undefined"},decode:function(){return void 0}}},r=function(){return{encode:function(e){return o[typeof e].encode(e)},decode:function(e){return o[t[e.substring(0,1)]].decode(e)}}}();e.Key=r}(idbModules),function(e){var t=function(e,t){return{type:e,debug:t,bubbles:!1,cancelable:!1,eventPhase:0,timeStamp:new Date}};e.Event=t}(idbModules),function(e){var t=function(){this.onsuccess=this.onerror=this.result=this.error=this.source=this.transaction=null,this.readyState="pending"},n=function(){this.onblocked=this.onupgradeneeded=null};n.prototype=t,e.IDBRequest=t,e.IDBOpenRequest=n}(idbModules),function(e,t){var n=function(e,t,n,o){this.lower=e,this.upper=t,this.lowerOpen=n,this.upperOpen=o};n.only=function(e){return new n(e,e,!1,!1)},n.lowerBound=function(e,o){return new n(e,t,o,t)},n.upperBound=function(e){return new n(t,e,t,open)},n.bound=function(e,t,o,r){return new n(e,t,o,r)},e.IDBKeyRange=n}(idbModules),function(e,t){function n(n,o,r,i,a,s){this.__range=n,this.source=this.__idbObjectStore=r,this.__req=i,this.key=t,this.direction=o,this.__keyColumnName=a,this.__valueColumnName=s,this.__valueDecoder="value"===s?e.Sca:e.Key,this.source.transaction.__active||e.util.throwDOMException("TransactionInactiveError - The transaction this IDBObjectStore belongs to is not active."),this.__offset=-1,this.__lastKeyContinued=t,this["continue"]()}n.prototype.__find=function(n,o,r,i,a){a=a||1;var s=this,c=["SELECT * FROM ",e.util.quote(s.__idbObjectStore.name)],u=[];c.push("WHERE ",s.__keyColumnName," NOT NULL"),s.__range&&(s.__range.lower||s.__range.upper)&&(c.push("AND"),s.__range.lower&&(c.push(s.__keyColumnName+(s.__range.lowerOpen?" >":" >= ")+" ?"),u.push(e.Key.encode(s.__range.lower))),s.__range.lower&&s.__range.upper&&c.push("AND"),s.__range.upper&&(c.push(s.__keyColumnName+(s.__range.upperOpen?" < ":" <= ")+" ?"),u.push(e.Key.encode(s.__range.upper)))),n!==t&&(s.__lastKeyContinued=n,s.__offset=0),s.__lastKeyContinued!==t&&(c.push("AND "+s.__keyColumnName+" >= ?"),u.push(e.Key.encode(s.__lastKeyContinued))),c.push("ORDER BY ",s.__keyColumnName),c.push("LIMIT "+a+" OFFSET "+s.__offset),e.DEBUG&&console.log(c.join(" "),u),s.__prefetchedData=null,o.executeSql(c.join(" "),u,function(n,o){o.rows.length>1?(s.__prefetchedData=o.rows,s.__prefetchedIndex=0,e.DEBUG&&console.log("Preloaded "+s.__prefetchedData.length+" records for cursor"),s.__decode(o.rows.item(0),r)):1===o.rows.length?s.__decode(o.rows.item(0),r):(e.DEBUG&&console.log("Reached end of cursors"),r(t,t))},function(t,n){e.DEBUG&&console.log("Could not execute Cursor.continue"),i(n)})},n.prototype.__decode=function(t,n){var o=e.Key.decode(t[this.__keyColumnName]),r=this.__valueDecoder.decode(t[this.__valueColumnName]),i=e.Key.decode(t.key);n(o,r,i)},n.prototype["continue"]=function(n){var o=e.cursorPreloadPackSize||100,r=this;this.__idbObjectStore.transaction.__addToTransactionQueue(function(e,i,a,s){r.__offset++;var c=function(e,n,o){r.key=e,r.value=n,r.primaryKey=o,a(r.key!==t?r:t,r.__req)};return r.__prefetchedData&&(r.__prefetchedIndex++,r.__prefetchedIndex<r.__prefetchedData.length)?(r.__decode(r.__prefetchedData.item(r.__prefetchedIndex),c),t):(r.__find(n,e,c,s,o),t)})},n.prototype.advance=function(n){0>=n&&e.util.throwDOMException("Type Error - Count is invalid - 0 or negative",n);var o=this;this.__idbObjectStore.transaction.__addToTransactionQueue(function(e,r,i,a){o.__offset+=n,o.__find(t,e,function(e,n){o.key=e,o.value=n,i(o.key!==t?o:t,o.__req)},a)})},n.prototype.update=function(n){var o=this,r=this.__idbObjectStore.transaction.__createRequest(function(){});return e.Sca.encode(n,function(n){o.__idbObjectStore.transaction.__pushToQueue(r,function(r,i,a,s){o.__find(t,r,function(t,i,c){var u="UPDATE "+e.util.quote(o.__idbObjectStore.name)+" SET value = ? WHERE key = ?";e.DEBUG&&console.log(u,n,t,c),r.executeSql(u,[n,e.Key.encode(c)],function(e,n){1===n.rowsAffected?a(t):s("No rows with key found"+t)},function(e,t){s(t)})},s)})}),r},n.prototype["delete"]=function(){var n=this;return this.__idbObjectStore.transaction.__addToTransactionQueue(function(o,r,i,a){n.__find(t,o,function(r,s,c){var u="DELETE FROM "+e.util.quote(n.__idbObjectStore.name)+" WHERE key = ?";e.DEBUG&&console.log(u,r,c),o.executeSql(u,[e.Key.encode(c)],function(e,o){1===o.rowsAffected?(n.__offset--,i(t)):a("No rows with key found"+r)},function(e,t){a(t)})},a)})},e.IDBCursor=n}(idbModules),function(idbModules,undefined){function IDBIndex(e,t){this.indexName=this.name=e,this.__idbObjectStore=this.objectStore=this.source=t;var n=t.__storeProps&&t.__storeProps.indexList;n&&(n=JSON.parse(n)),this.keyPath=n&&n[e]&&n[e].keyPath||e,["multiEntry","unique"].forEach(function(t){this[t]=!!(n&&n[e]&&n[e].optionalParams&&n[e].optionalParams[t])},this)}IDBIndex.prototype.__createIndex=function(indexName,keyPath,optionalParameters){var me=this,transaction=me.__idbObjectStore.transaction;transaction.__addToTransactionQueue(function(tx,args,success,failure){me.__idbObjectStore.__getStoreProps(tx,function(){function error(){idbModules.util.throwDOMException(0,"Could not create new index",arguments)}2!==transaction.mode&&idbModules.util.throwDOMException(0,"Invalid State error, not a version transaction",me.transaction);var idxList=JSON.parse(me.__idbObjectStore.__storeProps.indexList);idxList[indexName]!==undefined&&idbModules.util.throwDOMException(0,"Index already exists on store",idxList);var columnName=indexName;idxList[indexName]={columnName:columnName,keyPath:keyPath,optionalParams:optionalParameters},me.__idbObjectStore.__storeProps.indexList=JSON.stringify(idxList);var sql=["ALTER TABLE",idbModules.util.quote(me.__idbObjectStore.name),"ADD",columnName,"BLOB"].join(" ");idbModules.DEBUG&&console.log(sql),tx.executeSql(sql,[],function(tx,data){tx.executeSql("SELECT * FROM "+idbModules.util.quote(me.__idbObjectStore.name),[],function(tx,data){(function initIndexForRow(i){if(data.rows.length>i)try{var value=idbModules.Sca.decode(data.rows.item(i).value),indexKey=eval("value['"+keyPath+"']");tx.executeSql("UPDATE "+idbModules.util.quote(me.__idbObjectStore.name)+" set "+columnName+" = ? where key = ?",[idbModules.Key.encode(indexKey),data.rows.item(i).key],function(){initIndexForRow(i+1)},error)}catch(e){initIndexForRow(i+1)}else idbModules.DEBUG&&console.log("Updating the indexes in table",me.__idbObjectStore.__storeProps),tx.executeSql("UPDATE __sys__ set indexList = ? where name = ?",[me.__idbObjectStore.__storeProps.indexList,me.__idbObjectStore.name],function(){me.__idbObjectStore.__setReadyState("createIndex",!0),success(me)},error)})(0)},error)},error)},"createObjectStore")})},IDBIndex.prototype.openCursor=function(e,t){var n=new idbModules.IDBRequest;return new idbModules.IDBCursor(e,t,this.source,n,this.indexName,"value"),n},IDBIndex.prototype.openKeyCursor=function(e,t){var n=new idbModules.IDBRequest;return new idbModules.IDBCursor(e,t,this.source,n,this.indexName,"key"),n},IDBIndex.prototype.__fetchIndexData=function(e,t){var n=this;return n.__idbObjectStore.transaction.__addToTransactionQueue(function(o,r,i,a){var s=["SELECT * FROM ",idbModules.util.quote(n.__idbObjectStore.name)," WHERE",n.indexName,"NOT NULL"],c=[];e!==undefined&&(s.push("AND",n.indexName," = ?"),c.push(idbModules.Key.encode(e))),idbModules.DEBUG&&console.log("Trying to fetch data for Index",s.join(" "),c),o.executeSql(s.join(" "),c,function(e,n){var o;o="count"===t?n.rows.length:0===n.rows.length?undefined:"key"===t?idbModules.Key.decode(n.rows.item(0).key):idbModules.Sca.decode(n.rows.item(0).value),i(o)},a)})},IDBIndex.prototype.get=function(e){return this.__fetchIndexData(e,"value")},IDBIndex.prototype.getKey=function(e){return this.__fetchIndexData(e,"key")},IDBIndex.prototype.count=function(e){return this.__fetchIndexData(e,"count")},idbModules.IDBIndex=IDBIndex}(idbModules),function(idbModules){var IDBObjectStore=function(e,t,n){this.name=e,this.transaction=t,this.__ready={},this.__setReadyState("createObjectStore",n===void 0?!0:n),this.indexNames=new idbModules.util.StringList};IDBObjectStore.prototype.__setReadyState=function(e,t){this.__ready[e]=t},IDBObjectStore.prototype.__waitForReady=function(e,t){var n=!0;if(t!==void 0)n=this.__ready[t]===void 0?!0:this.__ready[t];else for(var o in this.__ready)this.__ready[o]||(n=!1);if(n)e();else{idbModules.DEBUG&&console.log("Waiting for to be ready",t);var r=this;window.setTimeout(function(){r.__waitForReady(e,t)},100)}},IDBObjectStore.prototype.__getStoreProps=function(e,t,n){var o=this;this.__waitForReady(function(){o.__storeProps?(idbModules.DEBUG&&console.log("Store properties - cached",o.__storeProps),t(o.__storeProps)):e.executeSql("SELECT * FROM __sys__ where name = ?",[o.name],function(e,n){1!==n.rows.length?t():(o.__storeProps={name:n.rows.item(0).name,indexList:n.rows.item(0).indexList,autoInc:n.rows.item(0).autoInc,keyPath:n.rows.item(0).keyPath},idbModules.DEBUG&&console.log("Store properties",o.__storeProps),t(o.__storeProps))},function(){t()})},n)},IDBObjectStore.prototype.__deriveKey=function(tx,value,key,callback){function getNextAutoIncKey(){tx.executeSql("SELECT * FROM sqlite_sequence where name like ?",[me.name],function(e,t){1!==t.rows.length?callback(0):callback(t.rows.item(0).seq)},function(e,t){idbModules.util.throwDOMException(0,"Data Error - Could not get the auto increment value for key",t)})}var me=this;me.__getStoreProps(tx,function(props){if(props||idbModules.util.throwDOMException(0,"Data Error - Could not locate defination for this table",props),props.keyPath)if(key!==void 0&&idbModules.util.throwDOMException(0,"Data Error - The object store uses in-line keys and the key parameter was provided",props),value)try{var primaryKey=eval("value['"+props.keyPath+"']");primaryKey?callback(primaryKey):"true"===props.autoInc?getNextAutoIncKey():idbModules.util.throwDOMException(0,"Data Error - Could not eval key from keyPath")}catch(e){idbModules.util.throwDOMException(0,"Data Error - Could not eval key from keyPath",e)}else idbModules.util.throwDOMException(0,"Data Error - KeyPath was specified, but value was not");else key!==void 0?callback(key):"false"===props.autoInc?idbModules.util.throwDOMException(0,"Data Error - The object store uses out-of-line keys and has no key generator and the key parameter was not provided. ",props):getNextAutoIncKey()})},IDBObjectStore.prototype.__insertData=function(tx,encoded,value,primaryKey,success,error){var paramMap={};primaryKey!==void 0&&(paramMap.key=idbModules.Key.encode(primaryKey));var indexes=JSON.parse(this.__storeProps.indexList);for(var key in indexes)try{paramMap[indexes[key].columnName]=idbModules.Key.encode(eval("value['"+indexes[key].keyPath+"']"))}catch(e){error(e)}var sqlStart=["INSERT INTO ",idbModules.util.quote(this.name),"("],sqlEnd=[" VALUES ("],sqlValues=[];for(key in paramMap)sqlStart.push(key+","),sqlEnd.push("?,"),sqlValues.push(paramMap[key]);sqlStart.push("value )"),sqlEnd.push("?)"),sqlValues.push(encoded);var sql=sqlStart.join(" ")+sqlEnd.join(" ");idbModules.DEBUG&&console.log("SQL for adding",sql,sqlValues),tx.executeSql(sql,sqlValues,function(){success(primaryKey)},function(e,t){error(t)})},IDBObjectStore.prototype.add=function(e,t){var n=this,o=n.transaction.__createRequest(function(){});return idbModules.Sca.encode(e,function(r){n.transaction.__pushToQueue(o,function(o,i,a,s){n.__deriveKey(o,e,t,function(t){n.__insertData(o,r,e,t,a,s)})})}),o},IDBObjectStore.prototype.put=function(e,t){var n=this,o=n.transaction.__createRequest(function(){});return idbModules.Sca.encode(e,function(r){n.transaction.__pushToQueue(o,function(o,i,a,s){n.__deriveKey(o,e,t,function(t){var i="DELETE FROM "+idbModules.util.quote(n.name)+" where key = ?";o.executeSql(i,[idbModules.Key.encode(t)],function(o,i){idbModules.DEBUG&&console.log("Did the row with the",t,"exist? ",i.rowsAffected),n.__insertData(o,r,e,t,a,s)},function(e,t){s(t)})})})}),o},IDBObjectStore.prototype.get=function(e){var t=this;return t.transaction.__addToTransactionQueue(function(n,o,r,i){t.__waitForReady(function(){var o=idbModules.Key.encode(e);idbModules.DEBUG&&console.log("Fetching",t.name,o),n.executeSql("SELECT * FROM "+idbModules.util.quote(t.name)+" where key = ?",[o],function(e,t){idbModules.DEBUG&&console.log("Fetched data",t);try{if(0===t.rows.length)return r();r(idbModules.Sca.decode(t.rows.item(0).value))}catch(n){idbModules.DEBUG&&console.log(n),r(void 0)}},function(e,t){i(t)})})})},IDBObjectStore.prototype["delete"]=function(e){var t=this;return t.transaction.__addToTransactionQueue(function(n,o,r,i){t.__waitForReady(function(){var o=idbModules.Key.encode(e);idbModules.DEBUG&&console.log("Fetching",t.name,o),n.executeSql("DELETE FROM "+idbModules.util.quote(t.name)+" where key = ?",[o],function(e,t){idbModules.DEBUG&&console.log("Deleted from database",t.rowsAffected),r()},function(e,t){i(t)})})})},IDBObjectStore.prototype.clear=function(){var e=this;return e.transaction.__addToTransactionQueue(function(t,n,o,r){e.__waitForReady(function(){t.executeSql("DELETE FROM "+idbModules.util.quote(e.name),[],function(e,t){idbModules.DEBUG&&console.log("Cleared all records from database",t.rowsAffected),o()},function(e,t){r(t)})})})},IDBObjectStore.prototype.count=function(e){var t=this;return t.transaction.__addToTransactionQueue(function(n,o,r,i){t.__waitForReady(function(){var o="SELECT * FROM "+idbModules.util.quote(t.name)+(e!==void 0?" WHERE key = ?":""),a=[];e!==void 0&&a.push(idbModules.Key.encode(e)),n.executeSql(o,a,function(e,t){r(t.rows.length)},function(e,t){i(t)})})})},IDBObjectStore.prototype.openCursor=function(e,t){var n=new idbModules.IDBRequest;return new idbModules.IDBCursor(e,t,this,n,"key","value"),n},IDBObjectStore.prototype.index=function(e){var t=new idbModules.IDBIndex(e,this);return t},IDBObjectStore.prototype.createIndex=function(e,t,n){var o=this;n=n||{},o.__setReadyState("createIndex",!1);var r=new idbModules.IDBIndex(e,o);return o.__waitForReady(function(){r.__createIndex(e,t,n)},"createObjectStore"),o.indexNames.push(e),r},IDBObjectStore.prototype.deleteIndex=function(e){var t=new idbModules.IDBIndex(e,this,!1);return t.__deleteIndex(e),t},idbModules.IDBObjectStore=IDBObjectStore}(idbModules),function(e){var t=0,n=1,o=2,r=function(o,r,i){if("number"==typeof r)this.mode=r,2!==r&&e.DEBUG&&console.log("Mode should be a string, but was specified as ",r);else if("string"==typeof r)switch(r){case"readwrite":this.mode=n;break;case"readonly":this.mode=t;break;default:this.mode=t}this.storeNames="string"==typeof o?[o]:o;for(var a=0;this.storeNames.length>a;a++)i.objectStoreNames.contains(this.storeNames[a])||e.util.throwDOMException(0,"The operation failed because the requested database object could not be found. For example, an object store did not exist but was being opened.",this.storeNames[a]);this.__active=!0,this.__running=!1,this.__requests=[],this.__aborted=!1,this.db=i,this.error=null,this.onabort=this.onerror=this.oncomplete=null};r.prototype.__executeRequests=function(){if(this.__running&&this.mode!==o)return e.DEBUG&&console.log("Looks like the request set is already running",this.mode),void 0;this.__running=!0;var t=this;window.setTimeout(function(){2===t.mode||t.__active||e.util.throwDOMException(0,"A request was placed against a transaction which is currently not active, or which is finished",t.__active),t.db.__db.transaction(function(n){function o(t,n){n&&(a.req=n),a.req.readyState="done",a.req.result=t,delete a.req.error;var o=e.Event("success");e.util.callback("onsuccess",a.req,o),s++,i()}function r(){a.req.readyState="done",a.req.error="DOMError";var t=e.Event("error",arguments);e.util.callback("onerror",a.req,t),s++,i()}function i(){return s>=t.__requests.length?(t.__active=!1,t.__requests=[],void 0):(a=t.__requests[s],a.op(n,a.args,o,r),void 0)}t.__tx=n;var a=null,s=0;try{i()}catch(c){e.DEBUG&&console.log("An exception occured in transaction",arguments),"function"==typeof t.onerror&&t.onerror()}},function(){e.DEBUG&&console.log("An error in transaction",arguments),"function"==typeof t.onerror&&t.onerror()},function(){e.DEBUG&&console.log("Transaction completed",arguments),"function"==typeof t.oncomplete&&t.oncomplete()})},1)},r.prototype.__addToTransactionQueue=function(t,n){this.__active||this.mode===o||e.util.throwDOMException(0,"A request was placed against a transaction which is currently not active, or which is finished.",this.__mode);var r=this.__createRequest();return this.__pushToQueue(r,t,n),r},r.prototype.__createRequest=function(){var t=new e.IDBRequest;return t.source=this.db,t.transaction=this,t},r.prototype.__pushToQueue=function(e,t,n){this.__requests.push({op:t,args:n,req:e}),this.__executeRequests()},r.prototype.objectStore=function(t){return new e.IDBObjectStore(t,this)},r.prototype.abort=function(){!this.__active&&e.util.throwDOMException(0,"A request was placed against a transaction which is currently not active, or which is finished",this.__active)},r.prototype.READ_ONLY=0,r.prototype.READ_WRITE=1,r.prototype.VERSION_CHANGE=2,e.IDBTransaction=r}(idbModules),function(e){var t=function(t,n,o,r){this.__db=t,this.version=o,this.__storeProperties=r,this.objectStoreNames=new e.util.StringList;for(var i=0;r.rows.length>i;i++)this.objectStoreNames.push(r.rows.item(i).name);this.name=n,this.onabort=this.onerror=this.onversionchange=null};t.prototype.createObjectStore=function(t,n){var o=this;n=n||{},n.keyPath=n.keyPath||null;var r=new e.IDBObjectStore(t,o.__versionTransaction,!1),i=o.__versionTransaction;return i.__addToTransactionQueue(function(i,a,s){function c(){e.util.throwDOMException(0,"Could not create new object store",arguments)}o.__versionTransaction||e.util.throwDOMException(0,"Invalid State error",o.transaction);var u=["CREATE TABLE",e.util.quote(t),"(key BLOB",n.autoIncrement?", inc INTEGER PRIMARY KEY AUTOINCREMENT":"PRIMARY KEY",", value BLOB)"].join(" ");e.DEBUG&&console.log(u),i.executeSql(u,[],function(e){e.executeSql("INSERT INTO __sys__ VALUES (?,?,?,?)",[t,n.keyPath,n.autoIncrement?!0:!1,"{}"],function(){r.__setReadyState("createObjectStore",!0),s(r)},c)},c)}),o.objectStoreNames.push(t),r},t.prototype.deleteObjectStore=function(t){var n=function(){e.util.throwDOMException(0,"Could not delete ObjectStore",arguments)},o=this;!o.objectStoreNames.contains(t)&&n("Object Store does not exist"),o.objectStoreNames.splice(o.objectStoreNames.indexOf(t),1);var r=o.__versionTransaction;r.__addToTransactionQueue(function(){o.__versionTransaction||e.util.throwDOMException(0,"Invalid State error",o.transaction),o.__db.transaction(function(o){o.executeSql("SELECT * FROM __sys__ where name = ?",[t],function(o,r){r.rows.length>0&&o.executeSql("DROP TABLE "+e.util.quote(t),[],function(){o.executeSql("DELETE FROM __sys__ WHERE name = ?",[t],function(){},n)},n)})})})},t.prototype.close=function(){},t.prototype.transaction=function(t,n){var o=new e.IDBTransaction(t,n||1,this);return o},e.IDBDatabase=t}(idbModules),function(e){var t=4194304;if(window.openDatabase){var n=window.openDatabase("__sysdb__",1,"System Database",t);n.transaction(function(t){t.executeSql("SELECT * FROM dbVersions",[],function(){},function(){n.transaction(function(t){t.executeSql("CREATE TABLE IF NOT EXISTS dbVersions (name VARCHAR(255), version INT);",[],function(){},function(){e.util.throwDOMException("Could not create table __sysdb__ to save DB versions")})})})},function(){e.DEBUG&&console.log("Error in sysdb transaction - when selecting from dbVersions",arguments)});var o={open:function(o,r){function i(){if(!c){var t=e.Event("error",arguments);s.readyState="done",s.error="DOMError",e.util.callback("onerror",s,t),c=!0}}function a(a){var c=window.openDatabase(o,1,o,t);s.readyState="done",r===void 0&&(r=a||1),(0>=r||a>r)&&e.util.throwDOMException(0,"An attempt was made to open a database using a lower version than the existing version.",r),c.transaction(function(t){t.executeSql("CREATE TABLE IF NOT EXISTS __sys__ (name VARCHAR(255), keyPath VARCHAR(255), autoInc BOOLEAN, indexList BLOB)",[],function(){t.executeSql("SELECT * FROM __sys__",[],function(t,u){var d=e.Event("success");s.source=s.result=new e.IDBDatabase(c,o,r,u),r>a?n.transaction(function(t){t.executeSql("UPDATE dbVersions set version = ? where name = ?",[r,o],function(){var t=e.Event("upgradeneeded");t.oldVersion=a,t.newVersion=r,s.transaction=s.result.__versionTransaction=new e.IDBTransaction([],2,s.source),e.util.callback("onupgradeneeded",s,t,function(){var t=e.Event("success");e.util.callback("onsuccess",s,t)})},i)},i):e.util.callback("onsuccess",s,d)},i)},i)},i)}var s=new e.IDBOpenRequest,c=!1;return n.transaction(function(e){e.executeSql("SELECT * FROM dbVersions where name = ?",[o],function(e,t){0===t.rows.length?e.executeSql("INSERT INTO dbVersions VALUES (?,?)",[o,r||1],function(){a(0)},i):a(t.rows.item(0).version)},i)},i),s},deleteDatabase:function(o){function r(t){if(!s){a.readyState="done",a.error="DOMError";var n=e.Event("error");n.message=t,n.debug=arguments,e.util.callback("onerror",a,n),s=!0}}function i(){n.transaction(function(t){t.executeSql("DELETE FROM dbVersions where name = ? ",[o],function(){a.result=void 0;var t=e.Event("success");t.newVersion=null,t.oldVersion=c,e.util.callback("onsuccess",a,t)},r)},r)}var a=new e.IDBOpenRequest,s=!1,c=null;return n.transaction(function(n){n.executeSql("SELECT * FROM dbVersions where name = ?",[o],function(n,s){if(0===s.rows.length){a.result=void 0;var u=e.Event("success");return u.newVersion=null,u.oldVersion=c,e.util.callback("onsuccess",a,u),void 0}c=s.rows.item(0).version;var d=window.openDatabase(o,1,o,t);d.transaction(function(t){t.executeSql("SELECT * FROM __sys__",[],function(t,n){var o=n.rows;(function a(n){n>=o.length?t.executeSql("DROP TABLE __sys__",[],function(){i()},r):t.executeSql("DROP TABLE "+e.util.quote(o.item(n).name),[],function(){a(n+1)},function(){a(n+1)})})(0)},function(){i()})},r)})},r),a},cmp:function(t,n){return e.Key.encode(t)>e.Key.encode(n)?1:t===n?0:-1}};e.shimIndexedDB=o}}(idbModules),function(e,t){e.openDatabase!==void 0&&(e.shimIndexedDB=t.shimIndexedDB,e.shimIndexedDB&&(e.shimIndexedDB.__useShim=function(){e.indexedDB=t.shimIndexedDB,e.IDBDatabase=t.IDBDatabase,e.IDBTransaction=t.IDBTransaction,e.IDBCursor=t.IDBCursor,e.IDBKeyRange=t.IDBKeyRange,e.indexedDB!==t.shimIndexedDB&&Object.defineProperty&&Object.defineProperty(e,"indexedDB",{value:t.shimIndexedDB})},e.shimIndexedDB.__debug=function(e){t.DEBUG=e})),"indexedDB"in e||(e.indexedDB=e.indexedDB||e.webkitIndexedDB||e.mozIndexedDB||e.oIndexedDB||e.msIndexedDB);var n=!1;if((navigator.userAgent.match(/Android 2/)||navigator.userAgent.match(/Android 3/)||navigator.userAgent.match(/Android 4\.[0-3]/))&&(navigator.userAgent.match(/Chrome/)||(n=!0)),void 0!==e.indexedDB&&!n||void 0===e.openDatabase){e.IDBDatabase=e.IDBDatabase||e.webkitIDBDatabase,e.IDBTransaction=e.IDBTransaction||e.webkitIDBTransaction,e.IDBCursor=e.IDBCursor||e.webkitIDBCursor,e.IDBKeyRange=e.IDBKeyRange||e.webkitIDBKeyRange,e.IDBTransaction||(e.IDBTransaction={});try{e.IDBTransaction.READ_ONLY=e.IDBTransaction.READ_ONLY||"readonly",e.IDBTransaction.READ_WRITE=e.IDBTransaction.READ_WRITE||"readwrite"}catch(o){}}else e.shimIndexedDB.__useShim()}(window,idbModules);
//@ sourceMappingURL=http://nparashuram.com/IndexedDBShim/dist/IndexedDBShim.min.map
This file has been truncated, but you can view the full file.
Location: http://17116613.r.lightningbase-cdn.com/wp-content/plugins/buddyboss-media/assets/vendor/plupload2/moxie.js?ver=1.2.1
Referrer: http://blogjob.com/
Content-Type: application/x-javascript
/**
* mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill
* v1.2.1
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*
* Date: 2014-05-14
*/
/**
* Compiled inline version. (Library mode)
*/
/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */
/*globals $code */
(function(exports, undefined) {
"use strict";
var modules = {};
function require(ids, callback) {
var module, defs = [];
for (var i = 0; i < ids.length; ++i) {
module = modules[ids[i]] || resolve(ids[i]);
if (!module) {
throw 'module definition dependecy not found: ' + ids[i];
}
defs.push(module);
}
callback.apply(null, defs);
}
function define(id, dependencies, definition) {
if (typeof id !== 'string') {
throw 'invalid module definition, module id must be defined and be a string';
}
if (dependencies === undefined) {
throw 'invalid module definition, dependencies must be specified';
}
if (definition === undefined) {
throw 'invalid module definition, definition function must be specified';
}
require(dependencies, function() {
modules[id] = definition.apply(null, arguments);
});
}
function defined(id) {
return !!modules[id];
}
function resolve(id) {
var target = exports;
var fragments = id.split(/[.\/]/);
for (var fi = 0; fi < fragments.length; ++fi) {
if (!target[fragments[fi]]) {
return;
}
target = target[fragments[fi]];
}
return target;
}
function expose(ids) {
for (var i = 0; i < ids.length; i++) {
var target = exports;
var id = ids[i];
var fragments = id.split(/[.\/]/);
for (var fi = 0; fi < fragments.length - 1; ++fi) {
if (target[fragments[fi]] === undefined) {
target[fragments[fi]] = {};
}
target = target[fragments[fi]];
}
target[fragments[fragments.length - 1]] = modules[id];
}
}
// Included from: src/javascript/core/utils/Basic.js
/**
* Basic.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Basic', [], function() {
/**
Gets the true type of the built-in object (better version of typeof).
@author Angus Croll (http://javascriptweblog.wordpress.com/)
@method typeOf
@for Utils
@static
@param {Object} o Object to check.
@return {String} Object [[Class]]
*/
var typeOf = function(o) {
var undef;
if (o === undef) {
return 'undefined';
} else if (o === null) {
return 'null';
} else if (o.nodeType) {
return 'node';
}
// the snippet below is awesome, however it fails to detect null, undefined and arguments types in IE lte 8
return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
};
/**
Extends the specified object with another object.
@method extend
@static
@param {Object} target Object to extend.
@param {Object} [obj]* Multiple objects to extend with.
@return {Object} Same as target, the extended object.
*/
var extend = function(target) {
var undef;
each(arguments, function(arg, i) {
if (i > 0) {
each(arg, function(value, key) {
if (value !== undef) {
if (typeOf(target[key]) === typeOf(value) && !!~inArray(typeOf(value), ['array', 'object'])) {
extend(target[key], value);
} else {
target[key] = value;
}
}
});
}
});
return target;
};
/**
Executes the callback function for each item in array/object. If you return false in the
callback it will break the loop.
@method each
@static
@param {Object} obj Object to iterate.
@param {function} callback Callback function to execute for each item.
*/
var each = function(obj, callback) {
var length, key, i, undef;
if (obj) {
try {
length = obj.length;
} catch(ex) {
length = undef;
}
if (length === undef) {
// Loop object items
for (key in obj) {
if (obj.hasOwnProperty(key)) {
if (callback(obj[key], key) === false) {
return;
}
}
}
} else {
// Loop array items
for (i = 0; i < length; i++) {
if (callback(obj[i], i) === false) {
return;
}
}
}
}
};
/**
Checks if object is empty.
@method isEmptyObj
@static
@param {Object} o Object to check.
@return {Boolean}
*/
var isEmptyObj = function(obj) {
var prop;
if (!obj || typeOf(obj) !== 'object') {
return true;
}
for (prop in obj) {
return false;
}
return true;
};
/**
Recieve an array of functions (usually async) to call in sequence, each function
receives a callback as first argument that it should call, when it completes. Finally,
after everything is complete, main callback is called. Passing truthy value to the
callback as a first argument will interrupt the sequence and invoke main callback
immediately.
@method inSeries
@static
@param {Array} queue Array of functions to call in sequence
@param {Function} cb Main callback that is called in the end, or in case of error
*/
var inSeries = function(queue, cb) {
var i = 0, length = queue.length;
if (typeOf(cb) !== 'function') {
cb = function() {};
}
if (!queue || !queue.length) {
cb();
}
function callNext(i) {
if (typeOf(queue[i]) === 'function') {
queue[i](function(error) {
/*jshint expr:true */
++i < length && !error ? callNext(i) : cb(error);
});
}
}
callNext(i);
};
/**
Recieve an array of functions (usually async) to call in parallel, each function
receives a callback as first argument that it should call, when it completes. After
everything is complete, main callback is called. Passing truthy value to the
callback as a first argument will interrupt the process and invoke main callback
immediately.
@method inParallel
@static
@param {Array} queue Array of functions to call in sequence
@param {Function} cb Main callback that is called in the end, or in case of erro
*/
var inParallel = function(queue, cb) {
var count = 0, num = queue.length, cbArgs = new Array(num);
each(queue, function(fn, i) {
fn(function(error) {
if (error) {
return cb(error);
}
var args = [].slice.call(arguments);
args.shift(); // strip error - undefined or not
cbArgs[i] = args;
count++;
if (count === num) {
cbArgs.unshift(null);
cb.apply(this, cbArgs);
}
});
});
};
/**
Find an element in array and return it's index if present, otherwise return -1.
@method inArray
@static
@param {Mixed} needle Element to find
@param {Array} array
@return {Int} Index of the element, or -1 if not found
*/
var inArray = function(needle, array) {
if (array) {
if (Array.prototype.indexOf) {
return Array.prototype.indexOf.call(array, needle);
}
for (var i = 0, length = array.length; i < length; i++) {
if (array[i] === needle) {
return i;
}
}
}
return -1;
};
/**
Returns elements of first array if they are not present in second. And false - otherwise.
@private
@method arrayDiff
@param {Array} needles
@param {Array} array
@return {Array|Boolean}
*/
var arrayDiff = function(needles, array) {
var diff = [];
if (typeOf(needles) !== 'array') {
needles = [needles];
}
if (typeOf(array) !== 'array') {
array = [array];
}
for (var i in needles) {
if (inArray(needles[i], array) === -1) {
diff.push(needles[i]);
}
}
return diff.length ? diff : false;
};
/**
Find intersection of two arrays.
@private
@method arrayIntersect
@param {Array} array1
@param {Array} array2
@return {Array} Intersection of two arrays or null if there is none
*/
var arrayIntersect = function(array1, array2) {
var result = [];
each(array1, function(item) {
if (inArray(item, array2) !== -1) {
result.push(item);
}
});
return result.length ? result : null;
};
/**
Forces anything into an array.
@method toArray
@static
@param {Object} obj Object with length field.
@return {Array} Array object containing all items.
*/
var toArray = function(obj) {
var i, arr = [];
for (i = 0; i < obj.length; i++) {
arr[i] = obj[i];
}
return arr;
};
/**
Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers.
The only way a user would be able to get the same ID is if the two persons at the same exact milisecond manages
to get 5 the same random numbers between 0-65535 it also uses a counter so each call will be guaranteed to be page unique.
It's more probable for the earth to be hit with an ansteriod. Y
@method guid
@static
@param {String} prefix to prepend (by default 'o' will be prepended).
@method guid
@return {String} Virtually unique id.
*/
var guid = (function() {
var counter = 0;
return function(prefix) {
var guid = new Date().getTime().toString(32), i;
for (i = 0; i < 5; i++) {
guid += Math.floor(Math.random() * 65535).toString(32);
}
return (prefix || 'o_') + guid + (counter++).toString(32);
};
}());
/**
Trims white spaces around the string
@method trim
@static
@param {String} str
@return {String}
*/
var trim = function(str) {
if (!str) {
return str;
}
return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, '');
};
/**
Parses the specified size string into a byte value. For example 10kb becomes 10240.
@method parseSizeStr
@static
@param {String/Number} size String to parse or number to just pass through.
@return {Number} Size in bytes.
*/
var parseSizeStr = function(size) {
if (typeof(size) !== 'string') {
return size;
}
var muls = {
t: 1099511627776,
g: 1073741824,
m: 1048576,
k: 1024
},
mul;
size = /^([0-9]+)([mgk]?)$/.exec(size.toLowerCase().replace(/[^0-9mkg]/g, ''));
mul = size[2];
size = +size[1];
if (muls.hasOwnProperty(mul)) {
size *= muls[mul];
}
return size;
};
return {
guid: guid,
typeOf: typeOf,
extend: extend,
each: each,
isEmptyObj: isEmptyObj,
inSeries: inSeries,
inParallel: inParallel,
inArray: inArray,
arrayDiff: arrayDiff,
arrayIntersect: arrayIntersect,
toArray: toArray,
trim: trim,
parseSizeStr: parseSizeStr
};
});
// Included from: src/javascript/core/I18n.js
/**
* I18n.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/core/I18n", [
"moxie/core/utils/Basic"
], function(Basic) {
var i18n = {};
return {
/**
* Extends the language pack object with new items.
*
* @param {Object} pack Language pack items to add.
* @return {Object} Extended language pack object.
*/
addI18n: function(pack) {
return Basic.extend(i18n, pack);
},
/**
* Translates the specified string by checking for the english string in the language pack lookup.
*
* @param {String} str String to look for.
* @return {String} Translated string or the input string if it wasn't found.
*/
translate: function(str) {
return i18n[str] || str;
},
/**
* Shortcut for translate function
*
* @param {String} str String to look for.
* @return {String} Translated string or the input string if it wasn't found.
*/
_: function(str) {
return this.translate(str);
},
/**
* Pseudo sprintf implementation - simple way to replace tokens with specified values.
*
* @param {String} str String with tokens
* @return {String} String with replaced tokens
*/
sprintf: function(str) {
var args = [].slice.call(arguments, 1);
return str.replace(/%[a-z]/g, function() {
var value = args.shift();
return Basic.typeOf(value) !== 'undefined' ? value : '';
});
}
};
});
// Included from: src/javascript/core/utils/Mime.js
/**
* Mime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/core/utils/Mime", [
"moxie/core/utils/Basic",
"moxie/core/I18n"
], function(Basic, I18n) {
var mimeData = "" +
"application/msword,doc dot," +
"application/pdf,pdf," +
"application/pgp-signature,pgp," +
"application/postscript,ps ai eps," +
"application/rtf,rtf," +
"application/vnd.ms-excel,xls xlb," +
"application/vnd.ms-powerpoint,ppt pps pot," +
"application/zip,zip," +
"application/x-shockwave-flash,swf swfl," +
"application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," +
"application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," +
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," +
"application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," +
"application/vnd.openxmlformats-officedocument.presentationml.template,potx," +
"application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," +
"application/x-javascript,js," +
"application/json,json," +
"audio/mpeg,mp3 mpga mpega mp2," +
"audio/x-wav,wav," +
"audio/x-m4a,m4a," +
"audio/ogg,oga ogg," +
"audio/aiff,aiff aif," +
"audio/flac,flac," +
"audio/aac,aac," +
"audio/ac3,ac3," +
"audio/x-ms-wma,wma," +
"image/bmp,bmp," +
"image/gif,gif," +
"image/jpeg,jpg jpeg jpe," +
"image/photoshop,psd," +
"image/png,png," +
"image/svg+xml,svg svgz," +
"image/tiff,tiff tif," +
"text/plain,asc txt text diff log," +
"text/html,htm html xhtml," +
"text/css,css," +
"text/csv,csv," +
"text/rtf,rtf," +
"video/mpeg,mpeg mpg mpe m2v," +
"video/quicktime,qt mov," +
"video/mp4,mp4," +
"video/x-m4v,m4v," +
"video/x-flv,flv," +
"video/x-ms-wmv,wmv," +
"video/avi,avi," +
"video/webm,webm," +
"video/3gpp,3gpp 3gp," +
"video/3gpp2,3g2," +
"video/vnd.rn-realvideo,rv," +
"video/ogg,ogv," +
"video/x-matroska,mkv," +
"application/vnd.oasis.opendocument.formula-template,otf," +
"application/octet-stream,exe";
var Mime = {
mimes: {},
extensions: {},
// Parses the default mime types string into a mimes and extensions lookup maps
addMimeType: function (mimeData) {
var items = mimeData.split(/,/), i, ii, ext;
for (i = 0; i < items.length; i += 2) {
ext = items[i + 1].split(/ /);
// extension to mime lookup
for (ii = 0; ii < ext.length; ii++) {
this.mimes[ext[ii]] = items[i];
}
// mime to extension lookup
this.extensions[items[i]] = ext;
}
},
extList2mimes: function (filters, addMissingExtensions) {
var self = this, ext, i, ii, type, mimes = [];
// convert extensions to mime types list
for (i = 0; i < filters.length; i++) {
ext = filters[i].extensions.split(/\s*,\s*/);
for (ii = 0; ii < ext.length; ii++) {
// if there's an asterisk in the list, then accept attribute is not required
if (ext[ii] === '*') {
return [];
}
type = self.mimes[ext[ii]];
if (!type) {
if (addMissingExtensions && /^\w+$/.test(ext[ii])) {
mimes.push('.' + ext[ii]);
} else {
return []; // accept all
}
} else if (Basic.inArray(type, mimes) === -1) {
mimes.push(type);
}
}
}
return mimes;
},
mimes2exts: function(mimes) {
var self = this, exts = [];
Basic.each(mimes, function(mime) {
if (mime === '*') {
exts = [];
return false;
}
// check if this thing looks like mime type
var m = mime.match(/^(\w+)\/(\*|\w+)$/);
if (m) {
if (m[2] === '*') {
// wildcard mime type detected
Basic.each(self.extensions, function(arr, mime) {
if ((new RegExp('^' + m[1] + '/')).test(mime)) {
[].push.apply(exts, self.extensions[mime]);
}
});
} else if (self.extensions[mime]) {
[].push.apply(exts, self.extensions[mime]);
}
}
});
return exts;
},
mimes2extList: function(mimes) {
var accept = [], exts = [];
if (Basic.typeOf(mimes) === 'string') {
mimes = Basic.trim(mimes).split(/\s*,\s*/);
}
exts = this.mimes2exts(mimes);
accept.push({
title: I18n.translate('Files'),
extensions: exts.length ? exts.join(',') : '*'
});
// save original mimes string
accept.mimes = mimes;
return accept;
},
getFileExtension: function(fileName) {
var matches = fileName && fileName.match(/\.([^.]+)$/);
if (matches) {
return matches[1].toLowerCase();
}
return '';
},
getFileMime: function(fileName) {
return this.mimes[this.getFileExtension(fileName)] || '';
}
};
Mime.addMimeType(mimeData);
return Mime;
});
// Included from: src/javascript/core/utils/Env.js
/**
* Env.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define("moxie/core/utils/Env", [
"moxie/core/utils/Basic"
], function(Basic) {
// UAParser.js v0.6.2
// Lightweight JavaScript-based User-Agent string parser
// https://github.com/faisalman/ua-parser-js
//
// Copyright © 2012-2013 Faisalman <[email protected]>
// Dual licensed under GPLv2 & MIT
var UAParser = (function (undefined) {
//////////////
// Constants
/////////////
var EMPTY = '',
UNKNOWN = '?',
FUNC_TYPE = 'function',
UNDEF_TYPE = 'undefined',
OBJ_TYPE = 'object',
MAJOR = 'major',
MODEL = 'model',
NAME = 'name',
TYPE = 'type',
VENDOR = 'vendor',
VERSION = 'version',
ARCHITECTURE= 'architecture',
CONSOLE = 'console',
MOBILE = 'mobile',
TABLET = 'tablet';
///////////
// Helper
//////////
var util = {
has : function (str1, str2) {
return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1;
},
lowerize : function (str) {
return str.toLowerCase();
}
};
///////////////
// Map helper
//////////////
var mapper = {
rgx : function () {
// loop through all regexes maps
for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) {
var regex = args[i], // even sequence (0,2,4,..)
props = args[i + 1]; // odd sequence (1,3,5,..)
// construct object barebones
if (typeof(result) === UNDEF_TYPE) {
result = {};
for (p in props) {
q = props[p];
if (typeof(q) === OBJ_TYPE) {
result[q[0]] = undefined;
} else {
result[q] = undefined;
}
}
}
// try matching uastring with regexes
for (j = k = 0; j < regex.length; j++) {
matches = regex[j].exec(this.getUA());
if (!!matches) {
for (p = 0; p < props.length; p++) {
match = matches[++k];
q = props[p];
// check if given property is actually array
if (typeof(q) === OBJ_TYPE && q.length > 0) {
if (q.length == 2) {
if (typeof(q[1]) == FUNC_TYPE) {
// assign modified match
result[q[0]] = q[1].call(this, match);
} else {
// assign given value, ignore regex match
result[q[0]] = q[1];
}
} else if (q.length == 3) {
// check whether function or regex
if (typeof(q[1]) === FUNC_TYPE && !(q[1].exec && q[1].test)) {
// call function (usually string mapper)
result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
} else {
// sanitize match using given regex
result[q[0]] = match ? match.replace(q[1], q[2]) : undefined;
}
} else if (q.length == 4) {
result[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined;
}
} else {
result[q] = match ? match : undefined;
}
}
break;
}
}
if(!!matches) break; // break the loop immediately if match found
}
return result;
},
str : function (str, map) {
for (var i in map) {
// check if array
if (typeof(map[i]) === OBJ_TYPE && map[i].length > 0) {
for (var j = 0; j < map[i].length; j++) {
if (util.has(map[i][j], str)) {
return (i === UNKNOWN) ? undefined : i;
}
}
} else if (util.has(map[i], str)) {
return (i === UNKNOWN) ? undefined : i;
}
}
return str;
}
};
///////////////
// String map
//////////////
var maps = {
browser : {
oldsafari : {
major : {
'1' : ['/8', '/1', '/3'],
'2' : '/4',
'?' : '/'
},
version : {
'1.0' : '/8',
'1.2' : '/1',
'1.3' : '/3',
'2.0' : '/412',
'2.0.2' : '/416',
'2.0.3' : '/417',
'2.0.4' : '/419',
'?' : '/'
}
}
},
device : {
sprint : {
model : {
'Evo Shift 4G' : '7373KT'
},
vendor : {
'HTC' : 'APA',
'Sprint' : 'Sprint'
}
}
},
os : {
windows : {
version : {
'ME' : '4.90',
'NT 3.11' : 'NT3.51',
'NT 4.0' : 'NT4.0',
'2000' : 'NT 5.0',
'XP' : ['NT 5.1', 'NT 5.2'],
'Vista' : 'NT 6.0',
'7' : 'NT 6.1',
'8' : 'NT 6.2',
'8.1' : 'NT 6.3',
'RT' : 'ARM'
}
}
}
};
//////////////
// Regex map
/////////////
var regexes = {
browser : [[
// Presto based
/(opera\smini)\/((\d+)?[\w\.-]+)/i, // Opera Mini
/(opera\s[mobiletab]+).+version\/((\d+)?[\w\.-]+)/i, // Opera Mobi/Tablet
/(opera).+version\/((\d+)?[\w\.]+)/i, // Opera > 9.80
/(opera)[\/\s]+((\d+)?[\w\.]+)/i // Opera < 9.80
], [NAME, VERSION, MAJOR], [
/\s(opr)\/((\d+)?[\w\.]+)/i // Opera Webkit
], [[NAME, 'Opera'], VERSION, MAJOR], [
// Mixed
/(kindle)\/((\d+)?[\w\.]+)/i, // Kindle
/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?((\d+)?[\w\.]+)*/i,
// Lunascape/Maxthon/Netfront/Jasmine/Blazer
// Trident based
/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?((\d+)?[\w\.]*)/i,
// Avant/IEMobile/SlimBrowser/Baidu
/(?:ms|\()(ie)\s((\d+)?[\w\.]+)/i, // Internet Explorer
// Webkit/KHTML based
/(rekonq)((?:\/)[\w\.]+)*/i, // Rekonq
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron)\/((\d+)?[\w\.-]+)/i
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron
], [NAME, VERSION, MAJOR], [
/(trident).+rv[:\s]((\d+)?[\w\.]+).+like\sgecko/i // IE11
], [[NAME, 'IE'], VERSION, MAJOR], [
/(yabrowser)\/((\d+)?[\w\.]+)/i // Yandex
], [[NAME, 'Yandex'], VERSION, MAJOR], [
/(comodo_dragon)\/((\d+)?[\w\.]+)/i // Comodo Dragon
], [[NAME, /_/g, ' '], VERSION, MAJOR], [
/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?((\d+)?[\w\.]+)/i
// Chrome/OmniWeb/Arora/Tizen/Nokia
], [NAME, VERSION, MAJOR], [
/(dolfin)\/((\d+)?[\w\.]+)/i // Dolphin
], [[NAME, 'Dolphin'], VERSION, MAJOR], [
/((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i // Chrome for Android/iOS
], [[NAME, 'Chrome'], VERSION, MAJOR], [
/((?:android.+))version\/((\d+)?[\w\.]+)\smobile\ssafari/i // Android Browser
], [[NAME, 'Android Browser'], VERSION, MAJOR], [
/version\/((\d+)?[\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
], [VERSION, MAJOR, [NAME, 'Mobile Safari']], [
/version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
], [VERSION, MAJOR, NAME], [
/webkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i // Safari < 3.0
], [NAME, [MAJOR, mapper.str, maps.browser.oldsafari.major], [VERSION, mapper.str, maps.browser.oldsafari.version]], [
/(konqueror)\/((\d+)?[\w\.]+)/i, // Konqueror
/(webkit|khtml)\/((\d+)?[\w\.]+)/i
], [NAME, VERSION, MAJOR], [
// Gecko based
/(navigator|netscape)\/((\d+)?[\w\.-]+)/i // Netscape
], [[NAME, 'Netscape'], VERSION, MAJOR], [
/(swiftfox)/i, // Swiftfox
/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,
// IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i,
// Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
// Other
/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|qqbrowser)[\/\s]?((\d+)?[\w\.]+)/i,
// UCBrowser/Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/QQBrowser
/(links)\s\(((\d+)?[\w\.]+)/i, // Links
/(gobrowser)\/?((\d+)?[\w\.]+)*/i, // GoBrowser
/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i, // ICE Browser
/(mosaic)[\/\s]((\d+)?[\w\.]+)/i // Mosaic
], [NAME, VERSION, MAJOR]
],
engine : [[
/(presto)\/([\w\.]+)/i, // Presto
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m
/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
/(icab)[\/\s]([23]\.[\d\.]+)/i // iCab
], [NAME, VERSION], [
/rv\:([\w\.]+).*(gecko)/i // Gecko
], [VERSION, NAME]
],
os : [[
// Windows based
/(windows)\snt\s6\.2;\s(arm)/i, // Windows RT
/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i
], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [
/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i
], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [
// Mobile/Embedded OS
/\((bb)(10);/i // BlackBerry 10
], [[NAME, 'BlackBerry'], VERSION], [
/(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry
/(tizen)\/([\w\.]+)/i, // Tizen
/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego)[\/\s-]?([\w\.]+)*/i
// Android/WebOS/Palm/QNX/Bada/RIM/MeeGo
], [NAME, VERSION], [
/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian
], [[NAME, 'Symbian'], VERSION],[
/mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS
], [[NAME, 'Firefox OS'], VERSION], [
// Console
/(nintendo|playstation)\s([wids3portablevu]+)/i, // Nintendo/Playstation
// GNU/Linux based
/(mint)[\/\s\(]?(\w+)*/i, // Mint
/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk)[\/\s-]?([\w\.-]+)*/i,
// Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
// Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk
/(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux
/(gnu)\s?([\w\.]+)*/i // GNU
], [NAME, VERSION], [
/(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS
], [[NAME, 'Chromium OS'], VERSION],[
// Solaris
/(sunos)\s?([\w\.]+\d)*/i // Solaris
], [[NAME, 'Solaris'], VERSION], [
// BSD based
/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly
], [NAME, VERSION],[
/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i // iOS
], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [
/(mac\sos\sx)\s?([\w\s\.]+\w)*/i // Mac OS
], [NAME, [VERSION, /_/g, '.']], [
// Other
/(haiku)\s(\w+)/i, // Haiku
/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, // AIX
/(macintosh|mac(?=_powerpc)|plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos)/i,
// Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS
/(unix)\s?([\w\.]+)*/i // UNIX
], [NAME, VERSION]
]
};
/////////////////
// Constructor
////////////////
var UAParser = function (uastring) {
var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
this.getBrowser = function () {
return mapper.rgx.apply(this, regexes.browser);
};
this.getEngine = function () {
return mapper.rgx.apply(this, regexes.engine);
};
this.getOS = function () {
return mapper.rgx.apply(this, regexes.os);
};
this.getResult = function() {
return {
ua : this.getUA(),
browser : this.getBrowser(),
engine : this.getEngine(),
os : this.getOS()
};
};
this.getUA = function () {
return ua;
};
this.setUA = function (uastring) {
ua = uastring;
return this;
};
this.setUA(ua);
};
return new UAParser().getResult();
})();
function version_compare(v1, v2, operator) {
// From: http://phpjs.org/functions
// + original by: Philippe Jausions (http://pear.php.net/user/jausions)
// + original by: Aidan Lister (http://aidanlister.com/)
// + reimplemented by: Kankrelune (http://www.webfaktory.info/)
// + improved by: Brett Zamir (http://brett-zamir.me)
// + improved by: Scott Baker
// + improved by: Theriault
// * example 1: version_compare('8.2.5rc', '8.2.5a');
// * returns 1: 1
// * example 2: version_compare('8.2.50', '8.2.52', '<');
// * returns 2: true
// * example 3: version_compare('5.3.0-dev', '5.3.0');
// * returns 3: -1
// * example 4: version_compare('4.1.0.52','4.01.0.51');
// * returns 4: 1
// Important: compare must be initialized at 0.
var i = 0,
x = 0,
compare = 0,
// vm maps textual PHP versions to negatives so they're less than 0.
// PHP currently defines these as CASE-SENSITIVE. It is important to
// leave these as negatives so that they can come before numerical versions
// and as if no letters were there to begin with.
// (1alpha is < 1 and < 1.1 but > 1dev1)
// If a non-numerical value can't be mapped to this table, it receives
// -7 as its value.
vm = {
'dev': -6,
'alpha': -5,
'a': -5,
'beta': -4,
'b': -4,
'RC': -3,
'rc': -3,
'#': -2,
'p': 1,
'pl': 1
},
// This function will be called to prepare each version argument.
// It replaces every _, -, and + with a dot.
// It surrounds any nonsequence of numbers/dots with dots.
// It replaces sequences of dots with a single dot.
// version_compare('4..0', '4.0') == 0
// Important: A string of 0 length needs to be converted into a value
// even less than an unexisting value in vm (-7), hence [-8].
// It's also important to not strip spaces because of this.
// version_compare('', ' ') == 1
prepVersion = function (v) {
v = ('' + v).replace(/[_\-+]/g, '.');
v = v.replace(/([^.\d]+)/g, '.$1.').replace(/\.{2,}/g, '.');
return (!v.length ? [-8] : v.split('.'));
},
// This converts a version component to a number.
// Empty component becomes 0.
// Non-numerical component becomes a negative number.
// Numerical component becomes itself as an integer.
numVersion = function (v) {
return !v ? 0 : (isNaN(v) ? vm[v] || -7 : parseInt(v, 10));
};
v1 = prepVersion(v1);
v2 = prepVersion(v2);
x = Math.max(v1.length, v2.length);
for (i = 0; i < x; i++) {
if (v1[i] == v2[i]) {
continue;
}
v1[i] = numVersion(v1[i]);
v2[i] = numVersion(v2[i]);
if (v1[i] < v2[i]) {
compare = -1;
break;
} else if (v1[i] > v2[i]) {
compare = 1;
break;
}
}
if (!operator) {
return compare;
}
// Important: operator is CASE-SENSITIVE.
// "No operator" seems to be treated as "<."
// Any other values seem to make the function return null.
switch (operator) {
case '>':
case 'gt':
return (compare > 0);
case '>=':
case 'ge':
return (compare >= 0);
case '<=':
case 'le':
return (compare <= 0);
case '==':
case '=':
case 'eq':
return (compare === 0);
case '<>':
case '!=':
case 'ne':
return (compare !== 0);
case '':
case '<':
case 'lt':
return (compare < 0);
default:
return null;
}
}
var can = (function() {
var caps = {
define_property: (function() {
/* // currently too much extra code required, not exactly worth it
try { // as of IE8, getters/setters are supported only on DOM elements
var obj = {};
if (Object.defineProperty) {
Object.defineProperty(obj, 'prop', {
enumerable: true,
configurable: true
});
return true;
}
} catch(ex) {}
if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__) {
return true;
}*/
return false;
}()),
create_canvas: (function() {
// On the S60 and BB Storm, getContext exists, but always returns undefined
// so we actually have to call getContext() to verify
// github.com/Modernizr/Modernizr/issues/issue/97/
var el = document.createElement('canvas');
return !!(el.getContext && el.getContext('2d'));
}()),
return_response_type: function(responseType) {
try {
if (Basic.inArray(responseType, ['', 'text', 'document']) !== -1) {
return true;
} else if (window.XMLHttpRequest) {
var xhr = new XMLHttpRequest();
xhr.open('get', '/'); // otherwise Gecko throws an exception
if ('responseType' in xhr) {
xhr.responseType = responseType;
// as of 23.0.1271.64, Chrome switched from throwing exception to merely logging it to the console (why? o why?)
if (xhr.responseType !== responseType) {
return false;
}
return true;
}
}
} catch (ex) {}
return false;
},
// ideas for this heavily come from Modernizr (http://modernizr.com/)
use_data_uri: (function() {
var du = new Image();
du.onload = function() {
caps.use_data_uri = (du.width === 1 && du.height === 1);
};
setTimeout(function() {
du.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==";
}, 1);
return false;
}()),
use_data_uri_over32kb: function() { // IE8
return caps.use_data_uri && (Env.browser !== 'IE' || Env.version >= 9);
},
use_data_uri_of: function(bytes) {
return (caps.use_data_uri && bytes < 33000 || caps.use_data_uri_over32kb());
},
use_fileinput: function() {
var el = document.createElement('input');
el.setAttribute('type', 'file');
return !el.disabled;
}
};
return function(cap) {
var args = [].slice.call(arguments);
args.shift(); // shift of cap
return Basic.typeOf(caps[cap]) === 'function' ? caps[cap].apply(this, args) : !!caps[cap];
};
}());
var Env = {
can: can,
browser: UAParser.browser.name,
version: parseFloat(UAParser.browser.major),
os: UAParser.os.name, // everybody intuitively types it in a lowercase for some reason
osVersion: UAParser.os.version,
verComp: version_compare,
swf_url: "../flash/Moxie.swf",
xap_url: "../silverlight/Moxie.xap",
global_event_dispatcher: "moxie.core.EventTarget.instance.dispatchEvent"
};
// for backward compatibility
// @deprecated Use `Env.os` instead
Env.OS = Env.os;
return Env;
});
// Included from: src/javascript/core/utils/Dom.js
/**
* Dom.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Dom', ['moxie/core/utils/Env'], function(Env) {
/**
Get DOM Element by it's id.
@method get
@for Utils
@param {String} id Identifier of the DOM Element
@return {DOMElement}
*/
var get = function(id) {
if (typeof id !== 'string') {
return id;
}
return document.getElementById(id);
};
/**
Checks if specified DOM element has specified class.
@method hasClass
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Class name
*/
var hasClass = function(obj, name) {
if (!obj.className) {
return false;
}
var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)");
return regExp.test(obj.className);
};
/**
Adds specified className to specified DOM element.
@method addClass
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Class name
*/
var addClass = function(obj, name) {
if (!hasClass(obj, name)) {
obj.className = !obj.className ? name : obj.className.replace(/\s+$/, '') + ' ' + name;
}
};
/**
Removes specified className from specified DOM element.
@method removeClass
@static
@param {Object} obj DOM element like object to add handler to.
@param {String} name Class name
*/
var removeClass = function(obj, name) {
if (obj.className) {
var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)");
obj.className = obj.className.replace(regExp, function($0, $1, $2) {
return $1 === ' ' && $2 === ' ' ? ' ' : '';
});
}
};
/**
Returns a given computed style of a DOM element.
@method getStyle
@static
@param {Object} obj DOM element like object.
@param {String} name Style you want to get from the DOM element
*/
var getStyle = function(obj, name) {
if (obj.currentStyle) {
return obj.currentStyle[name];
} else if (window.getComputedStyle) {
return window.getComputedStyle(obj, null)[name];
}
};
/**
Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields.
@method getPos
@static
@param {Element} node HTML element or element id to get x, y position from.
@param {Element} root Optional root element to stop calculations at.
@return {object} Absolute position of the specified element object with x, y fields.
*/
var getPos = function(node, root) {
var x = 0, y = 0, parent, doc = document, nodeRect, rootRect;
node = node;
root = root || doc.body;
// Returns the x, y cordinate for an element on IE 6 and IE 7
function getIEPos(node) {
var bodyElm, rect, x = 0, y = 0;
if (node) {
rect = node.getBoundingClientRect();
bodyElm = doc.compatMode === "CSS1Compat" ? doc.documentElement : doc.body;
x = rect.left + bodyElm.scrollLeft;
y = rect.top + bodyElm.scrollTop;
}
return {
x : x,
y : y
};
}
// Use getBoundingClientRect on IE 6 and IE 7 but not on IE 8 in standards mode
if (node && node.getBoundingClientRect && Env.browser === 'IE' && (!doc.documentMode || doc.documentMode < 8)) {
nodeRect = getIEPos(node);
rootRect = getIEPos(root);
return {
x : nodeRect.x - rootRect.x,
y : nodeRect.y - rootRect.y
};
}
parent = node;
while (parent && parent != root && parent.nodeType) {
x += parent.offsetLeft || 0;
y += parent.offsetTop || 0;
parent = parent.offsetParent;
}
parent = node.parentNode;
while (parent && parent != root && parent.nodeType) {
x -= parent.scrollLeft || 0;
y -= parent.scrollTop || 0;
parent = parent.parentNode;
}
return {
x : x,
y : y
};
};
/**
Returns the size of the specified node in pixels.
@method getSize
@static
@param {Node} node Node to get the size of.
@return {Object} Object with a w and h property.
*/
var getSize = function(node) {
return {
w : node.offsetWidth || node.clientWidth,
h : node.offsetHeight || node.clientHeight
};
};
return {
get: get,
hasClass: hasClass,
addClass: addClass,
removeClass: removeClass,
getStyle: getStyle,
getPos: getPos,
getSize: getSize
};
});
// Included from: src/javascript/core/Exceptions.js
/**
* Exceptions.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/Exceptions', [
'moxie/core/utils/Basic'
], function(Basic) {
function _findKey(obj, value) {
var key;
for (key in obj) {
if (obj[key] === value) {
return key;
}
}
return null;
}
return {
RuntimeError: (function() {
var namecodes = {
NOT_INIT_ERR: 1,
NOT_SUPPORTED_ERR: 9,
JS_ERR: 4
};
function RuntimeError(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": RuntimeError " + this.code;
}
Basic.extend(RuntimeError, namecodes);
RuntimeError.prototype = Error.prototype;
return RuntimeError;
}()),
OperationNotAllowedException: (function() {
function OperationNotAllowedException(code) {
this.code = code;
this.name = 'OperationNotAllowedException';
}
Basic.extend(OperationNotAllowedException, {
NOT_ALLOWED_ERR: 1
});
OperationNotAllowedException.prototype = Error.prototype;
return OperationNotAllowedException;
}()),
ImageError: (function() {
var namecodes = {
WRONG_FORMAT: 1,
MAX_RESOLUTION_ERR: 2
};
function ImageError(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": ImageError " + this.code;
}
Basic.extend(ImageError, namecodes);
ImageError.prototype = Error.prototype;
return ImageError;
}()),
FileException: (function() {
var namecodes = {
NOT_FOUND_ERR: 1,
SECURITY_ERR: 2,
ABORT_ERR: 3,
NOT_READABLE_ERR: 4,
ENCODING_ERR: 5,
NO_MODIFICATION_ALLOWED_ERR: 6,
INVALID_STATE_ERR: 7,
SYNTAX_ERR: 8
};
function FileException(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": FileException " + this.code;
}
Basic.extend(FileException, namecodes);
FileException.prototype = Error.prototype;
return FileException;
}()),
DOMException: (function() {
var namecodes = {
INDEX_SIZE_ERR: 1,
DOMSTRING_SIZE_ERR: 2,
HIERARCHY_REQUEST_ERR: 3,
WRONG_DOCUMENT_ERR: 4,
INVALID_CHARACTER_ERR: 5,
NO_DATA_ALLOWED_ERR: 6,
NO_MODIFICATION_ALLOWED_ERR: 7,
NOT_FOUND_ERR: 8,
NOT_SUPPORTED_ERR: 9,
INUSE_ATTRIBUTE_ERR: 10,
INVALID_STATE_ERR: 11,
SYNTAX_ERR: 12,
INVALID_MODIFICATION_ERR: 13,
NAMESPACE_ERR: 14,
INVALID_ACCESS_ERR: 15,
VALIDATION_ERR: 16,
TYPE_MISMATCH_ERR: 17,
SECURITY_ERR: 18,
NETWORK_ERR: 19,
ABORT_ERR: 20,
URL_MISMATCH_ERR: 21,
QUOTA_EXCEEDED_ERR: 22,
TIMEOUT_ERR: 23,
INVALID_NODE_TYPE_ERR: 24,
DATA_CLONE_ERR: 25
};
function DOMException(code) {
this.code = code;
this.name = _findKey(namecodes, code);
this.message = this.name + ": DOMException " + this.code;
}
Basic.extend(DOMException, namecodes);
DOMException.prototype = Error.prototype;
return DOMException;
}()),
EventException: (function() {
function EventException(code) {
this.code = code;
this.name = 'EventException';
}
Basic.extend(EventException, {
UNSPECIFIED_EVENT_TYPE_ERR: 0
});
EventException.prototype = Error.prototype;
return EventException;
}())
};
});
// Included from: src/javascript/core/EventTarget.js
/**
* EventTarget.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/EventTarget', [
'moxie/core/Exceptions',
'moxie/core/utils/Basic'
], function(x, Basic) {
/**
Parent object for all event dispatching components and objects
@class EventTarget
@constructor EventTarget
*/
function EventTarget() {
// hash of event listeners by object uid
var eventpool = {};
Basic.extend(this, {
/**
Unique id of the event dispatcher, usually overriden by children
@property uid
@type String
*/
uid: null,
/**
Can be called from within a child in order to acquire uniqie id in automated manner
@method init
*/
init: function() {
if (!this.uid) {
this.uid = Basic.guid('uid_');
}
},
/**
Register a handler to a specific event dispatched by the object
@method addEventListener
@param {String} type Type or basically a name of the event to subscribe to
@param {Function} fn Callback function that will be called when event happens
@param {Number} [priority=0] Priority of the event handler - handlers with higher priorities will be called first
@param {Object} [scope=this] A scope to invoke event handler in
*/
addEventListener: function(type, fn, priority, scope) {
var self = this, list;
type = Basic.trim(type);
if (/\s/.test(type)) {
// multiple event types were passed for one handler
Basic.each(type.split(/\s+/), function(type) {
self.addEventListener(type, fn, priority, scope);
});
return;
}
type = type.toLowerCase();
priority = parseInt(priority, 10) || 0;
list = eventpool[this.uid] && eventpool[this.uid][type] || [];
list.push({fn : fn, priority : priority, scope : scope || this});
if (!eventpool[this.uid]) {
eventpool[this.uid] = {};
}
eventpool[this.uid][type] = list;
},
/**
Check if any handlers were registered to the specified event
@method hasEventListener
@param {String} type Type or basically a name of the event to check
@return {Mixed} Returns a handler if it was found and false, if - not
*/
hasEventListener: function(type) {
return type ? !!(eventpool[this.uid] && eventpool[this.uid][type]) : !!eventpool[this.uid];
},
/**
Unregister the handler from the event, or if former was not specified - unregister all handlers
@method removeEventListener
@param {String} type Type or basically a name of the event
@param {Function} [fn] Handler to unregister
*/
removeEventListener: function(type, fn) {
type = type.toLowerCase();
var list = eventpool[this.uid] && eventpool[this.uid][type], i;
if (list) {
if (fn) {
for (i = list.length - 1; i >= 0; i--) {
if (list[i].fn === fn) {
list.splice(i, 1);
break;
}
}
} else {
list = [];
}
// delete event list if it has become empty
if (!list.length) {
delete eventpool[this.uid][type];
// and object specific entry in a hash if it has no more listeners attached
if (Basic.isEmptyObj(eventpool[this.uid])) {
delete eventpool[this.uid];
}
}
}
},
/**
Remove all event handlers from the object
@method removeAllEventListeners
*/
removeAllEventListeners: function() {
if (eventpool[this.uid]) {
delete eventpool[this.uid];
}
},
/**
Dispatch the event
@method dispatchEvent
@param {String/Object} Type of event or event object to dispatch
@param {Mixed} [...] Variable number of arguments to be passed to a handlers
@return {Boolean} true by default and false if any handler returned false
*/
dispatchEvent: function(type) {
var uid, list, args, tmpEvt, evt = {}, result = true, undef;
if (Basic.typeOf(type) !== 'string') {
// we can't use original object directly (because of Silverlight)
tmpEvt = type;
if (Basic.typeOf(tmpEvt.type) === 'string') {
type = tmpEvt.type;
if (tmpEvt.total !== undef && tmpEvt.loaded !== undef) { // progress event
evt.total = tmpEvt.total;
evt.loaded = tmpEvt.loaded;
}
evt.async = tmpEvt.async || false;
} else {
throw new x.EventException(x.EventException.UNSPECIFIED_EVENT_TYPE_ERR);
}
}
// check if event is meant to be dispatched on an object having specific uid
if (type.indexOf('::') !== -1) {
(function(arr) {
uid = arr[0];
type = arr[1];
}(type.split('::')));
} else {
uid = this.uid;
}
type = type.toLowerCase();
list = eventpool[uid] && eventpool[uid][type];
if (list) {
// sort event list by prority
list.sort(function(a, b) { return b.priority - a.priority; });
args = [].slice.call(arguments);
// first argument will be pseudo-event object
args.shift();
evt.type = type;
args.unshift(evt);
// Dispatch event to all listeners
var queue = [];
Basic.each(list, function(handler) {
// explicitly set the target, otherwise events fired from shims do not get it
args[0].target = handler.scope;
// if event is marked as async, detach the handler
if (evt.async) {
queue.push(function(cb) {
setTimeout(function() {
cb(handler.fn.apply(handler.scope, args) === false);
}, 1);
});
} else {
queue.push(function(cb) {
cb(handler.fn.apply(handler.scope, args) === false); // if handler returns false stop propagation
});
}
});
if (queue.length) {
Basic.inSeries(queue, function(err) {
result = !err;
});
}
}
return result;
},
/**
Alias for addEventListener
@method bind
@protected
*/
bind: function() {
this.addEventListener.apply(this, arguments);
},
/**
Alias for removeEventListener
@method unbind
@protected
*/
unbind: function() {
this.removeEventListener.apply(this, arguments);
},
/**
Alias for removeAllEventListeners
@method unbindAll
@protected
*/
unbindAll: function() {
this.removeAllEventListeners.apply(this, arguments);
},
/**
Alias for dispatchEvent
@method trigger
@protected
*/
trigger: function() {
return this.dispatchEvent.apply(this, arguments);
},
/**
Converts properties of on[event] type to corresponding event handlers,
is used to avoid extra hassle around the process of calling them back
@method convertEventPropsToHandlers
@private
*/
convertEventPropsToHandlers: function(handlers) {
var h;
if (Basic.typeOf(handlers) !== 'array') {
handlers = [handlers];
}
for (var i = 0; i < handlers.length; i++) {
h = 'on' + handlers[i];
if (Basic.typeOf(this[h]) === 'function') {
this.addEventListener(handlers[i], this[h]);
} else if (Basic.typeOf(this[h]) === 'undefined') {
this[h] = null; // object must have defined event properties, even if it doesn't make use of them
}
}
}
});
}
EventTarget.instance = new EventTarget();
return EventTarget;
});
// Included from: src/javascript/core/utils/Encode.js
/**
* Encode.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/core/utils/Encode', [], function() {
/**
Encode string with UTF-8
@method utf8_encode
@for Utils
@static
@param {String} str String to encode
@return {String} UTF-8 encoded string
*/
var utf8_encode = function(str) {
return unescape(encodeURIComponent(str));
};
/**
Decode UTF-8 encoded string
@method utf8_decode
@static
@param {String} str String to decode
@return {String} Decoded string
*/
var utf8_decode = function(str_data) {
return decodeURIComponent(escape(str_data));
};
/**
Decode Base64 encoded string (uses browser's default method if available),
from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_decode.js
@method atob
@static
@param {String} data String to decode
@return {String} Decoded string
*/
var atob = function(data, utf8) {
if (typeof(window.atob) === 'function') {
return utf8 ? utf8_decode(window.atob(data)) : window.atob(data);
}
// http://kevin.vanzonneveld.net
// + original by: Tyler Akins (http://rumkin.com)
// + improved by: Thunder.m
// + input by: Aman Gupta
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Onno Marsman
// + bugfixed by: Pellentesque Malesuada
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// * example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
// * returns 1: 'Kevin van Zonneveld'
// mozilla has this native
// - but breaks in 2.0.0.12!
//if (typeof this.window.atob == 'function') {
// return atob(data);
//}
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
ac = 0,
dec = "",
tmp_arr = [];
if (!data) {
return data;
}
data += '';
do { // unpack four hexets into three octets using index points in b64
h1 = b64.indexOf(data.charAt(i++));
h2 = b64.indexOf(data.charAt(i++));
h3 = b64.indexOf(data.charAt(i++));
h4 = b64.indexOf(data.charAt(i++));
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
o1 = bits >> 16 & 0xff;
o2 = bits >> 8 & 0xff;
o3 = bits & 0xff;
if (h3 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1);
} else if (h4 == 64) {
tmp_arr[ac++] = String.fromCharCode(o1, o2);
} else {
tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
}
} while (i < data.length);
dec = tmp_arr.join('');
return utf8 ? utf8_decode(dec) : dec;
};
/**
Base64 encode string (uses browser's default method if available),
from: https://raw.github.com/kvz/phpjs/master/functions/url/base64_encode.js
@method btoa
@static
@param {String} data String to encode
@return {String} Base64 encoded string
*/
var btoa = function(data, utf8) {
if (utf8) {
utf8_encode(data);
}
if (typeof(window.btoa) === 'function') {
return window.btoa(data);
}
// http://kevin.vanzonneveld.net
// + original by: Tyler Akins (http://rumkin.com)
// + improved by: Bayron Guevara
// + improved by: Thunder.m
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Pellentesque Malesuada
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Rafał Kukawski (http://kukawski.pl)
// * example 1: base64_encode('Kevin van Zonneveld');
// * returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
// mozilla has this native
// - but breaks in 2.0.0.12!
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
ac = 0,
enc = "",
tmp_arr = [];
if (!data) {
return data;
}
do { // pack three octets into four hexets
o1 = data.charCodeAt(i++);
o2 = data.charCodeAt(i++);
o3 = data.charCodeAt(i++);
bits = o1 << 16 | o2 << 8 | o3;
h1 = bits >> 18 & 0x3f;
h2 = bits >> 12 & 0x3f;
h3 = bits >> 6 & 0x3f;
h4 = bits & 0x3f;
// use hexets to index into b64, and append result to encoded string
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
} while (i < data.length);
enc = tmp_arr.join('');
var r = data.length % 3;
return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
};
return {
utf8_encode: utf8_encode,
utf8_decode: utf8_decode,
atob: atob,
btoa: btoa
};
});
// Included from: src/javascript/runtime/Runtime.js
/**
* Runtime.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/runtime/Runtime', [
"moxie/core/utils/Basic",
"moxie/core/utils/Dom",
"moxie/core/EventTarget"
], function(Basic, Dom, EventTarget) {
var runtimeConstructors = {}, runtimes = {};
/**
Common set of methods and properties for every runtime instance
@class Runtime
@param {Object} options
@param {String} type Sanitized name of the runtime
@param {Object} [caps] Set of capabilities that differentiate specified runtime
@param {Object} [modeCaps] Set of capabilities that do require specific operational mode
@param {String} [preferredMode='browser'] Preferred operational mode to choose if no required capabilities were requested
*/
function Runtime(options, type, caps, modeCaps, preferredMode) {
/**
Dispatched when runtime is initialized and ready.
Results in RuntimeInit on a connected component.
@event Init
*/
/**
Dispatched when runtime fails to initialize.
Results in RuntimeError on a connected component.
@event Error
*/
var self = this
, _shim
, _uid = Basic.guid(type + '_')
, defaultMode = preferredMode || 'browser'
;
options = options || {};
// register runtime in private hash
runtimes[_uid] = this;
/**
Default set of capabilities, which can be redifined later by specific runtime
@private
@property caps
@type Object
*/
caps = Basic.extend({
// Runtime can:
// provide access to raw binary data of the file
access_binary: false,
// provide access to raw binary data of the image (image extension is optional)
access_image_binary: false,
// display binary data as thumbs for example
display_media: false,
// make cross-domain requests
do_cors: false,
// accept files dragged and dropped from the desktop
drag_and_drop: false,
// filter files in selection dialog by their extensions
filter_by_extension: true,
// resize image (and manipulate it raw data of any file in general)
resize_image: false,
// periodically report how many bytes of total in the file were uploaded (loaded)
report_upload_progress: false,
// provide access to the headers of http response
return_response_headers: false,
// support response of specific type, which should be passed as an argument
// e.g. runtime.can('return_response_type', 'blob')
return_response_type: false,
// return http status code of the response
return_status_code: true,
// send custom http header with the request
send_custom_headers: false,
// pick up the files from a dialog
select_file: false,
// select whole folder in file browse dialog
select_folder: false,
// select multiple files at once in file browse dialog
select_multiple: true,
// send raw binary data, that is generated after image resizing or manipulation of other kind
send_binary_string: false,
// send cookies with http request and therefore retain session
send_browser_cookies: true,
// send data formatted as multipart/form-data
send_multipart: true,
// slice the file or blob to smaller parts
slice_blob: false,
// upload file without preloading it to memory, stream it out directly from disk
stream_upload: false,
// programmatically trigger file browse dialog
summon_file_dialog: false,
// upload file of specific size, size should be passed as argument
// e.g. runtime.can('upload_filesize', '500mb')
upload_filesize: true,
// initiate http request with specific http method, method should be passed as argument
// e.g. runtime.can('use_http_method', 'put')
use_http_method: true
}, caps);
// default to the mode that is compatible with preferred caps
if (options.preferred_caps) {
defaultMode = Runtime.getMode(modeCaps, options.preferred_caps, defaultMode);
}
// small extension factory here (is meant to be extended with actual extensions constructors)
_shim = (function() {
var objpool = {};
return {
exec: function(uid, comp, fn, args) {
if (_shim[comp]) {
if (!objpool[uid]) {
objpool[uid] = {
context: this,
instance: new _shim[comp]()
};
}
if (objpool[uid].instance[fn]) {
return objpool[uid].instance[fn].apply(this, args);
}
}
},
removeInstance: function(uid) {
delete objpool[uid];
},
removeAllInstances: function() {
var self = this;
Basic.each(objpool, function(obj, uid) {
if (Basic.typeOf(obj.instance.destroy) === 'function') {
obj.instance.destroy.call(obj.context);
}
self.removeInstance(uid);
});
}
};
}());
// public methods
Basic.extend(this, {
/**
Specifies whether runtime instance was initialized or not
@property initialized
@type {Boolean}
@default false
*/
initialized: false, // shims require this flag to stop initialization retries
/**
Unique ID of the runtime
@property uid
@type {String}
*/
uid: _uid,
/**
Runtime type (e.g. flash, html5, etc)
@property type
@type {String}
*/
type: type,
/**
Runtime (not native one) may operate in browser or client mode.
@property mode
@private
@type {String|Boolean} current mode or false, if none possible
*/
mode: Runtime.getMode(modeCaps, (options.required_caps), defaultMode),
/**
id of the DOM container for the runtime (if available)
@property shimid
@type {String}
*/
shimid: _uid + '_container',
/**
Number of connected clients. If equal to zero, runtime can be destroyed
@property clients
@type {Number}
*/
clients: 0,
/**
Runtime initialization options
@property options
@type {Object}
*/
options: options,
/**
Checks if the runtime has specific capability
@method can
@param {String} cap Name of capability to check
@param {Mixed} [value] If passed, capability should somehow correlate to the value
@param {Object} [refCaps] Set of capabilities to check the specified cap against (defaults to internal set)
@return {Boolean} true if runtime has such capability and false, if - not
*/
can: function(cap, value) {
var refCaps = arguments[2] || caps;
// if cap var is a comma-separated list of caps, convert it to object (key/value)
if (Basic.typeOf(cap) === 'string' && Basic.typeOf(value) === 'undefined') {
cap = Runtime.parseCaps(cap);
}
if (Basic.typeOf(cap) === 'object') {
for (var key in cap) {
if (!this.can(key, cap[key], refCaps)) {
return false;
}
}
return true;
}
// check the individual cap
if (Basic.typeOf(refCaps[cap]) === 'function') {
return refCaps[cap].call(this, value);
} else {
return (value === refCaps[cap]);
}
},
/**
Returns container for the runtime as DOM element
@method getShimContainer
@return {DOMElement}
*/
getShimContainer: function() {
var container, shimContainer = Dom.get(this.shimid);
// if no container for shim, create one
if (!shimContainer) {
container = this.options.container ? Dom.get(this.options.container) : document.body;
// create shim container and insert it at an absolute position into the outer container
shimContainer = document.createElement('div');
shimContainer.id = this.shimid;
shimContainer.className = 'moxie-shim moxie-shim-' + this.type;
Basic.extend(shimContainer.style, {
position: 'absolute',
top: '0px',
left: '0px',
width: '1px',
height: '1px',
overflow: 'hidden'
});
container.appendChild(shimContainer);
container = null;
}
return shimContainer;
},
/**
Returns runtime as DOM element (if appropriate)
@method getShim
@return {DOMElement}
*/
getShim: function() {
return _shim;
},
/**
Invokes a method within the runtime itself (might differ across the runtimes)
@method shimExec
@param {Mixed} []
@protected
@return {Mixed} Depends on the action and component
*/
shimExec: function(component, action) {
var args = [].slice.call(arguments, 2);
return self.getShim().exec.call(this, this.uid, component, action, args);
},
/**
Operaional interface that is used by components to invoke specific actions on the runtime
(is invoked in the scope of component)
@method exec
@param {Mixed} []*
@protected
@return {Mixed} Depends on the action and component
*/
exec: function(component, action) { // this is called in the context of component, not runtime
var args = [].slice.call(arguments, 2);
if (self[component] && self[component][action]) {
return self[component][action].apply(this, args);
}
return self.shimExec.apply(this, arguments);
},
/**
Destroys the runtime (removes all events and deletes DOM structures)
@method destroy
*/
destroy: function() {
if (!self) {
return; // obviously already destroyed
}
var shimContainer = Dom.get(this.shimid);
if (shimContainer) {
shimContainer.parentNode.removeChild(shimContainer);
}
if (_shim) {
_shim.removeAllInstances();
}
this.unbindAll();
delete runtimes[this.uid];
this.uid = null; // mark this runtime as destroyed
_uid = self = _shim = shimContainer = null;
}
});
// once we got the mode, test against all caps
if (this.mode && options.required_caps && !this.can(options.required_caps)) {
this.mode = false;
}
}
/**
Default order to try different runtime types
@property order
@type String
@static
*/
Runtime.order = 'html5,flash,silverlight,html4';
/**
Retrieves runtime from private hash by it's uid
@method getRuntime
@private
@static
@param {String} uid Unique identifier of the runtime
@return {Runtime|Boolean} Returns runtime, if it exists and false, if - not
*/
Runtime.getRuntime = function(uid) {
return runtimes[uid] ? runtimes[uid] : false;
};
/**
Register constructor for the Runtime of new (or perhaps modified) type
@method addConstructor
@static
@param {String} type Runtime type (e.g. flash, html5, etc)
@param {Function} construct Constructor for the Runtime type
*/
Runtime.addConstructor = function(type, constructor) {
constructor.prototype = EventTarget.instance;
runtimeConstructors[type] = constructor;
};
/**
Get the constructor for the specified type.
method getConstructor
@static
@param {String} type Runtime type (e.g. flash, html5, etc)
@return {Function} Constructor for the Runtime type
*/
Runtime.getConstructor = function(type) {
return runtimeConstructors[type] || null;
};
/**
Get info about the runtime (uid, type, capabilities)
@method getInfo
@static
@param {String} uid Unique identifier of the runtime
@return {Mixed} Info object or null if runtime doesn't exist
*/
Runtime.getInfo = function(uid) {
var runtime = Runtime.getRuntime(uid);
if (runtime) {
return {
uid: runtime.uid,
type: runtime.type,
mode: runtime.mode,
can: function() {
return runtime.can.apply(runtime, arguments);
}
};
}
return null;
};
/**
Convert caps represented by a comma-separated string to the object representation.
@method parseCaps
@static
@param {String} capStr Comma-separated list of capabilities
@return {Object}
*/
Runtime.parseCaps = function(capStr) {
var capObj = {};
if (Basic.typeOf(capStr) !== 'string') {
return capStr || {};
}
Basic.each(capStr.split(','), function(key) {
capObj[key] = true; // we assume it to be - true
});
return capObj;
};
/**
Test the specified runtime for specific capabilities.
@method can
@static
@param {String} type Runtime type (e.g. flash, html5, etc)
@param {String|Object} caps Set of capabilities to check
@return {Boolean} Result of the test
*/
Runtime.can = function(type, caps) {
var runtime
, constructor = Runtime.getConstructor(type)
, mode
;
if (constructor) {
runtime = new constructor({
required_caps: caps
});
mode = runtime.mode;
runtime.destroy();
return !!mode;
}
return false;
};
/**
Figure out a runtime that supports specified capabilities.
@method thatCan
@static
@param {String|Object} caps Set of capabilities to check
@param {String} [runtimeOrder] Comma-separated list of runtimes to check against
@return {String} Usable runtime identifier or null
*/
Runtime.thatCan = function(caps, runtimeOrder) {
var types = (runtimeOrder || Runtime.order).split(/\s*,\s*/);
for (var i in types) {
if (Runtime.can(types[i], caps)) {
return types[i];
}
}
return null;
};
/**
Figure out an operational mode for the specified set of capabilities.
@method getMode
@static
@param {Object} modeCaps Set of capabilities that depend on particular runtime mode
@param {Object} [requiredCaps] Supplied set of capabilities to find operational mode for
@param {String|Boolean} [defaultMode='browser'] Default mode to use
@return {String|Boolean} Compatible operational mode
*/
Runtime.getMode = function(modeCaps, requiredCaps, defaultMode) {
var mode = null;
if (Basic.typeOf(defaultMode) === 'undefined') { // only if not specified
defaultMode = 'browser';
}
if (requiredCaps && !Basic.isEmptyObj(modeCaps)) {
// loop over required caps and check if they do require the same mode
Basic.each(requiredCaps, function(value, cap) {
if (modeCaps.hasOwnProperty(cap)) {
var capMode = modeCaps[cap](value);
// make sure we always have an array
if (typeof(capMode) === 'string') {
capMode = [capMode];
}
if (!mode) {
mode = capMode;
} else if (!(mode = Basic.arrayIntersect(mode, capMode))) {
// if cap requires conflicting mode - runtime cannot fulfill required caps
return (mode = false);
}
}
});
if (mode) {
return Basic.inArray(defaultMode, mode) !== -1 ? defaultMode : mode[0];
} else if (mode === false) {
return false;
}
}
return defaultMode;
};
/**
Capability check that always returns true
@private
@static
@return {True}
*/
Runtime.capTrue = function() {
return true;
};
/**
Capability check that always returns false
@private
@static
@return {False}
*/
Runtime.capFalse = function() {
return false;
};
/**
Evaluate the expression to boolean value and create a function that always returns it.
@private
@static
@param {Mixed} expr Expression to evaluate
@return {Function} Function returning the result of evaluation
*/
Runtime.capTest = function(expr) {
return function() {
return !!expr;
};
};
return Runtime;
});
// Included from: src/javascript/runtime/RuntimeClient.js
/**
* RuntimeClient.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/runtime/RuntimeClient', [
'moxie/core/Exceptions',
'moxie/core/utils/Basic',
'moxie/runtime/Runtime'
], function(x, Basic, Runtime) {
/**
Set of methods and properties, required by a component to acquire ability to connect to a runtime
@class RuntimeClient
*/
return function RuntimeClient() {
var runtime;
Basic.extend(this, {
/**
Connects to the runtime specified by the options. Will either connect to existing runtime or create a new one.
Increments number of clients connected to the specified runtime.
@method connectRuntime
@param {Mixed} options Can be a runtme uid or a set of key-value pairs defining requirements and pre-requisites
*/
connectRuntime: function(options) {
var comp = this, ruid;
function initialize(items) {
var type, constructor;
// if we ran out of runtimes
if (!items.length) {
comp.trigger('RuntimeError', new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR));
runtime = null;
return;
}
type = items.shift();
constructor = Runtime.getConstructor(type);
if (!constructor) {
initialize(items);
return;
}
// try initializing the runtime
runtime = new constructor(options);
runtime.bind('Init', function() {
// mark runtime as initialized
runtime.initialized = true;
// jailbreak ...
setTimeout(function() {
runtime.clients++;
// this will be triggered on component
comp.trigger('RuntimeInit', runtime);
}, 1);
});
runtime.bind('Error', function() {
runtime.destroy(); // runtime cannot destroy itself from inside at a right moment, thus we do it here
initialize(items);
});
/*runtime.bind('Exception', function() { });*/
// check if runtime managed to pick-up operational mode
if (!runtime.mode) {
runtime.trigger('Error');
return;
}
runtime.init();
}
// check if a particular runtime was requested
if (Basic.typeOf(options) === 'string') {
ruid = options;
} else if (Basic.typeOf(options.ruid) === 'string') {
ruid = options.ruid;
}
if (ruid) {
runtime = Runtime.getRuntime(ruid);
if (runtime) {
runtime.clients++;
return runtime;
} else {
// there should be a runtime and there's none - weird case
throw new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR);
}
}
// initialize a fresh one, that fits runtime list and required features best
initialize((options.runtime_order || Runtime.order).split(/\s*,\s*/));
},
/**
Returns the runtime to which the client is currently connected.
@method getRuntime
@return {Runtime} Runtime or null if client is not connected
*/
getRuntime: function() {
if (runtime && runtime.uid) {
return runtime;
}
runtime = null; // make sure we do not leave zombies rambling around
return null;
},
/**
Disconnects from the runtime. Decrements number of clients connected to the specified runtime.
@method disconnectRuntime
*/
disconnectRuntime: function() {
if (runtime && --runtime.clients <= 0) {
runtime.destroy();
runtime = null;
}
}
});
};
});
// Included from: src/javascript/file/Blob.js
/**
* Blob.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/Blob', [
'moxie/core/utils/Basic',
'moxie/core/utils/Encode',
'moxie/runtime/RuntimeClient'
], function(Basic, Encode, RuntimeClient) {
var blobpool = {};
/**
@class Blob
@constructor
@param {String} ruid Unique id of the runtime, to which this blob belongs to
@param {Object} blob Object "Native" blob object, as it is represented in the runtime
*/
function Blob(ruid, blob) {
function _sliceDetached(start, end, type) {
var blob, data = blobpool[this.uid];
if (Basic.typeOf(data) !== 'string' || !data.length) {
return null; // or throw exception
}
blob = new Blob(null, {
type: type,
size: end - start
});
blob.detach(data.substr(start, blob.size));
return blob;
}
RuntimeClient.call(this);
if (ruid) {
this.connectRuntime(ruid);
}
if (!blob) {
blob = {};
} else if (Basic.typeOf(blob) === 'string') { // dataUrl or binary string
blob = { data: blob };
}
Basic.extend(this, {
/**
Unique id of the component
@property uid
@type {String}
*/
uid: blob.uid || Basic.guid('uid_'),
/**
Unique id of the connected runtime, if falsy, then runtime will have to be initialized
before this Blob can be used, modified or sent
@property ruid
@type {String}
*/
ruid: ruid,
/**
Size of blob
@property size
@type {Number}
@default 0
*/
size: blob.size || 0,
/**
Mime type of blob
@property type
@type {String}
@default ''
*/
type: blob.type || '',
/**
@method slice
@param {Number} [start=0]
*/
slice: function(start, end, type) {
if (this.isDetached()) {
return _sliceDetached.apply(this, arguments);
}
return this.getRuntime().exec.call(this, 'Blob', 'slice', this.getSource(), start, end, type);
},
/**
Returns "native" blob object (as it is represented in connected runtime) or null if not found
@method getSource
@return {Blob} Returns "native" blob object or null if not found
*/
getSource: function() {
if (!blobpool[this.uid]) {
return null;
}
return blobpool[this.uid];
},
/**
Detaches blob from any runtime that it depends on and initialize with standalone value
@method detach
@protected
@param {DOMString} [data=''] Standalone value
*/
detach: function(data) {
if (this.ruid) {
this.getRuntime().exec.call(this, 'Blob', 'destroy');
this.disconnectRuntime();
this.ruid = null;
}
data = data || '';
// if dataUrl, convert to binary string
var matches = data.match(/^data:([^;]*);base64,/);
if (matches) {
this.type = matches[1];
data = Encode.atob(data.substring(data.indexOf('base64,') + 7));
}
this.size = data.length;
blobpool[this.uid] = data;
},
/**
Checks if blob is standalone (detached of any runtime)
@method isDetached
@protected
@return {Boolean}
*/
isDetached: function() {
return !this.ruid && Basic.typeOf(blobpool[this.uid]) === 'string';
},
/**
Destroy Blob and free any resources it was using
@method destroy
*/
destroy: function() {
this.detach();
delete blobpool[this.uid];
}
});
if (blob.data) {
this.detach(blob.data); // auto-detach if payload has been passed
} else {
blobpool[this.uid] = blob;
}
}
return Blob;
});
// Included from: src/javascript/file/File.js
/**
* File.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/File', [
'moxie/core/utils/Basic',
'moxie/core/utils/Mime',
'moxie/file/Blob'
], function(Basic, Mime, Blob) {
/**
@class File
@extends Blob
@constructor
@param {String} ruid Unique id of the runtime, to which this blob belongs to
@param {Object} file Object "Native" file object, as it is represented in the runtime
*/
function File(ruid, file) {
var name, type;
if (!file) { // avoid extra errors in case we overlooked something
file = {};
}
// figure out the type
if (file.type && file.type !== '') {
type = file.type;
} else {
type = Mime.getFileMime(file.name);
}
// sanitize file name or generate new one
if (file.name) {
name = file.name.replace(/\\/g, '/');
name = name.substr(name.lastIndexOf('/') + 1);
} else {
var prefix = type.split('/')[0];
name = Basic.guid((prefix !== '' ? prefix : 'file') + '_');
if (Mime.extensions[type]) {
name += '.' + Mime.extensions[type][0]; // append proper extension if possible
}
}
Blob.apply(this, arguments);
Basic.extend(this, {
/**
File mime type
@property type
@type {String}
@default ''
*/
type: type || '',
/**
File name
@property name
@type {String}
@default UID
*/
name: name || Basic.guid('file_'),
/**
Date of last modification
@property lastModifiedDate
@type {String}
@default now
*/
lastModifiedDate: file.lastModifiedDate || (new Date()).toLocaleString() // Thu Aug 23 2012 19:40:00 GMT+0400 (GET)
});
}
File.prototype = Blob.prototype;
return File;
});
// Included from: src/javascript/file/FileInput.js
/**
* FileInput.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/FileInput', [
'moxie/core/utils/Basic',
'moxie/core/utils/Mime',
'moxie/core/utils/Dom',
'moxie/core/Exceptions',
'moxie/core/EventTarget',
'moxie/core/I18n',
'moxie/file/File',
'moxie/runtime/Runtime',
'moxie/runtime/RuntimeClient'
], function(Basic, Mime, Dom, x, EventTarget, I18n, File, Runtime, RuntimeClient) {
/**
Provides a convenient way to create cross-browser file-picker. Generates file selection dialog on click,
converts selected files to _File_ objects, to be used in conjunction with _Image_, preloaded in memory
with _FileReader_ or uploaded to a server through _XMLHttpRequest_.
@class FileInput
@constructor
@extends EventTarget
@uses RuntimeClient
@param {Object|String|DOMElement} options If options is string or node, argument is considered as _browse\_button_.
@param {String|DOMElement} options.browse_button DOM Element to turn into file picker.
@param {Array} [options.accept] Array of mime types to accept. By default accepts all.
@param {String} [options.file='file'] Name of the file field (not the filename).
@param {Boolean} [options.multiple=false] Enable selection of multiple files.
@param {Boolean} [options.directory=false] Turn file input into the folder input (cannot be both at the same time).
@param {String|DOMElement} [options.container] DOM Element to use as a container for file-picker. Defaults to parentNode
for _browse\_button_.
@param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support.
@example
<div id="container">
<a id="file-picker" href="javascript:;">Browse...</a>
</div>
<script>
var fileInput = new mOxie.FileInput({
browse_button: 'file-picker', // or document.getElementById('file-picker')
container: 'container',
accept: [
{title: "Image files", extensions: "jpg,gif,png"} // accept only images
],
multiple: true // allow multiple file selection
});
fileInput.onchange = function(e) {
// do something to files array
console.info(e.target.files); // or this.files or fileInput.files
};
fileInput.init(); // initialize
</script>
*/
var dispatches = [
/**
Dispatched when runtime is connected and file-picker is ready to be used.
@event ready
@param {Object} event
*/
'ready',
/**
Dispatched right after [ready](#event_ready) event, and whenever [refresh()](#method_refresh) is invoked.
Check [corresponding documentation entry](#method_refresh) for more info.
@event refresh
@param {Object} event
*/
/**
Dispatched when selection of files in the dialog is complete.
@event change
@param {Object} event
*/
'change',
'cancel', // TODO: might be useful
/**
Dispatched when mouse cursor enters file-picker area. Can be used to style element
accordingly.
@event mouseenter
@param {Object} event
*/
'mouseenter',
/**
Dispatched when mouse cursor leaves file-picker area. Can be used to style element
accordingly.
@event mouseleave
@param {Object} event
*/
'mouseleave',
/**
Dispatched when functional mouse button is pressed on top of file-picker area.
@event mousedown
@param {Object} event
*/
'mousedown',
/**
Dispatched when functional mouse button is released on top of file-picker area.
@event mouseup
@param {Object} event
*/
'mouseup'
];
function FileInput(options) {
var self = this,
container, browseButton, defaults;
// if flat argument passed it should be browse_button id
if (Basic.inArray(Basic.typeOf(options), ['string', 'node']) !== -1) {
options = { browse_button : options };
}
// this will help us to find proper default container
browseButton = Dom.get(options.browse_button);
if (!browseButton) {
// browse button is required
throw new x.DOMException(x.DOMException.NOT_FOUND_ERR);
}
// figure out the options
defaults = {
accept: [{
title: I18n.translate('All Files'),
extensions: '*'
}],
name: 'file',
multiple: false,
required_caps: false,
container: browseButton.parentNode || document.body
};
options = Basic.extend({}, defaults, options);
// convert to object representation
if (typeof(options.required_caps) === 'string') {
options.required_caps = Runtime.parseCaps(options.required_caps);
}
// normalize accept option (could be list of mime types or array of title/extensions pairs)
if (typeof(options.accept) === 'string') {
options.accept = Mime.mimes2extList(options.accept);
}
container = Dom.get(options.container);
// make sure we have container
if (!container) {
container = document.body;
}
// make container relative, if it's not
if (Dom.getStyle(container, 'position') === 'static') {
container.style.position = 'relative';
}
container = browseButton = null; // IE
RuntimeClient.call(self);
Basic.extend(self, {
/**
Unique id of the component
@property uid
@protected
@readOnly
@type {String}
@default UID
*/
uid: Basic.guid('uid_'),
/**
Unique id of the connected runtime, if any.
@property ruid
@protected
@type {String}
*/
ruid: null,
/**
Unique id of the runtime container. Useful to get hold of it for various manipulations.
@property shimid
@protected
@type {String}
*/
shimid: null,
/**
Array of selected mOxie.File objects
@property files
@type {Array}
@default null
*/
files: null,
/**
Initializes the file-picker, connects it to runtime and dispatches event ready when done.
@method init
*/
init: function() {
self.convertEventPropsToHandlers(dispatches);
self.bind('RuntimeInit', function(e, runtime) {
self.ruid = runtime.uid;
self.shimid = runtime.shimid;
self.bind("Ready", function() {
self.trigger("Refresh");
}, 999);
self.bind("Change", function() {
var files = runtime.exec.call(self, 'FileInput', 'getFiles');
self.files = [];
Basic.each(files, function(file) {
// ignore empty files (IE10 for example hangs if you try to send them via XHR)
if (file.size === 0) {
return true;
}
self.files.push(new File(self.ruid, file));
});
}, 999);
// re-position and resize shim container
self.bind('Refresh', function() {
var pos, size, browseButton, shimContainer;
browseButton = Dom.get(options.browse_button);
shimContainer = Dom.get(runtime.shimid); // do not use runtime.getShimContainer(), since it will create container if it doesn't exist
if (browseButton) {
pos = Dom.getPos(browseButton, Dom.get(options.container));
size = Dom.getSize(browseButton);
if (shimContainer) {
Basic.extend(shimContainer.style, {
top : pos.y + 'px',
left : pos.x + 'px',
width : size.w + 'px',
height : size.h + 'px'
});
}
}
shimContainer = browseButton = null;
});
runtime.exec.call(self, 'FileInput', 'init', options);
});
// runtime needs: options.required_features, options.runtime_order and options.container
self.connectRuntime(Basic.extend({}, options, {
required_caps: {
select_file: true
}
}));
},
/**
Disables file-picker element, so that it doesn't react to mouse clicks.
@method disable
@param {Boolean} [state=true] Disable component if - true, enable if - false
*/
disable: function(state) {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state);
}
},
/**
Reposition and resize dialog trigger to match the position and size of browse_button element.
@method refresh
*/
refresh: function() {
self.trigger("Refresh");
},
/**
Destroy component.
@method destroy
*/
destroy: function() {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileInput', 'destroy');
this.disconnectRuntime();
}
if (Basic.typeOf(this.files) === 'array') {
// no sense in leaving associated files behind
Basic.each(this.files, function(file) {
file.destroy();
});
}
this.files = null;
}
});
}
FileInput.prototype = EventTarget.instance;
return FileInput;
});
// Included from: src/javascript/file/FileDrop.js
/**
* FileDrop.js
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
define('moxie/file/FileDrop', [
'moxie/core/I18n',
'moxie/core/utils/Dom',
'moxie/core/Exceptions',
'moxie/core/utils/Basic',
'moxie/file/File',
'moxie/runtime/RuntimeClient',
'moxie/core/EventTarget',
'moxie/core/utils/Mime'
], function(I18n, Dom, x, Basic, File, RuntimeClient, EventTarget, Mime) {
/**
Turn arbitrary DOM element to a drop zone accepting files. Converts selected files to _File_ objects, to be used
in conjunction with _Image_, preloaded in memory with _FileReader_ or uploaded to a server through
_XMLHttpRequest_.
@example
<div id="drop_zone">
Drop files here
</div>
<br />
<div id="filelist"></div>
<script type="text/javascript">
var fileDrop = new mOxie.FileDrop('drop_zone'), fileList = mOxie.get('filelist');
fileDrop.ondrop = function() {
mOxie.each(this.files, function(file) {
fileList.innerHTML += '<div>' + file.name + '</div>';
});
};
fileDrop.init();
</script>
@class FileDrop
@constructor
@extends EventTarget
@uses RuntimeClient
@param {Object|String} options If options has typeof string, argument is considered as options.drop_zone
@param {String|DOMElement} options.drop_zone DOM Element to turn into a drop zone
@param {Array} [options.accept] Array of mime types to accept. By default accepts all
@param {Object|String} [options.required_caps] Set of required capabilities, that chosen runtime must support
*/
var dispatches = [
/**
Dispatched when runtime is connected and drop zone is ready to accept files.
@event ready
@param {Object} event
*/
'ready',
/**
Dispatched when dragging cursor enters the drop zone.
@event dragenter
@param {Object} event
*/
'dragenter',
/**
Dispatched when dragging cursor leaves the drop zone.
@event dragleave
@param {Object} event
*/
'dragleave',
/**
Dispatched when file is dropped onto the drop zone.
@event drop
@param {Object} event
*/
'drop',
/**
Dispatched if error occurs.
@event error
@param {Object} event
*/
'error'
];
function FileDrop(options) {
var self = this, defaults;
// if flat argument passed it should be drop_zone id
if (typeof(options) === 'string') {
options = { drop_zone : options };
}
// figure out the options
defaults = {
accept: [{
title: I18n.translate('All Files'),
extensions: '*'
}],
required_caps: {
drag_and_drop: true
}
};
options = typeof(options) === 'object' ? Basic.extend({}, defaults, options) : defaults;
// this will help us to find proper default container
options.container = Dom.get(options.drop_zone) || document.body;
// make container relative, if it is not
if (Dom.getStyle(options.container, 'position') === 'static') {
options.container.style.position = 'relative';
}
// normalize accept option (could be list of mime types or array of title/extensions pairs)
if (typeof(options.accept) === 'string') {
options.accept = Mime.mimes2extList(options.accept);
}
RuntimeClient.call(self);
Basic.extend(self, {
uid: Basic.guid('uid_'),
ruid: null,
files: null,
init: function() {
self.convertEventPropsToHandlers(dispatches);
self.bind('RuntimeInit', function(e, runtime) {
self.ruid = runtime.uid;
self.bind("Drop", function() {
var files = runtime.exec.call(self, 'FileDrop', 'getFiles');
self.files = [];
Basic.each(files, function(file) {
self.files.push(new File(self.ruid, file));
});
}, 999);
runtime.exec.call(self, 'FileDrop', 'init', options);
self.dispatchEvent('ready');
});
// runtime needs: options.required_features, options.runtime_order and options.container
self.connectRuntime(options); // throws RuntimeError
},
destroy: function() {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileDrop', 'destroy');
this.disconnectRuntime();
}
this.files = null;
}
});
}
FileDrop.prototype = EventTarget.instance;
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment