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

Commit

Permalink
qrcode encode working
Browse files Browse the repository at this point in the history
  • Loading branch information
scheideman committed Nov 30, 2015
1 parent c662c85 commit 2830a6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
21 changes: 5 additions & 16 deletions src/blackberry10/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,24 @@ module.exports = {
encode: function (success, fail, args, env) {

var result = new PluginResult(args, env);
//resultObjs[result.callbackId] = result;
//readCallback = result.callbackId;
//console.log(args);
values = decodeURIComponent(args[0]);
values = JSON.parse(values);
//console.log(values);
data = values["data"];
type = values["type"];
console.log("Type: "+type + " Data: " + data);
var bdiv = document.createElement('div');
//maybe add try catch

var bdiv = document.createElement('div'); //need div to make QRcode
var options = {
text: data,
width: 128,
height: 128,
colorDark : "#000000",
colorLight : "#ffffff",
};
qr.makeQRcode(bdiv, options);

//console.log(bdiv);
var barcode = bdiv.childNodes[1];
console.log(String(barcode.src));
var image = encodeURI(barcode.src);
var qrcode = qr.makeQRcode(bdiv, options);
var imageURI = qrcode._oDrawing._elCanvas.toDataURL();
try{
//result.callbackOk({image: barcode}, true);
//result.ok(bdiv,true);
result.ok(barcode,false);
//success(bdiv);
result.ok(imageURI,false);
}catch(e){
result.error("Failed to encode barcode", false);
}
Expand Down
3 changes: 2 additions & 1 deletion src/blackberry10/qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ var QRCode;

module.exports = {
makeQRcode : function(el, vOption){
qrcode = new QRCode(el, vOption);
var qrcode = new QRCode(el, vOption);
return qrcode
}
}
})();

0 comments on commit 2830a6d

Please sign in to comment.