50 lines
25 KiB
JavaScript
50 lines
25 KiB
JavaScript
var QRCode;
|
|
!function(){function J(a){this.mode=x.MODE_8BIT_BYTE;this.data=a;this.parsedData=[];a=0;for(var b=this.data.length;a<b;a++){var c=[],d=this.data.charCodeAt(a);65536<d?(c[0]=240|(1835008&d)>>>18,c[1]=128|(258048&d)>>>12,c[2]=128|(4032&d)>>>6,c[3]=128|63&d):2048<d?(c[0]=224|(61440&d)>>>12,c[1]=128|(4032&d)>>>6,c[2]=128|63&d):128<d?(c[0]=192|(1984&d)>>>6,c[1]=128|63&d):c[0]=d;this.parsedData.push(c)}this.parsedData=Array.prototype.concat.apply([],this.parsedData);this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),
|
|
this.parsedData.unshift(187),this.parsedData.unshift(239))}function q(a,b){this.typeNumber=a;this.errorCorrectLevel=b;this.modules=null;this.moduleCount=0;this.dataCache=null;this.dataList=[]}function D(a,b){if(null==a.length)throw Error(a.length+"/"+b);for(var c=0;c<a.length&&0==a[c];)c++;this.num=Array(a.length-c+b);for(b=0;b<a.length-c;b++)this.num[b]=a[b+c]}function z(a,b){this.totalCount=a;this.dataCount=b}function E(){this.buffer=[];this.length=0}function K(){var a=!1,b=navigator.userAgent;
|
|
/android/i.test(b)&&(a=!0,(b=b.toString().match(/android ([0-9]\.[0-9])/i))&&b[1]&&(a=parseFloat(b[1])));return a}function M(a,b){this._el=a;this._htOption=b}function A(a,b){this._el=a;this._htOption=b}J.prototype={getLength:function(a){return this.parsedData.length},write:function(a){for(var b=0,c=this.parsedData.length;b<c;b++)a.put(this.parsedData[b],8)}};q.prototype={addData:function(a){a=new J(a);this.dataList.push(a);this.dataCache=null},isDark:function(a,b){if(0>a||this.moduleCount<=a||0>b||
|
|
this.moduleCount<=b)throw Error(a+","+b);return this.modules[a][b]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(a,b){this.moduleCount=4*this.typeNumber+17;this.modules=Array(this.moduleCount);for(var c=0;c<this.moduleCount;c++){this.modules[c]=Array(this.moduleCount);for(var d=0;d<this.moduleCount;d++)this.modules[c][d]=null}this.setupPositionProbePattern(0,0);this.setupPositionProbePattern(this.moduleCount-7,0);
|
|
this.setupPositionProbePattern(0,this.moduleCount-7);this.setupPositionAdjustPattern();this.setupTimingPattern();this.setupTypeInfo(a,b);7<=this.typeNumber&&this.setupTypeNumber(a);null==this.dataCache&&(this.dataCache=q.createData(this.typeNumber,this.errorCorrectLevel,this.dataList));this.mapData(this.dataCache,b)},setupPositionProbePattern:function(a,b){for(var c=-1;7>=c;c++)if(!(-1>=a+c||this.moduleCount<=a+c))for(var d=-1;7>=d;d++)-1>=b+d||this.moduleCount<=b+d||(this.modules[a+c][b+d]=0<=c&&
|
|
6>=c&&(0==d||6==d)||0<=d&&6>=d&&(0==c||6==c)||2<=c&&4>=c&&2<=d&&4>=d)},getBestMaskPattern:function(){for(var a=0,b=0,c=0;8>c;c++){this.makeImpl(!0,c);var d=p.getLostPoint(this);(0==c||d<a)&&(a=d,b=c)}return b},createMovieClip:function(a,b,c){a=a.createEmptyMovieClip(b,c);this.make();for(b=0;b<this.modules.length;b++){c=1*b;for(var d=0;d<this.modules[b].length;d++){var e=1*d;this.modules[b][d]&&(a.beginFill(0,100),a.moveTo(e,c),a.lineTo(1+e,c),a.lineTo(1+e,1+c),a.lineTo(e,1+c),a.endFill())}}return a},
|
|
setupTimingPattern:function(){for(var a=8;a<this.moduleCount-8;a++)null==this.modules[a][6]&&(this.modules[a][6]=0==a%2);for(a=8;a<this.moduleCount-8;a++)null==this.modules[6][a]&&(this.modules[6][a]=0==a%2)},setupPositionAdjustPattern:function(){for(var a=p.getPatternPosition(this.typeNumber),b=0;b<a.length;b++)for(var c=0;c<a.length;c++){var d=a[b],e=a[c];if(null==this.modules[d][e])for(var f=-2;2>=f;f++)for(var h=-2;2>=h;h++)this.modules[d+f][e+h]=-2==f||2==f||-2==h||2==h||0==f&&0==h}},setupTypeNumber:function(a){for(var b=
|
|
p.getBCHTypeNumber(this.typeNumber),c=0;18>c;c++){var d=!a&&1==(b>>c&1);this.modules[Math.floor(c/3)][c%3+this.moduleCount-8-3]=d}for(c=0;18>c;c++)d=!a&&1==(b>>c&1),this.modules[c%3+this.moduleCount-8-3][Math.floor(c/3)]=d},setupTypeInfo:function(a,b){b=p.getBCHTypeInfo(this.errorCorrectLevel<<3|b);for(var c=0;15>c;c++){var d=!a&&1==(b>>c&1);6>c?this.modules[c][8]=d:8>c?this.modules[c+1][8]=d:this.modules[this.moduleCount-15+c][8]=d}for(c=0;15>c;c++)d=!a&&1==(b>>c&1),8>c?this.modules[8][this.moduleCount-
|
|
c-1]=d:9>c?this.modules[8][15-c-1+1]=d:this.modules[8][15-c-1]=d;this.modules[this.moduleCount-8][8]=!a},mapData:function(a,b){for(var c=-1,d=this.moduleCount-1,e=7,f=0,h=this.moduleCount-1;0<h;h-=2)for(6==h&&h--;;){for(var g=0;2>g;g++)if(null==this.modules[d][h-g]){var l=!1;f<a.length&&(l=1==(a[f]>>>e&1));p.getMask(b,d,h-g)&&(l=!l);this.modules[d][h-g]=l;-1==--e&&(f++,e=7)}if(0>(d+=c)||this.moduleCount<=d){d-=c;c=-c;break}}}};q.PAD0=236;q.PAD1=17;q.createData=function(a,b,c){b=z.getRSBlocks(a,b);
|
|
for(var d=new E,e=0;e<c.length;e++){var f=c[e];d.put(f.mode,4);d.put(f.getLength(),p.getLengthInBits(f.mode,a));f.write(d)}for(e=a=0;e<b.length;e++)a+=b[e].dataCount;if(d.getLengthInBits()>8*a)throw Error("code length overflow. ("+d.getLengthInBits()+">"+8*a+")");for(d.getLengthInBits()+4<=8*a&&d.put(0,4);0!=d.getLengthInBits()%8;)d.putBit(!1);for(;!(d.getLengthInBits()>=8*a||(d.put(q.PAD0,8),d.getLengthInBits()>=8*a));)d.put(q.PAD1,8);return q.createBytes(d,b)};q.createBytes=function(a,b){for(var c=
|
|
0,d=0,e=0,f=Array(b.length),h=Array(b.length),g=0;g<b.length;g++){var l=b[g].dataCount,m=b[g].totalCount-l;d=Math.max(d,l);e=Math.max(e,m);f[g]=Array(l);for(var k=0;k<f[g].length;k++)f[g][k]=255&a.buffer[k+c];c+=l;k=p.getErrorCorrectPolynomial(m);l=(new D(f[g],k.getLength()-1)).mod(k);h[g]=Array(k.getLength()-1);for(k=0;k<h[g].length;k++)m=k+l.getLength()-h[g].length,h[g][k]=0<=m?l.get(m):0}for(k=g=0;k<b.length;k++)g+=b[k].totalCount;a=Array(g);for(k=c=0;k<d;k++)for(g=0;g<b.length;g++)k<f[g].length&&
|
|
(a[c++]=f[g][k]);for(k=0;k<e;k++)for(g=0;g<b.length;g++)k<h[g].length&&(a[c++]=h[g][k]);return a};for(var x={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},B={L:1,M:0,Q:3,H:2},p={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[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,90],[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,118],[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,32,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,getBCHTypeInfo:function(a){for(var b=a<<10;0<=p.getBCHDigit(b)-p.getBCHDigit(p.G15);)b^=p.G15<<p.getBCHDigit(b)-p.getBCHDigit(p.G15);return(a<<
|
|
10|b)^p.G15_MASK},getBCHTypeNumber:function(a){for(var b=a<<12;0<=p.getBCHDigit(b)-p.getBCHDigit(p.G18);)b^=p.G18<<p.getBCHDigit(b)-p.getBCHDigit(p.G18);return a<<12|b},getBCHDigit:function(a){for(var b=0;0!=a;)b++,a>>>=1;return b},getPatternPosition:function(a){return p.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,b,c){switch(a){case 0:return 0==(b+c)%2;case 1:return 0==b%2;case 2:return 0==c%3;case 3:return 0==(b+c)%3;case 4:return 0==(Math.floor(b/2)+Math.floor(c/3))%2;case 5:return 0==b*c%
|
|
2+b*c%3;case 6:return 0==(b*c%2+b*c%3)%2;case 7:return 0==(b*c%3+(b+c)%2)%2;default:throw Error("bad maskPattern:"+a);}},getErrorCorrectPolynomial:function(a){for(var b=new D([1],0),c=0;c<a;c++)b=b.multiply(new D([1,r.gexp(c)],0));return b},getLengthInBits:function(a,b){if(1<=b&&10>b)switch(a){case x.MODE_NUMBER:return 10;case x.MODE_ALPHA_NUM:return 9;case x.MODE_8BIT_BYTE:case x.MODE_KANJI:return 8;default:throw Error("mode:"+a);}else if(27>b)switch(a){case x.MODE_NUMBER:return 12;case x.MODE_ALPHA_NUM:return 11;
|
|
case x.MODE_8BIT_BYTE:return 16;case x.MODE_KANJI:return 10;default:throw Error("mode:"+a);}else{if(!(41>b))throw Error("type:"+b);switch(a){case x.MODE_NUMBER:return 14;case x.MODE_ALPHA_NUM:return 13;case x.MODE_8BIT_BYTE:return 16;case x.MODE_KANJI:return 12;default:throw Error("mode:"+a);}}},getLostPoint:function(a){for(var b=a.getModuleCount(),c=0,d=0;d<b;d++)for(var e=0;e<b;e++){for(var f=0,h=a.isDark(d,e),g=-1;1>=g;g++)if(!(0>d+g||b<=d+g))for(var l=-1;1>=l;l++)0>e+l||b<=e+l||0==g&&0==l||h==
|
|
a.isDark(d+g,e+l)&&f++;5<f&&(c+=3+f-5)}for(d=0;d<b-1;d++)for(e=0;e<b-1;e++)f=0,a.isDark(d,e)&&f++,a.isDark(d+1,e)&&f++,a.isDark(d,e+1)&&f++,a.isDark(d+1,e+1)&&f++,0!=f&&4!=f||(c+=3);for(d=0;d<b;d++)for(e=0;e<b-6;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;e<b;e++)for(d=0;d<b-6;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(e=f=0;e<b;e++)for(d=0;d<b;d++)a.isDark(d,e)&&f++;return c+Math.abs(100*f/b/b-50)/5*10}},r={glog:function(a){if(1>a)throw Error("glog("+a+")");return r.LOG_TABLE[a]},gexp:function(a){for(;0>a;)a+=255;for(;256<=a;)a-=255;return r.EXP_TABLE[a]},EXP_TABLE:Array(256),LOG_TABLE:Array(256)},t=0;8>t;t++)r.EXP_TABLE[t]=1<<t;for(t=8;256>t;t++)r.EXP_TABLE[t]=r.EXP_TABLE[t-4]^r.EXP_TABLE[t-5]^r.EXP_TABLE[t-6]^r.EXP_TABLE[t-8];for(t=0;255>t;t++)r.LOG_TABLE[r.EXP_TABLE[t]]=t;D.prototype={get:function(a){return this.num[a]},
|
|
getLength:function(){return this.num.length},multiply:function(a){for(var b=Array(this.getLength()+a.getLength()-1),c=0;c<this.getLength();c++)for(var d=0;d<a.getLength();d++)b[c+d]^=r.gexp(r.glog(this.get(c))+r.glog(a.get(d)));return new D(b,0)},mod:function(a){if(0>this.getLength()-a.getLength())return this;for(var b=r.glog(this.get(0))-r.glog(a.get(0)),c=Array(this.getLength()),d=0;d<this.getLength();d++)c[d]=this.get(d);for(d=0;d<a.getLength();d++)c[d]^=r.gexp(r.glog(a.get(d))+b);return(new D(c,
|
|
0)).mod(a)}};z.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,70,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,7,37,13],[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,151,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,116,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],[34,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,153,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,145,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,75,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,16],[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,74,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],[48,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,46,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]];z.getRSBlocks=function(a,b){var c=z.getRsBlockTable(a,b);if(null==c)throw Error("bad rs block @ typeNumber:"+a+"/errorCorrectLevel:"+
|
|
b);a=c.length/3;b=[];for(var d=0;d<a;d++)for(var e=c[3*d],f=c[3*d+1],h=c[3*d+2],g=0;g<e;g++)b.push(new z(f,h));return b};z.getRsBlockTable=function(a,b){switch(b){case B.L:return z.RS_BLOCK_TABLE[4*(a-1)];case B.M:return z.RS_BLOCK_TABLE[4*(a-1)+1];case B.Q:return z.RS_BLOCK_TABLE[4*(a-1)+2];case B.H:return z.RS_BLOCK_TABLE[4*(a-1)+3]}};E.prototype={get:function(a){return 1==(this.buffer[Math.floor(a/8)]>>>7-a%8&1)},put:function(a,b){for(var c=0;c<b;c++)this.putBit(1==(a>>>b-c-1&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++}};var H=[[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,108,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,382],[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,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]],N=(M.prototype.draw=function(a){function b(g,l){g=document.createElementNS("http://www.w3.org/2000/svg",
|
|
g);for(var m in l)l.hasOwnProperty(m)&&g.setAttribute(m,l[m]);return g}var c=this._htOption,d=this._el,e=a.getModuleCount();Math.floor(c.width/e);Math.floor(c.height/e);this.clear();var f=b("svg",{viewBox:"0 0 "+String(e)+" "+String(e),width:"100%",height:"100%",fill:c.colorLight});f.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink");d.appendChild(f);f.appendChild(b("rect",{fill:c.colorLight,width:"100%",height:"100%"}));f.appendChild(b("rect",{fill:c.colorDark,
|
|
width:"1",height:"1",id:"template"}));for(c=0;c<e;c++)for(d=0;d<e;d++)if(a.isDark(c,d)){var h=b("use",{x:String(d),y:String(c)});h.setAttributeNS("http://www.w3.org/1999/xlink","href","#template");f.appendChild(h)}},M.prototype.clear=function(){for(;this._el.hasChildNodes();)this._el.removeChild(this._el.lastChild)},M),O="svg"===document.documentElement.tagName.toLowerCase()?N:"undefined"==typeof CanvasRenderingContext2D?(A.prototype.draw=function(a){for(var b=this._htOption,c=this._el,d=a.getModuleCount(),
|
|
e=Math.floor(b.width/d),f=Math.floor(b.height/d),h=['<table style="border:0;border-collapse:collapse;">'],g=0;g<d;g++){h.push("<tr>");for(var l=0;l<d;l++)h.push('<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:'+e+"px;height:"+f+"px;background-color:"+(a.isDark(g,l)?b.colorDark:b.colorLight)+';"></td>');h.push("</tr>")}h.push("</table>");c.innerHTML=h.join("");a=c.childNodes[0];c=(b.width-a.offsetWidth)/2;b=(b.height-a.offsetHeight)/2;0<c&&0<b&&(a.style.margin=b+"px "+c+"px")},
|
|
A.prototype.clear=function(){this._el.innerHTML=""},A):function(){function a(){this._elImage.src=this._elCanvas.toDataURL("image/png");this._elImage.style.display="block";this._elCanvas.style.display="none"}function b(e,f){this._bIsPainted=!1;this._android=K();this._htOption=f;this._elCanvas=document.createElement("canvas");this._elCanvas.width=f.width;this._elCanvas.height=f.height;e.appendChild(this._elCanvas);this._el=e;this._oContext=this._elCanvas.getContext("2d");this._bIsPainted=!1;this._elImage=
|
|
document.createElement("img");this._elImage.alt="Scan me!";this._elImage.style.display="none";this._el.appendChild(this._elImage);this._bSupportDataURI=null}if(this._android&&2.1>=this._android){var c=1/window.devicePixelRatio,d=CanvasRenderingContext2D.prototype.drawImage;CanvasRenderingContext2D.prototype.drawImage=function(e,f,h,g,l,m,k,u,v){if("nodeName"in e&&/img/i.test(e.nodeName))for(var n=arguments.length-1;1<=n;n--)arguments[n]*=c;else void 0===u&&(f*=c,h*=c,g*=c,l*=c);d.apply(this,arguments)}}return b.prototype.draw=
|
|
function(e){var f=this._elImage,h=this._oContext,g=this._htOption,l=e.getModuleCount(),m=g.width/l,k=g.height/l,u=Math.round(m),v=Math.round(k);f.style.display="none";this.clear();for(f=0;f<l;f++)for(var n=0;n<l;n++){var C=e.isDark(f,n),w=n*m,F=f*k;h.strokeStyle=C?g.colorDark:g.colorLight;h.lineWidth=1;h.fillStyle=C?g.colorDark:g.colorLight;h.fillRect(w,F,m,k);h.strokeRect(Math.floor(w)+.5,Math.floor(F)+.5,u,v);h.strokeRect(Math.ceil(w)-.5,Math.ceil(F)-.5,u,v)}this._bIsPainted=!0},b.prototype.makeImage=
|
|
function(){this._bIsPainted&&function(e,f){var h=this;if(h._fFail=f,h._fSuccess=e,null===h._bSupportDataURI)return e=function(){h._bSupportDataURI=!1;h._fFail&&h._fFail.call(h)},f=document.createElement("img"),f.onabort=e,f.onerror=e,f.onload=function(){h._bSupportDataURI=!0;h._fSuccess&&h._fSuccess.call(h)},void(f.src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==");!0===h._bSupportDataURI&&h._fSuccess?h._fSuccess.call(h):
|
|
!1===h._bSupportDataURI&&h._fFail&&h._fFail.call(h)}.call(this,a)},b.prototype.isPainted=function(){return this._bIsPainted},b.prototype.clear=function(){this._oContext.clearRect(0,0,this._elCanvas.width,this._elCanvas.height);this._bIsPainted=!1},b.prototype.round=function(e){return e?Math.floor(1E3*e)/1E3:e},b}();(QRCode=function(a,b){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:B.H},"string"==typeof b&&(b={text:b}),b)for(var c in b)this._htOption[c]=
|
|
b[c];"string"==typeof a&&(a=document.getElementById(a));this._htOption.useSVG&&(O=N);this._android=K();this._el=a;this._oQRCode=null;this._oDrawing=new O(this._el,this._htOption);this._htOption.text&&this.makeCode(this._htOption.text)}).prototype.makeCode=function(a){var b=this._htOption.correctLevel,c=1;var d=encodeURI(a).toString().replace(/%[0-9a-fA-F]{2}/g,"a");d=d.length+(d.length!=a?3:0);for(var e=0,f=H.length;e<=f;e++){var h=0;switch(b){case B.L:h=H[e][0];break;case B.M:h=H[e][1];break;case B.Q:h=
|
|
H[e][2];break;case B.H:h=H[e][3]}if(d<=h)break;c++}if(H.length<c)throw Error("Too long data");this._oQRCode=new q(c,this._htOption.correctLevel);this._oQRCode.addData(a);this._oQRCode.make();this._el.title=a;this._oDrawing.draw(this._oQRCode);this.makeImage()};QRCode.prototype.makeImage=function(){"function"==typeof this._oDrawing.makeImage&&(!this._android||3<=this._android)&&this._oDrawing.makeImage()};QRCode.prototype.clear=function(){this._oDrawing.clear()};QRCode.CorrectLevel=B}();
|
|
"undefined"!=typeof module&&(module.exports=QRCode);
|
|
(function(J,q,D){function z(e){return(q.querySelectorAll||J.jQuery||J.Zepto||function(f){var h=[];return A(f.split(/\s*,\s*/),function(g){g=g.match(/([#.])(\w+)/);if(null===g)throw Error("Supports only simple single #ID or .CLASS selector.");g[1]&&(g=q.getElementById(g[2]))&&h.push(g);h=h.concat(K(f))}),h}).call(q,e)}function E(e){return(q.getElementsByName(e)[0]||0).content}function K(e,f,h){if(e.getElementsByClassName)return e.getElementsByClassName(f);var g=[];e=e.getElementsByTagName(h||"*");
|
|
return f=" "+f+" ",A(e,function(l){0<=(" "+(l.className||"")+" ").indexOf(f)&&g.push(l)}),g}function M(e){var f=q.createElement("div");return f.innerHTML=e,f.childNodes}function A(e,f){var h=e.length;if(h===D)for(var g in e){if(e.hasOwnProperty(g)&&!1===f.call(e[g],e[g],g))break}else for(g=0;g<h&&!1!==f.call(e[g],e[g],g);g++);}var x=Array.prototype.indexOf,B=Object.assign,p=/MicroMessenger/i.test(navigator.userAgent),r=768>=q.documentElement.clientWidth,t=(q.images[0]||0).src||"",H=E("site")||E("Site")||
|
|
q.title,N=E("title")||E("Title")||q.title,O=E("description")||E("Description")||"",a={url:location.href,origin:location.origin,source:H,title:N,description:O,image:t,imageSelector:D,weiboKey:"",wechatQrcodeTitle:"\u5fae\u4fe1\u626b\u4e00\u626b\uff1a\u5206\u4eab",wechatQrcodeHelper:"<p>\u5fae\u4fe1\u91cc\u70b9\u201c\u53d1\u73b0\u201d\uff0c\u626b\u4e00\u4e0b</p><p>\u4e8c\u7ef4\u7801\u4fbf\u53ef\u5c06\u672c\u6587\u5206\u4eab\u81f3\u670b\u53cb\u5708\u3002</p>",wechatQrcodeSize:100,sites:"weibo qq wechat douban qzone linkedin facebook twitter google".split(" "),
|
|
mobileSites:[],disabled:[],initialized:!1},b={qzone:"http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={{URL}}&title={{TITLE}}&desc={{DESCRIPTION}}&summary={{SUMMARY}}&site={{SOURCE}}&pics={{IMAGE}}",qq:'http://connect.qq.com/widget/shareqq/index.html?url={{URL}}&title={{TITLE}}&source={{SOURCE}}&desc={{DESCRIPTION}}&pics={{IMAGE}}&summary="{{SUMMARY}}"',weibo:"https://service.weibo.com/share/share.php?url={{URL}}&title={{TITLE}}&pic={{IMAGE}}&appkey={{WEIBOKEY}}",wechat:"javascript:",
|
|
douban:"http://shuo.douban.com/!service/share?href={{URL}}&name={{TITLE}}&text={{DESCRIPTION}}&image={{IMAGE}}&starid=0&aid=0&style=11",linkedin:"http://www.linkedin.com/shareArticle?mini=true&ro=true&title={{TITLE}}&url={{URL}}&summary={{SUMMARY}}&source={{SOURCE}}&armin=armin",facebook:"https://www.facebook.com/sharer/sharer.php?u={{URL}}",twitter:"https://twitter.com/intent/tweet?text={{TITLE}}&url={{URL}}&via={{ORIGIN}}",google:"https://plus.google.com/share?url={{URL}}"};J.socialShare=function(e,
|
|
f){(e="string"==typeof e?z(e):e).length===D&&(e=[e]);A(e,function(h){h.initialized||function(g,l){l=function(){var m=arguments;if(B)return B.apply(null,m);var k={};return A(m,function(u){A(u,function(v,n){k[n]=v})}),m[0]=k}({},a,l||{},function(m){if(m.dataset)return JSON.parse(JSON.stringify(m.dataset));var k={};return m.hasAttributes()?(A(m.attributes,function(u){var v=u.name;if(0!==v.indexOf("data-"))return!0;v=v.replace(/^data-/i,"").replace(/-(\w)/g,function(n,C){return C.toUpperCase()});k[v]=
|
|
u.value}),k):{}}(g));l.imageSelector&&(l.image=z(l.imageSelector).map(function(m){return m.src}).join("||"));(function(m,k){if(k&&"string"==typeof k){k=(m.className+" "+k).split(/\s+/);var u=" ";A(k,function(v){0>u.indexOf(" "+v+" ")&&(u+=v+" ")});m.className=u.slice(1,-1)}})(g,"share-component social-share");(function(m,k){var u=function(n){n.mobileSites.length||(n.mobileSites=n.sites);var C=(r?n.mobileSites:n.sites).slice(0);n=n.disabled;"string"==typeof C&&(C=C.split(/\s*,\s*/));"string"==typeof n&&
|
|
(n=n.split(/\s*,\s*/));p&&n.push("wechat");return n.length&&A(n,function(w){var F=C,I=F.splice;a:{var G=C,y=void 0;if(G){if(x){w=x.call(G,w,y);break a}var L=G.length;for(y=y?0>y?Math.max(0,L+y):y:0;y<L;y++)if(y in G&&G[y]===w){w=y;break a}}w=-1}I.call(F,w,1)}),C}(k),v="prepend"==k.mode;A(v?u.reverse():u,function(n){var C=function(F,I){I.summary||(I.summary=I.description);return b[F].replace(/\{\{(\w)(\w*)\}\}/g,function(G,y,L){G=F+y+L.toLowerCase();return L=(y+L).toLowerCase(),encodeURIComponent((I[G]===
|
|
D?I[L]:I[G])||"")})}(n,k),w=k.initialized?K(m,"icon-"+n):M('<a class="social-share-icon icon-'+n+'"></a>');if(!w.length)return!0;w[0].href=C;"wechat"===n?w[0].tabindex=-1:w[0].target="_blank";k.initialized||(v?m.insertBefore(w[0],m.firstChild):m.appendChild(w[0]))})})(g,l);(function(m,k){m=K(m,"icon-wechat","a");if(0!==m.length){var u=M('<div class="wechat-qrcode"><h4></h4><div class="qrcode"></div><div class="help"></div></div>'),v=K(u[0],"qrcode","div");$(".wechat-qrcode .qrcode").attr("title",
|
|
null);new QRCode(v[0],{text:k.url,width:k.wechatQrcodeSize,height:k.wechatQrcodeSize});m[0].appendChild(u[0])}})(g,l);g.initialized=!0}(h,f)})};var c=function(){socialShare(".social-share, .share-component")};var d=q.addEventListener?"":"on";~q.readyState.indexOf("m")?c():"load DOMContentLoaded readystatechange".replace(/\w+/g,function(e,f){(f?q:J)[d?"attachEvent":"addEventListener"](d+e,function(){c&&(6>f||~q.readyState.indexOf("m"))&&(c(),c=0)},!1)})})(window,document); |