Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update version.js #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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))
{
Expand Down Expand Up @@ -187,19 +187,19 @@ 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)
{
return this.getVersionForNumber(i + 7);
}
// 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;
Expand Down Expand Up @@ -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))));
}
}