mirror of
https://github.com/lrsjng/jquery-qrcode.git
synced 2026-08-12 20:01:55 +08:00
Maintenance. Add utf-8 support.
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
{
|
||||
"disallowDanglingUnderscores": {
|
||||
"allExcept": ["_exception", "_obj" , "_private"]
|
||||
},
|
||||
"disallowEmptyBlocks": true,
|
||||
"disallowImplicitTypeConversion": [
|
||||
"binary",
|
||||
"boolean",
|
||||
"numeric",
|
||||
"string"
|
||||
],
|
||||
"disallowKeywords": [
|
||||
"with"
|
||||
],
|
||||
"disallowKeywordsOnNewLine": [
|
||||
"else"
|
||||
],
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowMultipleLineStrings": true,
|
||||
"disallowMultipleSpaces": true,
|
||||
"disallowMultipleVarDecl": true,
|
||||
"disallowNewlineBeforeBlockStatements": true,
|
||||
"disallowQuotedKeysInObjects": true,
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": [
|
||||
"++",
|
||||
"--",
|
||||
"+",
|
||||
"-",
|
||||
"~",
|
||||
"!"
|
||||
],
|
||||
"disallowSpaceBeforePostfixUnaryOperators": [
|
||||
"++",
|
||||
"--"
|
||||
],
|
||||
"disallowSpacesInCallExpression": true,
|
||||
"disallowSpacesInsideArrayBrackets": "all",
|
||||
"disallowSpacesInsideObjectBrackets": true,
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowTrailingComma": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"disallowYodaConditions": true,
|
||||
"requireCapitalizedConstructors": true,
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
"requireCurlyBraces": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"try",
|
||||
"catch",
|
||||
"case",
|
||||
"default"
|
||||
],
|
||||
"requireDollarBeforejQueryAssignment": true,
|
||||
"requireDotNotation": true,
|
||||
"requireLineBreakAfterVariableAssignment": true,
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
"requireOperatorBeforeLineBreak": [
|
||||
"?",
|
||||
"=",
|
||||
"+",
|
||||
"-",
|
||||
"/",
|
||||
"*",
|
||||
"==",
|
||||
"===",
|
||||
"!=",
|
||||
"!==",
|
||||
">",
|
||||
">=",
|
||||
"<",
|
||||
"<="
|
||||
],
|
||||
"requireParenthesesAroundIIFE": true,
|
||||
"requireSemicolons": true,
|
||||
"requireSpaceAfterBinaryOperators": [
|
||||
"=",
|
||||
",",
|
||||
"+",
|
||||
"-",
|
||||
"/",
|
||||
"*",
|
||||
"==",
|
||||
"===",
|
||||
"!=",
|
||||
"!=="
|
||||
],
|
||||
"requireSpaceAfterKeywords": [
|
||||
"do",
|
||||
"for",
|
||||
"if",
|
||||
"else",
|
||||
"switch",
|
||||
"case",
|
||||
"try",
|
||||
"catch",
|
||||
"void",
|
||||
"while",
|
||||
"with",
|
||||
"return",
|
||||
"typeof",
|
||||
"function"
|
||||
],
|
||||
"requireSpaceAfterLineComment": true,
|
||||
"requireSpaceBeforeBinaryOperators": [
|
||||
"=",
|
||||
"+",
|
||||
"-",
|
||||
"/",
|
||||
"*",
|
||||
"==",
|
||||
"===",
|
||||
"!=",
|
||||
"!=="
|
||||
],
|
||||
"requireSpaceBeforeBlockStatements": true,
|
||||
"requireSpaceBeforeKeywords": [
|
||||
"else",
|
||||
"while",
|
||||
"catch"
|
||||
],
|
||||
"requireSpaceBeforeObjectValues": true,
|
||||
"requireSpaceBetweenArguments": true,
|
||||
"requireSpacesInAnonymousFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true,
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"requireSpacesInConditionalExpression": {
|
||||
"afterTest": true,
|
||||
"beforeConsequent": true,
|
||||
"afterConsequent": true,
|
||||
"beforeAlternate": true
|
||||
},
|
||||
"requireSpacesInForStatement": true,
|
||||
"validateIndentation": 4,
|
||||
"validateJSDoc": {
|
||||
"checkParamNames": true,
|
||||
"checkRedundantParams": true,
|
||||
"requireParamTypes": true
|
||||
},
|
||||
"validateLineBreaks": "LF",
|
||||
"validateParameterSeparator": ", ",
|
||||
"validateQuoteMarks": "'"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"bitwise": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"forin": true,
|
||||
"freeze": true,
|
||||
"futurehostile": true,
|
||||
"latedef": true,
|
||||
"maxdepth": 3,
|
||||
"noarg": true,
|
||||
"nocomma": true,
|
||||
"nonbsp": true,
|
||||
"nonew": true,
|
||||
"plusplus": true,
|
||||
"strict": false,
|
||||
"supernew": true,
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
|
||||
"browser": true,
|
||||
|
||||
"globals": {
|
||||
"jQuery": false,
|
||||
"qrcode": false
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ jQuery plugin to dynamically generate QR codes. Uses [QR Code Generator][qrcode]
|
||||
## License
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Lars Jung (http://larsjung.de)
|
||||
Copyright (c) 2015 Lars Jung (http://larsjung.de)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -32,9 +32,9 @@ THE SOFTWARE.
|
||||
[web]: http://larsjung.de/qrcode/
|
||||
[github]: https://github.com/lrsjng/jquery-qrcode
|
||||
|
||||
[license-img]: http://img.shields.io/badge/license-MIT-a0a060.svg?style=flat-square
|
||||
[web-img]: http://img.shields.io/badge/web-larsjung.de/qrcode-a0a060.svg?style=flat-square
|
||||
[github-img]: http://img.shields.io/badge/github-lrsjng/jquery--qrcode-a0a060.svg?style=flat-square
|
||||
[bower-img]: http://img.shields.io/badge/bower-lrsjng/jquery--qrcode-a0a060.svg?style=flat-square
|
||||
[license-img]: https://img.shields.io/badge/license-MIT-a0a060.svg?style=flat-square
|
||||
[web-img]: https://img.shields.io/badge/web-larsjung.de/qrcode-a0a060.svg?style=flat-square
|
||||
[github-img]: https://img.shields.io/badge/github-lrsjng/jquery--qrcode-a0a060.svg?style=flat-square
|
||||
[bower-img]: https://img.shields.io/badge/bower-lrsjng/jquery--qrcode-a0a060.svg?style=flat-square
|
||||
|
||||
[qrcode]: https://github.com/kazuhikoarase/qrcode-generator
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jquery-qrcode",
|
||||
"version": "0.11.0",
|
||||
"version": "0.12.0",
|
||||
"description": "generate QR codes dynamically",
|
||||
"homepage": "http://larsjung.de/jquery-qrcode/",
|
||||
"authors": [
|
||||
|
||||
Vendored
+166
-100
@@ -1,14 +1,12 @@
|
||||
/* jQuery.qrcode 0.11.0 - http://larsjung.de/jquery-qrcode/ - uses //github.com/kazuhikoarase/qrcode-generator (MIT) */
|
||||
(function () {
|
||||
'use strict';
|
||||
/* jQuery.qrcode 0.12.0 - http://larsjung.de/jquery-qrcode/ - uses //github.com/kazuhikoarase/qrcode-generator (MIT) */
|
||||
(function (qrcode) {
|
||||
'use strict';
|
||||
|
||||
var $ = jQuery;
|
||||
var $ = jQuery;
|
||||
|
||||
// Wrapper for the original QR code generator.
|
||||
function QRCode(text, level, version, quiet) {
|
||||
// Wrapper for the original QR code generator.
|
||||
function QRCode(text, level, version, quiet) {
|
||||
|
||||
// `qrcode` is the single public function that will be defined by the `QR Code Generator`
|
||||
// at the end of the file.
|
||||
var qr = qrcode(version, level);
|
||||
qr.addData(text);
|
||||
qr.make();
|
||||
@@ -16,7 +14,7 @@ function QRCode(text, level, version, quiet) {
|
||||
quiet = quiet || 0;
|
||||
|
||||
var qrModuleCount = qr.getModuleCount();
|
||||
var quietModuleCount = qr.getModuleCount() + 2*quiet;
|
||||
var quietModuleCount = qr.getModuleCount() + 2 * quiet;
|
||||
|
||||
function isDark(row, col) {
|
||||
|
||||
@@ -52,19 +50,19 @@ function QRCode(text, level, version, quiet) {
|
||||
this.moduleCount = quietModuleCount;
|
||||
this.isDark = isDark;
|
||||
this.addBlank = addBlank;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if canvas is available in the browser (as Modernizr does)
|
||||
var hasCanvas = (function () {
|
||||
// Check if canvas is available in the browser (as Modernizr does)
|
||||
var hasCanvas = (function () {
|
||||
|
||||
var elem = document.createElement('canvas');
|
||||
return !!(elem.getContext && elem.getContext('2d'));
|
||||
return Boolean(elem.getContext && elem.getContext('2d'));
|
||||
}());
|
||||
var hasArcTo = Object.prototype.toString.call(window.opera) !== '[object Opera]';
|
||||
var hasArcTo = Object.prototype.toString.call(window.opera) !== '[object Opera]';
|
||||
|
||||
// Returns a minimal QR code for the given text starting with version `minVersion`.
|
||||
// Returns `undefined` if `text` is too long to be encoded in `maxVersion`.
|
||||
function createQRCode(text, level, minVersion, maxVersion, quiet) {
|
||||
// Returns a minimal QR code for the given text starting with version `minVersion`.
|
||||
// Returns `undefined` if `text` is too long to be encoded in `maxVersion`.
|
||||
function createQRCode(text, level, minVersion, maxVersion, quiet) {
|
||||
|
||||
minVersion = Math.max(1, minVersion || 1);
|
||||
maxVersion = Math.min(40, maxVersion || 40);
|
||||
@@ -73,13 +71,13 @@ function createQRCode(text, level, minVersion, maxVersion, quiet) {
|
||||
return new QRCode(text, level, version, quiet);
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawBackgroundLabel(qr, context, settings) {
|
||||
function drawBackgroundLabel(qr, context, settings) {
|
||||
|
||||
var size = settings.size;
|
||||
var font = "bold " + (settings.mSize * size) + "px " + settings.fontname;
|
||||
var ctx = $('<canvas/>')[0].getContext("2d");
|
||||
var font = 'bold ' + (settings.mSize * size) + 'px ' + settings.fontname;
|
||||
var ctx = $('<canvas/>')[0].getContext('2d');
|
||||
|
||||
ctx.font = font;
|
||||
|
||||
@@ -102,10 +100,10 @@ function drawBackgroundLabel(qr, context, settings) {
|
||||
|
||||
context.fillStyle = settings.fontcolor;
|
||||
context.font = font;
|
||||
context.fillText(settings.label, sl*size, st*size + 0.75 * settings.mSize * size);
|
||||
}
|
||||
context.fillText(settings.label, sl * size, st * size + 0.75 * settings.mSize * size);
|
||||
}
|
||||
|
||||
function drawBackgroundImage(qr, context, settings) {
|
||||
function drawBackgroundImage(qr, context, settings) {
|
||||
|
||||
var size = settings.size;
|
||||
var w = settings.image.naturalWidth || 1;
|
||||
@@ -126,10 +124,10 @@ function drawBackgroundImage(qr, context, settings) {
|
||||
qr.addBlank(sl - pad, st - pad, sr + pad, sb + pad);
|
||||
}
|
||||
|
||||
context.drawImage(settings.image, sl*size, st*size, sw*size, sh*size);
|
||||
}
|
||||
context.drawImage(settings.image, sl * size, st * size, sw * size, sh * size);
|
||||
}
|
||||
|
||||
function drawBackground(qr, context, settings) {
|
||||
function drawBackground(qr, context, settings) {
|
||||
|
||||
if ($(settings.background).is('img')) {
|
||||
context.drawImage(settings.background, 0, 0, settings.size, settings.size);
|
||||
@@ -144,16 +142,16 @@ function drawBackground(qr, context, settings) {
|
||||
} else if (mode === 3 || mode === 4) {
|
||||
drawBackgroundImage(qr, context, settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawModuleDefault(qr, context, settings, left, top, width, row, col) {
|
||||
function drawModuleDefault(qr, context, settings, left, top, width, row, col) {
|
||||
|
||||
if (qr.isDark(row, col)) {
|
||||
context.rect(left, top, width, width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawModuleRoundedDark(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
function drawModuleRoundedDark(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
|
||||
if (nw) {
|
||||
ctx.moveTo(l + rad, t);
|
||||
@@ -188,9 +186,9 @@ function drawModuleRoundedDark(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
} else {
|
||||
ctx.lineTo(l, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawModuleRoundendLight(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
function drawModuleRoundendLight(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
|
||||
if (nw) {
|
||||
ctx.moveTo(l + rad, t);
|
||||
@@ -219,9 +217,9 @@ function drawModuleRoundendLight(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
ctx.lineTo(l, b - rad);
|
||||
ctx.arcTo(l, b, l + rad, b, rad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawModuleRounded(qr, context, settings, left, top, width, row, col) {
|
||||
function drawModuleRounded(qr, context, settings, left, top, width, row, col) {
|
||||
|
||||
var isDark = qr.isDark;
|
||||
var right = left + width;
|
||||
@@ -246,14 +244,15 @@ function drawModuleRounded(qr, context, settings, left, top, width, row, col) {
|
||||
} else {
|
||||
drawModuleRoundendLight(context, left, top, right, bottom, radius, north && west && northwest, north && east && northeast, south && east && southeast, south && west && southwest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawModules(qr, context, settings) {
|
||||
function drawModules(qr, context, settings) {
|
||||
|
||||
var moduleCount = qr.moduleCount;
|
||||
var moduleSize = settings.size / moduleCount;
|
||||
var fn = drawModuleDefault;
|
||||
var row, col;
|
||||
var row;
|
||||
var col;
|
||||
|
||||
if (hasArcTo && settings.radius > 0 && settings.radius <= 0.5) {
|
||||
fn = drawModuleRounded;
|
||||
@@ -263,9 +262,9 @@ function drawModules(qr, context, settings) {
|
||||
for (row = 0; row < moduleCount; row += 1) {
|
||||
for (col = 0; col < moduleCount; col += 1) {
|
||||
|
||||
var l = settings.left + col * moduleSize,
|
||||
t = settings.top + row * moduleSize,
|
||||
w = moduleSize;
|
||||
var l = settings.left + col * moduleSize;
|
||||
var t = settings.top + row * moduleSize;
|
||||
var w = moduleSize;
|
||||
|
||||
fn(qr, context, settings, l, t, w, row, col);
|
||||
}
|
||||
@@ -275,7 +274,7 @@ function drawModules(qr, context, settings) {
|
||||
context.lineWidth = 2;
|
||||
context.stroke();
|
||||
var prev = context.globalCompositeOperation;
|
||||
context.globalCompositeOperation = "destination-out";
|
||||
context.globalCompositeOperation = 'destination-out';
|
||||
context.fill();
|
||||
context.globalCompositeOperation = prev;
|
||||
|
||||
@@ -286,10 +285,10 @@ function drawModules(qr, context, settings) {
|
||||
context.fillStyle = settings.fill;
|
||||
context.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draws QR code to the given `canvas` and returns it.
|
||||
function drawOnCanvas(canvas, settings) {
|
||||
// Draws QR code to the given `canvas` and returns it.
|
||||
function drawOnCanvas(canvas, settings) {
|
||||
|
||||
var qr = createQRCode(settings.text, settings.ecLevel, settings.minVersion, settings.maxVersion, settings.quiet);
|
||||
if (!qr) {
|
||||
@@ -303,23 +302,23 @@ function drawOnCanvas(canvas, settings) {
|
||||
drawModules(qr, context, settings);
|
||||
|
||||
return $canvas;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a `canvas` element representing the QR code for the given settings.
|
||||
function createCanvas(settings) {
|
||||
// Returns a `canvas` element representing the QR code for the given settings.
|
||||
function createCanvas(settings) {
|
||||
|
||||
var $canvas = $('<canvas/>').attr('width', settings.size).attr('height', settings.size);
|
||||
return drawOnCanvas($canvas, settings);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns an `image` element representing the QR code for the given settings.
|
||||
function createImage(settings) {
|
||||
// Returns an `image` element representing the QR code for the given settings.
|
||||
function createImage(settings) {
|
||||
|
||||
return $('<img/>').attr('src', createCanvas(settings)[0].toDataURL('image/png'));
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a `div` element representing the QR code for the given settings.
|
||||
function createDiv(settings) {
|
||||
// Returns a `div` element representing the QR code for the given settings.
|
||||
function createDiv(settings) {
|
||||
|
||||
var qr = createQRCode(settings.text, settings.ecLevel, settings.minVersion, settings.maxVersion, settings.quiet);
|
||||
if (!qr) {
|
||||
@@ -335,7 +334,8 @@ function createDiv(settings) {
|
||||
var moduleSize = math_floor(settings_size / moduleCount);
|
||||
var offset = math_floor(0.5 * (settings_size - moduleSize * moduleCount));
|
||||
|
||||
var row, col;
|
||||
var row;
|
||||
var col;
|
||||
|
||||
var containerCSS = {
|
||||
position: 'relative',
|
||||
@@ -376,9 +376,9 @@ function createDiv(settings) {
|
||||
}
|
||||
|
||||
return $div;
|
||||
}
|
||||
}
|
||||
|
||||
function createHTML(settings) {
|
||||
function createHTML(settings) {
|
||||
|
||||
if (hasCanvas && settings.render === 'canvas') {
|
||||
return createCanvas(settings);
|
||||
@@ -387,14 +387,14 @@ function createHTML(settings) {
|
||||
}
|
||||
|
||||
return createDiv(settings);
|
||||
}
|
||||
}
|
||||
|
||||
// Plugin
|
||||
// ======
|
||||
// Plugin
|
||||
// ======
|
||||
|
||||
// Default settings
|
||||
// ----------------
|
||||
var defaults = {
|
||||
// Default settings
|
||||
// ----------------
|
||||
var defaults = {
|
||||
|
||||
// render method: `'canvas'`, `'image'` or `'div'`
|
||||
render: 'canvas',
|
||||
@@ -447,9 +447,9 @@ var defaults = {
|
||||
image: null
|
||||
};
|
||||
|
||||
// Register the plugin
|
||||
// -------------------
|
||||
$.fn.qrcode = function(options) {
|
||||
// Register the plugin
|
||||
// -------------------
|
||||
$.fn.qrcode = function (options) {
|
||||
|
||||
var settings = $.extend({}, defaults, options);
|
||||
|
||||
@@ -461,31 +461,28 @@ $.fn.qrcode = function(options) {
|
||||
$(this).append(createHTML(settings));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
}(function () {
|
||||
|
||||
// jQuery.qrcode plug in code ends here
|
||||
// `qrcode` is the single public function defined by the `QR Code Generator`
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// QR Code Generator for JavaScript
|
||||
//
|
||||
// Copyright (c) 2009 Kazuhiko Arase
|
||||
//
|
||||
// URL: http://www.d-project.com/
|
||||
//
|
||||
// Licensed under the MIT license:
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
// The word 'QR Code' is registered trademark of
|
||||
// DENSO WAVE INCORPORATED
|
||||
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
// QR Code Generator
|
||||
// =================
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// QR Code Generator for JavaScript
|
||||
//
|
||||
// Copyright (c) 2009 Kazuhiko Arase
|
||||
//
|
||||
// URL: http://www.d-project.com/
|
||||
//
|
||||
// Licensed under the MIT license:
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
// The word 'QR Code' is registered trademark of
|
||||
// DENSO WAVE INCORPORATED
|
||||
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
var qrcode = function() {
|
||||
var qrcode = function() {
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// qrcode
|
||||
@@ -493,7 +490,7 @@ var qrcode = function() {
|
||||
|
||||
/**
|
||||
* qrcode
|
||||
* @param typeNumber 1 to 10
|
||||
* @param typeNumber 1 to 40
|
||||
* @param errorCorrectLevel 'L','M','Q','H'
|
||||
*/
|
||||
var qrcode = function(typeNumber, errorCorrectLevel) {
|
||||
@@ -766,7 +763,7 @@ var qrcode = function() {
|
||||
ecdata[r] = new Array(rsPoly.getLength() - 1);
|
||||
for (var i = 0; i < ecdata[r].length; i += 1) {
|
||||
var modIndex = i + modPoly.getLength() - ecdata[r].length;
|
||||
ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0;
|
||||
ecdata[r][i] = (modIndex >= 0)? modPoly.getAt(modIndex) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1402,7 +1399,7 @@ var qrcode = function() {
|
||||
|
||||
var _this = {};
|
||||
|
||||
_this.get = function(index) {
|
||||
_this.getAt = function(index) {
|
||||
return _num[index];
|
||||
};
|
||||
|
||||
@@ -1416,7 +1413,7 @@ var qrcode = function() {
|
||||
|
||||
for (var i = 0; i < _this.getLength(); i += 1) {
|
||||
for (var j = 0; j < e.getLength(); j += 1) {
|
||||
num[i + j] ^= QRMath.gexp(QRMath.glog(_this.get(i) ) + QRMath.glog(e.get(j) ) );
|
||||
num[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i) ) + QRMath.glog(e.getAt(j) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1429,15 +1426,15 @@ var qrcode = function() {
|
||||
return _this;
|
||||
}
|
||||
|
||||
var ratio = QRMath.glog(_this.get(0) ) - QRMath.glog(e.get(0) );
|
||||
var ratio = QRMath.glog(_this.getAt(0) ) - QRMath.glog(e.getAt(0) );
|
||||
|
||||
var num = new Array(_this.getLength() );
|
||||
for (var i = 0; i < _this.getLength(); i += 1) {
|
||||
num[i] = _this.get(i);
|
||||
num[i] = _this.getAt(i);
|
||||
}
|
||||
|
||||
for (var i = 0; i < e.getLength(); i += 1) {
|
||||
num[i] ^= QRMath.gexp(QRMath.glog(e.get(i) ) + ratio);
|
||||
num[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i) ) + ratio);
|
||||
}
|
||||
|
||||
// recursive call
|
||||
@@ -1548,7 +1545,7 @@ var qrcode = function() {
|
||||
[5, 109, 87, 1, 110, 88],
|
||||
[5, 65, 41, 5, 66, 42],
|
||||
[5, 54, 24, 7, 55, 25],
|
||||
[11, 36, 12],
|
||||
[11, 36, 12, 7, 37, 13],
|
||||
|
||||
// 16
|
||||
[5, 122, 98, 1, 123, 99],
|
||||
@@ -1771,7 +1768,7 @@ var qrcode = function() {
|
||||
return _buffer;
|
||||
};
|
||||
|
||||
_this.get = function(index) {
|
||||
_this.getAt = function(index) {
|
||||
var bufIndex = Math.floor(index / 8);
|
||||
return ( (_buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
|
||||
};
|
||||
@@ -2281,7 +2278,76 @@ var qrcode = function() {
|
||||
// returns qrcode function.
|
||||
|
||||
return qrcode;
|
||||
}();
|
||||
}();
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define([], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory();
|
||||
}
|
||||
}(function () {
|
||||
return qrcode;
|
||||
}));
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// QR Code Generator for JavaScript UTF8 Support (optional)
|
||||
//
|
||||
// Copyright (c) 2011 Kazuhiko Arase
|
||||
//
|
||||
// URL: http://www.d-project.com/
|
||||
//
|
||||
// Licensed under the MIT license:
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
// The word 'QR Code' is registered trademark of
|
||||
// DENSO WAVE INCORPORATED
|
||||
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
}());
|
||||
!function(qrcode) {
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// overwrite qrcode.stringToBytes
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
qrcode.stringToBytes = function(s) {
|
||||
// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array
|
||||
function toUTF8Array(str) {
|
||||
var utf8 = [];
|
||||
for (var i=0; i < str.length; i++) {
|
||||
var charcode = str.charCodeAt(i);
|
||||
if (charcode < 0x80) utf8.push(charcode);
|
||||
else if (charcode < 0x800) {
|
||||
utf8.push(0xc0 | (charcode >> 6),
|
||||
0x80 | (charcode & 0x3f));
|
||||
}
|
||||
else if (charcode < 0xd800 || charcode >= 0xe000) {
|
||||
utf8.push(0xe0 | (charcode >> 12),
|
||||
0x80 | ((charcode>>6) & 0x3f),
|
||||
0x80 | (charcode & 0x3f));
|
||||
}
|
||||
// surrogate pair
|
||||
else {
|
||||
i++;
|
||||
// UTF-16 encodes 0x10000-0x10FFFF by
|
||||
// subtracting 0x10000 and splitting the
|
||||
// 20 bits of 0x0-0xFFFFF into two halves
|
||||
charcode = 0x10000 + (((charcode & 0x3ff)<<10)
|
||||
| (str.charCodeAt(i) & 0x3ff));
|
||||
utf8.push(0xf0 | (charcode >>18),
|
||||
0x80 | ((charcode>>12) & 0x3f),
|
||||
0x80 | ((charcode>>6) & 0x3f),
|
||||
0x80 | (charcode & 0x3f));
|
||||
}
|
||||
}
|
||||
return utf8;
|
||||
}
|
||||
return toUTF8Array(s);
|
||||
};
|
||||
|
||||
}(qrcode);
|
||||
|
||||
return qrcode;
|
||||
}()));
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+10
-31
@@ -1,10 +1,8 @@
|
||||
/*jshint node: true */
|
||||
'use strict';
|
||||
|
||||
|
||||
module.exports = function (suite) {
|
||||
|
||||
|
||||
var path = require('path');
|
||||
var root = path.resolve(__dirname);
|
||||
var src = path.join(root, 'src');
|
||||
@@ -12,50 +10,28 @@ module.exports = function (suite) {
|
||||
var build = path.join(root, 'build');
|
||||
|
||||
var $ = require('fquery');
|
||||
$.plugin('fquery-handlebars');
|
||||
$.plugin('fquery-includeit');
|
||||
$.plugin('fquery-jade');
|
||||
$.plugin('fquery-jshint');
|
||||
$.plugin('fquery-jszip');
|
||||
$.plugin('fquery-uglifyjs');
|
||||
|
||||
|
||||
suite.defaults('release');
|
||||
|
||||
|
||||
suite.target('clean', [], 'delete build folder').task(function () {
|
||||
|
||||
$([build, dist], {dirs: true}).delete();
|
||||
});
|
||||
|
||||
|
||||
suite.target('lint', [], 'lint all JavaScript files with JSHint').task(function () {
|
||||
|
||||
var options = {
|
||||
// Enforcing Options
|
||||
bitwise: true,
|
||||
curly: true,
|
||||
eqeqeq: true,
|
||||
forin: true,
|
||||
latedef: true,
|
||||
newcap: true,
|
||||
noempty: true,
|
||||
plusplus: true,
|
||||
trailing: true,
|
||||
undef: true,
|
||||
|
||||
// Environments
|
||||
browser: true
|
||||
};
|
||||
var global = {
|
||||
'jQuery': true,
|
||||
'qrcode': true
|
||||
};
|
||||
var fs = require('fs');
|
||||
var jshint = JSON.parse(fs.readFileSync('.jshintrc', 'utf-8'));
|
||||
|
||||
$(src + ': jquery.qrcode.js, demo/scripts.js')
|
||||
.jshint(options, global);
|
||||
.jshint(jshint, jshint.globals);
|
||||
});
|
||||
|
||||
|
||||
suite.target('release', ['clean', 'lint'], 'build all files and create a zipball').task(function () {
|
||||
|
||||
var pkg = require('./package.json');
|
||||
@@ -73,15 +49,18 @@ module.exports = function (suite) {
|
||||
.write($.map.p(src, dist).s('.js', '.min.js'), true)
|
||||
.write($.map.p(src, build).s('.js', '-' + pkg.version + '.min.js'), true);
|
||||
|
||||
$(src + ': **, ! *.js')
|
||||
.handlebars(env)
|
||||
$(src + ': **/*.jade')
|
||||
.jade(env)
|
||||
.write($.map.p(src, build).s('.jade', ''), true);
|
||||
|
||||
$(src + ': **, ! *.js, ! **/*.jade, ! lib/**')
|
||||
.write($.map.p(src, build), true);
|
||||
|
||||
$(root + ': *.md')
|
||||
.write($.map.p(root, build), true);
|
||||
|
||||
$(build + ': **')
|
||||
.jszip({dir: build})
|
||||
.jszip({dir: build, level: 9})
|
||||
.write(target, true);
|
||||
});
|
||||
};
|
||||
|
||||
+12
-8
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jquery-qrcode",
|
||||
"displayName": "jQuery.qrcode",
|
||||
"version": "0.11.0",
|
||||
"version": "0.12.0",
|
||||
"description": "generate QR codes dynamically",
|
||||
"homepage": "http://larsjung.de/jquery-qrcode/",
|
||||
"bugs": "https://github.com/lrsjng/jquery-qrcode/issues",
|
||||
@@ -12,12 +12,16 @@
|
||||
"url": "https://github.com/lrsjng/jquery-qrcode.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"fquery": "~0.16.2",
|
||||
"fquery-handlebars": "~0.2.0",
|
||||
"fquery-includeit": "~0.2.0",
|
||||
"fquery-jshint": "~0.2.0",
|
||||
"fquery-jszip": "~0.4.0",
|
||||
"fquery-uglifyjs": "~0.2.1",
|
||||
"mkr": "~0.6.1"
|
||||
"fquery": "~0.16.4",
|
||||
"fquery-includeit": "~0.3.0",
|
||||
"fquery-jade": "~0.5.0",
|
||||
"fquery-jshint": "~0.3.0",
|
||||
"fquery-jszip": "~0.5.1",
|
||||
"fquery-uglifyjs": "~0.3.0",
|
||||
"mkr": "~0.8.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10",
|
||||
"iojs": ">=1.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,294 +0,0 @@
|
||||
/*
|
||||
html5slider - a JS implementation of <input type=range> for Firefox 16 and up
|
||||
https://github.com/fryn/html5slider
|
||||
|
||||
Copyright (c) 2010-2013 Frank Yan, <http://frankyan.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
// test for native support
|
||||
var test = document.createElement('input');
|
||||
try {
|
||||
test.type = 'range';
|
||||
if (test.type == 'range')
|
||||
return;
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
|
||||
// test for required property support
|
||||
test.style.background = 'linear-gradient(red, red)';
|
||||
if (!test.style.backgroundImage || !('MozAppearance' in test.style))
|
||||
return;
|
||||
|
||||
var scale;
|
||||
var isMac = navigator.platform == 'MacIntel';
|
||||
var thumb = {
|
||||
radius: isMac ? 9 : 6,
|
||||
width: isMac ? 22 : 12,
|
||||
height: isMac ? 16 : 20
|
||||
};
|
||||
var track = 'linear-gradient(transparent ' + (isMac ?
|
||||
'6px, #999 6px, #999 7px, #ccc 8px, #bbb 9px, #bbb 10px, transparent 10px' :
|
||||
'9px, #999 9px, #bbb 10px, #fff 11px, transparent 11px') +
|
||||
', transparent)';
|
||||
var styles = {
|
||||
'min-width': thumb.width + 'px',
|
||||
'min-height': thumb.height + 'px',
|
||||
'max-height': thumb.height + 'px',
|
||||
padding: '0 0 ' + (isMac ? '2px' : '1px'),
|
||||
border: 0,
|
||||
'border-radius': 0,
|
||||
cursor: 'default',
|
||||
'text-indent': '-999999px' // -moz-user-select: none; breaks mouse capture
|
||||
};
|
||||
var options = {
|
||||
attributes: true,
|
||||
attributeFilter: ['min', 'max', 'step', 'value']
|
||||
};
|
||||
var onInput = document.createEvent('HTMLEvents');
|
||||
onInput.initEvent('input', true, false);
|
||||
var onChange = document.createEvent('HTMLEvents');
|
||||
onChange.initEvent('change', true, false);
|
||||
|
||||
if (document.readyState == 'loading')
|
||||
document.addEventListener('DOMContentLoaded', initialize, true);
|
||||
else
|
||||
initialize();
|
||||
addEventListener('pageshow', recreate, true);
|
||||
|
||||
function initialize() {
|
||||
// create initial sliders
|
||||
recreate();
|
||||
// create sliders on-the-fly
|
||||
new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.addedNodes)
|
||||
Array.forEach(mutation.addedNodes, function(node) {
|
||||
if (!(node instanceof Element))
|
||||
;
|
||||
else if (node.childElementCount)
|
||||
Array.forEach(node.querySelectorAll('input[type=range]'), check);
|
||||
else if (node.mozMatchesSelector('input[type=range]'))
|
||||
check(node);
|
||||
});
|
||||
});
|
||||
}).observe(document, { childList: true, subtree: true });
|
||||
}
|
||||
|
||||
function recreate() {
|
||||
Array.forEach(document.querySelectorAll('input[type=range]'), check);
|
||||
}
|
||||
|
||||
function check(input) {
|
||||
if (input.type != 'range')
|
||||
transform(input);
|
||||
}
|
||||
|
||||
function transform(slider) {
|
||||
|
||||
var isValueSet, areAttrsSet, isUI, isClick, prevValue, rawValue, prevX;
|
||||
var min, max, step, range, value = slider.value;
|
||||
|
||||
// lazily create shared slider affordance
|
||||
if (!scale) {
|
||||
scale = document.body.appendChild(document.createElement('hr'));
|
||||
style(scale, {
|
||||
'-moz-appearance': isMac ? 'scale-horizontal' : 'scalethumb-horizontal',
|
||||
display: 'block',
|
||||
visibility: 'visible',
|
||||
opacity: 1,
|
||||
position: 'fixed',
|
||||
top: '-999999px'
|
||||
});
|
||||
document.mozSetImageElement('__sliderthumb__', scale);
|
||||
}
|
||||
|
||||
// reimplement value and type properties
|
||||
var getValue = function() { return '' + value; };
|
||||
var setValue = function setValue(val) {
|
||||
value = '' + val;
|
||||
isValueSet = true;
|
||||
draw();
|
||||
delete slider.value;
|
||||
slider.value = value;
|
||||
slider.__defineGetter__('value', getValue);
|
||||
slider.__defineSetter__('value', setValue);
|
||||
};
|
||||
slider.__defineGetter__('value', getValue);
|
||||
slider.__defineSetter__('value', setValue);
|
||||
Object.defineProperty(slider, 'type', {
|
||||
get: function() { return 'range'; }
|
||||
});
|
||||
|
||||
// sync properties with attributes
|
||||
['min', 'max', 'step'].forEach(function(name) {
|
||||
if (slider.hasAttribute(name))
|
||||
areAttrsSet = true;
|
||||
Object.defineProperty(slider, name, {
|
||||
get: function() {
|
||||
return this.hasAttribute(name) ? this.getAttribute(name) : '';
|
||||
},
|
||||
set: function(val) {
|
||||
val === null ?
|
||||
this.removeAttribute(name) :
|
||||
this.setAttribute(name, val);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// initialize slider
|
||||
slider.readOnly = true;
|
||||
style(slider, styles);
|
||||
update();
|
||||
|
||||
new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.attributeName != 'value') {
|
||||
update();
|
||||
areAttrsSet = true;
|
||||
}
|
||||
// note that value attribute only sets initial value
|
||||
else if (!isValueSet) {
|
||||
value = slider.getAttribute('value');
|
||||
draw();
|
||||
}
|
||||
});
|
||||
}).observe(slider, options);
|
||||
|
||||
slider.addEventListener('mousedown', onDragStart, true);
|
||||
slider.addEventListener('keydown', onKeyDown, true);
|
||||
slider.addEventListener('focus', onFocus, true);
|
||||
slider.addEventListener('blur', onBlur, true);
|
||||
|
||||
function onDragStart(e) {
|
||||
isClick = true;
|
||||
setTimeout(function() { isClick = false; }, 0);
|
||||
if (e.button || !range)
|
||||
return;
|
||||
var width = parseFloat(getComputedStyle(this).width);
|
||||
var multiplier = (width - thumb.width) / range;
|
||||
if (!multiplier)
|
||||
return;
|
||||
// distance between click and center of thumb
|
||||
var dev = e.clientX - this.getBoundingClientRect().left - thumb.width / 2 -
|
||||
(value - min) * multiplier;
|
||||
// if click was not on thumb, move thumb to click location
|
||||
if (Math.abs(dev) > thumb.radius) {
|
||||
isUI = true;
|
||||
this.value -= -dev / multiplier;
|
||||
}
|
||||
rawValue = value;
|
||||
prevX = e.clientX;
|
||||
this.addEventListener('mousemove', onDrag, true);
|
||||
this.addEventListener('mouseup', onDragEnd, true);
|
||||
}
|
||||
|
||||
function onDrag(e) {
|
||||
var width = parseFloat(getComputedStyle(this).width);
|
||||
var multiplier = (width - thumb.width) / range;
|
||||
if (!multiplier)
|
||||
return;
|
||||
rawValue += (e.clientX - prevX) / multiplier;
|
||||
prevX = e.clientX;
|
||||
isUI = true;
|
||||
this.value = rawValue;
|
||||
}
|
||||
|
||||
function onDragEnd() {
|
||||
this.removeEventListener('mousemove', onDrag, true);
|
||||
this.removeEventListener('mouseup', onDragEnd, true);
|
||||
slider.dispatchEvent(onInput);
|
||||
slider.dispatchEvent(onChange);
|
||||
}
|
||||
|
||||
function onKeyDown(e) {
|
||||
if (e.keyCode > 36 && e.keyCode < 41) { // 37-40: left, up, right, down
|
||||
onFocus.call(this);
|
||||
isUI = true;
|
||||
this.value = value + (e.keyCode == 38 || e.keyCode == 39 ? step : -step);
|
||||
}
|
||||
}
|
||||
|
||||
function onFocus() {
|
||||
if (!isClick)
|
||||
this.style.boxShadow = !isMac ? '0 0 0 2px #fb0' :
|
||||
'inset 0 0 20px rgba(0,127,255,.1), 0 0 1px rgba(0,127,255,.4)';
|
||||
}
|
||||
|
||||
function onBlur() {
|
||||
this.style.boxShadow = '';
|
||||
}
|
||||
|
||||
// determines whether value is valid number in attribute form
|
||||
function isAttrNum(value) {
|
||||
return !isNaN(value) && +value == parseFloat(value);
|
||||
}
|
||||
|
||||
// validates min, max, and step attributes and redraws
|
||||
function update() {
|
||||
min = isAttrNum(slider.min) ? +slider.min : 0;
|
||||
max = isAttrNum(slider.max) ? +slider.max : 100;
|
||||
if (max < min)
|
||||
max = min > 100 ? min : 100;
|
||||
step = isAttrNum(slider.step) && slider.step > 0 ? +slider.step : 1;
|
||||
range = max - min;
|
||||
draw(true);
|
||||
}
|
||||
|
||||
// recalculates value property
|
||||
function calc() {
|
||||
if (!isValueSet && !areAttrsSet)
|
||||
value = slider.getAttribute('value');
|
||||
if (!isAttrNum(value))
|
||||
value = (min + max) / 2;;
|
||||
// snap to step intervals (WebKit sometimes does not - bug?)
|
||||
value = Math.round((value - min) / step) * step + min;
|
||||
if (value < min)
|
||||
value = min;
|
||||
else if (value > max)
|
||||
value = min + ~~(range / step) * step;
|
||||
}
|
||||
|
||||
// renders slider using CSS background ;)
|
||||
function draw(attrsModified) {
|
||||
calc();
|
||||
var wasUI = isUI;
|
||||
isUI = false;
|
||||
if (wasUI && value != prevValue)
|
||||
slider.dispatchEvent(onInput);
|
||||
if (!attrsModified && value == prevValue)
|
||||
return;
|
||||
prevValue = value;
|
||||
var position = range ? (value - min) / range * 100 : 0;
|
||||
var bg = '-moz-element(#__sliderthumb__) ' + position + '% no-repeat, ';
|
||||
style(slider, { background: bg + track });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function style(element, styles) {
|
||||
for (var prop in styles)
|
||||
element.style.setProperty(prop, styles[prop], 'important');
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,90 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html class="no-js no-browser" lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{pkg.displayName}} {{pkg.version}} · Demo</title>
|
||||
<meta name="description" content="demo for the jQuery plug in jQuery.qrcode (http://larsjung.de/qrcode/)">
|
||||
<meta name="author" content="Lars Jung">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="author" href="http://plus.google.com/106403733398479106535">
|
||||
<link rel="shortcut icon" href="dummy.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="dummy.png" type="image/png">
|
||||
<link href='http://fonts.googleapis.com/css?family=Ubuntu:400,700' rel='stylesheet'>
|
||||
<link href='styles.css' rel='stylesheet'>
|
||||
<script src="jquery-1.10.2.js"></script>
|
||||
<script src="../jquery.qrcode-{{pkg.version}}.js"></script>
|
||||
<script src="ff-range.js"></script>
|
||||
<script src="scripts.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
|
||||
<div class="control left">
|
||||
<a id="banner" href="http://larsjung.de/qrcode/">{{pkg.displayName}} {{pkg.version}}</a>
|
||||
<hr/>
|
||||
<label for="render">RENDER MODE</label>
|
||||
<select id="render">
|
||||
<option value="canvas" selected="selected">Canvas</option>
|
||||
<option value="image">Image</option>
|
||||
<option value="div">DIV</option>
|
||||
</select>
|
||||
<hr/>
|
||||
<label for="size">SIZE:</label>
|
||||
<input id="size" type="range" value="400" min="100" max="1000" step="50" />
|
||||
<label for="fill">FILL</label>
|
||||
<input id="fill" type="color" value="#333333" />
|
||||
<label for="background">BACKGROUND</label>
|
||||
<input id="background" type="color" value="#ffffff" />
|
||||
<label for="text">CONTENT</label>
|
||||
<textarea id="text">http://larsjung.de/qrcode/</textarea>
|
||||
<hr/>
|
||||
<label for="minversion">MIN VERSION:</label>
|
||||
<input id="minversion" type="range" value="6" min="1" max="10" step="1" />
|
||||
<label for="eclevel">ERROR CORRECTION LEVEL</label>
|
||||
<select id="eclevel">
|
||||
<option value="L">L - Low (7%)</option>
|
||||
<option value="M">M - Medium (15%)</option>
|
||||
<option value="Q">Q - Quartile (25%)</option>
|
||||
<option value="H" selected="selected">H - High (30%)</option>
|
||||
</select>
|
||||
<label for="quiet">QUIET ZONE:</label>
|
||||
<input id="quiet" type="range" value="1" min="0" max="4" step="1" />
|
||||
<label for="radius">CORNER RADIUS (not in Opera):</label>
|
||||
<input id="radius" type="range" value="50" min="0" max="50" step="10" />
|
||||
</div>
|
||||
|
||||
<div class="control right">
|
||||
<label for="mode">MODE</label>
|
||||
<select id="mode">
|
||||
<option value="0">0 - Normal</option>
|
||||
<option value="1">1 - Label-Strip</option>
|
||||
<option value="2" selected="selected">2 - Label-Box</option>
|
||||
<option value="3">3 - Image-Strip</option>
|
||||
<option value="4">4 - Image-Box</option>
|
||||
</select>
|
||||
<hr/>
|
||||
<label for="msize">SIZE:</label>
|
||||
<input id="msize" type="range" value="11" min="0" max="40" step="1" />
|
||||
<label for="mposx">POS X:</label>
|
||||
<input id="mposx" type="range" value="50" min="0" max="100" step="1" />
|
||||
<label for="mposy">POS Y:</label>
|
||||
<input id="mposy" type="range" value="50" min="0" max="100" step="1" />
|
||||
<hr/>
|
||||
<label for="label">LABEL</label>
|
||||
<input id="label" type="text" value="jQuery.qrcode" />
|
||||
<label for="font">FONT NAME</label>
|
||||
<input id="font" type="text" value="Ubuntu" />
|
||||
<label for="fontcolor">FONT COLOR:</label>
|
||||
<input id="fontcolor" type="color" value="#ff9818" />
|
||||
<hr/>
|
||||
<label for="image">IMAGE</label>
|
||||
<input id="image" type="file" />
|
||||
</div>
|
||||
|
||||
<img id="img-buffer" src="dummy.png" />
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,83 @@
|
||||
doctype html
|
||||
html(lang='en')
|
||||
head
|
||||
meta(charset='utf-8')
|
||||
meta(http-equiv='x-ua-compatible', content='ie=edge')
|
||||
title #{pkg.displayName} #{pkg.version} · Demo
|
||||
meta(name='description', content='demo for #{pkg.displayName} (#{pkg.homepage})')
|
||||
meta(name='viewport', content='width=device-width, initial-scale=1')
|
||||
link(rel='shortcut icon', type='image/png', href='dummy.png')
|
||||
link(rel='apple-touch-icon-precomposed', type='image/png', href='dummy.png')
|
||||
link(href='//fonts.googleapis.com/css?family=Ubuntu:300,400,700', rel='stylesheet')
|
||||
link(href='styles.css', rel='stylesheet')
|
||||
script(src='jquery-1.11.3.min.js')
|
||||
script(src='../jquery.qrcode-#{pkg.version}.js')
|
||||
script(src='scripts.js')
|
||||
|
||||
body
|
||||
div#container
|
||||
|
||||
div.control.left
|
||||
a#banner(href='#{pkg.homepage}') #{pkg.displayName} #{pkg.version}
|
||||
|
||||
hr
|
||||
label(for='render') RENDER MODE
|
||||
select#render
|
||||
option(value='canvas', selected='selected') canvas
|
||||
option(value='image') image
|
||||
option(value='div') div
|
||||
|
||||
hr
|
||||
label(for='size') SIZE:
|
||||
input#size(type='range', value='400', min='100', max='1000', step='50')
|
||||
label(for='fill') FILL
|
||||
input#fill(type='color', value='#333333')
|
||||
label(for='background') BACKGROUND
|
||||
input#background(type='color', value='#ffffff')
|
||||
label(for='text') CONTENT
|
||||
textarea#text #{pkg.homepage}
|
||||
|
||||
hr
|
||||
label(for='minversion') MIN VERSION:
|
||||
input#minversion(type='range', value='6', min='1', max='10', step='1')
|
||||
label(for='eclevel') ERROR CORRECTION LEVEL
|
||||
select#eclevel
|
||||
option(value='L') L - Low (7%)
|
||||
option(value='M') M - Medium (15%)
|
||||
option(value='Q') Q - Quartile (25%)
|
||||
option(value='H', selected='selected') H - High (30%)
|
||||
label(for='quiet') QUIET ZONE:
|
||||
input#quiet(type='range', value='1', min='0', max='4', step='1')
|
||||
label(for='radius') CORNER RADIUS:
|
||||
input#radius(type='range', value='50', min='0', max='50', step='10')
|
||||
|
||||
div.control.right
|
||||
label(for='mode') MODE
|
||||
select#mode
|
||||
option(value='0') 0 - Normal
|
||||
option(value='1') 1 - Label-Strip
|
||||
option(value='2', selected='selected') 2 - Label-Box
|
||||
option(value='3') 3 - Image-Strip
|
||||
option(value='4') 4 - Image-Box
|
||||
|
||||
hr
|
||||
label(for='msize') SIZE:
|
||||
input#msize(type='range', value='11', min='0', max='40', step='1')
|
||||
label(for='mposx') POS X:
|
||||
input#mposx(type='range', value='50', min='0', max='100', step='1')
|
||||
label(for='mposy') POS Y:
|
||||
input#mposy(type='range', value='50', min='0', max='100', step='1')
|
||||
|
||||
hr
|
||||
label(for='label') LABEL
|
||||
input#label(type='text', value='#{pkg.displayName}')
|
||||
label(for='font') FONT NAME
|
||||
input#font(type='text', value='Ubuntu')
|
||||
label(for='fontcolor') FONT COLOR
|
||||
input#fontcolor(type='color', value='#ff9818')
|
||||
|
||||
hr
|
||||
label(for='image') IMAGE
|
||||
input#image(type='file')
|
||||
|
||||
img#img-buffer(src='dummy.png')
|
||||
Vendored
-9789
File diff suppressed because it is too large
Load Diff
Vendored
+5
File diff suppressed because one or more lines are too long
+45
-58
@@ -2,101 +2,88 @@
|
||||
'use strict';
|
||||
|
||||
var $ = jQuery;
|
||||
var guiValuePairs = [
|
||||
['size', 'px'],
|
||||
['minversion', ''],
|
||||
['quiet', ' modules'],
|
||||
['radius', '%'],
|
||||
['msize', '%'],
|
||||
['mposx', '%'],
|
||||
['mposy', '%']
|
||||
];
|
||||
|
||||
var isOpera = Object.prototype.toString.call(window.opera) === '[object Opera]',
|
||||
|
||||
guiValuePairs = [
|
||||
["size", "px"],
|
||||
["minversion", ""],
|
||||
["quiet", " modules"],
|
||||
["radius", "%"],
|
||||
["msize", "%"],
|
||||
["mposx", "%"],
|
||||
["mposy", "%"]
|
||||
],
|
||||
|
||||
updateGui = function () {
|
||||
function updateGui() {
|
||||
|
||||
$.each(guiValuePairs, function (idx, pair) {
|
||||
|
||||
var $label = $('label[for="' + pair[0] + '"]');
|
||||
|
||||
$label.text($label.text().replace(/:.*/, ': ' + $('#' + pair[0]).val() + pair[1]));
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
updateQrCode = function () {
|
||||
function updateQrCode() {
|
||||
|
||||
var options = {
|
||||
render: $("#render").val(),
|
||||
ecLevel: $("#eclevel").val(),
|
||||
minVersion: parseInt($("#minversion").val(), 10),
|
||||
render: $('#render').val(),
|
||||
ecLevel: $('#eclevel').val(),
|
||||
minVersion: parseInt($('#minversion').val(), 10),
|
||||
|
||||
fill: $("#fill").val(),
|
||||
background: $("#background").val(),
|
||||
// fill: $("#img-buffer")[0],
|
||||
fill: $('#fill').val(),
|
||||
background: $('#background').val(),
|
||||
// fill: $('#img-buffer')[0],
|
||||
|
||||
text: $("#text").val(),
|
||||
size: parseInt($("#size").val(), 10),
|
||||
radius: parseInt($("#radius").val(), 10) * 0.01,
|
||||
quiet: parseInt($("#quiet").val(), 10),
|
||||
text: $('#text').val(),
|
||||
size: parseInt($('#size').val(), 10),
|
||||
radius: parseInt($('#radius').val(), 10) * 0.01,
|
||||
quiet: parseInt($('#quiet').val(), 10),
|
||||
|
||||
mode: parseInt($("#mode").val(), 10),
|
||||
mode: parseInt($('#mode').val(), 10),
|
||||
|
||||
mSize: parseInt($("#msize").val(), 10) * 0.01,
|
||||
mPosX: parseInt($("#mposx").val(), 10) * 0.01,
|
||||
mPosY: parseInt($("#mposy").val(), 10) * 0.01,
|
||||
mSize: parseInt($('#msize').val(), 10) * 0.01,
|
||||
mPosX: parseInt($('#mposx').val(), 10) * 0.01,
|
||||
mPosY: parseInt($('#mposy').val(), 10) * 0.01,
|
||||
|
||||
label: $("#label").val(),
|
||||
fontname: $("#font").val(),
|
||||
fontcolor: $("#fontcolor").val(),
|
||||
label: $('#label').val(),
|
||||
fontname: $('#font').val(),
|
||||
fontcolor: $('#fontcolor').val(),
|
||||
|
||||
image: $("#img-buffer")[0]
|
||||
image: $('#img-buffer')[0]
|
||||
};
|
||||
|
||||
$("#container").empty().qrcode(options);
|
||||
},
|
||||
$('#container').empty().qrcode(options);
|
||||
}
|
||||
|
||||
update = function () {
|
||||
function update() {
|
||||
|
||||
updateGui();
|
||||
updateQrCode();
|
||||
},
|
||||
}
|
||||
|
||||
onImageInput = function () {
|
||||
|
||||
var input = $("#image")[0];
|
||||
function onImageInput() {
|
||||
|
||||
var input = $('#image')[0];
|
||||
if (input.files && input.files[0]) {
|
||||
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function (event) {
|
||||
$("#img-buffer").attr("src", event.target.result);
|
||||
$("#mode").val("4");
|
||||
$('#img-buffer').attr('src', event.target.result);
|
||||
$('#mode').val('4');
|
||||
setTimeout(update, 250);
|
||||
};
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
download = function (event) {
|
||||
function download() {
|
||||
|
||||
var data = $("#container canvas")[0].toDataURL('image/png');
|
||||
$("#download").attr("href", data);
|
||||
};
|
||||
$('#download').attr('href', $('#container canvas')[0].toDataURL('image/png'));
|
||||
}
|
||||
|
||||
|
||||
$(function () {
|
||||
|
||||
if (isOpera) {
|
||||
$('html').addClass('opera');
|
||||
$('#radius').prop('disabled', true);
|
||||
}
|
||||
|
||||
$("#download").on("click", download);
|
||||
$("#image").on('change', onImageInput);
|
||||
$("input, textarea, select").on("input change", update);
|
||||
$('#download').on('click', download);
|
||||
$('#image').on('change', onImageInput);
|
||||
$('input, textarea, select').on('input change', update);
|
||||
$(window).load(update);
|
||||
update();
|
||||
});
|
||||
|
||||
+7
-12
@@ -1,9 +1,9 @@
|
||||
body {
|
||||
font-family: Ubuntu;
|
||||
font-family: 'Ubuntu', 'Arial', 'sans';
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
background: repeat url("back.png");
|
||||
background: repeat url('back.png');
|
||||
}
|
||||
|
||||
#banner {
|
||||
@@ -56,14 +56,10 @@ hr {
|
||||
|
||||
label {
|
||||
font-size: 10px;
|
||||
color: #bbb;
|
||||
color: #aaa;
|
||||
padding: 12px 4px 0 4px;
|
||||
}
|
||||
|
||||
html.opera label[for="radius"] {
|
||||
color: #e55;
|
||||
}
|
||||
|
||||
#download {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
@@ -78,7 +74,7 @@ html.opera label[for="radius"] {
|
||||
}
|
||||
|
||||
input, textarea, select {
|
||||
font-family: Ubuntu;
|
||||
font-family: 'Ubuntu', 'Arial', 'sans';
|
||||
display: block;
|
||||
background-color: #fff;
|
||||
margin: 2px;
|
||||
@@ -96,16 +92,15 @@ input, textarea, select {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
input[type="range"] {
|
||||
input[type='range'] {
|
||||
-webkit-appearance: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 3px;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #aaa), color-stop(1, #aaa) );
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #aaa), color-stop(1, #aaa));
|
||||
}
|
||||
|
||||
+72
-74
@@ -1,13 +1,11 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
(function (qrcode) {
|
||||
'use strict';
|
||||
|
||||
var $ = jQuery;
|
||||
var $ = jQuery;
|
||||
|
||||
// Wrapper for the original QR code generator.
|
||||
function QRCode(text, level, version, quiet) {
|
||||
// Wrapper for the original QR code generator.
|
||||
function QRCode(text, level, version, quiet) {
|
||||
|
||||
// `qrcode` is the single public function that will be defined by the `QR Code Generator`
|
||||
// at the end of the file.
|
||||
var qr = qrcode(version, level);
|
||||
qr.addData(text);
|
||||
qr.make();
|
||||
@@ -15,7 +13,7 @@ function QRCode(text, level, version, quiet) {
|
||||
quiet = quiet || 0;
|
||||
|
||||
var qrModuleCount = qr.getModuleCount();
|
||||
var quietModuleCount = qr.getModuleCount() + 2*quiet;
|
||||
var quietModuleCount = qr.getModuleCount() + 2 * quiet;
|
||||
|
||||
function isDark(row, col) {
|
||||
|
||||
@@ -51,19 +49,19 @@ function QRCode(text, level, version, quiet) {
|
||||
this.moduleCount = quietModuleCount;
|
||||
this.isDark = isDark;
|
||||
this.addBlank = addBlank;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if canvas is available in the browser (as Modernizr does)
|
||||
var hasCanvas = (function () {
|
||||
// Check if canvas is available in the browser (as Modernizr does)
|
||||
var hasCanvas = (function () {
|
||||
|
||||
var elem = document.createElement('canvas');
|
||||
return !!(elem.getContext && elem.getContext('2d'));
|
||||
return Boolean(elem.getContext && elem.getContext('2d'));
|
||||
}());
|
||||
var hasArcTo = Object.prototype.toString.call(window.opera) !== '[object Opera]';
|
||||
var hasArcTo = Object.prototype.toString.call(window.opera) !== '[object Opera]';
|
||||
|
||||
// Returns a minimal QR code for the given text starting with version `minVersion`.
|
||||
// Returns `undefined` if `text` is too long to be encoded in `maxVersion`.
|
||||
function createQRCode(text, level, minVersion, maxVersion, quiet) {
|
||||
// Returns a minimal QR code for the given text starting with version `minVersion`.
|
||||
// Returns `undefined` if `text` is too long to be encoded in `maxVersion`.
|
||||
function createQRCode(text, level, minVersion, maxVersion, quiet) {
|
||||
|
||||
minVersion = Math.max(1, minVersion || 1);
|
||||
maxVersion = Math.min(40, maxVersion || 40);
|
||||
@@ -72,13 +70,13 @@ function createQRCode(text, level, minVersion, maxVersion, quiet) {
|
||||
return new QRCode(text, level, version, quiet);
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawBackgroundLabel(qr, context, settings) {
|
||||
function drawBackgroundLabel(qr, context, settings) {
|
||||
|
||||
var size = settings.size;
|
||||
var font = "bold " + (settings.mSize * size) + "px " + settings.fontname;
|
||||
var ctx = $('<canvas/>')[0].getContext("2d");
|
||||
var font = 'bold ' + (settings.mSize * size) + 'px ' + settings.fontname;
|
||||
var ctx = $('<canvas/>')[0].getContext('2d');
|
||||
|
||||
ctx.font = font;
|
||||
|
||||
@@ -101,10 +99,10 @@ function drawBackgroundLabel(qr, context, settings) {
|
||||
|
||||
context.fillStyle = settings.fontcolor;
|
||||
context.font = font;
|
||||
context.fillText(settings.label, sl*size, st*size + 0.75 * settings.mSize * size);
|
||||
}
|
||||
context.fillText(settings.label, sl * size, st * size + 0.75 * settings.mSize * size);
|
||||
}
|
||||
|
||||
function drawBackgroundImage(qr, context, settings) {
|
||||
function drawBackgroundImage(qr, context, settings) {
|
||||
|
||||
var size = settings.size;
|
||||
var w = settings.image.naturalWidth || 1;
|
||||
@@ -125,10 +123,10 @@ function drawBackgroundImage(qr, context, settings) {
|
||||
qr.addBlank(sl - pad, st - pad, sr + pad, sb + pad);
|
||||
}
|
||||
|
||||
context.drawImage(settings.image, sl*size, st*size, sw*size, sh*size);
|
||||
}
|
||||
context.drawImage(settings.image, sl * size, st * size, sw * size, sh * size);
|
||||
}
|
||||
|
||||
function drawBackground(qr, context, settings) {
|
||||
function drawBackground(qr, context, settings) {
|
||||
|
||||
if ($(settings.background).is('img')) {
|
||||
context.drawImage(settings.background, 0, 0, settings.size, settings.size);
|
||||
@@ -143,16 +141,16 @@ function drawBackground(qr, context, settings) {
|
||||
} else if (mode === 3 || mode === 4) {
|
||||
drawBackgroundImage(qr, context, settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawModuleDefault(qr, context, settings, left, top, width, row, col) {
|
||||
function drawModuleDefault(qr, context, settings, left, top, width, row, col) {
|
||||
|
||||
if (qr.isDark(row, col)) {
|
||||
context.rect(left, top, width, width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawModuleRoundedDark(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
function drawModuleRoundedDark(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
|
||||
if (nw) {
|
||||
ctx.moveTo(l + rad, t);
|
||||
@@ -187,9 +185,9 @@ function drawModuleRoundedDark(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
} else {
|
||||
ctx.lineTo(l, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawModuleRoundendLight(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
function drawModuleRoundendLight(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
|
||||
if (nw) {
|
||||
ctx.moveTo(l + rad, t);
|
||||
@@ -218,9 +216,9 @@ function drawModuleRoundendLight(ctx, l, t, r, b, rad, nw, ne, se, sw) {
|
||||
ctx.lineTo(l, b - rad);
|
||||
ctx.arcTo(l, b, l + rad, b, rad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawModuleRounded(qr, context, settings, left, top, width, row, col) {
|
||||
function drawModuleRounded(qr, context, settings, left, top, width, row, col) {
|
||||
|
||||
var isDark = qr.isDark;
|
||||
var right = left + width;
|
||||
@@ -245,14 +243,15 @@ function drawModuleRounded(qr, context, settings, left, top, width, row, col) {
|
||||
} else {
|
||||
drawModuleRoundendLight(context, left, top, right, bottom, radius, north && west && northwest, north && east && northeast, south && east && southeast, south && west && southwest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawModules(qr, context, settings) {
|
||||
function drawModules(qr, context, settings) {
|
||||
|
||||
var moduleCount = qr.moduleCount;
|
||||
var moduleSize = settings.size / moduleCount;
|
||||
var fn = drawModuleDefault;
|
||||
var row, col;
|
||||
var row;
|
||||
var col;
|
||||
|
||||
if (hasArcTo && settings.radius > 0 && settings.radius <= 0.5) {
|
||||
fn = drawModuleRounded;
|
||||
@@ -262,9 +261,9 @@ function drawModules(qr, context, settings) {
|
||||
for (row = 0; row < moduleCount; row += 1) {
|
||||
for (col = 0; col < moduleCount; col += 1) {
|
||||
|
||||
var l = settings.left + col * moduleSize,
|
||||
t = settings.top + row * moduleSize,
|
||||
w = moduleSize;
|
||||
var l = settings.left + col * moduleSize;
|
||||
var t = settings.top + row * moduleSize;
|
||||
var w = moduleSize;
|
||||
|
||||
fn(qr, context, settings, l, t, w, row, col);
|
||||
}
|
||||
@@ -274,7 +273,7 @@ function drawModules(qr, context, settings) {
|
||||
context.lineWidth = 2;
|
||||
context.stroke();
|
||||
var prev = context.globalCompositeOperation;
|
||||
context.globalCompositeOperation = "destination-out";
|
||||
context.globalCompositeOperation = 'destination-out';
|
||||
context.fill();
|
||||
context.globalCompositeOperation = prev;
|
||||
|
||||
@@ -285,10 +284,10 @@ function drawModules(qr, context, settings) {
|
||||
context.fillStyle = settings.fill;
|
||||
context.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draws QR code to the given `canvas` and returns it.
|
||||
function drawOnCanvas(canvas, settings) {
|
||||
// Draws QR code to the given `canvas` and returns it.
|
||||
function drawOnCanvas(canvas, settings) {
|
||||
|
||||
var qr = createQRCode(settings.text, settings.ecLevel, settings.minVersion, settings.maxVersion, settings.quiet);
|
||||
if (!qr) {
|
||||
@@ -302,23 +301,23 @@ function drawOnCanvas(canvas, settings) {
|
||||
drawModules(qr, context, settings);
|
||||
|
||||
return $canvas;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a `canvas` element representing the QR code for the given settings.
|
||||
function createCanvas(settings) {
|
||||
// Returns a `canvas` element representing the QR code for the given settings.
|
||||
function createCanvas(settings) {
|
||||
|
||||
var $canvas = $('<canvas/>').attr('width', settings.size).attr('height', settings.size);
|
||||
return drawOnCanvas($canvas, settings);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns an `image` element representing the QR code for the given settings.
|
||||
function createImage(settings) {
|
||||
// Returns an `image` element representing the QR code for the given settings.
|
||||
function createImage(settings) {
|
||||
|
||||
return $('<img/>').attr('src', createCanvas(settings)[0].toDataURL('image/png'));
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a `div` element representing the QR code for the given settings.
|
||||
function createDiv(settings) {
|
||||
// Returns a `div` element representing the QR code for the given settings.
|
||||
function createDiv(settings) {
|
||||
|
||||
var qr = createQRCode(settings.text, settings.ecLevel, settings.minVersion, settings.maxVersion, settings.quiet);
|
||||
if (!qr) {
|
||||
@@ -334,7 +333,8 @@ function createDiv(settings) {
|
||||
var moduleSize = math_floor(settings_size / moduleCount);
|
||||
var offset = math_floor(0.5 * (settings_size - moduleSize * moduleCount));
|
||||
|
||||
var row, col;
|
||||
var row;
|
||||
var col;
|
||||
|
||||
var containerCSS = {
|
||||
position: 'relative',
|
||||
@@ -375,9 +375,9 @@ function createDiv(settings) {
|
||||
}
|
||||
|
||||
return $div;
|
||||
}
|
||||
}
|
||||
|
||||
function createHTML(settings) {
|
||||
function createHTML(settings) {
|
||||
|
||||
if (hasCanvas && settings.render === 'canvas') {
|
||||
return createCanvas(settings);
|
||||
@@ -386,14 +386,14 @@ function createHTML(settings) {
|
||||
}
|
||||
|
||||
return createDiv(settings);
|
||||
}
|
||||
}
|
||||
|
||||
// Plugin
|
||||
// ======
|
||||
// Plugin
|
||||
// ======
|
||||
|
||||
// Default settings
|
||||
// ----------------
|
||||
var defaults = {
|
||||
// Default settings
|
||||
// ----------------
|
||||
var defaults = {
|
||||
|
||||
// render method: `'canvas'`, `'image'` or `'div'`
|
||||
render: 'canvas',
|
||||
@@ -446,9 +446,9 @@ var defaults = {
|
||||
image: null
|
||||
};
|
||||
|
||||
// Register the plugin
|
||||
// -------------------
|
||||
$.fn.qrcode = function(options) {
|
||||
// Register the plugin
|
||||
// -------------------
|
||||
$.fn.qrcode = function (options) {
|
||||
|
||||
var settings = $.extend({}, defaults, options);
|
||||
|
||||
@@ -460,13 +460,11 @@ $.fn.qrcode = function(options) {
|
||||
$(this).append(createHTML(settings));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
}(function () {
|
||||
|
||||
// jQuery.qrcode plug in code ends here
|
||||
|
||||
|
||||
// QR Code Generator
|
||||
// =================
|
||||
// @include "qrcode.js"
|
||||
|
||||
}());
|
||||
// `qrcode` is the single public function defined by the `QR Code Generator`
|
||||
// @include "lib/qrcode.js"
|
||||
// @include "lib/qrcode_UTF8.js"
|
||||
return qrcode;
|
||||
}()));
|
||||
|
||||
+1824
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// QR Code Generator for JavaScript UTF8 Support (optional)
|
||||
//
|
||||
// Copyright (c) 2011 Kazuhiko Arase
|
||||
//
|
||||
// URL: http://www.d-project.com/
|
||||
//
|
||||
// Licensed under the MIT license:
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
// The word 'QR Code' is registered trademark of
|
||||
// DENSO WAVE INCORPORATED
|
||||
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
!function(qrcode) {
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// overwrite qrcode.stringToBytes
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
qrcode.stringToBytes = function(s) {
|
||||
// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array
|
||||
function toUTF8Array(str) {
|
||||
var utf8 = [];
|
||||
for (var i=0; i < str.length; i++) {
|
||||
var charcode = str.charCodeAt(i);
|
||||
if (charcode < 0x80) utf8.push(charcode);
|
||||
else if (charcode < 0x800) {
|
||||
utf8.push(0xc0 | (charcode >> 6),
|
||||
0x80 | (charcode & 0x3f));
|
||||
}
|
||||
else if (charcode < 0xd800 || charcode >= 0xe000) {
|
||||
utf8.push(0xe0 | (charcode >> 12),
|
||||
0x80 | ((charcode>>6) & 0x3f),
|
||||
0x80 | (charcode & 0x3f));
|
||||
}
|
||||
// surrogate pair
|
||||
else {
|
||||
i++;
|
||||
// UTF-16 encodes 0x10000-0x10FFFF by
|
||||
// subtracting 0x10000 and splitting the
|
||||
// 20 bits of 0x0-0xFFFFF into two halves
|
||||
charcode = 0x10000 + (((charcode & 0x3ff)<<10)
|
||||
| (str.charCodeAt(i) & 0x3ff));
|
||||
utf8.push(0xf0 | (charcode >>18),
|
||||
0x80 | ((charcode>>12) & 0x3f),
|
||||
0x80 | ((charcode>>6) & 0x3f),
|
||||
0x80 | (charcode & 0x3f));
|
||||
}
|
||||
}
|
||||
return utf8;
|
||||
}
|
||||
return toUTF8Array(s);
|
||||
};
|
||||
|
||||
}(qrcode);
|
||||
-1814
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user