-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript-scan.js
62 lines (45 loc) · 1.44 KB
/
script-scan.js
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
51
52
53
54
55
56
57
58
EVT.use(EVT.Scan);
var evtLastScannedProduct = '';
function scanSuccess (data){
'use strict';
$(document).ready(function () {
$('#results').html('<h2>Scan Successful</h2>' + '<pre>' +
JSON.stringify(data, null, 2) + '</pre>');
evtLastScannedProduct = data.evrythngId;
console.log('Last Scanned Product : ' + evtLastScannedProduct);
});
}
function scanError (error){
'use strict';
$(document).ready(function () {
$('#results').html('<h2>Error</h2>' + '<pre>' +
JSON.stringify(error, null, 2) + '</pre>');
});
}
// bar code (ean13) : 7806723188635
function scanProduct(scanType) {
'use strict';
// Config can be changed at scan time, eg a QR CODE -> scanThng.identify({scanType: 'QRCODE'});
console.log('Scan Type : ' + scanType);
console.log('Scan geolocation activated='+geoactive);
currentProject.app.scan({redirect: false,
createScanAction : geoactive,
type : scanType})
.then(
scanSuccess,
scanError
);
}
function scanWithSnapShot(dataUri){
currentProject.app.scan(dataUri).then(scanSuccess, scanError);
}
$(document).ready(function() {
$("#koscan").click(function(){
scanProduct('objpic');
});
/* Register event for taking an snap shot */
$("#kosnap").click(function(){
image = takeSnapshot();
scanWithSnapShot(image);
});
});