qr.dgnum.eu/www/js/qr-dgnum.min.js
2024-01-24 20:17:20 +01:00

1 line
677 B
JavaScript

const $=e=>document.querySelector(e),n=e=>$(`[name=${e}]`),qr=new QRious({element:$("img"),size:250}),c="change",w=(e,l,r)=>e.addEventListener(l,r);["png","jpeg"].forEach(e=>{let l=n(e);w(l,"click",()=>{let l=document.createElement("a");l.href=qr.toDataURL(`image/${e}`),l.download=`qr-code.${e}`,l.click(),setTimeout(()=>l.remove(),50)})});const a=(e,l)=>{let r=n(l);w(r,e,()=>{qr[l]=r.value||null})};["background","backgroundAlpha","foreground","foregroundAlpha","level"].forEach(e=>a(c,e)),a("input","value");const p=n("padding");w(p,c,()=>{p.validity.valid&&(qr.padding=""!==p.value?p.value:null)});const s=n("size");w(s,c,()=>{s.validity.valid&&(qr.size=s.value||null)});