/
zbarcodescanner.js
executable file
·42 lines (31 loc) · 1.16 KB
/
zbarcodescanner.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
;(function(){
//-------------------------------------------------------------------
var ZbarcodeScanner = function() {
}
//-------------------------------------------------------------------
ZbarcodeScanner.prototype.scan = function(success, fail, options) {
console.log("start scan");
function successWrapper(result) {
result.cancelled = (result.cancelled == 1)
success.call(null, result)
}
if (!fail) { fail = function() {}}
if (typeof fail != "function") {
console.log("ZbarcodeScanner.scan failure: failure parameter not a function")
return
}
if (typeof success != "function") {
fail("success callback parameter must be a function")
return
}
if ( null == options )
options = []
return Cordova.exec(successWrapper, fail, "jp.artisanedge.cordova.ZbarcodeScanner", "scan", options)
}
//-------------------------------------------------------------------
// remove Cordova.addConstructor since it was not supported on PhoneGap 2.0
if (!window.plugins) window.plugins = {}
if (!window.plugins.ZbarcodeScanner) {
window.plugins.ZbarcodeScanner = new ZbarcodeScanner()
}
})();