From 6fd905a8e60a0341fc4a4453f594222eb7cd0b8d Mon Sep 17 00:00:00 2001 From: Eccenux Date: Mon, 29 Jul 2013 14:38:23 +0200 Subject: [PATCH] Encode object access fix. --- www/barcodescanner.js | 56 ++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/www/barcodescanner.js b/www/barcodescanner.js index 3224aad..06b9e46 100644 --- a/www/barcodescanner.js +++ b/www/barcodescanner.js @@ -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; - }); \ No newline at end of file + });