mirror of
https://github.com/lrsjng/jquery-qrcode.git
synced 2026-08-12 20:01:55 +08:00
Fixes.
This commit is contained in:
+32
-39
@@ -10,50 +10,44 @@
|
|||||||
// Wrapper for the original QR code generator.
|
// Wrapper for the original QR code generator.
|
||||||
var QRCode = function (version, level, text) {
|
var QRCode = function (version, level, text) {
|
||||||
|
|
||||||
try {
|
// `qrcode` is the single public function that will be defined by the `QR Code Generator`
|
||||||
|
// at the end of the file.
|
||||||
|
var qr = qrcode(version, level);
|
||||||
|
qr.addData(text);
|
||||||
|
qr.make();
|
||||||
|
|
||||||
// `qrcode` is the single public function that will be defined by the `QR Code Generator`
|
var moduleCount = qr.getModuleCount(),
|
||||||
// at the end of the file.
|
isDark = function (col, row) {
|
||||||
var qr = qrcode(version, level);
|
|
||||||
qr.addData(text);
|
|
||||||
qr.make();
|
|
||||||
|
|
||||||
var moduleCount = qr.getModuleCount(),
|
return qr.isDark(col, row);
|
||||||
isDark = function (col, row) {
|
},
|
||||||
|
extIsDarkFn = function (width, height, blank) {
|
||||||
|
|
||||||
return qr.isDark(col, row);
|
if (!blank) {
|
||||||
},
|
return isDark;
|
||||||
extIsDarkFn = function (width, height, blank) {
|
}
|
||||||
|
|
||||||
if (!blank) {
|
var moduleCount = qr.getModuleCount(),
|
||||||
return isDark;
|
moduleWidth = width / moduleCount,
|
||||||
}
|
moduleHeight = height / moduleCount;
|
||||||
|
|
||||||
var moduleCount = qr.getModuleCount(),
|
return function (row, col) {
|
||||||
moduleWidth = width / moduleCount,
|
|
||||||
moduleHeight = height / moduleCount;
|
|
||||||
|
|
||||||
return function (row, col) {
|
var l = col * moduleWidth,
|
||||||
|
t = row * moduleHeight,
|
||||||
|
r = l + moduleWidth,
|
||||||
|
b = t + moduleHeight;
|
||||||
|
|
||||||
var l = col * moduleWidth,
|
return isDark(row, col) && (blank.l > r || l > blank.r || blank.t > b || t > blank.b);
|
||||||
t = row * moduleHeight,
|
|
||||||
r = l + moduleWidth,
|
|
||||||
b = t + moduleHeight;
|
|
||||||
|
|
||||||
return isDark(row, col) && (blank.l > r || l > blank.r || blank.t > b || t > blank.b);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.moduleCount = moduleCount;
|
this.moduleCount = moduleCount;
|
||||||
this.isDark = isDark;
|
this.isDark = isDark;
|
||||||
this.extIsDarkFn = extIsDarkFn;
|
this.extIsDarkFn = extIsDarkFn;
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Check if canvas is available in the browser (as Modernizr does)
|
// Check if canvas is available in the browser (as Modernizr does)
|
||||||
@@ -70,10 +64,9 @@
|
|||||||
minVersion = Math.max(1, minVersion);
|
minVersion = Math.max(1, minVersion);
|
||||||
maxVersion = Math.min(40, maxVersion);
|
maxVersion = Math.min(40, maxVersion);
|
||||||
for (var version = minVersion; version <= maxVersion; version += 1) {
|
for (var version = minVersion; version <= maxVersion; version += 1) {
|
||||||
var qr = new QRCode(version, level, text);
|
try {
|
||||||
if (qr) {
|
return new QRCode(version, level, text);
|
||||||
return qr;
|
} catch (err) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user