diff options
Diffstat (limited to 'deps/npm/node_modules/qrcode-terminal/vendor/QRCode')
8 files changed, 159 insertions, 158 deletions
diff --git a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js index 8460b910b7..94bf74f0e8 100644 --- a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js +++ b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js @@ -10,7 +10,7 @@ QR8bitByte.prototype = { getLength : function() { return this.data.length; }, - + write : function(buffer) { for (var i = 0; i < this.data.length; i++) { // not JIS ... diff --git a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js index 3e857b5345..e2861f68d1 100644 --- a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js +++ b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js @@ -9,28 +9,28 @@ QRBitBuffer.prototype = { var bufIndex = Math.floor(index / 8); return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1; }, - + put : function(num, length) { for (var i = 0; i < length; i++) { this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1); } }, - + getLengthInBits : function() { return this.length; }, - + putBit : function(bit) { - + var bufIndex = Math.floor(this.length / 8); if (this.buffer.length <= bufIndex) { this.buffer.push(0); } - + if (bit) { this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) ); } - + this.length++; } }; diff --git a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js index 14e08fbaa3..9b4b30099d 100644 --- a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js +++ b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js @@ -4,3 +4,4 @@ module.exports = { Q : 3, H : 2 }; + diff --git a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRMath.js b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRMath.js index 11e324c981..8f4a0370eb 100644 --- a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRMath.js +++ b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRMath.js @@ -1,33 +1,33 @@ var QRMath = { glog : function(n) { - + if (n < 1) { throw new Error("glog(" + n + ")"); } - + return QRMath.LOG_TABLE[n]; }, - + gexp : function(n) { - + while (n < 0) { n += 255; } - + while (n >= 256) { n -= 255; } - + return QRMath.EXP_TABLE[n]; }, - + EXP_TABLE : new Array(256), - + LOG_TABLE : new Array(256) }; - + for (var i = 0; i < 8; i++) { QRMath.EXP_TABLE[i] = 1 << i; } diff --git a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js index f8754cbcb4..0c05f38ef3 100644 --- a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js +++ b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js @@ -22,42 +22,42 @@ QRPolynomial.prototype = { get : function(index) { return this.num[index]; }, - + getLength : function() { return this.num.length; }, - + multiply : function(e) { - + var num = new Array(this.getLength() + e.getLength() - 1); - + for (var i = 0; i < this.getLength(); i++) { for (var j = 0; j < e.getLength(); j++) { num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i) ) + QRMath.glog(e.get(j) ) ); } } - + return new QRPolynomial(num, 0); }, - + mod : function(e) { - + if (this.getLength() - e.getLength() < 0) { return this; } - + var ratio = QRMath.glog(this.get(0) ) - QRMath.glog(e.get(0) ); - + var num = new Array(this.getLength() ); - + for (var i = 0; i < this.getLength(); i++) { num[i] = this.get(i); } - + for (var x = 0; x < e.getLength(); x++) { num[x] ^= QRMath.gexp(QRMath.glog(e.get(x) ) + ratio); } - + // recursive call return new QRPolynomial(num, 0).mod(e); } diff --git a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js index becd24d4dd..d150af1746 100644 --- a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js +++ b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js @@ -17,7 +17,7 @@ QRRSBlock.RS_BLOCK_TABLE = [ [1, 26, 16], [1, 26, 13], [1, 26, 9], - + // 2 [1, 44, 34], [1, 44, 28], @@ -30,43 +30,43 @@ QRRSBlock.RS_BLOCK_TABLE = [ [2, 35, 17], [2, 35, 13], - // 4 + // 4 [1, 100, 80], [2, 50, 32], [2, 50, 24], [4, 25, 9], - + // 5 [1, 134, 108], [2, 67, 43], [2, 33, 15, 2, 34, 16], [2, 33, 11, 2, 34, 12], - + // 6 [2, 86, 68], [4, 43, 27], [4, 43, 19], [4, 43, 15], - - // 7 + + // 7 [2, 98, 78], [4, 49, 31], [2, 32, 14, 4, 33, 15], [4, 39, 13, 1, 40, 14], - + // 8 [2, 121, 97], [2, 60, 38, 2, 61, 39], [4, 40, 18, 2, 41, 19], [4, 40, 14, 2, 41, 15], - + // 9 [2, 146, 116], [3, 58, 36, 2, 59, 37], [4, 36, 16, 4, 37, 17], [4, 36, 12, 4, 37, 13], - - // 10 + + // 10 [2, 86, 68, 2, 87, 69], [4, 69, 43, 1, 70, 44], [6, 43, 19, 2, 44, 20], @@ -254,17 +254,17 @@ QRRSBlock.RS_BLOCK_TABLE = [ ]; QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) { - + var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel); - + if (rsBlock === undefined) { throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel); } var length = rsBlock.length / 3; - + var list = []; - + for (var i = 0; i < length; i++) { var count = rsBlock[i * 3 + 0]; @@ -272,10 +272,10 @@ QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) { var dataCount = rsBlock[i * 3 + 2]; for (var j = 0; j < count; j++) { - list.push(new QRRSBlock(totalCount, dataCount) ); + list.push(new QRRSBlock(totalCount, dataCount) ); } } - + return list; }; diff --git a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js index 31008cb466..e5b7d5b3cc 100644 --- a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js +++ b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js @@ -16,7 +16,7 @@ var QRUtil = { [6, 24, 42], [6, 26, 46], [6, 28, 50], - [6, 30, 54], + [6, 30, 54], [6, 32, 58], [6, 34, 62], [6, 26, 46, 66], @@ -55,7 +55,7 @@ var QRUtil = { getBCHTypeInfo : function(data) { var d = data << 10; while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) { - d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) ); + d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) ); } return ( (data << 10) | d) ^ QRUtil.G15_MASK; }, @@ -63,7 +63,7 @@ var QRUtil = { getBCHTypeNumber : function(data) { var d = data << 12; while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) { - d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) ); + d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) ); } return (data << 12) | d; }, @@ -85,9 +85,9 @@ var QRUtil = { }, getMask : function(maskPattern, i, j) { - + switch (maskPattern) { - + case QRMaskPattern.PATTERN000 : return (i + j) % 2 === 0; case QRMaskPattern.PATTERN001 : return i % 2 === 0; case QRMaskPattern.PATTERN010 : return j % 3 === 0; @@ -160,15 +160,15 @@ var QRUtil = { }, getLostPoint : function(qrCode) { - + var moduleCount = qrCode.getModuleCount(); var lostPoint = 0; - var row = 0; + var row = 0; var col = 0; - + // LEVEL1 - + for (row = 0; row < moduleCount; row++) { for (col = 0; col < moduleCount; col++) { @@ -223,12 +223,12 @@ var QRUtil = { for (row = 0; row < moduleCount; row++) { for (col = 0; col < moduleCount - 6; col++) { - if (qrCode.isDark(row, col) && - !qrCode.isDark(row, col + 1) && - qrCode.isDark(row, col + 2) && - qrCode.isDark(row, col + 3) && - qrCode.isDark(row, col + 4) && - !qrCode.isDark(row, col + 5) && + if (qrCode.isDark(row, col) && + !qrCode.isDark(row, col + 1) && + qrCode.isDark(row, col + 2) && + qrCode.isDark(row, col + 3) && + qrCode.isDark(row, col + 4) && + !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6) ) { lostPoint += 40; } @@ -250,7 +250,7 @@ var QRUtil = { } // LEVEL4 - + var darkCount = 0; for (col = 0; col < moduleCount; col++) { @@ -260,11 +260,11 @@ var QRUtil = { } } } - + var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5; lostPoint += ratio * 10; - return lostPoint; + return lostPoint; } }; diff --git a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/index.js b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/index.js index 0fb6c39362..10eb8eb0a0 100644 --- a/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/index.js +++ b/deps/npm/node_modules/qrcode-terminal/vendor/QRCode/index.js @@ -8,7 +8,7 @@ // Licensed under the MIT license: // http://www.opensource.org/licenses/mit-license.php // -// The word "QR Code" is registered trademark of +// The word "QR Code" is registered trademark of // DENSO WAVE INCORPORATED // http://www.denso-wave.com/qrcode/faqpatent-e.html // @@ -32,13 +32,13 @@ function QRCode(typeNumber, errorCorrectLevel) { } QRCode.prototype = { - + addData : function(data) { var newData = new QR8bitByte(data); this.dataList.push(newData); this.dataCache = null; }, - + isDark : function(row, col) { if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) { throw new Error(row + "," + col); @@ -49,7 +49,7 @@ QRCode.prototype = { getModuleCount : function() { return this.moduleCount; }, - + make : function() { // Calculate automatically typeNumber if provided is < 1 if (this.typeNumber < 1 ){ @@ -76,96 +76,96 @@ QRCode.prototype = { } this.makeImpl(false, this.getBestMaskPattern() ); }, - + makeImpl : function(test, maskPattern) { - + this.moduleCount = this.typeNumber * 4 + 17; this.modules = new Array(this.moduleCount); - + for (var row = 0; row < this.moduleCount; row++) { - + this.modules[row] = new Array(this.moduleCount); - + for (var col = 0; col < this.moduleCount; col++) { this.modules[row][col] = null;//(col + row) % 3; } } - + this.setupPositionProbePattern(0, 0); this.setupPositionProbePattern(this.moduleCount - 7, 0); this.setupPositionProbePattern(0, this.moduleCount - 7); this.setupPositionAdjustPattern(); this.setupTimingPattern(); this.setupTypeInfo(test, maskPattern); - + if (this.typeNumber >= 7) { this.setupTypeNumber(test); } - + if (this.dataCache === null) { this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList); } - + this.mapData(this.dataCache, maskPattern); }, setupPositionProbePattern : function(row, col) { - + for (var r = -1; r <= 7; r++) { - + if (row + r <= -1 || this.moduleCount <= row + r) continue; - + for (var c = -1; c <= 7; c++) { - + if (col + c <= -1 || this.moduleCount <= col + c) continue; - - if ( (0 <= r && r <= 6 && (c === 0 || c === 6) ) || - (0 <= c && c <= 6 && (r === 0 || r === 6) ) || + + if ( (0 <= r && r <= 6 && (c === 0 || c === 6) ) || + (0 <= c && c <= 6 && (r === 0 || r === 6) ) || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) { this.modules[row + r][col + c] = true; } else { this.modules[row + r][col + c] = false; } - } - } + } + } }, - + getBestMaskPattern : function() { - + var minLostPoint = 0; var pattern = 0; - + for (var i = 0; i < 8; i++) { - + this.makeImpl(true, i); - + var lostPoint = QRUtil.getLostPoint(this); - + if (i === 0 || minLostPoint > lostPoint) { minLostPoint = lostPoint; pattern = i; } } - + return pattern; }, - + createMovieClip : function(target_mc, instance_name, depth) { - + var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth); var cs = 1; - + this.make(); for (var row = 0; row < this.modules.length; row++) { - + var y = row * cs; - + for (var col = 0; col < this.modules[row].length; col++) { - + var x = col * cs; var dark = this.modules[row][col]; - + if (dark) { qr_mc.beginFill(0, 100); qr_mc.moveTo(x, y); @@ -176,19 +176,19 @@ QRCode.prototype = { } } } - + return qr_mc; }, setupTimingPattern : function() { - + for (var r = 8; r < this.moduleCount - 8; r++) { if (this.modules[r][6] !== null) { continue; } this.modules[r][6] = (r % 2 === 0); } - + for (var c = 8; c < this.moduleCount - 8; c++) { if (this.modules[6][c] !== null) { continue; @@ -196,27 +196,27 @@ QRCode.prototype = { this.modules[6][c] = (c % 2 === 0); } }, - + setupPositionAdjustPattern : function() { - + var pos = QRUtil.getPatternPosition(this.typeNumber); - + for (var i = 0; i < pos.length; i++) { - + for (var j = 0; j < pos.length; j++) { - + var row = pos[i]; var col = pos[j]; - + if (this.modules[row][col] !== null) { continue; } - + for (var r = -2; r <= 2; r++) { - + for (var c = -2; c <= 2; c++) { - - if (Math.abs(r) === 2 || + + if (Math.abs(r) === 2 || Math.abs(c) === 2 || (r === 0 && c === 0) ) { this.modules[row + r][col + c] = true; @@ -228,34 +228,34 @@ QRCode.prototype = { } } }, - + setupTypeNumber : function(test) { - + var bits = QRUtil.getBCHTypeNumber(this.typeNumber); var mod; - + for (var i = 0; i < 18; i++) { mod = (!test && ( (bits >> i) & 1) === 1); this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod; } - + for (var x = 0; x < 18; x++) { mod = (!test && ( (bits >> x) & 1) === 1); this.modules[x % 3 + this.moduleCount - 8 - 3][Math.floor(x / 3)] = mod; } }, - + setupTypeInfo : function(test, maskPattern) { - + var data = (this.errorCorrectLevel << 3) | maskPattern; var bits = QRUtil.getBCHTypeInfo(data); var mod; - - // vertical + + // vertical for (var v = 0; v < 15; v++) { - + mod = (!test && ( (bits >> v) & 1) === 1); - + if (v < 6) { this.modules[v][8] = mod; } else if (v < 8) { @@ -264,12 +264,12 @@ QRCode.prototype = { this.modules[this.moduleCount - 15 + v][8] = mod; } } - + // horizontal for (var h = 0; h < 15; h++) { - + mod = (!test && ( (bits >> h) & 1) === 1); - + if (h < 8) { this.modules[8][this.moduleCount - h - 1] = mod; } else if (h < 9) { @@ -278,53 +278,53 @@ QRCode.prototype = { this.modules[8][15 - h - 1] = mod; } } - + // fixed module this.modules[this.moduleCount - 8][8] = (!test); - + }, - + mapData : function(data, maskPattern) { - + var inc = -1; var row = this.moduleCount - 1; var bitIndex = 7; var byteIndex = 0; - + for (var col = this.moduleCount - 1; col > 0; col -= 2) { - + if (col === 6) col--; - + while (true) { - + for (var c = 0; c < 2; c++) { - + if (this.modules[row][col - c] === null) { - + var dark = false; - + if (byteIndex < data.length) { dark = ( ( (data[byteIndex] >>> bitIndex) & 1) === 1); } - + var mask = QRUtil.getMask(maskPattern, row, col - c); - + if (mask) { dark = !dark; } - + this.modules[row][col - c] = dark; bitIndex--; - + if (bitIndex === -1) { byteIndex++; bitIndex = 7; } } } - + row += inc; - + if (row < 0 || this.moduleCount <= row) { row -= inc; inc = -inc; @@ -332,7 +332,7 @@ QRCode.prototype = { } } } - + } }; @@ -341,11 +341,11 @@ QRCode.PAD0 = 0xEC; QRCode.PAD1 = 0x11; QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) { - + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel); - + var buffer = new QRBitBuffer(); - + for (var i = 0; i < dataList.length; i++) { var data = dataList[i]; buffer.put(data.mode, 4); @@ -360,10 +360,10 @@ QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) { } if (buffer.getLengthInBits() > totalDataCount * 8) { - throw new Error("code length overflow. (" + - buffer.getLengthInBits() + - ">" + - totalDataCount * 8 + + throw new Error("code length overflow. (" + + buffer.getLengthInBits() + + ">" + + totalDataCount * 8 + ")"); } @@ -379,12 +379,12 @@ QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) { // padding while (true) { - + if (buffer.getLengthInBits() >= totalDataCount * 8) { break; } buffer.put(QRCode.PAD0, 8); - + if (buffer.getLengthInBits() >= totalDataCount * 8) { break; } @@ -397,13 +397,13 @@ QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) { QRCode.createBytes = function(buffer, rsBlocks) { var offset = 0; - + var maxDcCount = 0; var maxEcCount = 0; - + var dcdata = new Array(rsBlocks.length); var ecdata = new Array(rsBlocks.length); - + for (var r = 0; r < rsBlocks.length; r++) { var dcCount = rsBlocks[r].dataCount; @@ -411,14 +411,14 @@ QRCode.createBytes = function(buffer, rsBlocks) { maxDcCount = Math.max(maxDcCount, dcCount); maxEcCount = Math.max(maxEcCount, ecCount); - + dcdata[r] = new Array(dcCount); - + for (var i = 0; i < dcdata[r].length; i++) { dcdata[r][i] = 0xff & buffer.buffer[i + offset]; } offset += dcCount; - + var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount); var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1); @@ -430,7 +430,7 @@ QRCode.createBytes = function(buffer, rsBlocks) { } } - + var totalCodeCount = 0; for (var y = 0; y < rsBlocks.length; y++) { totalCodeCount += rsBlocks[y].totalCount; |