Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

QRCodeGener

ator

I
ndex.
html
<!
DOCTYPEht
ml>

<ht
mlxml
ns="
htt
p:/
/www.
w3.
org/
1999/
xht
ml"
>

<head>

<met
aht
tp-
equi
v="
Cont
ent
-Ty
pe"cont
ent
="t
ext
/ht
ml;
char
set
=iso-
8859-
1"/
>

<t
it
le>QRCodeGener
ator
</t
it
le>

<st
yle>

#body
{

posi
ti
on:
absol
ute;

t
op:
0;l
eft
:0;

wi
dth:
100%;
hei
ght
:100%;

#t
it
le{

col
or:
#CCCCCC;

f
ont
-f
ami
l
y:Cal
i
bri
;

f
ont
-si
ze:
42px;

f
ont
-wei
ght
:bol
d;

mar
gin-
top:
100px;

mar
gin-
bot
tom:
100px;

#ar
ea1,
#ar
ea2{

wi
dth:
250px;
hei
ght
:250px;

bor
der
:doubl
e1px#FFFFFF;

bor
der
-r
adi
us:
12px;
bor
der
-wi
dth:
10px;

f
loat
:l
eft
;mar
gin-
lef
t:
20px;

#t
ext
{

wi
dth:
100%;
hei
ght
:100%;

backgr
ound-
col
or:
#FFFFFF;

bor
der
:none;
font
-f
ami
l
y:Cal
i
bri
;

f
ont
-si
ze:
14px;
bor
der
-r
adi
us:
05px5px5px;

#gener
ate{

paddi
ng:
10px;

bor
der
:sol
i
d2px#CCCCCC;

bor
der
-r
adi
us:
10px;

backgr
ound-
col
or:
#000000;

col
or:
#CCCCCC;
font
-si
ze:
24px;

f
ont
-f
ami
l
y:Cal
i
bri
;font
-wei
ght
:bol
d;

wi
dth:
270px;
cur
sor
:poi
nter
;

#qr
code{

backgr
ound-
col
or:
#FFFFFF;

hei
ght
:100%;
widt
h:100%;

#l
ayer
{

wi
dth:
600px;

</
sty
le>

</
head>
<bodybgcol
or="
#000000"
>

<di
vid="
body
"al
i
gn="
cent
er"
>

<di
vid="
ti
tl
e">QRCODE</
div
>

<di
vid="
lay
er"
>

<cent
er>

<p>

<di
vid="
area1"><text
areai
d="
text
"pl
acehol
der
="Ent
ery
ourt
ext
,li
nk,
promocode,
emai
lorcont
act
her
e..
."
></t
extarea></di
v>

</
p>

<p>

<di
vid="
area2"
><di
vid="
qrcode"
></
div
></
div
>

</
p>

</
div
>

</
div
>

<scr
iptsr
c="
qrcode.
js"
></
scr
ipt
>

<scr
iptsr
c="
scr
ipt
.j
s"></
scr
ipt
>

</
body
>

</
html
>

Qr
code.
js
varQRCode; !
funct i
on(){f
unct i
ona( a) {
this.mode=c. MODE_ 8BI T_BYTE, thi
s.data=a,thi
s.parsedDat a=[];
for(var
b=[],
d=0, e=this.data.
length;e>d;d++) {var
f=this.data.char CodeAt(d);
f>65536? (b[0]=240|(1835008&f )>>>18,b[1]=128| (
258048&f )>>>12,b[2]=128|(4032&f)
>>>6, b[3]
=128| 63&f )
:f>2048? (
b[0]=224| (61440&f )>>>12,b[
1]=128| (
4032&f )>>>6,
b[2]=128|63&f )
:f>128? (
b[0]=192
|
(1984&f )>>>6,b[1]=128|63&f):b[0]=f,t
his.parsedDat a=thi
s.parsedDat a.concat (
b)}t
his.parsedDat a.l
ength!=thi
s.d
ata.length&&( this.
parsedDat a.unshi ft
(191) ,
thi
s.par sedDat
a. unshif
t (
187) ,
this.
parsedDat a.unshi
f t(
239) )
}functi
on
b(a,b){this.t
ypeNumber =a,thi
s.error CorrectLevel=b,thi
s.modul es=null,
thi
s.modul eCount =0,thi
s.dataCache=nul l
,t
his.dataLi st
=[]}
functioni(a,b){
if(void0==a. length)thrownewEr r
or(a.l
ength+" /"
+b);
for(var
c=0;c<a. l
engt h&&0==a[ c];
)c++;this.num=newAr ray(a.l
ength-c+b);f
or (
vard=0; d<a.l
engt h-
c;d++) thi s.num[ d]=a[ d+c] }funct ionj (a,b) {this. tot alCount =a,t his. dat aCount =b} funct i
on
k(){thi s.buf fer =[],t
hi s.lengt h=0} funct ionm( ) {ret urn" undef i
ned" !=t y peofCanv asRender ingCont ext 2D} funct ion
n(){v ara=! 1,b=nav igat or .user Agent ;ret ur n/andr oid/ i.test (b) &&( a=! 0, aMat =b. toSt r i
ng( ).
mat ch( /andr oid( [0-9]
\ .[0-
9])/i),aMat &&aMat [1]&&( a=par seFl oat (aMat [1] ))),a} funct i
onr (a, b) {for (v ar
c=1, e=s( a) ,f=0, g=l .l
engt h; g>=f ;
f ++) {v arh=0; swi t
ch( b) {cased. L:h=l [f][0];br eak; cased. M: h=l[f
][1];break; case
d.Q: h=l [f][2];br eak; cased. H: h=l [f][3]}if(h>=e) br eak; c++} if(c>l .lengt h) thr ownewEr ror ("Tool ongdat a");
retur n
c}funct ions( a) {varb=encodeURI (a) .toSt ri
ng( ).repl ace( / \%[ 0-9a- fA- F]{2} /g, "a");ret urn
b.lengt h+( b.lengt h!=a? 3:0) } a.pr ot oty pe={ get Lengt h: funct ion( ){ret ur n
this.par sedDat a.lengt h} ,
wr i
t e:f unct ion( a) {for (v ar
b=0, c=t his. par sedDat a.lengt h; c>b; b++) a.put ( this.par sedDat a[ b],8) }} ,
b. pr otot ype={ addDat a:funct ion( b){var
c=new
a(b) ;this. dat aLi st .
push( c) ,this. dat aCache=nul l
} ,
isDar k: funct ion( a, b) {if(0>a| |this.modul eCount <=a| |0>b||this.mod
uleCount <=b) thr ownewEr ror (a+" ,"+b) ;
ret ur nt his.modul es[ a] [b] },
get Modul eCount :f
unct i
on( ){
ret ur n
this.modul eCount },
make: funct ion( ){t his. makeI mpl (!1, this.get Best MaskPat t
er n( ))},makeI mpl :funct i
on(a, c){t
hi s.
modul eCount =4* this. typeNumber +17, this.modul es=newAr ray (thi s.modul eCount );
for (var
d=0; d<t his. modul eCount ;d++) {thi s.modul es[ d] =newAr ray (thi s. modul eCount )
;for (v ar
e=0; e<t his. modul eCount ;
e++) thi s. modul es[ d][e] =nul l
} this.set upPosi tionPr obePat ter n(0,0),t
his. set upPosi ti
onPr
obePat ter n( this. modul eCount -7,0) ,this. set upPosi tionPr obePat t er n( 0,this. modul eCount -
7),this. set upPosi ti
onAdj ust Pat ter n( ),
t his. set upTi mi ngPat t
er n( ) ,
t his. set upTy peI nf o(a, c),
this.typeNumber >=7&&t
his.set upTy peNumber (a),nul l==t his.dat aCache&&( thi s. dat aCache=b. creat eDat a( this.typeNumber ,
this.errorCor r
ect Lev el,this. dat aLi st )),
thi s.mapDat a( thi s.dat aCache, c) }
,set upPosi tionPr obePat tern: function( a,b) {for(
v arc=-
1;7>=c; c++) i
f(!(-1>=a+c| |
thi s. modul eCount <=a+c) )for (v ard=- 1; 7>=d; d++) -
1>=b+d| |
thi s.modul eCount <=b+d| |(this. modul es[ a+c] [b+d] =c>=0&&6>=c&&( 0==d| |6==d) |
|d>=0&&6>=d&&( 0==c| |
6==c) ||c>=2&&4>=c&&d>=2&&4>=d? !
0: !1) },
get Best MaskPat t er n:f unct ion( ){for (v ar
a=0, b=0, c=0; 8>c; c++) {t
hi s.makeI mpl (!0, c);vard=f .get Lost Poi nt (thi s) ;
(0==c| |
a>d) &&( a=d, b=c) }retur n
b},creat eMov i
eCl i
p: funct ion( a,b, c) {vard=a. cr eat eEmpt y Mov ieCl ip( b,c) ,e=1; t
hi s.make( );
for(var
f=0; f<thi s.modul es. lengt h;f++) for (varg=f *e,h=0; h<t hi s. modul es[ f].lengt h;h++) {v ar
i
=h* e,j=t his. modul es[ f][h];j&&( d.begi nFi ll
(0,100) ,d.mov eTo( i,g) ,d. l
ineTo( i+e, g) ,
d. lineTo( i+e,g+e) ,d.lineTo( i,g+e),d.
endFi ll
( ))}ret urnd} ,set upTi mi ngPat ter n: funct ion( ){for (v ara=8; a<t hi s.modul eCount -
8;a++) nul l==t his.modul es[ a] [6] &&( this. modul es[ a][6] =0==a%2) ;for (v arb=8; b<t hi s.modul eCount -
8;b++) nul l
==t his. modul es[ 6] [b] &&( thi s.modul es[ 6] [
b] =0==b%2) },set upPosi t i
onAdj ust Pat tern:funct i
on( )
{ for(var
a=f .get Pat ter nPosi tion( thi s. ty peNumber ),
b=0; b<a. lengt h;b++) for ( varc=0; c<a. lengt h;c++) {var
d=a[ b] ,e=a[ c];if(null==t his. modul es[ d] [e] )for( varg=- 2; 2>=g; g++) for (v arh=- 2;2>=h; h++) this.modul es[ d+g] [e+h] =-
2==g| |2==g| |
-2==h| |
2==h| |0==g&&0==h? !0:!1} },set upTy peNumber :funct ion( a){for (v ar
b=f .get BCHTy peNumber (thi s. typeNumber ),c=0; 18>c; c++) {v ar
d=! a&&1==( 1&b>>c) ;
thi s.modul es[ Mat h.floor (c/ 3)][c%3+t hi s. modul eCount -8-3] =d} for(varc=0; 18>c; c++) {var
d=! a&&1==( 1&b>>c) ;
thi s.modul es[ c%3+t his. modul eCount -8-
3][Mat h. floor (c/ 3) ]=d} },set upTy peI nf o: funct ion( a,b) { for (var
c=t his. err orCor rect Lev el<<3| b,d=f .get BCHTy peI nfo( c) ,
e=0; 15>e; e++) {var
g=! a&&1==( 1&d>>e) ;
6>e? thi s.modul es[ e][8] =g: 8>e? t his. modul es[ e+1] [8] =g: this.modul es[this.modul eCount -
15+e] [8] =g} for (v are=0; 15>e; e++) { varg=! a&&1==( 1&d>>e) ;8>e? thi s.modul es[ 8][thi s.modul eCount -e-
1]=g: 9>e? this. modul es[ 8] [15- e-1+1] =g: thi s.modul es[ 8] [15-e- 1] =g} thi s.modul es[ thi s.modul eCount -
8][8]=! a} ,
mapDat a:f unct i
on( a, b) {for (v arc=- 1, d=t his.modul eCount -1,e=7, g=0, h=t hi s.modul eCount -1;h>0;h-
=2) for (6==h&&h- -;;
){f or(v ari =0; 2>i ;
i++) i
f (nul l
==t his. modul es[ d] [h-i]){ var
j
=! 1;g<a. lengt h&&( j=1==( 1&a[ g] >>>e) ) ;
v ark=f .get Mask( b,d,h- i);k&&( j=!j),this. modul es[ d][h-i
]=j,
e- -,
-
1==e&&( g++, e=7) }i
f(d+=c, 0>d| |this. modul eCount <=d) {d-=c, c=-
c;break} }}
},b.PAD0=236, b. PAD1=17, b.cr eat eDat a=f unct i
on( a,c,d) {
for (vare=j .get RSBl ocks( a,c) ,
g=new
k,h=0;h<d. lengt h;h++) {var
i
=d[ h];g.put (i.mode, 4) ,
g. put (i.
get Lengt h(),f.get Lengt hInBi ts( i.mode, a) ),
i
.wr ite( g)}for (v ar
l
=0, h=0; h<e. lengt h;h++) l+=e[ h].dat aCount ;i
f(g. get Lengt hInBi ts()>8* l)thrownewEr ror ("
codel engt hov erflow.
("+g.get Lengt hI nBi ts( )
+" >"+8* l
+" )");for (g.get Lengt hI nBi ts()+4<=8* l
&&g. put (0,4) ;
0! =g. get Lengt hInBi ts()%8; )g.put
Bit(!
1) ;
f or(;;
){if(g. get Lengt hInBi ts( )>=8* l)break; if(g. put (b.PAD0, 8) ,
g. getLengt hI nBi ts( )>=8* l
)break; g.put (b.PAD1,
8)}retur nb. cr eat eBy tes( g, e) },b.cr eat eBy tes=f unct ion( a,b) {for (varc=0, d=0, e=0, g=newAr ray (
b. lengt h),h=new
Ar r
ay (b.lengt h) ,
j=0; j
<b. lengt h;j++) {vark=b[ j].
dat aCount ,l=b[ j
].tot alCount -
k;d=Mat h.max( d,k),e=Mat h.max( e,l),
g[ j]
=newAr ray (k);for(v ar
m=0; m<g[ j]
.lengt h;m++) g[ j][m] =255&a. buf fer [m+c] ;c+=k; varn=f .get ErrorCor rect Pol y nomi al(l
) ,
o=new
i
(g[j],
n. get Lengt h( )-1),p=o. mod( n) ;
h[ j]
=newAr ray (n. get Lengt h()-1) ;
for (varm=0; m<h[ j].l
engt h;m++) {v ar
q=m+p. get Lengt h()-h[j].lengt h; h[j][m] =q>=0? p.get (q) :
0} }for (var
r=0,m=0; m<b. lengt h;m++) r+=b[ m] .tot alCount ;for(v ars=newAr r
ay (r) ,
t=0,m=0; d>m; m++) for(var
j
=0; j
<b. lengt h; j++) m<g[ j
].lengt h&&( s[ t++] =g[ j
][m] );
f or (
v arm=0; e>m; m++) for (var
j
=0; j
<b. lengt h; j++) m<h[ j
].lengt h&&( s[ t++] =h[ j
][m] );
r etur ns} ;
for (var
c={MODE_ NUMBER: 1,MODE_ ALPHA_ NUM: 2,MODE_ 8BI T_ BYTE: 4,MODE_ KANJI :8} ,
d={ L:1,M: 0,Q: 3,H: 2} ,
e={ PATT
ERN000: 0,PATTERN001: 1, PATTERN010: 2, PATTERN011: 3,PATTERN100: 4, PATTERN101: 5,PATTERN110: 6,PAT
TERN111: 7},f={ PATTERN_ POSI TI ON_ TABLE: [[]
,[6,18] ,[6,22] ,[6,26] ,
[6,30] ,
[6,34] ,[6,22, 38] ,[
6,24, 42] ,[
6, 26,46] ,
[6,28,5
0],[
6,30, 54] ,[
6, 32, 58] ,
[6,34, 62] ,[6,26, 46, 66] ,[6,26, 48, 70] ,[6,26, 50, 74] ,
[6,30, 54,78] ,[6,30, 56, 82] ,[
6,30, 58, 86] ,[6,34,62, 9
0],[
6,28, 50, 72, 94] ,[
6,26, 50, 74, 98] ,
[6,30, 54, 78, 102] ,[6,28, 54, 80, 106] ,
[6,32,58, 84, 110] ,
[6, 30,58, 86,114] ,[6,34, 62,90, 11
8],[
6,26, 50, 74, 98, 122] ,[6,30, 54, 78, 102, 126] ,
[6,26, 52, 78,104, 130] ,
[6,30, 56,82, 108, 134] ,
[6,34, 60,86, 112, 138] ,
[6,30,58,
86,114, 142] ,
[6, 34, 62,90, 118, 146] ,[6,30, 54, 78, 102, 126, 150] ,
[6, 24,50, 76, 102, 128, 154] ,[6,28, 54,80, 106, 132, 158] ,[6,3
2,58,84, 110, 136, 162] ,
[6, 26, 54, 82, 110, 138, 166] ,
[6,30, 58,86, 114, 142, 170] ],G15: 1335, G18: 7973, G15_ MASK: 21522,
getBCHTy peI nf o: f
unct ion( a) {for (varb=a<<10; f.
get BCHDi gi t(b) -
f.
get BCHDi gi t(f.G15) >=0; )b^ =f .G15<<f .
get BCHDi gi t(b) -
f.
get BCHDi gi t(f.G15) ;
ret ur n( a<<10| b)^ f.
G15_ MASK} ,
get BCHTy peNumber :funct i
on( a) {f
or (var
b=a<<12; f.
get BCHDi git (b) -f.get BCHDi gi t
(f .
G18) >=0; )b^=f .G18<<f .get BCHDi git(b) -f.get BCHDi gi t(f.G18) ;return
a<<12| b} ,get BCHDi gi t:
f unct ion( a){ for(v arb=0; 0!=a; ) b++, a>>>=1; retur nb} ,get Pat t
er nPosi t
ion:f unct ion( a){retur n
f.
PATTERN_ POSI TION_ TABLE[ a- 1] },
get Mask: funct i
on( a, b,c) {swi tch( a){casee. PATTERN000: ret urn
0==( b+c) %2; casee. PATTERN001: retur n0==b%2; casee. PATTERN010: retur n0==c%3; case
e.PATTERN011: retur n0==( b+c) %3; casee. PATTERN100: r
et ur n0==( Mat h.f l
oor (b/ 2) +Mat h.fl
oor (c/ 3)) %2; case
e.PATTERN101: retur n0==b* c%2+b* c%3; casee. PATTERN110: retur n0==( b* c%2+b* c%3) %2;case
e.PATTERN111: retur n0==( b* c%3+( b+c) %2) %2; def aul t:
thr ownewEr ror("bad
maskPat t
er n:"+a) }},
get Er ror Cor rect Pol y nomi al:funct i
on( a){for (varb=newi ([1],0),c=0; a>c; c++) b=b. mul tiply(new
i
([1,g.gexp( c) ],
0) ) ;
retur nb} ,get Lengt hInBi ts: funct i
on( a,b) {i
f(b>=1&&10>b) swi t ch( a){ case
c.MODE_ NUMBER: ret ur n10; casec. MODE_ ALPHA_ NUM: retur n9; casec. MODE_ 8BI T_ BYTE: ret urn8; case
c.MODE_ KANJI :retur n8; def aul t:thr ownewEr ror ("mode: "+a) }elsei f(27>b) swi tch( a) {case
c.MODE_ NUMBER: ret ur n12; casec. MODE_ ALPHA_ NUM: retur n11; casec. MODE_ 8BI T_ BYTE: retur n16; case
c.MODE_ KANJI :retur n10; def aul t:thrownewEr ror ("mode: "+a) }
el se{ i
f(!(
41>b) )thrownew
Error (
"ty pe:"+b) ;swi tch( a) {casec. MODE_ NUMBER: ret urn14; casec. MODE_ ALPHA_ NUM: r
etur n13; case
c.MODE_ 8BI T_ BYTE: ret ur n16; casec. MODE_ KANJI :r
et urn12; def aul t:
thrownew
Error (
"mode: "+a) }}},
get Lost Poi nt:funct ion( a) {for (varb=a. get Modul eCount (),c=0, d=0; b>d; d++) for (
v ar
e=0; b>e; e++) { for (varf =0, g=a. isDar k( d,e),h=- 1; 1>=h; h++) if(!
(0>d+h| |d+h>=b) )for (vari =-
1;1>=i ;
i++) 0>e+i ||
e+i >=b| |(0!=h| |0!=i )&&g==a. i
sDar k( d+h, e+i )&&f ++; f>5&&( c+=3+f -5)} for(vard=0; b-
1>d; d++) f or (vare=0; b- 1>e; e++) {var
j
=0; a.i
sDar k( d,e) &&j ++, a. i
sDar k( d+1, e) &&j ++, a.isDar k( d,e+1) &&j ++, a.isDar k( d+1, e+1) &&j ++, (
0==j ||
4==j )&&( c+=3) }
for (vard=0; b>d; d++) for (v are=0; b-
6>e; e++) a. isDar k(d, e)&&! a. isDar k( d,e+1) &&a. isDar k( d,e+2) &&a. isDar k(d, e+3) &&a. isDar k( d,e+4) &&! a.isDar k( d,e+
5) &&a. i
sDar k( d,e+6) &&( c+=40) ;
for (v are=0; b>e; e++) for (v ard=0; b-
6>d; d++) a. isDar k(d, e) &&! a. isDar k( d+1, e) &&a. isDar k( d+2, e) &&a. isDar k(d+3, e) &&a. isDar k( d+4, e) &&! a.isDar k(d+5,
e) &&a. i
sDar k(d+6, e) &&( c+=40) ;
for (v ark=0, e=0; b>e; e++) for (vard=0; b>d; d++) a.isDar k(d, e) &&k++; var
l
=Mat h. abs( 100* k/ b/ b- 50) / 5;ret ur nc+=10* l}},
g={ glog: funct ion( a) {if(1>a) thr ownewEr ror ("glog( "+a+" ) ");
ret urn
g.LOG_ TABLE[ a]},
gexp: funct ion( a) {for ( ;
0>a; )a+=255; for (;a>=256; )a- =255; retur n
g.EXP_ TABLE[ a] },
EXP_ TABLE: newAr ray (256) ,LOG_ TABLE: new
Ar ray (256) },h=0; 8>h; h++) g. EXP_ TABLE[ h]=1<<h; for (v arh=8; 256>h; h++) g. EXP_ TABLE[ h]=g. EXP_ TABLE[ h-
4]^ g.EXP_ TABLE[ h-5] ^g. EXP_ TABLE[ h- 6] ^g. EXP_ TABLE[ h-8] ;for(v ar
h=0; 255>h; h++) g.LOG_ TABLE[ g.EXP_ TABLE[ h] ]
=h; i.
pr otot y pe={ get :funct ion( a) {retur n
this. num[ a] },get Lengt h: funct ion( ){ret ur nt hi s.num. l
engt h} ,
mul tiply :
f unct ion( a) {for (varb=new
Ar ray (this. get Lengt h( )+a. get Lengt h( )-1) ,c=0; c<t his.get Lengt h();c++) for (v ar
d=0; d<a. get Lengt h( );
d++) b[ c+d] ^=g. gexp( g. gl og( this. get (c) )+g. glog( a. get (d) ));retur nnew
i
( b,0) }
,mod: funct ion( a) {if(thi s.get Lengt h() -a.get Lengt h( )<0) ret urnt hi s;for (varb=g. glog( this.get (0) )-
g.gl og( a.get (0) ),
c=newAr ray (this.get Lengt h( )),d=0; d<t his. get Lengt h( );
d++) c[d] =thi s.get (d) ;for(v ar
d=0; d<a. get Lengt h( );
d++) c[ d]^=g. gexp( g.gl og( a.get (d) )+b) ;retur nnew
i
( c,0) .
mod( a) }} ,
j.
RS_ BLOCK_ TABLE=[ [1,26, 19] ,
[1,26, 16] ,
[1, 26, 13] ,
[1,26, 9],[1,44, 34] ,[1,44, 28] ,
[1,44, 22] ,
[1,44, 16] ,[
1,7
0,55] ,
[
1, 70, 44] ,[2,35, 17] ,[2,35, 13] ,
[1, 100, 80] ,[2,50, 32] ,[2,50, 24] ,
[4,25, 9] ,
[1, 134, 108] ,
[2,67, 43] ,
[2,33, 15, 2,34, 16],[2,33,
11, 2,34, 12] ,[2,86, 68] ,[4,43, 27] ,
[4, 43, 19] ,[4,43, 15] ,
[2,98, 78] ,
[4, 49, 31] ,
[2, 32, 14, 4,33, 15],[4,39, 13, 1,40, 14] ,[
2, 121, 97] ,
[2,
60, 38, 2,61, 39] ,
[4,40, 18, 2, 41, 19] ,[4,40, 14, 2,41, 15] ,[2,146, 116] ,[3,58, 36, 2,59, 37] ,[
4, 36,16, 4, 37, 17] ,[
4,36, 12, 4,37, 13] ,
[2,
86, 68, 2,87, 69] ,
[4,69, 43, 1, 70, 44] ,[6,43, 19, 2,44, 20] ,[6,43, 15, 2, 44, 16] ,
[4, 101, 81] ,[1,80, 50, 4,81, 51] ,[4,50,22, 4,51, 23] ,[
3,
36, 12, 8,37, 13] ,
[2,116, 92, 2,117, 93] ,
[6, 58, 36, 2, 59, 37] ,
[4, 46, 20, 6,47, 21] ,[7,42, 14, 4,43, 15] ,[
4, 133, 107] ,[
8,59, 37, 1,60, 38],
[8,44, 20, 4,45, 21] ,
[12, 33, 11, 4, 34, 12] ,[3,145, 115, 1,146, 116] ,[4,64, 40, 5,65, 41] ,
[11, 36,16, 5, 37, 17] ,
[11, 36, 12,5, 37,13] ,[5,
109, 87,1, 110, 88] ,[
5,65, 41, 5,66, 42] ,
[5, 54, 24, 7, 55, 25] ,
[11, 36, 12] ,[
5,122, 98, 1, 123, 99] ,
[7,73, 45, 3,74, 46] ,
[15,43, 19, 2,44,
20] ,[3,
45, 15, 13, 46, 16] ,[
1, 135, 107, 5,136, 108] ,
[10, 74, 46, 1,75, 47] ,[
1,50, 22, 15, 51, 23] ,
[
2, 42, 14, 17, 43, 15] ,
[5,150, 120, 1,1
51, 121] ,[9,69, 43, 4,70, 44] ,[17, 50, 22, 1, 51, 23] ,[2,42, 14, 19, 43, 15] ,[
3,141, 113, 4,142, 114] ,[3,70, 44, 11, 71,45] ,[17,47, 21, 4,
48, 22] ,
[9,39, 13, 16, 40, 14] ,[3,135, 107, 5,136, 108] ,
[3,67, 41, 13, 68, 42] ,
[15, 54, 24, 5,55, 25] ,[15, 43, 15,10, 44, 16] ,[
4,144, 11
6,4,145, 117] ,[17, 68,42] ,
[17, 50, 22, 6,51, 23] ,[
19, 46, 16,6, 47, 17] ,[2,139, 111, 7,140, 112] ,
[17, 74, 46] ,
[7,54, 24,16, 55, 25] ,
[3
4,37, 13] ,[
4, 151, 121, 5, 152, 122] ,[
4, 75, 47, 14, 76, 48] ,[
11, 54, 24, 14, 55,25] ,
[16, 45, 15, 14, 46, 16] ,[
6, 147, 117, 4,148, 118] ,[6,
73, 45, 14, 74, 46] ,
[11,54, 24, 16, 55, 25] ,[30, 46, 16, 2,47, 17] ,[8,132, 106, 4, 133, 107] ,[
8, 75, 47, 13, 76, 48] ,
[7,54, 24, 22,55, 25] ,[
22, 45, 15, 13, 46, 16] ,[
10, 142, 114, 2,143, 115] ,[19, 74, 46, 4,75, 47] ,
[28, 50, 22, 6,51, 23] ,[33,46, 16, 4, 47, 17] ,
[8,152, 122, 4,15
3,123] ,
[22, 73, 45, 3,74, 46] ,[8,53, 23, 26, 54, 24] ,[12, 45, 15, 28, 46, 16] ,
[3,147, 117, 10, 148, 118] ,
[3,73, 45, 23, 74,46] ,
[4,54, 24,
31, 55, 25] ,
[11, 45, 15,31, 46, 16] ,[7,146, 116, 7,147, 117] ,[
21, 73, 45, 7,74, 46] ,
[1,53, 23, 37, 54, 24] ,[
19, 45, 15, 26,46, 16] ,[5,14
5,115, 10, 146, 116] ,[19, 75, 47, 10, 76, 48] ,[15, 54, 24, 25, 55, 25] ,[23, 45, 15, 25, 46, 16] ,
[13, 145, 115, 3,146, 116] ,
[2,74, 46, 29, 7
5,47] ,
[
42, 54, 24, 1,55, 25] ,[23, 45, 15, 28, 46, 16] ,[17, 145, 115] ,
[10, 74, 46, 23, 75, 47] ,
[10, 54,24, 35, 55, 25] ,[19,45, 15, 35, 46,1
6],[17,145, 115, 1,146, 116] ,[14, 74, 46, 21, 75, 47] ,[29, 54,24, 19, 55, 25] ,[
11, 45, 15, 46, 46, 16] ,[13, 145, 115, 6,146, 116] ,
[14, 7
4,46, 23, 75, 47] ,
[44, 54, 24, 7,55, 25] ,[
59, 46, 16, 1, 47, 17] ,
[12, 151, 121, 7,152, 122] ,[12, 75, 47, 26, 76, 48] ,
[39, 54,24, 14, 55, 25],
[22, 45,15, 41, 46, 16] ,
[6, 151, 121, 14, 152, 122] ,[6,75, 47, 34, 76, 48] ,
[46, 54, 24, 10, 55, 25] ,
[2,45, 15, 64, 46, 16] ,
[17, 152, 122, 4,
153, 123] ,[29, 74, 46, 14, 75, 47] ,
[49, 54, 24, 10, 55, 25] ,[24,45, 15, 46, 46, 16] ,[4,152, 122, 18, 153, 123] ,
[13, 74,46, 32, 75,47] ,[4
8,54, 24, 14, 55, 25] ,
[42, 45, 15, 32, 46, 16] ,[
20, 147, 117, 4,148, 118] ,
[40, 75, 47, 7,76, 48] ,[43,54, 24, 22, 55, 25] ,[
10, 45, 15, 67,4
6,16] ,
[
19, 148, 118, 6,149, 119] ,
[18, 75, 47, 31, 76, 48] ,[34,54, 24, 34, 55, 25] ,[20, 45, 15, 61, 46, 16] ],j
.get RSBl ocks=f unct i
on(
a,b) {varc=j .get RsBl ockTabl e( a,b) ;i
f( voi d0==c) t
hr ownewEr ror ("badr sbl ock@
typeNumber :"+a+" /er ror Cor r ect Lev el:"+b) ;for (v ard=c. lengt h/ 3,e=[ ]
,f=0; d>f ;
f ++) for( var
g=c[ 3* f+0] ,
h=c[ 3* f+1] ,
i=c[ 3* f+2] ,
k=0; g>k; k++) e.push( newj (h,i));ret ur n
e},j.
get RsBl ockTabl e=f unct ion( a, b) {swi tch( b){ cased. L: retur nj .RS_ BLOCK_ TABLE[ 4* (a-1) +0] ;cased. M: retur n
j
.RS_ BLOCK_ TABLE[ 4* ( a-1) +1] ;cased. Q: ret ur nj .RS_ BLOCK_ TABLE[ 4* ( a-1) +2] ;cased. H: ret urn
j
.RS_ BLOCK_ TABLE[ 4* ( a-1) +3] ;def aul t:retur nv oid0} },k.pr ot ot ype={ get :funct ion( a){ varb=Mat h.floor (a/ 8) ;
ret urn
1==( 1&t his.buf fer [b] >>>7- a%8) },put :funct i
on( a, b){for (v arc=0; b>c; c++) thi s.put Bi t(1==( 1&a>>>b- c-
1)) },
get Lengt hI nBi t s:funct ion( ){ret ur nt his. l
engt h},put Bi t:funct i
on( a) {v ar
b=Mat h.floor (thi s.lengt h/ 8) ;thi s.buf fer .lengt h<=b&&t his.buf fer .push( 0) ,
a&&( thi s.buf fer [
b] |
=128>>>t hi s.lengt h%8)
,
thi s.lengt h++} };var
l
=[ [17, 14, 11, 7] ,
[32, 26, 20, 14] ,
[53, 42, 32, 24] ,[78, 62, 46, 34] ,[106, 84, 60, 44] ,[134, 106, 74, 58] ,
[154, 122, 86, 64] ,
[192, 152, 1
08, 84] ,[230, 180, 130, 98] ,[271, 213, 151, 119] ,
[321, 251, 177, 137] ,
[367, 287, 203, 155] ,[425, 331, 241, 177] ,[458, 362, 258,
194] ,
[520, 412, 292, 220] ,[586, 450, 322, 250] ,[644, 504, 364, 280] ,[718, 560, 394, 310] ,
[792, 624, 442, 338] ,[858, 666, 482, 3
82] ,[
929, 711, 509, 403] ,
[1003, 779, 565, 439] ,[1091, 857, 611, 461] ,[
1171, 911, 661, 511] ,
[1273, 997, 715, 535] ,[1367, 1059,
751, 593] ,[
1465, 1125, 805, 625] ,
[1528, 1190, 868, 658] ,
[1628, 1264, 908, 698] ,
[1732, 1370, 982, 742] ,[1840, 1452, 1030, 7
90] ,[
1952, 1538, 1112, 842] ,[2068, 1628, 1168, 898] ,[
2188, 1722, 1228, 958] ,[2303, 1809, 1283, 983] ,
[2431, 1911, 1351, 1
051] ,
[2563, 1989, 1423, 1093] ,[2699, 2099, 1499, 1139] ,[
2809, 2213, 1579, 1219] ,[2953, 2331, 1663, 1273] ],o=f unct ion()
{vara=f unct ion( a, b) {thi s. _el =a, thi s._ ht Opt i
on=b} ;
ret ur na. pr ot ot y pe. dr aw=f unct ion( a) {funct iong( a,b) {v ar
c=document .cr eat eEl ement NS( "ht t p:/ /www. w3. org/ 2000/ sv g",a) ;for (vardi n
b)b. hasOwnPr oper ty( d) &&c. set At tr i
but e( d,b[ d] );
ret urnc} var
b=t hi s._ htOpt ion, c=t his. _ el,d=a. get Modul eCount ();
Mat h.floor (b. wi dt h/ d),Mat h.f l
oor (b. height /d) ,
thi s.cl ear ();var
h=g( "sv g" ,{
viewBox :"00" +St r i
ng( d) +"
"+St ring( d),wi dt h:"100%" ,
hei ght :
"100%" ,fill
:b. col or Light });
h. set At tr i
but eNS( "ht tp:/ /www. w3. or g/ 2000/ xml ns/ ",
"x
ml ns: xl ink","ht tp:/ /www. w3. or g/ 1999/ xlink" ),c. appendChi ld( h),h. appendChi ld( g( "rect ",{f
ill:
b. col or Dar k,wi dth: "1",
hei ght :"1" ,i
d:"templ at e" }));for (v ari =0; d>i ;i
++) for (varj =0; d>j ;
j++) if(a.isDar k(i,j
) ){v ar
k=g( "use" ,{
x:St ring( i),y:St r i
ng( j)});k. set At tribut eNS( "ht tp: //www. w3. or g/ 1999/ xl ink" ,"hr ef",
"#t empl at e" ),h.append
Chi ld( k) }},
a.pr ot ot y pe. cl ear =f unct ion( ){for (;this. _el.hasChi ldNodes( );)thi s._el .remov eChi l
d( thi s._el .l
ast Chi ld) },
a}()
,
p=" sv g" ===document .document El ement .tagName. toLower Case( ),
q=p? o: m( )? funct ion( ){funct i
on
a() {
t his. _elImage. sr c=t hi s. _el Canv as. toDat aURL( "i
mage/ png" ),
thi s._ elImage. st yle. displ ay =" block" ,this. _elCanv a
s.st yle. display =" none" }f unct iond( a, b) {v arc=t hi s;if(c. _fFai l=b, c._ fSuccess=a, nul l===c. _bSuppor tDat aURI ){
v ar
d=document .creat eEl ement ("img" ),e=f unct i
on( ){c._ bSuppor tDat aURI =! 1,c._ fFai l&&_ fFail.cal l(c)},f=f unct ion( ){c._
bSuppor tDat aURI =! 0, c._ fSuccess&&c. _ fSuccess. call(c) };retur n
d.onabor t=e,d. oner ror =e, d.onl oad=f ,
d. src=" dat a: i
mage/ gi f;
base64, i
VBORw0KGgoAAAANSUhEUgAAAAUAAAAF
CAYAAACNby blAAAAHEl EQVQI 12P4/ /8/ w38GI AXDI BKE0DHxgl jNBAAO9TXL0Y4OHwAAAABJRU5Er kJggg==" ,
voi d
0}c. _bSuppor tDat aURI ===! 0&&c. _fSuccess? c. _fSuccess. cal l(c) :c._ bSuppor tDat aURI ===! 1&&c. _ fFai l&&c. _f Fai l
.c
all(c) }i
f (this._andr oi d&&t hi s._ andr oi d<=2. 1) {var
b=1/ wi ndow. dev icePi xel Rat io,c=Canv asRender i
ngCont ext 2D. pr ot ot ype. dr awI mage; Canv asRender ingCont ext 2
D. prot ot y pe.dr awI mage=f unct ion( a, d,e,f,g,h, i,
j){if("nodeName" ina&&/ img/ i.
t est (a. nodeName) )
f or (var
l
=ar gument s.lengt h- 1;l>=1; l--)ar gument s[ l
]=ar gument s[ l
]* b;else" undef ined" ==t y peof
j
&&( ar gument s[ 1] *=b, ar gument s[ 2]* =b, ar gument s[ 3]* =b, argument s[ 4]* =b) ;c. appl y( this,argument s) }}var
e=f unct ion( a,b) {t his. _bI sPai nt ed=! 1, this. _andr oi d=n( ),this. _ht Opt ion=b, thi s._ elCanv as=document .creat eEl ement
("canv as" ),
this. _el Canv as. wi dt h=b. wi dt h,thi s._ elCanv as. hei ght =b. hei ght ,
a. appendChi ld(thi s._el Canv as) ,this._ el
=
a,this. _oCont ext =t his. _el Canv as. get Cont ext ("2d" ) ,
this. _bI sPai nt ed=! 1,thi s._el Image=document .cr eat eEl ement ("
i
mg" ),thi s._elImage. st y le.di spl ay =" none" ,
thi s._ el .
appendChi ld( thi s._ elImage) ,this. _bSuppor tDat aURI =nul l}
;ret urn
e.pr ot ot ype. dr aw=f unct ion( a) { var
b=t his. _el I
mage, c=t his. _oCont ext ,
d=t his._ htOpt ion, e=a. get Modul eCount (),f=d.wi dth/ e,g=d. height /e,h=Mat h.rou
nd( f),i
=Mat h. round( g) ;
b. style. displ ay ="none" ,
this. clear ();f
or (varj =0; e>j ;
j++) for(vark=0; e>k; k++) {v ar
l
=a. isDar k( j,
k) ,
m=k* f,n=j *g;c.st rokeSt y le=l? d.col orDar k:d.col or Light ,c.l
ineWi dth=1, c. fi
llSt yl
e=l ?d. col or Dark:d.col
orLight ,c.fill
Rect (m, n,f,g) ,
c.st rokeRect (Mat h.fl
oor (m) +. 5,Mat h.floor (n)+. 5,h,i),
c.strokeRect (Mat h. cei l(m)
-.
5,Mat h.cei l(n)
-.
5,h, i
) }this._bI sPai nted=! 0},e.pr otot ype. makeI mage=f unct i
on( ){
thi s._bI sPai nted&&d. cal l
(this,a) },
e. pr ototype.isP
ainted=f unct ion( ){ret urn
this._ bIsPai nt ed} ,e. prot oty pe. clear =f unct ion( ){this. _oCont ext.clear Rect (0,0,this._el Canv as. widt h,thi s._el
Canv as.
height ),this._ bIsPai nted=! 1},e.pr otot ype. round=f unct i
on( a){ret urna? Mat h. fl
oor (1e3* a)/ 1e3: a},e}():funct ion(){var
a=f unct ion( a,b) {thi s._el =a, t
hi s._ht Opt i
on=b} ;
ret urna. prot ot ype. dr aw=f unct ion(a) {for(v ar
b=t his. _ht Opt ion, c=t his._ el,d=a. get Modul eCount (),
e=Mat h. f
loor (b. wi dth/ d) ,
f=Mat h.floor (b.hei ght /d) ,g=['
<t able
style=" bor der :0; bor der -
col lapse: col l
apse; " >']
,h=0; d>h; h++) {g.push( "<tr>");for(vari =0; d>i;i++) g.push( '
<t d
style=" bor der :0; bor der -
col lapse: col l
apse; paddi ng: 0;mar gin:0;wi dt h:'+e+" px; height :
"+f +" px;backgr ound-
color :"+( a.isDar k( h, i
)? b.col orDar k:b.col orLi ght)+' ;
"></ td>' );
g. push( "</ tr
>" )}g.push( "</ tabl e>" ),
c.inner HTML=g. join
(""
);varj =c. chi ldNodes[ 0] ,
k=( b. widt h-j.of fset Wi dth) /2,l=( b.hei ght -
j
.of fset Hei ght )/2; k>0&&l >0&&( j.
st yle.mar gi n=l+" px
"+k+" px" )},
a. pr ot oty pe. clear =f unct ion( ){t
hi s._el.inner HTML=" "},
a} ();QRCode=f unct ion( a,b) {
if(this._ ht Opt i
on={ wid
th:256, hei ght :256, typeNumber :4,col or Dar k:"#000000" ,col orLight :
" #ffffff",
cor rectLev el:d. H},"string" ==t ypeof
b&&( b={ text:b} ),b) for (varci nb) this. _ht Opt i
on[ c]=b[ c];"st r
ing" ==t y peof
a&&( a=document .get El ement By Id(a) ),this. _andr oi d=n( ),this._ el=a, this._oQRCode=nul l,
this._ oDr awi ng=new
q(thi s._ el,t
hi s._ ht Opt i
on) ,
this._ htOpt ion. t
ext &&t his. makeCode( thi s._htOpt ion.text) },
QRCode. prot ot ype. makeCod
e=f unct ion( a) {this. _oQRCode=new
b(r(a, this. _htOpt ion. cor rect Lev el),this. _ht Opt ion. cor r
ect Lev el),this. _oQRCode. addDat a(a) ,
this._ oQRCode. make( )
,
this. _el .ti
tle=a, t his. _oDr awi ng. draw( thi s._oQRCode) ,this.makeI mage( )},QRCode. pr otot ype. makeI mage=f unctio
n(){"funct i
on" ==t y peof
this._ oDr awi ng. makeI mage&&( !t
hi s._andr oi d||
thi s._andr oid>=3) &&t his. _oDr awi ng. makeI mage( ) },
QRCode. protot
ype. clear =funct ion( ){this._ oDr awi ng. clear ( )
},QRCode. Cor rect Lev el=d} ();

Scr
ipt
.j
s
l
eti
nput=document
.quer
ySel
ect
or(
't
ext
area'
);

l
etqr
code=newQRCode(
document
.quer
ySel
ect
or(
'#qr
code'
),
{

wi
dth:
250,

hei
ght
:250,

col
orDar
k:"
#000000"
,

col
orLi
ght
:"#f
fff
ff"
,

cor
rect
Lev
el:
QRCode.
Cor
rect
Lev
el.
H

}
);
i
nput
.addEv
ent
List
ener
('
key
down'
,(
)=>{

l
eti
nput
Val
ue=i
nput
.val
ue;

qr
code.
makeCode(
input
Val
ue)
;

}
);

/
/THEEND

You might also like