-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqrcode_worker.js
More file actions
50 lines (45 loc) · 1.28 KB
/
qrcode_worker.js
File metadata and controls
50 lines (45 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
self.addEventListener('message', function(e) {
const input = e.data;
switch (input.cmd) {
case 'init':
init();
break;
case 'process':
process(input);
break;
default:
console.log('Unknown command for QRCode worker.');
break;
}
});
function init() {
self.importScripts(
'lib/jsqrcode/src/grid.js',
'lib/jsqrcode/src/version.js',
'lib/jsqrcode/src/detector.js',
'lib/jsqrcode/src/formatinf.js',
'lib/jsqrcode/src/errorlevel.js',
'lib/jsqrcode/src/bitmat.js',
'lib/jsqrcode/src/datablock.js',
'lib/jsqrcode/src/bmparser.js',
'lib/jsqrcode/src/datamask.js',
'lib/jsqrcode/src/rsdecoder.js',
'lib/jsqrcode/src/gf256poly.js',
'lib/jsqrcode/src/gf256.js',
'lib/jsqrcode/src/decoder.js',
'lib/jsqrcode/src/qrcode.js',
'lib/jsqrcode/src/findpat.js',
'lib/jsqrcode/src/alignpat.js',
'lib/jsqrcode/src/databr.js'
);
}
function process(input) {
qrcode.width = input.width;
qrcode.height = input.height;
qrcode.imagedata = input.imageData;
let result = false;
try {
result = qrcode.process();
} catch (e) {}
postMessage(result);
}