From b3982a102d37f01c897f13581c699d6248d4d368 Mon Sep 17 00:00:00 2001 From: PASSER-BY Date: Thu, 16 May 2024 08:12:24 +0800 Subject: [PATCH] =?UTF-8?q?updated=20=E5=B1=9E=E6=80=A7=E5=80=BC=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/widget-qrcode.min.js | 4 ++-- src/widget-qrcode.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/widget-qrcode.min.js b/dist/widget-qrcode.min.js index 9c078eb..db4f57a 100644 --- a/dist/widget-qrcode.min.js +++ b/dist/widget-qrcode.min.js @@ -8,8 +8,8 @@ * Released under the MIT License * https://github.com/mumuy/widget-qrcode * - * Created on: 2024-05-16 + * Created on: 2024-05-15 */ !function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r65536?(n[0]=240|(1835008&a)>>>18,n[1]=128|(258048&a)>>>12,n[2]=128|(4032&a)>>>6,n[3]=128|63&a):a>2048?(n[0]=224|(61440&a)>>>12,n[1]=128|(4032&a)>>>6,n[2]=128|63&a):a>128?(n[0]=192|(1984&a)>>>6,n[1]=128|63&a):n[0]=a,this.parsedData.push(n)}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 m(){this.buffer=[],this.length=0}p.prototype={getLength:function(t){return this.parsedData.length},write:function(t){for(var e=0,r=this.parsedData.length;e>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-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++}};for(var y={glog:function(t){if(t<1)throw new Error("glog("+t+")");return y.LOG_TABLE[t]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return y.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},b=0;b<8;b++)y.EXP_TABLE[b]=1<=0;)e^=S.G15<=0;)e^=S.G18<>>=1;return e},getPatternPosition:function(t){return S.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case L:return(e+r)%2==0;case M:return e%2==0;case B:return r%3==0;case A:return(e+r)%3==0;case T:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case E:return e*r%2+e*r%3==0;case D:return(e*r%2+e*r%3)%2==0;case I:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new C([1],0),r=0;r5&&(r+=3+o-5)}for(var l=0;lc.length)throw new Error("Too long data");return r}function O(t,e,r,n,a){var o,i;switch(n){case 0:o=e*a,i=r*a,t.lineTo(o,i);break;case 1:o=e*a+a,i=r*a,t.lineTo(o,i);break;case 2:o=e*a+a,i=r*a+a,t.lineTo(o,i);break;case 3:o=e*a,i=r*a+a,t.lineTo(o,i)}}function V(t,e,r,n,a){var o,i,u=a/2;switch(n){case 0:o=e*a+u,i=r*a+u,t.arc(o,i,u,Math.PI,1.5*Math.PI,!1);break;case 1:o=e*a+a-u,i=r*a+u,t.arc(o,i,u,1.5*Math.PI,2*Math.PI,!1);break;case 2:o=e*a+a-u,i=r*a+a-u,t.arc(o,i,u,0,Math.PI/2,!1);break;case 3:o=e*a+u,i=r*a+a-u,t.arc(o,i,u,Math.PI/2,Math.PI,!1)}}function x(t,e,r,n,a){var o,i,u=a/2;switch(t.beginPath(),n){case 0:o=e*a+u,i=r*a+u,t.arc(o,i,u,Math.PI,1.5*Math.PI,!1),o=e*a,i=r*a;break;case 1:o=e*a+a-u,i=r*a+u,t.arc(o,i,u,1.5*Math.PI,2*Math.PI,!1),o=e*a+a,i=r*a;break;case 2:o=e*a+a-u,i=r*a+a-u,t.arc(o,i,u,0,Math.PI/2,!1),o=e*a+a,i=r*a+a;break;case 3:o=e*a+u,i=r*a+a-u,t.arc(o,i,u,Math.PI/2,Math.PI,!1),o=e*a,i=r*a+a}t.lineTo(o,i),t.closePath(),t.fill(),t.stroke()}function H(t){return{getValue:function(e,r){var n;return null==t||null===(n=t[e])||void 0===n?void 0:n[r]},isPositionPoint:function(e,r){if(!t)return!1;var n=t.length,a=0;return e>=2&&e<5&&r>=2&&r<5?a=1:e<7&&r<7?a=2:e>=n-5&&e=2&r<5?a=1:e>=n-7&&e=0&r<7?a=2:e>=2&&e<5&&r>=n-5&r=0&&e<7&&r>=n-7&r=o||u>=o||(t[i][u]=2)}}}R.prototype={addData:function(t){var e=new p(t);this.dataList.push(e),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var r=0;r=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=R.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(this.modules[t+r][e+n]=0<=r&&r<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=n&&n<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=S.getLostPoint(this);(0==r||t>n)&&(t=n,e=r)}return e},createMovieClip:function(t,e,r){var n=t.createEmptyMovieClip(e,r);this.make();for(var a=0;a>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(var a=0;a<18;a++){var o=!t&&1==(e>>a&1);this.modules[a%3+this.moduleCount-8-3][Math.floor(a/3)]=o}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,n=S.getBCHTypeInfo(r),a=0;a<15;a++){var o=!t&&1==(n>>a&1);a<6?this.modules[a][8]=o:a<8?this.modules[a+1][8]=o:this.modules[this.moduleCount-15+a][8]=o}for(var i=0;i<15;i++){var u=!t&&1==(n>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=u:i<9?this.modules[8][15-i-1+1]=u:this.modules[8][15-i-1]=u}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,n=this.moduleCount-1,a=7,o=0,i=this.moduleCount-1;i>0;i-=2)for(6==i&&i--;;){for(var u=0;u<2;u++)if(null==this.modules[n][i-u]){var s=!1;o>>a&1)),S.getMask(e,n,i-u)&&(s=!s),this.modules[n][i-u]=s,-1==--a&&(o++,a=7)}if((n+=r)<0||this.moduleCount<=n){n-=r,r=-r;break}}}},R.PAD0=236,R.PAD1=17,R.createData=function(t,e,r){for(var n=k.getRSBlocks(t,e),a=new m,o=0;o8*u)throw new Error("code length overflow. ("+a.getLengthInBits()+">"+8*u+")");for(a.getLengthInBits()+4<=8*u&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(!1);for(;!(a.getLengthInBits()>=8*u||(a.put(R.PAD0,8),a.getLengthInBits()>=8*u));)a.put(R.PAD1,8);return R.createBytes(a,n)},R.createBytes=function(t,e){for(var r=0,n=0,a=0,o=new Array(e.length),i=new Array(e.length),u=0;u=0?f.get(d):0}}for(var v=0,p=0;p\n \n ',e.$module=e.shadowRoot.querySelector(".mod-qrcode"),e.$canvas=e.$module.querySelector("canvas"),e.context=e.$canvas.getContext("2d"),e.resize(),"undefined"!=typeof ResizeObserver&&new ResizeObserver((function(){e.resize()})).observe(e)}},{key:"resize",value:function(){var t=this,e=Math.max(t.clientWidth,t.clientHeight);t.$canvas.width=2*e,t.$canvas.height=2*e,t.drawQRCode()}},{key:"drawQRCode",value:function(){var t=this,e=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://passer-by.com/",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"H",r=new R(_(t,h[e]),h[e]);return r.addData(t),r.make(),r.modules}(t.value,t.level);t.context.clearRect(0,0,t.$canvas.width,t.$canvas.height),(j[t.template]||j.default)(t.context,e,{})}}],i=[{key:"observedAttributes",get:function(){return["value","template","level","width","height"]}}],n&&a(r.prototype,n),i&&a(r,i),Object.defineProperty(r,"prototype",{writable:!1}),s}(l(HTMLElement));customElements.get("widget-qrcode")||customElements.define("widget-qrcode",z)}(); +s.getValue(l,h-1)&&s.getValue(l-1,h)&&x(t,l,h,0,o),s.getValue(l,h+1)&&s.getValue(l-1,h)&&x(t,l,h,3,o),s.getValue(l,h+1)&&s.getValue(l+1,h)&&x(t,l,h,2,o),s.getValue(l,h-1)&&s.getValue(l+1,h)&&x(t,l,h,1,o);t.restore()},star:function(t,e,r){var n=e.length,a=.05*t.canvas.width,o=(t.canvas.width-2*a)/n,i=a,u=a,s=H(e);t.save(),t.fillStyle="#ffffff",t.fillRect(0,0,t.canvas.width,t.canvas.height),t.restore(),t.save(),t.translate(i,u),t.fillStyle="rgb(17,36,67)";for(var l=0;l\n \n ',e.$module=e.shadowRoot.querySelector(".mod-qrcode"),e.$canvas=e.$module.querySelector("canvas"),e.context=e.$canvas.getContext("2d"),e.resize(),"undefined"!=typeof ResizeObserver&&new ResizeObserver((function(){e.resize()})).observe(e)}},{key:"resize",value:function(){var t=this,e=Math.max(t.clientWidth,t.clientHeight);t.$canvas.width=2*e,t.$canvas.height=2*e,t.drawQRCode()}},{key:"drawQRCode",value:function(){var t=this,e=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://passer-by.com/",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"H",r=new R(_(t,h[e]),h[e]);return r.addData(t),r.make(),r.modules}(t.value,t.level);t.context.clearRect(0,0,t.$canvas.width,t.$canvas.height),(j[t.template]||j.default)(t.context,e,{})}}],i=[{key:"observedAttributes",get:function(){return["value","template","level","width","height"]}}],n&&a(r.prototype,n),i&&a(r,i),Object.defineProperty(r,"prototype",{writable:!1}),s}(l(HTMLElement));customElements.get("widget-qrcode")||customElements.define("widget-qrcode",z)}(); diff --git a/src/widget-qrcode.js b/src/widget-qrcode.js index ef6e609..e2d89d1 100644 --- a/src/widget-qrcode.js +++ b/src/widget-qrcode.js @@ -25,7 +25,7 @@ class WidgetQRCode extends HTMLElement { return +this.getAttribute('height')||0; } attributeChangedCallback(name, oldValue, newValue){ - if(name=='text'&&oldValue!=newValue){ + if(name=='value'&&oldValue!=newValue){ this.context&&this.drawQRCode(); } }