diff --git a/qr/logger.js b/qr/logger.js new file mode 100644 index 0000000000..daabcd5581 --- /dev/null +++ b/qr/logger.js @@ -0,0 +1 @@ +!function(){"use strict";var t=["log","error","info","warn","debug"],e=[/\%c next state/,/\%c prev state/,/\%c action/],r=["up","down","up"],n=2e3,o={default:{37:["left","Left"],38:["up","Up"],39:["right","Right"],40:["down","Down"],13:["action","Enter"],32:["toggle","Space"],80:["stop","p"],8:["back","Backspace"],27:["quit","Escape"],81:["special1","q"]},playstation:{37:["left","Left"],38:["up","Up"],39:["right","Right"],40:["down","Down"],32:["action","Square"],13:["toggle","X"],112:["stop","Triangle"],8:["back","O"],117:["quit","R1"],116:["special1","L1"]},samsungTv:{37:["left","Left"],38:["up","Up"],39:["right","Right"],40:["down","Down"],13:["action","Enter"],427:["toggle","ChannelUp"],10009:["back","Back"],428:["quit","ChannelDown"]},canalStb:{13:["action","OK"],37:["left","Left"],38:["up","Up"],39:["right","Right"],40:["down","Down"],48:["toggle","0"],49:["stop","1"],50:["quit","2"],51:["special1","3"],8:["back","Back"]}},i=[["playstation",{userAgent:/PlayStation/i}],["canalStb",{userAgent:/WyplaySTB/}],["samsungTv",{userAgent:/Tizen/}]],a="function"==typeof window.TextDecoder?new TextDecoder:null,s="function"==typeof window.TextEncoder?new TextEncoder:null;function u(t,e,r){if(null==t||null==e)return t;var n=String(t),o=e;if(isNaN(o)||!isFinite(o))return n;var i=n.length;if(i>=o)return n;var a=String(r);""===a&&(a=" ");for(var s=o-i;a.lengths?a.substr(0,s):a)+n}function l(t){if(s)try{return s.encode(t)}catch(t){}var e,r=encodeURIComponent(t);if("function"==typeof unescape)e=unescape(r);else{var n=/[0-9a-fA-F]/,o=r.length;e="";for(var i=0;i=e?r:new Array(e-r.length+1).join("0")+r}function c(t){if(a)try{return a.decode(t)}catch(t){}var e,r=t;239===r[0]&&187===r[1]&&191===r[2]&&(r=r.subarray(3));var n=function(t){for(var e="",r=0;r=256?"%u"+f(s,4):"%"+f(s,2)}}return decodeURIComponent(e)}var h={backgroundColor:"transparent",margin:"0px",border:"none",overflow:"initial",fontSize:"13px",padding:"4px",fontFamily:"monospace mono",whiteSpace:"break-spaces"},g=function(){function r(t,e){this._stopListeningFns=[],this._logsContainerElt=t,this._scrollToLast=e,this._focusedLogIdx=-1,this._stopListeningFns=[],this._lastLogId=0,this._LOGS_ARRAY=[]}return r.prototype.getLogs=function(){for(var t="",e=Math.max(this._LOGS_ARRAY.length-500,0);e0},r.prototype.startListening=function(){if(!this.isListening()){var r=console.error.bind(console),n=this;this._stopListeningFns=t.map((function(t){var r=console[t];return console[t]=function(){if(!n.isListening())return r.apply(this,arguments);for(var o=[],i=0;i=50;)this._logsContainerElt.removeChild(this._logsContainerElt.children[0]);this._logsContainerElt.appendChild(r)},r.prototype._addLog=function(t,e){var r=new Date,n=u(String(r.getHours()),2,"0")+":"+u(String(r.getMinutes()),2,"0")+":"+u(String(r.getSeconds()),2,"0")+" ["+t+"] "+e;for(this._lastLogId>=9007199254740991&&(this._lastLogId=0,this._LOGS_ARRAY.length=0,-1===this._focusedLogIdx&&(this._logsContainerElt.innerHTML="")),this._LOGS_ARRAY.push([this._lastLogId++,t,l(n)]);this._LOGS_ARRAY.length>1e3;)this._LOGS_ARRAY.shift();-1===this._focusedLogIdx&&(this._appendLogLine(t,n),this._scrollToLast())},r}();function d(t){var e;switch(typeof t){case"function":case"symbol":case"bigint":default:e="";break;case"string":e=t;break;case"number":case"undefined":case"boolean":e=String(t);break;case"object":e=null===t?"null":t instanceof Error?"NAME: "+String(t.name)+" ~ CODE: "+String(t.code)+" ~ MESSAGE: "+String(t.message):"{}"}return"string"==typeof e&&e.length>2e3?e.substring(0,1999)+"…":e}function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}var v=function(){var t=function(t,e){var r=t,n=f[e],o=null,i=0,a=null,s=[],u={},l=function(t,e){o=function(t){for(var e=new Array(t),r=0;r=7&&d(t),null==a&&(a=_(r,n,s)),y(a,e)},c=function(t,e){for(var r=-1;r<=7;r+=1)if(!(t+r<=-1||i<=t+r))for(var n=-1;n<=7;n+=1)e+n<=-1||i<=e+n||(o[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)},h=function(){for(var t=8;t>n&1);o[Math.floor(n/3)][n%3+i-8-3]=a}for(n=0;n<18;n+=1){a=!t&&1==(e>>n&1);o[n%3+i-8-3][Math.floor(n/3)]=a}},v=function(t,e){for(var r=n<<3|e,a=A.getBCHTypeInfo(r),s=0;s<15;s+=1){var u=!t&&1==(a>>s&1);s<6?o[s][8]=u:s<8?o[s+1][8]=u:o[i-15+s][8]=u}for(s=0;s<15;s+=1){u=!t&&1==(a>>s&1);s<8?o[8][i-s-1]=u:s<9?o[8][15-s-1+1]=u:o[8][15-s-1]=u}o[i-8][8]=!t},y=function(t,e){for(var r=-1,n=i-1,a=7,s=0,u=A.getMaskFunction(e),l=i-1;l>0;l-=2)for(6==l&&(l-=1);;){for(var f=0;f<2;f+=1)if(null==o[n][l-f]){var c=!1;s>>a&1)),u(n,l-f)&&(c=!c),o[n][l-f]=c,-1==(a-=1)&&(s+=1,a=7)}if((n+=r)<0||i<=n){n-=r,r=-r;break}}},_=function(t,e,r){for(var n=x.getRSBlocks(t,e),o=b(),i=0;i8*s)throw"code length overflow. ("+o.getLengthInBits()+">"+8*s+")";for(o.getLengthInBits()+4<=8*s&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(!1);for(;!(o.getLengthInBits()>=8*s||(o.put(236,8),o.getLengthInBits()>=8*s));)o.put(17,8);return function(t,e){for(var r=0,n=0,o=0,i=new Array(e.length),a=new Array(e.length),s=0;s=0?h.getAt(g):0}}var d=0;for(f=0;fn)&&(t=n,e=r)}return e}())},u.createTableTag=function(t,e){t=t||2;var r="";r+='',r+="";for(var n=0;n";for(var o=0;o';r+=""}return r+="",r+="
"},u.createSvgTag=function(t,e,r,n){var o={};"object"==p(arguments[0])&&(t=(o=arguments[0]).cellSize,e=o.margin,r=o.alt,n=o.title),t=t||2,e=void 0===e?4*t:e,(r="string"==typeof r?{text:r}:r||{}).text=r.text||null,r.id=r.text?r.id||"qrcode-description":null,(n="string"==typeof n?{text:n}:n||{}).text=n.text||null,n.id=n.text?n.id||"qrcode-title":null;var i,a,s,l,f=u.getModuleCount()*t+2*e,c="";for(l="l"+t+",0 0,"+t+" -"+t+",0 0,-"+t+"z ",c+=''+w(n.text)+"":"",c+=r.text?''+w(r.text)+"":"",c+='',c+='":e+=">";break;case"&":e+="&";break;case'"':e+=""";break;default:e+=n}}return e};return u.createASCII=function(t,e){if((t=t||1)<2)return function(t){t=void 0===t?2:t;var e,r,n,o,i,a=1*u.getModuleCount()+2*t,s=t,l=a-t,f={"██":"█","█ ":"▀"," █":"▄"," ":" "},c={"██":"▀","█ ":"▀"," █":" "," ":" "},h="";for(e=0;e=l?c[i]:f[i];h+="\n"}return a%2&&t>0?h.substring(0,h.length-a-1)+Array(a+1).join("▀"):h.substring(0,h.length-1)}(e);t-=1,e=void 0===e?2*t:e;var r,n,o,i,a=u.getModuleCount()*t+2*e,s=e,l=a-e,f=Array(t+1).join("██"),c=Array(t+1).join(" "),h="",g="";for(r=0;r>>8),e.push(255&a)):e.push(n)}}return e}};var e,r,n,o,i,a=1,s=2,u=4,l=8,f={L:1,M:0,Q:3,H:2},c=0,h=1,g=2,d=3,v=4,y=5,_=6,w=7,A=(e=[[],[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]],r=1335,n=7973,i=function(t){for(var e=0;0!=t;)e+=1,t>>>=1;return e},(o={}).getBCHTypeInfo=function(t){for(var e=t<<10;i(e)-i(r)>=0;)e^=r<=0;)e^=n<5&&(r+=3+i-5)}for(n=0;n=256;)e-=255;return t[e]}};return n}();function L(t,e){if(void 0===t.length)throw t.length+"/"+e;var r=function(){for(var r=0;r>>7-e%8&1)},put:function(t,e){for(var n=0;n>>e-n-1&1))},getLengthInBits:function(){return e},putBit:function(r){var n=Math.floor(e/8);t.length<=n&&t.push(0),r&&(t[n]|=128>>>e%8),e+=1}};return r},C=function(t){var e=a,r=t,n={getMode:function(){return e},getLength:function(t){return r.length},write:function(t){for(var e=r,n=0;n+2>>8&255)+(255&n),t.put(n,13),r+=2}if(r>>8)},writeBytes:function(t,r,n){r=r||0,n=n||t.length;for(var o=0;o0&&(e+=","),e+=t[r];return e+="]"}};return e},D=function(t){var e=t,r=0,n=0,o=0,i={read:function(){for(;o<8;){if(r>=e.length){if(0==o)return-1;throw"unexpected end of file./"+o}var t=e.charAt(r);if(r+=1,"="==t)return o=0,-1;t.match(/^\s$/)||(n=n<<6|a(t.charCodeAt(0)),o+=6)}var i=n>>>o-8&255;return o-=8,i}},a=function(t){if(65<=t&&t<=90)return t-65;if(97<=t&&t<=122)return t-97+26;if(48<=t&&t<=57)return t-48+52;if(43==t)return 62;if(47==t)return 63;throw"c:"+t};return i},T=function(t,e,r){for(var n=function(t,e){var r=t,n=e,o=new Array(t*e),i={setPixel:function(t,e,n){o[e*r+t]=n},write:function(t){t.writeString("GIF87a"),t.writeShort(r),t.writeShort(n),t.writeByte(128),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(255),t.writeByte(255),t.writeByte(255),t.writeString(","),t.writeShort(0),t.writeShort(0),t.writeShort(r),t.writeShort(n),t.writeByte(0);var e=a(2);t.writeByte(2);for(var o=0;e.length-o>255;)t.writeByte(255),t.writeBytes(e,o,255),o+=255;t.writeByte(e.length-o),t.writeBytes(e,o,e.length-o),t.writeByte(0),t.writeString(";")}},a=function(t){for(var e=1<>>e!=0)throw"length over";for(;l+e>=8;)u.writeByte(255&(t<>>=8-l,f=0,l=0;f|=t<0&&u.writeByte(f)}});h.write(e,n);var g=0,d=String.fromCharCode(o[g]);for(g+=1;g=6;)i(t>>>e-6),e-=6},o.flush=function(){if(e>0&&(i(t<<6-e),t=0,e=0),r%3!=0)for(var o=3-r%3,a=0;a>6,128|63&n):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|63&n):(r++,n=65536+((1023&n)<<10|1023&t.charCodeAt(r)),e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return e}(t)};var y=function(){function t(t){var e,r;this._qrCodeImageElt=((e=document.createElement("div")).style.position="fixed",e.style.top="20px",e.style.left="20px",e.style.zIndex="9999999999",e),this._titleElt=((r=document.createElement("div")).style.position="fixed",r.style.top="750px",r.style.left="20px",r.style.zIndex="9999999999",r.style.color="#000",r.style.backgroundColor="#fff",r.style.padding="5px",r.style.fontWeight="bold",r),this._sourceArray=function(t){for(var e=[],r=600,n=0;n=this._codes.length&&(this._nextQrToDisplay=0),this._displayCode(this._nextQrToDisplay),this._nextQrToDisplay++,this.stopAutoUpdates())},t.prototype.displayPrevious=function(){this.canNavigate()&&(this._nextQrToDisplay-=2,this._nextQrToDisplay<0&&(this._nextQrToDisplay=this._codes.length-1),this._displayCode(this._nextQrToDisplay),this._nextQrToDisplay++,this.stopAutoUpdates())},t.prototype.canNavigate=function(){return this._nextQrToGenerate>=this._sourceArray.length},t.prototype.dispose=function(){this.stopAutoUpdates(),null!==this._qrCodeImageElt.parentElement&&this._qrCodeImageElt.parentElement.removeChild(this._qrCodeImageElt),null!==this._titleElt.parentElement&&this._titleElt.parentElement.removeChild(this._titleElt)},t.prototype._nextStep=function(){var t=this;if(this._nextQrToGenerate>=this._sourceArray.length){if(0===this._codes.length)return;this._nextQrToDisplay>=this._codes.length&&(this._nextQrToDisplay=0),this._displayCode(this._nextQrToDisplay),this._nextQrToDisplay++,this._timeoutId=setTimeout((function(){return t._nextStep()}),400)}else if(this._sourceArray.length>=0){var e=this._generateQrCodeFor(this._nextQrToGenerate);null!==e&&(this._codes.push(e),this._displayCode(this._codes.length-1)),this._nextQrToGenerate++,this._timeoutId=setTimeout((function(){return t._nextStep()}),100)}else this._timeoutId=null},t.prototype._generateQrCodeFor=function(t){if(t<0||t>=this._sourceArray.length)return null;var e=v(0,"M");return e.addData(String(t+1)+"/"+String(this._sourceArray.length)+"."),e.addData(this._sourceArray[t]),e.make(),e.createImgTag(4)},t.prototype._displayCode=function(t){this._nextQrToGenerate>=this._sourceArray.length?this._titleElt.textContent="Generation OK! Displaying: "+String(t+1)+" / "+String(this._codes.length):this._titleElt.textContent="Generating QR codes... (navigation not possible yet): "+String(t+1)+" / "+String(this._sourceArray.length),this._qrCodeImageElt.innerHTML=this._codes[t],this._qrCodeImageElt.children[0].height=720,this._qrCodeImageElt.children[0].width=720},t}();var _={top:"0px",left:"0px",padding:"20px 20px 0px 20px",width:"100%",height:"calc(100% - 80px)",fontSize:"12px",fontFamily:"monospace mono",zIndex:"999999999999999999",backgroundColor:"#000000",opacity:"0.7",color:"#ffffff",display:"flex",flexDirection:"column-reverse",position:"fixed",pointerEvents:"none",overflow:"hidden"},w={bottom:"0px",padding:"10px 20px 20px 20px",width:"100%",height:"50px",fontSize:"14px",zIndex:"9999999999999999999",backgroundColor:"#000",opacity:"0.7",color:"#fff",position:"fixed",pointerEvents:"none",overflow:"hidden"};function A(t){var e=document.createElement("div"),a=document.createElement("div");!function(t){for(var e=Object.keys(_),r=0;r0){for(var g=0;g0){s.appendChild(document.createTextNode(" Available commands: "));for(var _=0;_0&&s.appendChild(document.createTextNode(" - ")),s.appendChild(w(t[_][0])),s.appendChild(document.createTextNode(": "+t[_][1]))}function w(t){var e=document.createElement("span");return e.style.fontWeight="bold",e.textContent=t,e}}function L(e){try{t.removeChild(e)}catch(t){}}function x(e){t.appendChild(e)}}A(document.body)}();