Skip to content

Commit

Permalink
hide qrcode behind a function (#62)
Browse files Browse the repository at this point in the history
* hide qrcode behind a function
  • Loading branch information
mebjas authored Jun 13, 2020
1 parent 97a3c10 commit bb9abbc
Show file tree
Hide file tree
Showing 6 changed files with 2,603 additions and 2,586 deletions.
16 changes: 11 additions & 5 deletions html5-qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ class Html5Qrcode {
* would be printed to console.
*/
constructor(elementId, verbose) {
if (!qrcode) {
if (!getLazarSoftScanner) {
throw 'Use html5qrcode.min.js without edit, getLazarSoftScanner'
+ 'not found.';
}

this.qrcode = getLazarSoftScanner();
if (!this.qrcode) {
throw 'qrcode is not defined, use the minified/html5-qrcode.min.js'
+ ' for proper support';
}
Expand Down Expand Up @@ -119,7 +125,7 @@ class Html5Qrcode {

this._shouldScan = true;
this._element = element;
qrcode.callback = qrCodeSuccessCallback;
this.qrcode.callback = qrCodeSuccessCallback;

// Validate before insertion
if (isShadedBoxEnabled) {
Expand Down Expand Up @@ -211,7 +217,7 @@ class Html5Qrcode {
/* dWidth= */ $this._qrRegion.width,
/* dHeight= */ $this._qrRegion.height);
try {
qrcode.decode();
$this.qrcode.decode();
this._possiblyUpdateShaders(/* qrMatch= */ true);
} catch (exception) {
this._possiblyUpdateShaders(/* qrMatch= */ false);
Expand Down Expand Up @@ -326,7 +332,7 @@ class Html5Qrcode {

const $this = this;
return new Promise((resolve, /* ignore */ reject) => {
qrcode.callback = null;
$this.qrcode.callback = null;
const tracksToClose
= $this._localMediaStream.getVideoTracks().length;
var tracksClosed = 0;
Expand Down Expand Up @@ -494,7 +500,7 @@ class Html5Qrcode {
/* dWidth= */ config.width,
/* dHeight= */ config.height);
try {
resolve(qrcode.decode());
resolve($this.qrcode.decode());
} catch (exception) {
reject(`QR code parse error, error = ${exception}`);
}
Expand Down
4 changes: 2 additions & 2 deletions minified/html5-qrcode.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html5-qrcode",
"version": "1.1.2",
"version": "1.1.3",
"description": "a cross platform HTML5 QR Code scanner",
"main": "html5-qrcode.js",
"scripts": {
Expand Down
Loading

0 comments on commit bb9abbc

Please sign in to comment.