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

Fix accidental global variables #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/QRCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/


qrcode = {};
var qrcode = {};
qrcode.imagedata = null;
qrcode.width = 0;
qrcode.height = 0;
Expand Down Expand Up @@ -154,8 +154,8 @@ qrcode.getPixel = function(x,y){
if (qrcode.height < y) {
throw "point error";
}
point = (x * 4) + (y * qrcode.width * 4);
p = (qrcode.imagedata.data[point]*33 + qrcode.imagedata.data[point + 1]*34 + qrcode.imagedata.data[point + 2]*33)/100;
var point = (x * 4) + (y * qrcode.width * 4);
var p = (qrcode.imagedata.data[point]*33 + qrcode.imagedata.data[point + 1]*34 + qrcode.imagedata.data[point + 2]*33)/100;
return p;
}

Expand Down
2 changes: 1 addition & 1 deletion src/databr.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ function QRCodeDataBlockReader(blocks, version, numErrorCorrectionCode)
canvas.println("Guessed mode: " + mode); */
throw "Invalid mode: " + mode + " in (block:" + this.blockPointer + " bit:" + this.bitPointer + ")";
}
dataLength = this.getDataLength(mode);
var dataLength = this.getDataLength(mode);
if (dataLength < 1)
throw "Invalid data length: " + dataLength;
//canvas.println("length: " + dataLength);
Expand Down
2 changes: 1 addition & 1 deletion src/datamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/


DataMask = {};
var DataMask = {};

DataMask.forReference = function(reference)
{
Expand Down
2 changes: 1 addition & 1 deletion src/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/


Decoder={};
var Decoder={};
Decoder.rsDecoder = new ReedSolomonDecoder(GF256.QR_CODE_FIELD);

Decoder.correctErrors=function( codewordBytes, numDataCodewords)
Expand Down
22 changes: 11 additions & 11 deletions src/detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,21 @@ PerspectiveTransform.quadrilateralToQuadrilateral=function( x0, y0, x1, y1,

PerspectiveTransform.squareToQuadrilateral=function( x0, y0, x1, y1, x2, y2, x3, y3)
{
dy2 = y3 - y2;
dy3 = y0 - y1 + y2 - y3;
var dy2 = y3 - y2;
var dy3 = y0 - y1 + y2 - y3;
if (dy2 == 0.0 && dy3 == 0.0)
{
return new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0, 0.0, 1.0);
}
else
{
dx1 = x1 - x2;
dx2 = x3 - x2;
dx3 = x0 - x1 + x2 - x3;
dy1 = y1 - y2;
denominator = dx1 * dy2 - dx2 * dy1;
a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
var dx1 = x1 - x2;
var dx2 = x3 - x2;
var dx3 = x0 - x1 + x2 - x3;
var dy1 = y1 - y2;
var denominator = dx1 * dy2 - dx2 * dy1;
var a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
var a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0);
}
}
Expand Down Expand Up @@ -258,8 +258,8 @@ function Detector(image)

this.distance=function( pattern1, pattern2)
{
xDiff = pattern1.X - pattern2.X;
yDiff = pattern1.Y - pattern2.Y;
var xDiff = pattern1.X - pattern2.X;
var yDiff = pattern1.Y - pattern2.Y;
return Math.sqrt( (xDiff * xDiff + yDiff * yDiff));
}
this.computeDimension=function( topLeft, topRight, bottomLeft, moduleSize)
Expand Down
6 changes: 3 additions & 3 deletions src/findpat.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ qrcode.orderBestPatterns=function(patterns)

function distance( pattern1, pattern2)
{
xDiff = pattern1.X - pattern2.X;
yDiff = pattern1.Y - pattern2.Y;
var xDiff = pattern1.X - pattern2.X;
var yDiff = pattern1.Y - pattern2.Y;
return Math.sqrt( (xDiff * xDiff + yDiff * yDiff));
}

Expand Down Expand Up @@ -391,7 +391,7 @@ function FinderPatternFinder()
if (startSize < 3)
{
// Couldn't find enough finder patterns
throw "Couldn't find enough finder patterns";
throw "Couldn't find enough finder patterns (found " + startSize + ")";
}

// Filter outlier possibilities whose module size is too different
Expand Down
2 changes: 1 addition & 1 deletion src/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/


GridSampler = {};
var GridSampler = {};

GridSampler.checkAndNudgePoints=function( image, points)
{
Expand Down