From 798b3572e42356ddb052a1f65b45bf8907914c6d Mon Sep 17 00:00:00 2001 From: Rohit Paul <113459757+RohitPaul12345@users.noreply.github.com> Date: Thu, 17 Aug 2023 18:43:31 +0530 Subject: [PATCH] Update version.js --- src/version.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/version.js b/src/version.js index 4e19c7f1..08bc7961 100644 --- a/src/version.js +++ b/src/version.js @@ -59,8 +59,8 @@ function ECBlocks( ecCodewordsPerBlock, ecBlocks1, ecBlocks2) this.__defineGetter__("NumBlocks", function() { - var total = 0; - for (var i = 0; i < this.ecBlocks.length; i++) + let total = 0; + for (let i = 0; i < this.ecBlocks.length; i++) { total += this.ecBlocks[i].length; } @@ -79,12 +79,12 @@ function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks this.alignmentPatternCenters = alignmentPatternCenters; this.ecBlocks = new Array(ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4); - var total = 0; - var ecCodewords = ecBlocks1.ECCodewordsPerBlock; - var ecbArray = ecBlocks1.getECBlocks(); - for (var i = 0; i < ecbArray.length; i++) + let total = 0; + let ecCodewords = ecBlocks1.ECCodewordsPerBlock; + let ecbArray = ecBlocks1.getECBlocks(); + for (let i = 0; i < ecbArray.length; i++) { - var ecBlock = ecbArray[i]; + let ecBlock = ecbArray[i]; total += ecBlock.Count * (ecBlock.DataCodewords + ecCodewords); } this.totalCodewords = total; @@ -109,8 +109,8 @@ function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks this.buildFunctionPattern=function() { - var dimension = this.DimensionForVersion; - var bitMatrix = new BitMatrix(dimension); + let dimension = this.DimensionForVersion; + let bitMatrix = new BitMatrix(dimension); // Top left finder pattern + separator + format bitMatrix.setRegion(0, 0, 9, 9); @@ -120,11 +120,11 @@ function Version( versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks bitMatrix.setRegion(0, dimension - 8, 9, 8); // Alignment patterns - var max = this.alignmentPatternCenters.length; - for (var x = 0; x < max; x++) + let max = this.alignmentPatternCenters.length; + for (let x = 0; x < max; x++) { - var i = this.alignmentPatternCenters[x] - 2; - for (var y = 0; y < max; y++) + let i = this.alignmentPatternCenters[x] - 2; + for (let y = 0; y < max; y++) { if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) { @@ -187,11 +187,11 @@ Version.getProvisionalVersionForDimension=function(dimension) Version.decodeVersionInformation=function( versionBits) { - var bestDifference = 0xffffffff; - var bestVersion = 0; - for (var i = 0; i < Version.VERSION_DECODE_INFO.length; i++) + let bestDifference = 0xffffffff; + let bestVersion = 0; + for (let i = 0; i < Version.VERSION_DECODE_INFO.length; i++) { - var targetVersion = Version.VERSION_DECODE_INFO[i]; + let targetVersion = Version.VERSION_DECODE_INFO[i]; // Do the version info bits match exactly? done. if (targetVersion == versionBits) { @@ -199,7 +199,7 @@ Version.decodeVersionInformation=function( versionBits) } // Otherwise see if this is the closest to a real version info bit string // we have seen so far - var bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion); + let bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion); if (bitsDifference < bestDifference) { bestVersion = i + 7; @@ -258,4 +258,4 @@ function buildVersions() new Version(38, new Array(6, 32, 58, 84, 110, 136, 162), new ECBlocks(30, new ECB(4, 122), new ECB(18, 123)), new ECBlocks(28, new ECB(13, 46), new ECB(32, 47)), new ECBlocks(30, new ECB(48, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(42, 15), new ECB(32, 16))), new Version(39, new Array(6, 26, 54, 82, 110, 138, 166), new ECBlocks(30, new ECB(20, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(40, 47), new ECB(7, 48)), new ECBlocks(30, new ECB(43, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(10, 15), new ECB(67, 16))), new Version(40, new Array(6, 30, 58, 86, 114, 142, 170), new ECBlocks(30, new ECB(19, 118), new ECB(6, 119)), new ECBlocks(28, new ECB(18, 47), new ECB(31, 48)), new ECBlocks(30, new ECB(34, 24), new ECB(34, 25)), new ECBlocks(30, new ECB(20, 15), new ECB(61, 16)))); -} \ No newline at end of file +}