qrcode
Advanced tools
Comparing version 0.2.3 to 0.2.4
{ "name": "qrcode" | ||
,"description": "QRCode / 2d Barcode api with both server side and client side support using canvas" | ||
,"version": "0.2.3" | ||
,"version": "0.2.4" | ||
,"author": "Ryan Day <soldair@gmail.com>" | ||
@@ -5,0 +5,0 @@ ,"keywords": ["canvas", "qrcode", "barcode"] |
@@ -28,2 +28,6 @@ /* | ||
// | ||
// export error correct levels. | ||
// | ||
exports.errorCorrectLevels = QRCodeLib.QRErrorCorrectLevel; | ||
@@ -36,3 +40,3 @@ /* | ||
//TODO THIS NEEDS TO WORK | ||
console.log('this doesnt work yet. comming soon =)'); | ||
console.log('this doesnt work yet. comming soon =)'); | ||
}; | ||
@@ -55,3 +59,9 @@ | ||
options = args.shift()||{}; | ||
var textKeys = {'minimum':"L",'medium':"M",'high':"Q",'max':"H"} | ||
if(options.errorCorrectLevel) { | ||
var ec = options.errorCorrectLevel; | ||
if(textKeys[ec]){ | ||
options.errorCorrectLevel = textKeys[ec]; | ||
} | ||
} | ||
//NOTE the width and height are determined from within the qr code lib and are not configurable from the outside yet | ||
@@ -58,0 +68,0 @@ |
@@ -42,21 +42,16 @@ [![Build Status](https://secure.travis-ci.org/soldair/node-qrcode.png)](http://travis-ci.org/soldair/node-qrcode) | ||
<!--[if ie]><script type="text/javascript" src="/vendors/excanvas/excanvas.js"></script><![endif]--> | ||
<script src="/build/qrcode.js"></script> | ||
<canvas id="test"></canvas> | ||
<script> | ||
<!--[if ie]><script type="text/javascript" src="/vendors/excanvas/excanvas.js"></script><![endif]--> | ||
<script src="/build/qrcode.js"></script> | ||
<canvas id="test"></canvas> | ||
<script> | ||
var qrcodedraw = new qrcodelib.qrcodedraw(); | ||
//triggered errors will throw | ||
qrcodedraw.errorbehavior.length = false; | ||
var qrcodedraw = new qrcodelib.qrcodedraw(); | ||
qrcodedraw.draw(document.getElementByID('test'),text,function(error,canvas){ | ||
if(error) { | ||
if(window.console && window.console.warn) { | ||
console.warn(error); | ||
} else { | ||
alert(error); | ||
} | ||
} | ||
}); | ||
</script> | ||
qrcodedraw.draw(document.getElementByID('test'),"this text will be in the code!",function(error,canvas){ | ||
if(error) { | ||
return console.log('Error =( ',error); | ||
} | ||
console.log('success!'); | ||
}); | ||
</script> | ||
@@ -87,3 +82,11 @@ ``` | ||
options | ||
--------- | ||
errorCorrectLevel | ||
can be one of the values in qrcode.errorCorrectLevel | ||
can be a string. one of "minumum","medium","high","max" | ||
if undefined defaults to H which is max error correction | ||
if invalid value defaults to minimum error correction | ||
client side api | ||
@@ -93,6 +96,6 @@ --------------- | ||
window.qrcodelib | ||
- .qrcodedraw() Constructor | ||
- qrcodelib.qrcodedraw() Constructor | ||
qrcodedraw instance | ||
- .draw(canvasElement,text,[optional options],cb); | ||
qrcode = new qrcodelib.qrcodedraw() | ||
- qrcode.draw(canvasElement,text,[optional options],cb); | ||
@@ -99,0 +102,0 @@ |
@@ -21,3 +21,3 @@ var test = require('tap').test; | ||
test('qrcode generated with changed error correction should be expected value',function(t){ | ||
QRCode.toDataURL('i am a pony!',{errorCorrectLevel:'L'},function(err,url){ | ||
QRCode.toDataURL('i am a pony!',{errorCorrectLevel:'minimum'},function(err,url){ | ||
t.ok(!err,'there should be no error '+err); | ||
@@ -24,0 +24,0 @@ t.equals(url,lShouldBe,"url should match expected value for error correction L"); |
791189
29
4137
152