(function(L){L.fn.qrcode=function(a){var B;function y(t){this.mode=B,this.data=t}function p(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function d(t,e){if(t.length==null)throw Error(t.length+"/"+e);for(var o=0;ot||this.moduleCount<=t||0>e||this.moduleCount<=e)throw Error(t+","+e);return this.modules[t][e]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){for(var t=1,t=1;40>t;t++){for(var e=C.getRSBlocks(t,this.errorCorrectLevel),o=new c,r=0,n=0;n=o;o++)if(!(-1>=t+o||this.moduleCount<=t+o))for(var r=-1;7>=r;r++)-1>=e+r||this.moduleCount<=e+r||(this.modules[t+o][e+r]=0<=o&&6>=o&&(r==0||r==6)||0<=r&&6>=r&&(o==0||o==6)||2<=o&&4>=o&&2<=r&&4>=r)},getBestMaskPattern:function(){for(var t=0,e=0,o=0;8>o;o++){this.makeImpl(!0,o);var r=g.getLostPoint(this);(o==0||t>r)&&(t=r,e=o)}return e},createMovieClip:function(t,e,o){for(t=t.createEmptyMovieClip(e,o),this.make(),e=0;e=i;i++)for(var u=-2;2>=u;u++)this.modules[r+i][n+u]=i==-2||i==2||u==-2||u==2||i==0&&u==0}},setupTypeNumber:function(t){for(var e=g.getBCHTypeNumber(this.typeNumber),o=0;18>o;o++){var r=!t&&(e>>o&1)==1;this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=r}for(o=0;18>o;o++)r=!t&&(e>>o&1)==1,this.modules[o%3+this.moduleCount-8-3][Math.floor(o/3)]=r},setupTypeInfo:function(t,e){for(var o=g.getBCHTypeInfo(this.errorCorrectLevel<<3|e),r=0;15>r;r++){var n=!t&&(o>>r&1)==1;6>r?this.modules[r][8]=n:8>r?this.modules[r+1][8]=n:this.modules[this.moduleCount-15+r][8]=n}for(r=0;15>r;r++)n=!t&&(o>>r&1)==1,8>r?this.modules[8][this.moduleCount-r-1]=n:9>r?this.modules[8][15-r-1+1]=n:this.modules[8][15-r-1]=n;this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var o=-1,r=this.moduleCount-1,n=7,i=0,u=this.moduleCount-1;0s;s++)if(this.modules[r][u-s]==null){var l=!1;i>>n&1)==1),g.getMask(e,r,u-s)&&(l=!l),this.modules[r][u-s]=l,n--,n==-1&&(i++,n=7)}if(r+=o,0>r||this.moduleCount<=r){r-=o,o=-o;break}}}},p.PAD0=236,p.PAD1=17,p.createData=function(t,e,o){for(var e=C.getRSBlocks(t,e),r=new c,n=0;n8*t)throw Error("code length overflow. ("+r.getLengthInBits()+">"+8*t+")");for(r.getLengthInBits()+4<=8*t&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*t)&&(r.put(p.PAD0,8),!(r.getLengthInBits()>=8*t));)r.put(p.PAD1,8);return p.createBytes(r,e)},p.createBytes=function(t,e){for(var o=0,r=0,n=0,i=Array(e.length),u=Array(e.length),s=0;s>>=1;return e},getPatternPosition:function(t){return g.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,o){switch(t){case 0:return(e+o)%2==0;case 1:return e%2==0;case 2:return o%3==0;case 3:return(e+o)%3==0;case 4:return(Math.floor(e/2)+Math.floor(o/3))%2==0;case 5:return e*o%2+e*o%3==0;case 6:return(e*o%2+e*o%3)%2==0;case 7:return(e*o%3+(e+o)%2)%2==0;default:throw Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new d([1],0),o=0;oe)switch(t){case 1:return 10;case 2:return 9;case B:return 8;case 8:return 8;default:throw Error("mode:"+t)}else if(27>e)switch(t){case 1:return 12;case 2:return 11;case B:return 16;case 8:return 10;default:throw Error("mode:"+t)}else if(41>e)switch(t){case 1:return 14;case 2:return 13;case B:return 16;case 8:return 12;default:throw Error("mode:"+t)}else throw Error("type:"+e)},getLostPoint:function(t){for(var e=t.getModuleCount(),o=0,r=0;r=s;s++)if(!(0>r+s||e<=r+s))for(var l=-1;1>=l;l++)0>n+l||e<=n+l||s==0&&l==0||u==t.isDark(r+s,n+l)&&i++;5t)throw Error("glog("+t+")");return f.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;256<=t;)t-=255;return f.EXP_TABLE[t]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},m=0;8>m;m++)f.EXP_TABLE[m]=1<m;m++)f.EXP_TABLE[m]=f.EXP_TABLE[m-4]^f.EXP_TABLE[m-5]^f.EXP_TABLE[m-6]^f.EXP_TABLE[m-8];for(m=0;255>m;m++)f.LOG_TABLE[f.EXP_TABLE[m]]=m;return d.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=Array(this.getLength()+t.getLength()-1),o=0;othis.getLength()-t.getLength())return this;for(var e=f.glog(this.get(0))-f.glog(t.get(0)),o=Array(this.getLength()),r=0;r>>7-t%8&1)==1},put:function(t,e){for(var o=0;o>>e-o-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},typeof a=="string"&&(a={text:a}),a=L.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,correctLevel:2,background:"#ffffff",foreground:"#000000"},a),this.each(function(){var t;if(a.render=="canvas"){t=new p(a.typeNumber,a.correctLevel),t.addData(a.text),t.make();var e=document.createElement("canvas");e.width=a.width,e.height=a.height;for(var o=e.getContext("2d"),r=a.width/t.getModuleCount(),n=a.height/t.getModuleCount(),i=0;i").css("width",a.width+"px").css("height",a.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",a.background),o=a.width/t.getModuleCount(),r=a.height/t.getModuleCount(),n=0;n").css("height",r+"px").appendTo(e),u=0;u").css("width",o+"px").css("background-color",t.isDark(n,u)?a.foreground:a.background).appendTo(i);t=e,jQuery(t).appendTo(this)})}})(jQuery);