function qr8bitbyte(a){ this.mode=qrmode.mode_8bit_byte, this.data=a } function qrcode(a,b){ this.typenumber=a, this.errorcorrectlevel=b, this.modules=null, this.modulecount=0, this.datacache=null, this.datalist=new array() } function qrpolynomial(a,b){ var c,d; if(void 0==a.length){ throw new error(a.length+"/"+b) } for(c=0;c").css("width",b.width+"px").css("height",b.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",b.background),e=b.width/c.getmodulecount(),f=b.height/c.getmodulecount(),g=0;g").css("height",f+"px").appendto(d),i=0;i").css("width",e+"px").css("background-color",c.isdark(g,i)?b.foreground:b.background).appendto(h)}}return d},this.each(function(){var e="canvas"==b.render?c():d();a(e).appendto(this)})}}(jquery),qr8bitbyte.prototype={getlength:function(){return this.data.length},write:function(a){for(var b=0;ba||this.modulecount<=a||0>b||this.modulecount<=b){throw new error(a+","+b)}return this.modules[a][b]},getmodulecount:function(){return this.modulecount},make:function(){var a,b,c,d,e,f;if(this.typenumber<1){for(a=1,a=1;40>a;a++){for(b=qrrsblock.getrsblocks(a,this.errorcorrectlevel),c=new qrbitbuffer(),d=0,e=0;e=7&&this.setuptypenumber(a),null==this.datacache&&(this.datacache=qrcode.createdata(this.typenumber,this.errorcorrectlevel,this.datalist)),this.mapdata(this.datacache,b)},setuppositionprobepattern:function(a,b){var c,d;for(c=-1;7>=c;c++){if(!(-1>=a+c||this.modulecount<=a+c)){for(d=-1;7>=d;d++){-1>=b+d||this.modulecount<=b+d||(this.modules[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)}}}},getbestmaskpattern:function(){var c,d,a=0,b=0;for(c=0;8>c;c++){this.makeimpl(!0,c),d=qrutil.getlostpoint(this),(0==c||a>d)&&(a=d,b=c)}return b},createmovieclip:function(a,b,c){var f,g,h,i,j,d=a.createemptymovieclip(b,c),e=1;for(this.make(),f=0;f=f;f++){for(g=-2;2>=g;g++){this.modules[d+f][e+g]=-2==f||2==f||-2==g||2==g||0==f&&0==g?!0:!1}}}}}},setuptypenumber:function(a){var c,d,b=qrutil.getbchtypenumber(this.typenumber);for(c=0;18>c;c++){d=!a&&1==(1&b>>c),this.modules[math.floor(c/3)][c%3+this.modulecount-8-3]=d}for(c=0;18>c;c++){d=!a&&1==(1&b>>c),this.modules[c%3+this.modulecount-8-3][math.floor(c/3)]=d}},setuptypeinfo:function(a,b){var e,f,c=this.errorcorrectlevel<<3|b,d=qrutil.getbchtypeinfo(c);for(e=0;15>e;e++){f=!a&&1==(1&d>>e),6>e?this.modules[e][8]=f:8>e?this.modules[e+1][8]=f:this.modules[this.modulecount-15+e][8]=f}for(e=0;15>e;e++){f=!a&&1==(1&d>>e),8>e?this.modules[8][this.modulecount-e-1]=f:9>e?this.modules[8][15-e-1+1]=f:this.modules[8][15-e-1]=f}this.modules[this.modulecount-8][8]=!a},mapdata:function(a,b){var g,h,i,j,c=-1,d=this.modulecount-1,e=7,f=0;for(g=this.modulecount-1;g>0;g-=2){for(6==g&&g--;;){for(h=0;2>h;h++){null==this.modules[d][g-h]&&(i=!1,f>>e)),j=qrutil.getmask(b,d,g-h),j&&(i=!i),this.modules[d][g-h]=i,e--,-1==e&&(f++,e=7))}if(d+=c,0>d||this.modulecount<=d){d-=c,c=-c;break}}}}},qrcode.pad0=236,qrcode.pad1=17,qrcode.createdata=function(a,b,c){var f,g,h,d=qrrsblock.getrsblocks(a,b),e=new qrbitbuffer();for(f=0;f8*h){throw new error("code length overflow. ("+e.getlengthinbits()+">"+8*h+")")}for(e.getlengthinbits()+4<=8*h&&e.put(0,4);0!=e.getlengthinbits()%8;){e.putbit(!1)}for(;;){if(e.getlengthinbits()>=8*h){break}if(e.put(qrcode.pad0,8),e.getlengthinbits()>=8*h){break}e.put(qrcode.pad1,8)}return qrcode.createbytes(e,d)},qrcode.createbytes=function(a,b){var h,i,j,k,l,m,n,o,p,q,r,c=0,d=0,e=0,f=new array(b.length),g=new array(b.length);for(h=0;h=0?n.get(o):0}}for(p=0,k=0;kk;k++){for(h=0;hk;k++){for(h=0;h=0;){b^=qrutil.g15<=0;){b^=qrutil.g18<>>=1}return b},getpatternposition:function(a){return qrutil.pattern_position_table[a-1]},getmask:function(a,b,c){switch(a){case qrmaskpattern.pattern000:return 0==(b+c)%2;case qrmaskpattern.pattern001:return 0==b%2;case qrmaskpattern.pattern010:return 0==c%3;case qrmaskpattern.pattern011:return 0==(b+c)%3;case qrmaskpattern.pattern100:return 0==(math.floor(b/2)+math.floor(c/3))%2;case qrmaskpattern.pattern101:return 0==b*c%2+b*c%3;case qrmaskpattern.pattern110:return 0==(b*c%2+b*c%3)%2;case qrmaskpattern.pattern111:return 0==(b*c%3+(b+c)%2)%2;default:throw new error("bad maskpattern:"+a)}},geterrorcorrectpolynomial:function(a){var c,b=new qrpolynomial([1],0);for(c=0;a>c;c++){b=b.multiply(new qrpolynomial([1,qrmath.gexp(c)],0))}return b},getlengthinbits:function(a,b){if(b>=1&&10>b){switch(a){case qrmode.mode_number:return 10;case qrmode.mode_alpha_num:return 9;case qrmode.mode_8bit_byte:return 8;case qrmode.mode_kanji:return 8;default:throw new error("mode:"+a)}}else{if(27>b){switch(a){case qrmode.mode_number:return 12;case qrmode.mode_alpha_num:return 11;case qrmode.mode_8bit_byte:return 16;case qrmode.mode_kanji:return 10;default:throw new error("mode:"+a)}}else{if(!(41>b)){throw new error("type:"+b)}switch(a){case qrmode.mode_number:return 14;case qrmode.mode_alpha_num:return 13;case qrmode.mode_8bit_byte:return 16;case qrmode.mode_kanji:return 12;default:throw new error("mode:"+a)}}}},getlostpoint:function(a){var d,e,f,g,h,i,j,k,l,b=a.getmodulecount(),c=0;for(d=0;b>d;d++){for(e=0;b>e;e++){for(f=0,g=a.isdark(d,e),h=-1;1>=h;h++){if(!(0>d+h||d+h>=b)){for(i=-1;1>=i;i++){0>e+i||e+i>=b||(0!=h||0!=i)&&g==a.isdark(d+h,e+i)&&f++}}}f>5&&(c+=3+f-5)}}for(d=0;b-1>d;d++){for(e=0;b-1>e;e++){j=0,a.isdark(d,e)&&j++,a.isdark(d+1,e)&&j++,a.isdark(d,e+1)&&j++,a.isdark(d+1,e+1)&&j++,(0==j||4==j)&&(c+=3)}}for(d=0;b>d;d++){for(e=0;b-6>e;e++){a.isdark(d,e)&&!a.isdark(d,e+1)&&a.isdark(d,e+2)&&a.isdark(d,e+3)&&a.isdark(d,e+4)&&!a.isdark(d,e+5)&&a.isdark(d,e+6)&&(c+=40)}}for(e=0;b>e;e++){for(d=0;b-6>d;d++){a.isdark(d,e)&&!a.isdark(d+1,e)&&a.isdark(d+2,e)&&a.isdark(d+3,e)&&a.isdark(d+4,e)&&!a.isdark(d+5,e)&&a.isdark(d+6,e)&&(c+=40)}}for(k=0,e=0;b>e;e++){for(d=0;b>d;d++){a.isdark(d,e)&&k++}}return l=math.abs(100*k/b/b-50)/5,c+=10*l}},qrmath={glog:function(a){if(1>a){throw new error("glog("+a+")")}return qrmath.log_table[a]},gexp:function(a){for(;0>a;){a+=255}for(;a>=256;){a-=255}return qrmath.exp_table[a]},exp_table:new array(256),log_table:new array(256)},i=0;8>i;i++){qrmath.exp_table[i]=1<i;i++){qrmath.exp_table[i]=qrmath.exp_table[i-4]^qrmath.exp_table[i-5]^qrmath.exp_table[i-6]^qrmath.exp_table[i-8]}for(i=0;255>i;i++){qrmath.log_table[qrmath.exp_table[i]]=i}qrpolynomial.prototype={get:function(a){return this.num[a]},getlength:function(){return this.num.length},multiply:function(a){var c,d,b=new array(this.getlength()+a.getlength()-1);for(c=0;cf;f++){for(g=c[3*f+0],h=c[3*f+1],i=c[3*f+2],j=0;g>j;j++){e.push(new qrrsblock(h,i))}}return e},qrrsblock.getrsblocktable=function(a,b){switch(b){case qrerrorcorrectlevel.l:return qrrsblock.rs_block_table[4*(a-1)+0];case qrerrorcorrectlevel.m:return qrrsblock.rs_block_table[4*(a-1)+1];case qrerrorcorrectlevel.q:return qrrsblock.rs_block_table[4*(a-1)+2];case qrerrorcorrectlevel.h:return qrrsblock.rs_block_table[4*(a-1)+3];default:return void 0}},qrbitbuffer.prototype={get:function(a){var b=math.floor(a/8);return 1==(1&this.buffer[b]>>>7-a%8)},put:function(a,b){for(var c=0;b>c;c++){this.putbit(1==(1&a>>>b-c-1))}},getlengthinbits:function(){return this.length},putbit:function(a){var b=math.floor(this.length/8);this.buffer.length<=b&&this.buffer.push(0),a&&(this.buffer[b]|=128>>>this.length%8),this.length++}};