Skip to content

Commit e5acf19

Browse files
committed
Merge pull request #62 from serratus/issue-53
Adding support for IE
2 parents bc72830 + 2758c9f commit e5acf19

File tree

6 files changed

+44
-13
lines changed

6 files changed

+44
-13
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
quaggaJS
22
========
33

4-
- [Changelog](#changelog) (2015-08-13)
4+
- [Changelog](#changelog) (2015-08-29)
55

66
## What is QuaggaJS?
77

@@ -34,10 +34,10 @@ be aligned with the viewport.
3434

3535
In order to take full advantage of quaggaJS, the browser needs to support the
3636
`getUserMedia` API which is already implemented in recent versions of Firefox,
37-
Chrome and Opera. The API is also available on their mobile counterparts
38-
installed on Android. Safari and IE do not allow the access to the camera yet,
39-
neither on desktop, nor on mobile. You can check [caniuse][caniuse_getusermedia]
40-
for updates.
37+
Chrome, IE (Edge) and Opera. The API is also available on their mobile
38+
counterparts installed on Android (except IE). Safari does not allow the access
39+
to the camera yet, neither on desktop, nor on mobile. You can check
40+
[caniuse][caniuse_getusermedia] for updates.
4141

4242
In cases where real-time decoding is not needed, or the platform does not
4343
support `getUserMedia` QuaggaJS is also capable of decoding image-files using
@@ -377,6 +377,10 @@ on the ``singleChannel`` flag in the configuration when using ``decodeSingle``.
377377

378378
## <a name="changelog">Changelog</a>
379379

380+
### 2015-08-29
381+
- Improvements
382+
- Added support for Internet Explorer (only Edge+ supports `getUserMedia`)
383+
380384
### 2015-08-13
381385
- Improvements
382386
- Added `offProcessed` and `offDetected` methods for detaching event-

dist/quagga.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,15 @@ if (typeof window !== 'undefined') {
835835
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
836836
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
837837
}
838-
838+
Math.imul = Math.imul || function(a, b) {
839+
var ah = (a >>> 16) & 0xffff,
840+
al = a & 0xffff,
841+
bh = (b >>> 16) & 0xffff,
842+
bl = b & 0xffff;
843+
// the shift by 0 fixes the sign on the high part
844+
// the final |0 converts the unsigned value into a signed value
845+
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
846+
};
839847
define("typedefs", (function (global) {
840848
return function () {
841849
var ret, fn;
@@ -9084,10 +9092,10 @@ function(InputStream,
90849092

90859093
blobURL = generateWorkerBlob();
90869094
workerThread.worker = new Worker(blobURL);
9087-
URL.revokeObjectURL(blobURL);
90889095

90899096
workerThread.worker.onmessage = function(e) {
90909097
if (e.data.event === 'initialized') {
9098+
URL.revokeObjectURL(blobURL);
90919099
workerThread.busy = false;
90929100
workerThread.imageData = new Uint8Array(e.data.imageData);
90939101
console.log("Worker initialized");
@@ -9096,6 +9104,8 @@ function(InputStream,
90969104
workerThread.imageData = new Uint8Array(e.data.imageData);
90979105
workerThread.busy = false;
90989106
publishResult(e.data.result, workerThread.imageData);
9107+
} else if (e.data.event === 'error') {
9108+
console.log("Worker error: " + e.data.message);
90999109
}
91009110
};
91019111

@@ -9110,10 +9120,13 @@ function(InputStream,
91109120

91119121
function workerInterface(factory) {
91129122
if (factory) {
9123+
/* jshint ignore:start */
91139124
var Quagga = factory();
91149125
if (!Quagga) {
9126+
self.postMessage({'event': 'error', message: 'Quagga could not be created'});
91159127
return;
91169128
}
9129+
/* jshint ignore:end */
91179130
}
91189131
/* jshint ignore:start */
91199132
var imageWrapper;

dist/quagga.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "quagga",
3-
"version": "0.6.15",
3+
"version": "0.6.16",
44
"description": "An advanced barcode-scanner written in JavaScript",
55
"main": "dist/quagga.js",
66
"devDependencies": {

src/quagga.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ function(InputStream,
332332

333333
blobURL = generateWorkerBlob();
334334
workerThread.worker = new Worker(blobURL);
335-
URL.revokeObjectURL(blobURL);
336335

337336
workerThread.worker.onmessage = function(e) {
338337
if (e.data.event === 'initialized') {
338+
URL.revokeObjectURL(blobURL);
339339
workerThread.busy = false;
340340
workerThread.imageData = new Uint8Array(e.data.imageData);
341341
console.log("Worker initialized");
@@ -344,6 +344,8 @@ function(InputStream,
344344
workerThread.imageData = new Uint8Array(e.data.imageData);
345345
workerThread.busy = false;
346346
publishResult(e.data.result, workerThread.imageData);
347+
} else if (e.data.event === 'error') {
348+
console.log("Worker error: " + e.data.message);
347349
}
348350
};
349351

@@ -358,10 +360,13 @@ function(InputStream,
358360

359361
function workerInterface(factory) {
360362
if (factory) {
363+
/* jshint ignore:start */
361364
var Quagga = factory();
362365
if (!Quagga) {
366+
self.postMessage({'event': 'error', message: 'Quagga could not be created'});
363367
return;
364368
}
369+
/* jshint ignore:end */
365370
}
366371
/* jshint ignore:start */
367372
var imageWrapper;

src/typedefs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,12 @@ if (typeof window !== 'undefined') {
1919
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
2020
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
2121
}
22+
Math.imul = Math.imul || function(a, b) {
23+
var ah = (a >>> 16) & 0xffff,
24+
al = a & 0xffff,
25+
bh = (b >>> 16) & 0xffff,
26+
bl = b & 0xffff;
27+
// the shift by 0 fixes the sign on the high part
28+
// the final |0 converts the unsigned value into a signed value
29+
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
30+
};

0 commit comments

Comments
 (0)