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

Commit

Permalink
encode method or blackberry
Browse files Browse the repository at this point in the history
  • Loading branch information
scheideman committed Nov 27, 2015
1 parent b005d77 commit c662c85
Show file tree
Hide file tree
Showing 4 changed files with 676 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugin.xml
Expand Up @@ -351,6 +351,7 @@
<!-- BlackBerry 10 -->
<platform name="blackberry10">
<source-file src="src/blackberry10/index.js" target-dir="BarcodeScanner" />
<source-file src="src/blackberry10/qrcode.js" target-dir="BarcodeScanner" />
<lib-file src="src/blackberry10/native/device/libBarcodeScanner.so" arch="device"/>
<lib-file src="src/blackberry10/native/simulator/libBarcodeScanner.so" arch="simulator"/>
<config-file target="www/config.xml" parent="/widget">
Expand Down
38 changes: 38 additions & 0 deletions src/blackberry10/index.js
Expand Up @@ -17,6 +17,10 @@ var barcodescanner,
resultObjs = {},
readCallback,
_utils = require("../../lib/utils");
var qr = require('plugin/BarcodeScanner/qrcode.js');

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


module.exports = {

Expand Down Expand Up @@ -47,6 +51,40 @@ 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 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);
try{
//result.callbackOk({image: barcode}, true);
//result.ok(bdiv,true);
result.ok(barcode,false);
//success(bdiv);
}catch(e){
result.error("Failed to encode barcode", false);
}

}
};

Expand Down

0 comments on commit c662c85

Please sign in to comment.