mirror of
https://github.com/wahyd4/BarcodeScanner.git
synced 2026-08-09 04:55:57 +10:00
Encode object access fix.
This commit is contained in:
+37
-19
@@ -13,34 +13,52 @@ cordova.define("cordova/plugin/BarcodeScanner",
|
||||
|
||||
var exec = require("cordova/exec");
|
||||
|
||||
var BarcodeScanner = function () {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @returns {BarcodeScanner}
|
||||
*/
|
||||
function BarcodeScanner() {
|
||||
|
||||
/**
|
||||
* Encoding constants.
|
||||
*
|
||||
* @type Object
|
||||
*/
|
||||
this.Encode = {
|
||||
TEXT_TYPE: "TEXT_TYPE",
|
||||
EMAIL_TYPE: "EMAIL_TYPE",
|
||||
PHONE_TYPE: "PHONE_TYPE",
|
||||
SMS_TYPE: "SMS_TYPE"
|
||||
// CONTACT_TYPE: "CONTACT_TYPE", // TODO: not implemented, requires passing a Bundle class from Javascript to Java
|
||||
// LOCATION_TYPE: "LOCATION_TYPE" // TODO: not implemented, requires passing a Bundle class from Javascript to Java
|
||||
};
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
BarcodeScanner.Encode = {
|
||||
TEXT_TYPE: "TEXT_TYPE",
|
||||
EMAIL_TYPE: "EMAIL_TYPE",
|
||||
PHONE_TYPE: "PHONE_TYPE",
|
||||
SMS_TYPE: "SMS_TYPE",
|
||||
// CONTACT_TYPE: "CONTACT_TYPE", // TODO: not implemented, requires passing a Bundle class from Javascript to Java
|
||||
// LOCATION_TYPE: "LOCATION_TYPE" // TODO: not implemented, requires passing a Bundle class from Javascript to Java
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/**
|
||||
* Read code from scanner.
|
||||
*
|
||||
* @param {Function} successCallback This function will recieve a result object: {
|
||||
* text : '12345-mock', // The code that was scanned.
|
||||
* format : 'FORMAT_NAME', // Code format.
|
||||
* cancelled : true/false, // Was canceled.
|
||||
* }
|
||||
* @param {Function} errorCallback
|
||||
*/
|
||||
BarcodeScanner.prototype.scan = function (successCallback, errorCallback) {
|
||||
if (errorCallback == null) {
|
||||
errorCallback = function () {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof errorCallback != "function") {
|
||||
console.log("BarcodeScanner.scan failure: failure parameter not a function");
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof successCallback != "function") {
|
||||
console.log("BarcodeScanner.scan failure: success callback parameter must be a function");
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
exec(successCallback, errorCallback, 'BarcodeScanner', 'scan', []);
|
||||
@@ -50,17 +68,17 @@ cordova.define("cordova/plugin/BarcodeScanner",
|
||||
BarcodeScanner.prototype.encode = function (type, data, successCallback, errorCallback, options) {
|
||||
if (errorCallback == null) {
|
||||
errorCallback = function () {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof errorCallback != "function") {
|
||||
console.log("BarcodeScanner.encode failure: failure parameter not a function");
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof successCallback != "function") {
|
||||
console.log("BarcodeScanner.encode failure: success callback parameter must be a function");
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
exec(successCallback, errorCallback, 'BarcodeScanner', 'encode', [
|
||||
@@ -70,4 +88,4 @@ cordova.define("cordova/plugin/BarcodeScanner",
|
||||
|
||||
var barcodeScanner = new BarcodeScanner();
|
||||
module.exports = barcodeScanner;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user