-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarcodescanner-ios.js
executable file
·76 lines (59 loc) · 2.27 KB
/
barcodescanner-ios.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* PhoneGap/Cordova is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
* Copyright (c) Matt Kane 2010
* Copyright (c) 2010, IBM Corporation
*/
;(function(){
//-------------------------------------------------------------------
var BarcodeScanner = function() {
}
//-------------------------------------------------------------------
BarcodeScanner.Encode = {
TEXT_TYPE: "TEXT_TYPE",
EMAIL_TYPE: "EMAIL_TYPE",
PHONE_TYPE: "PHONE_TYPE",
SMS_TYPE: "SMS_TYPE",
CONTACT_TYPE: "CONTACT_TYPE",
LOCATION_TYPE: "LOCATION_TYPE"
}
//-------------------------------------------------------------------
BarcodeScanner.prototype.scan = function(success, fail, options) {
function successWrapper(result) {
result.cancelled = (result.cancelled == 1)
success.call(null, result)
}
if (!fail) { fail = function() {}}
if (typeof fail != "function") {
console.log("BarcodeScanner.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, "org.apache.cordova.barcodeScanner", "scan", options)
}
//-------------------------------------------------------------------
BarcodeScanner.prototype.encode = function(type, data, success, fail, options) {
if (!fail) { fail = function() {}}
if (typeof fail != "function") {
console.log("BarcodeScanner.scan failure: failure parameter not a function")
return
}
if (typeof success != "function") {
fail("success callback parameter must be a function")
return
}
return Cordova.exec(success, fail, "org.apache.cordova.barcodeScanner", "encode", [{type: type, data: data, options: options}])
}
//-------------------------------------------------------------------
// remove Cordova.addConstructor since it was not supported on PhoneGap 2.0
if (!window.plugins) window.plugins = {}
if (!window.plugins.barcodeScanner) {
window.plugins.barcodeScanner = new BarcodeScanner()
}
})();