tiny-slitaz view qrcode.min.js @ rev 34

index.php: no more embedded filesystem
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Feb 28 18:38:34 2020 +0100 (2020-02-28)
parents
children
line source
1 var QRCode=(function(){var V=[null,[[10,7,17,13],[1,1,1,1],[]],[[16,10,28,22],[1,1,1,1],[4,16]],[[26,15,22,18],[1,1,2,2],[4,20]],[[18,20,16,26],[2,1,4,2],[4,24]],[[24,26,22,18],[2,1,4,4],[4,28]],[[16,18,28,24],[4,2,4,4],[4,32]],[[18,20,26,18],[4,2,5,6],[4,20,36]],[[22,24,26,22],[4,2,6,6],[4,22,40]],[[22,30,24,20],[5,2,8,8],[4,24,44]],[[26,18,28,24],[5,4,8,8],[4,26,48]],[[30,20,24,28],[5,4,11,8],[4,28,52]],[[22,24,28,26],[8,4,11,10],[4,30,56]],[[22,26,22,24],[9,4,16,12],[4,32,60]],[[24,30,24,20],[9,4,16,16],[4,24,44,64]],[[24,22,24,30],[10,6,18,12],[4,24,46,68]],[[28,24,30,24],[10,6,16,17],[4,24,48,72]],[[28,28,28,28],[11,6,19,16],[4,28,52,76]],[[26,30,28,28],[13,6,21,18],[4,28,54,80]],[[26,28,26,26],[14,7,25,21],[4,28,56,84]],[[26,28,28,30],[16,8,25,20],[4,32,60,88]],[[26,28,30,28],[17,8,25,23],[4,26,48,70,92]],[[28,28,24,30],[17,9,34,23],[4,24,48,72,96]],[[28,30,30,30],[18,9,30,25],[4,28,52,76,100]],[[28,30,30,30],[20,10,32,27],[4,26,52,78,104]],[[28,26,30,30],[21,12,35,29],[4,30,56,82,108]],[[28,28,30,28],[23,12,37,34],[4,28,56,84,112]],[[28,30,30,30],[25,12,40,34],[4,32,60,88,116]],[[28,30,30,30],[26,13,42,35],[4,24,48,72,96,120]],[[28,30,30,30],[28,14,45,38],[4,28,52,76,100,124]],[[28,30,30,30],[29,15,48,40],[4,24,50,76,102,128]],[[28,30,30,30],[31,16,51,43],[4,28,54,80,106,132]],[[28,30,30,30],[33,17,54,45],[4,32,58,84,110,136]],[[28,30,30,30],[35,18,57,48],[4,28,56,84,112,140]],[[28,30,30,30],[37,19,60,51],[4,32,60,88,116,144]],[[28,30,30,30],[38,19,63,53],[4,28,52,76,100,124,148]],[[28,30,30,30],[40,20,66,56],[4,22,48,74,100,126,152]],[[28,30,30,30],[43,21,70,59],[4,26,52,78,104,130,156]],[[28,30,30,30],[45,22,74,62],[4,30,56,82,108,134,160]],[[28,30,30,30],[47,24,77,65],[4,24,52,80,108,136,164]],[[28,30,30,30],[49,25,81,68],[4,28,56,84,112,140,168]]];var l=0;var o=1,U=2,R=4,y=8;var G=/^\d*$/;var E=/^[A-Za-z0-9 $%*+\-./:]*$/;var t=/^[A-Z0-9 $%*+\-./:]*$/;var h=1,g=0,c=3,n=2;var B=[],Q=[-1];for(var P=0,H=1;P<255;++P){B.push(H);Q[H]=P;H=(H*2)^(H>=128?285:0)}var m=[[]];for(var P=0;P<30;++P){var D=m[P],F=[];for(var O=0;O<=P;++O){var T=(O<P?B[D[O]]:0);var S=B[(P+(D[O-1]||0))%255];F.push(Q[T^S])}m.push(F)}var q={};for(var P=0;P<45;++P){q["0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".charAt(P)]=P}var J=[function(b,a){return(b+a)%2==0},function(b,a){return b%2==0},function(b,a){return a%3==0},function(b,a){return(b+a)%3==0},function(b,a){return(((b/2)|0)+((a/3)|0))%2==0},function(b,a){return(b*a)%2+(b*a)%3==0},function(b,a){return((b*a)%2+(b*a)%3)%2==0},function(b,a){return((b+a)%2+(b*a)%3)%2==0}];var f=function(a){return a>6};var x=function(a){return 4*a+17};var u=function(a){var b=V[a];var i=16*a*a+128*a+64;if(f(a)){i-=36}if(b[2].length){i-=25*b[2].length*b[2].length-10*b[2].length-55}return i};var p=function(a,b){var j=u(a)&~7;var i=V[a];j-=8*i[0][b]*i[1][b];return j};var A=function(a,b){switch(b){case o:return(a<10?10:a<27?12:14);case U:return(a<10?9:a<27?11:13);case R:return(a<10?8:16);case y:return(a<10?8:a<27?10:12)}};var z=function(a,j,b){var i=p(a,b)-4-A(a,j);switch(j){case o:return((i/10)|0)*3+(i%10<4?0:i%10<7?1:2);case U:return((i/11)|0)*2+(i%11<6?0:1);case R:return(i/8)|0;case y:return(i/13)|0}};var s=function(W,j){switch(W){case o:if(!j.match(G)){return null}return j;case U:if(!j.match(E)){return null}return j.toUpperCase();case R:if(typeof j==="string"){var v=[];for(var a=0;a<j.length;++a){var b=j.charCodeAt(a);if(b<128){v.push(b)}else{if(b<2048){v.push(192|(b>>6),128|(b&63))}else{if(b<65536){v.push(224|(b>>12),128|((b>>6)&63),128|(b&63))}else{v.push(240|(b>>18),128|((b>>12)&63),128|((b>>6)&63),128|(b&63))}}}}return v}else{return j}}};var k=function(aa,Y,X,Z){var b=[];var ac=0,v=8;var a=X.length;var ab=function(i,ad){if(ad>=v){b.push(ac|(i>>(ad-=v)));while(ad>=8){b.push((i>>(ad-=8))&255)}ac=0;v=8}if(ad>0){ac|=(i&((1<<ad)-1))<<(v-=ad)}};var j=A(aa,Y);ab(Y,4);ab(a,j);switch(Y){case o:for(var W=2;W<a;W+=3){ab(parseInt(X.substring(W-2,W+1),10),10)}ab(parseInt(X.substring(W-2),10),[0,4,7][a%3]);break;case U:for(var W=1;W<a;W+=2){ab(q[X.charAt(W-1)]*45+q[X.charAt(W)],11)}if(a%2==1){ab(q[X.charAt(W-1)],6)}break;case R:for(var W=0;W<a;++W){ab(X[W],8)}break}ab(l,4);if(v<8){b.push(ac)}while(b.length+1<Z){b.push(236,17)}if(b.length<Z){b.push(236)}return b};var C=function(Z,a){var b=Z.slice(0);var aa=Z.length,X=a.length;for(var W=0;W<X;++W){b.push(0)}for(var W=0;W<aa;){var Y=Q[b[W++]];if(Y>=0){for(var v=0;v<X;++v){b[W+v]^=B[(Y+a[v])%255]}}}return b.slice(aa)};var N=function(a,Y,b){var ae=[];var ab=(a.length/Y)|0,ac=0;var aa=Y-a.length%Y;for(var W=0;W<aa;++W){ae.push(ac);ac+=ab}for(var W=aa;W<Y;++W){ae.push(ac);ac+=ab+1}ae.push(ac);var Z=[];for(var W=0;W<Y;++W){Z.push(C(a.slice(ae[W],ae[W+1]),b))}var ad=[];var X=(a.length/Y)|0;for(var W=0;W<X;++W){for(var v=0;v<Y;++v){ad.push(a[ae[v]+W])}}for(var v=aa;v<Y;++v){ad.push(a[ae[v+1]-1])}for(var W=0;W<b.length;++W){for(var v=0;v<Y;++v){ad.push(Z[v][W])}}return ad};var M=function(W,X,a,v){var b=W<<v;for(var j=X-1;j>=0;--j){if((b>>(v+j))&1){b^=a<<j}}return(W<<v)|b};var I=function(af){var ah=V[af],X=x(af);var ag=[],W=[];for(var ad=0;ad<X;++ad){ag.push([]);W.push([])}var ab=function(an,v,al,ai,am){for(var ak=0;ak<al;++ak){for(var aj=0;aj<ai;++aj){ag[an+ak][v+aj]=(am[ak]>>aj)&1;W[an+ak][v+aj]=1}}};ab(0,0,9,9,[127,65,93,93,93,65,383,0,64]);ab(X-8,0,8,9,[256,127,65,93,93,93,65,127]);ab(0,X-8,9,8,[254,130,186,186,186,130,254,0,0]);for(var ad=9;ad<X-8;++ad){ag[6][ad]=ag[ad][6]=~ad&1;W[6][ad]=W[ad][6]=1}var b=ah[2],Y=b.length;for(var ad=0;ad<Y;++ad){var ae=(ad==0||ad==Y-1?1:0),Z=(ad==0?Y-1:Y);for(var ac=ae;ac<Z;++ac){ab(b[ad],b[ac],5,5,[31,17,21,17,31])}}if(f(af)){var a=M(af,6,7973,12);var aa=0;for(var ad=0;ad<6;++ad){for(var ac=0;ac<3;++ac){ag[ad][(X-11)+ac]=ag[(X-11)+ac][ad]=(a>>aa++)&1;W[ad][(X-11)+ac]=W[(X-11)+ac][ad]=1}}}return{matrix:ag,reserved:W}};var L=function(ab,b,a){var v=ab.length;var X=0,W=-1;for(var Z=v-1;Z>=0;Z-=2){if(Z==6){--Z}var aa=(W<0?v-1:0);for(var Y=0;Y<v;++Y){for(var ac=Z;ac>Z-2;--ac){if(!b[aa][ac]){ab[aa][ac]=(a[X>>3]>>(~X&7))&1;++X}}aa+=W}W=-W}return ab};var K=function(v,a,b){var X=J[b];var Z=v.length;for(var Y=0;Y<Z;++Y){for(var W=0;W<Z;++W){if(!a[Y][W]){v[Y][W]^=X(Y,W)}}}return v};var e=function(Z,v,b,aa){var W=Z.length;var j=M((b<<3)|aa,5,1335,10)^21522;for(var X=0;X<15;++X){var a=[0,1,2,3,4,5,7,8,W-7,W-6,W-5,W-4,W-3,W-2,W-1][X];var Y=[W-1,W-2,W-3,W-4,W-5,W-6,W-7,W-8,7,5,4,3,2,1,0][X];Z[a][8]=Z[8][Y]=(j>>X)&1}return Z};var w=function(ad){var Z=3;var ai=3;var af=40;var ag=10;var a=function(j){var al=0;for(var aj=0;aj<j.length;++aj){if(j[aj]>=5){al+=Z+(j[aj]-5)}}for(var aj=5;aj<j.length;aj+=2){var ak=j[aj];if(j[aj-1]==ak&&j[aj-2]==3*ak&&j[aj-3]==ak&&j[aj-4]==ak&&(j[aj-5]>=4*ak||j[aj+1]>=4*ak)){al+=af}}return al};var W=ad.length;var Y=0,X=0;for(var ac=0;ac<W;++ac){var ah=ad[ac];var v;v=[0];for(var ab=0;ab<W;){var aa;for(aa=0;ab<W&&ah[ab];++aa){++ab}v.push(aa);for(aa=0;ab<W&&!ah[ab];++aa){++ab}v.push(aa)}Y+=a(v);v=[0];for(var ab=0;ab<W;){var aa;for(aa=0;ab<W&&ad[ab][ac];++aa){++ab}v.push(aa);for(aa=0;ab<W&&!ad[ab][ac];++aa){++ab}v.push(aa)}Y+=a(v);var ae=ad[ac+1]||[];X+=ah[0];for(var ab=1;ab<W;++ab){var b=ah[ab];X+=b;if(ah[ab-1]==b&&ae[ab]===b&&ae[ab-1]===b){Y+=ai}}}Y+=ag*((Math.abs(X/W/W-0.5)/0.05)|0);return Y};var d=function(X,aa,Z,a,ad){var ac=V[aa];var i=k(aa,Z,X,p(aa,a)>>3);i=N(i,ac[1][a],m[ac[0][a]]);var ae=I(aa);var ab=ae.matrix,b=ae.reserved;L(ab,b,i);if(ad<0){K(ab,b,0);e(ab,b,a,0);var W=0,Y=w(ab);K(ab,b,0);for(ad=1;ad<8;++ad){K(ab,b,ad);e(ab,b,a,ad);var j=w(ab);if(Y>j){Y=j;W=ad}K(ab,b,ad)}ad=W}K(ab,b,ad);e(ab,b,a,ad);return ab};var r={generate:function(X,v){var W={numeric:o,alphanumeric:U,octet:R};var j={L:h,M:g,Q:c,H:n};v=v||{};var a=v.version||-1;var i=j[(v.ecclevel||"L").toUpperCase()];var Y=v.mode?W[v.mode.toLowerCase()]:-1;var b="mask" in v?v.mask:-1;if(Y<0){if(typeof X==="string"){if(X.match(G)){Y=o}else{if(X.match(t)){Y=U}else{Y=R}}}else{Y=R}}else{if(!(Y==o||Y==U||Y==R)){throw"invalid or unsupported mode"}}X=s(Y,X);if(X===null){throw"invalid data format"}if(i<0||i>3){throw"invalid ECC level"}if(a<0){for(a=1;a<=40;++a){if(X.length<=z(a,Y,i)){break}}if(a>40){throw"too large data"}}else{if(a<1||a>40){throw"invalid version"}}if(b!=-1&&(b<0||b>8)){throw"invalid mask"}return d(X,a,Y,i,b)},generatePNG:function(Z,ad){ad=ad||{};var ab=r.generate(Z,ad);var aa=Math.max(ad.modulesize||5,0.5);var W=Math.max(ad.margin||4,0);var v=ab.length;var ac=aa*(v+2*W);var b=document.createElement("canvas"),a;b.width=b.height=ac;a=b.getContext("2d");if(!a){throw"canvas support is needed for PNG output"}a.fillStyle="#fff";a.fillRect(0,0,ac,ac);a.fillStyle="#000";for(var Y=0;Y<v;++Y){for(var X=0;X<v;++X){if(ab[Y][X]){a.fillRect(aa*(W+X),aa*(W+Y),aa,aa)}}}return b.toDataURL()}};return r})();