Encode object access fix.

This commit is contained in:
Eccenux
2013-07-29 14:38:23 +02:00
parent 32880fc1fa
commit 6fd905a8e6
+37 -19
View File
@@ -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;
});
});