Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
error checking, data validation
Browse files Browse the repository at this point in the history
  • Loading branch information
scheideman committed Dec 2, 2015
1 parent 2830a6d commit d5e84c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
22 changes: 17 additions & 5 deletions src/blackberry10/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
var barcodescanner,
resultObjs = {},
readCallback,
_utils = require("../../lib/utils");
var qr = require('plugin/BarcodeScanner/qrcode.js');
_utils = require("../../lib/utils"),
qr = require('plugin/BarcodeScanner/qrcode.js');


//var _qr = require('qrcode');


module.exports = {
Expand Down Expand Up @@ -56,9 +56,20 @@ module.exports = {
values = JSON.parse(values);
data = values["data"];
type = values["type"];

if(data == "" || data == undefined || data.length == 0){
result.error("Data was not specified", false);
return;
}
if(type == "" || type == undefined){
type = "TEXT_TYPE";
}

console.log("Type: "+type + " Data: " + data);

var bdiv = document.createElement('div'); //need div to make QRcode
//Make QRcode using javascript library
var bdiv = document.createElement('div');
var tdiv = document.createElement('div');
var options = {
text: data,
width: 128,
Expand All @@ -67,13 +78,14 @@ module.exports = {
colorLight : "#ffffff",
};
var qrcode = qr.makeQRcode(bdiv, options);

var imageURI = qrcode._oDrawing._elCanvas.toDataURL();

try{
result.ok(imageURI,false);
}catch(e){
result.error("Failed to encode barcode", false);
}

}
};

Expand Down
1 change: 0 additions & 1 deletion www/blackberry10/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ var encode = function(type, data, succ, fail) {
var value = null,
success = function (data, response) {
value = data;
console.log("Hello");
succ(data["image"]);
},
failure = function (data, response) {
Expand Down

0 comments on commit d5e84c9

Please sign in to comment.