diff --git a/README.md b/README.md index 3040b9a..7c9e266 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,13 @@ jQuery.qrcode is provided under the terms of the [MIT License](http://github.com Uses [QR Code Generator](http://www.d-project.com/qrcode/index.html) (MIT). Kudos to [jquery.qrcode.js](http://github.com/jeromeetienne/jquery-qrcode) (MIT). + ## Changelog +### v0.5.0 - *2013-07-23* + +* adds option to set error correction level + ### v0.4 - *2013-07-09* diff --git a/package.json b/package.json index fa553e4..d1257fc 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "name": "jquery.qrcode", "displayName": "jQuery.qrcode", - "version": "0.4" + "version": "0.5.0" } \ No newline at end of file diff --git a/src/jquery.qrcode.js b/src/jquery.qrcode.js index 339bdda..3aa7b32 100644 --- a/src/jquery.qrcode.js +++ b/src/jquery.qrcode.js @@ -14,11 +14,11 @@ }()), // Wrapper for the original QR code generator. - createQr = function (typeNumber, correctLevel, text) { + createQr = function (typeNumber, correctionLevel, text) { // `qrcode` is the single public function that will be defined by the `QR Code Generator` // at the end of the file. - var qr = qrcode(typeNumber, correctLevel); + var qr = qrcode(typeNumber, correctionLevel); qr.addData(text); qr.make(); @@ -26,12 +26,12 @@ }, // Returns a minimal QR code for the given text. Returns `null` if `text` - // is to long to be encoded. At the moment it should work with up to 271 characters. - createBestQr = function (text) { + // is to long to be encoded. At the moment it should work with up to ~2900 characters. + createBestQr = function (text, correctionLevel) { for (var type = 2; type <= 40; type += 1) { try { - return createQr(type, 'L', text); + return createQr(type, correctionLevel, text); } catch (err) {} } @@ -43,6 +43,7 @@ // some shortcuts to improve compression var settings_text = settings.text, + settings_ecl = settings.ecl, settings_left = settings.left, settings_top = settings.top, settings_width = settings.width, @@ -50,7 +51,7 @@ settings_color = settings.color, settings_bgColor = settings.bgColor, - qr = createBestQr(settings_text), + qr = createBestQr(settings_text, settings_ecl), $canvas = $(canvas), ctx = $canvas[0].getContext('2d'); @@ -93,13 +94,14 @@ // some shortcuts to improve compression var settings_text = settings.text, + settings_ecl = settings.ecl, settings_width = settings.width, settings_height = settings.height, settings_color = settings.color, settings_bgColor = settings.bgColor, math_floor = Math.floor, - qr = createBestQr(settings_text), + qr = createBestQr(settings_text, settings_ecl), $div = $('
').css({ position: 'relative', left: 0, @@ -164,6 +166,9 @@ // render method: `'canvas'` or `'div'` render: 'canvas', + // error correction level: `'L'`, `'M'`, `'Q'` or `'H'` + ecl: 'L', + // left and top in pixel if drawn onto existing canvas left: 0, top: 0,