Skip to content

Commit b3fd09d

Browse files
committed
Update.
1 parent 9034d88 commit b3fd09d

9 files changed

+37
-27
lines changed

dist/kjua.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kjua",
3-
"version": "0.8.0",
3+
"version": "0.9.0",
44
"description": "Dynamically generated QR codes for modern browsers.",
55
"homepage": "https://larsjung.de/kjua/",
66
"author": "Lars Jung <lrsjng@gmail.com> (https://larsjung.de)",

src/demo/index.html.pug

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ doctype html
22
html(lang='en')
33
head
44
meta(charset='utf-8')
5-
meta(http-equiv='x-ua-compatible', content='ie=edge')
65
title #{pkg.name} #{pkg.version} · Demo
76
meta(name='description', content=`demo for ${pkg.name} (${pkg.homepage})`)
87
meta(name='viewport', content='width=device-width, initial-scale=1')
9-
link(href='//fonts.googleapis.com/css?family=Ubuntu', rel='stylesheet')
8+
link(href='//fonts.googleapis.com/css2?family=Ubuntu+Mono:wght@400;700&display=swap' rel='stylesheet')
109
link(href='styles.css', rel='stylesheet')
1110
script(src=`../${pkg.name}-${pkg.version}.min.js`)
1211
script(src='scripts.js')
@@ -35,7 +34,7 @@ html(lang='en')
3534
input#fill(type='color', value='#333333')
3635
label(for='back') BACK
3736
input#back(type='color', value='#ffffff')
38-
label(for='text') CONTENT
37+
label(for='text') TEXT
3938
textarea#text #{pkg.homepage}
4039

4140
hr
@@ -61,7 +60,7 @@ html(lang='en')
6160

6261
hr
6362
label(for='msize') SIZE:
64-
input#msize(type='range', value='30', min='0', max='40', step='1')
63+
input#msize(type='range', value='20', min='0', max='40', step='1')
6564
label(for='mposx') POS X:
6665
input#mposx(type='range', value='50', min='0', max='100', step='1')
6766
label(for='mposy') POS Y:
@@ -71,7 +70,7 @@ html(lang='en')
7170
label(for='label') LABEL
7271
input#label(type='text', value=pkg.name)
7372
label(for='font') FONT NAME
74-
input#font(type='text', value='Ubuntu')
73+
input#font(type='text', value='Ubuntu Mono')
7574
label(for='fontcolor') FONT COLOR
7675
input#fontcolor(type='color', value='#ff9818')
7776

src/demo/styles.css

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55

66
body {
7-
font-family: 'Ubuntu', 'Arial', 'sans';
7+
font-family: 'Ubuntu Mono', 'monospace';
88
text-align: center;
99
background: repeat url('back.png');
1010
}
@@ -59,13 +59,14 @@ hr {
5959
}
6060

6161
label {
62-
font-size: 10px;
63-
color: #aaa;
64-
padding: 12px 4px 0 4px;
62+
display: block;
63+
font-size: 12px;
64+
color: #555;
65+
padding: 12px 4px 4px 4px;
6566
}
6667

6768
input, textarea, select {
68-
font-family: 'Ubuntu', 'Arial', 'sans';
69+
font-family: 'Ubuntu Mono', 'monospace';
6970
display: block;
7071
background-color: #fff;
7172
margin: 2px;

src/kjua.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const qrcode = require('./lib/qrcode');
33
const create_canvas_qrcode = require('./lib/create_canvas_qrcode');
44
const create_svg_qrcode = require('./lib/create_svg_qrcode');
55

6-
module.exports = options => {
6+
const kjua = options => {
77
const settings = Object.assign({}, defaults, options);
88
const qr = qrcode(settings.text, settings.ecLevel, settings.minVersion, settings.quiet);
99

@@ -12,3 +12,11 @@ module.exports = options => {
1212
}
1313
return create_canvas_qrcode(qr, settings, settings.render === 'image');
1414
};
15+
16+
module.exports = kjua;
17+
18+
/* eslint-disable */ try {
19+
jQuery.fn.kjua = function (options) {
20+
return this.each((idx, el) => el.appendChild(kjua(options)));
21+
};
22+
} catch (e) {} /* eslint-enable */

src/lib/create_canvas_qrcode.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {create_canvas, canvas_to_img, dpr} = require('./dom');
1+
const dom = require('./dom');
22
const draw_module_rounded = require('./draw_rounded');
33
const draw_mode = require('./draw_mode');
44

@@ -49,13 +49,13 @@ const draw = (qr, ctx, settings) => {
4949
};
5050

5151
const create_canvas_qrcode = (qr, settings, as_image) => {
52-
const ratio = settings.ratio || dpr;
53-
const canvas = create_canvas(settings.size, ratio);
52+
const ratio = settings.ratio || dom.dpr;
53+
const canvas = dom.create_canvas(settings.size, ratio);
5454
const context = canvas.getContext('2d');
5555

5656
context.scale(ratio, ratio);
5757
draw(qr, context, settings);
58-
return as_image ? canvas_to_img(canvas) : canvas;
58+
return as_image ? dom.canvas_to_img(canvas) : canvas;
5959
};
6060

6161
module.exports = create_canvas_qrcode;

src/lib/create_svg_qrcode.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {create_svg_el, get_attr} = require('./dom');
1+
const {SVG_NS, get_attr, create_svg_el} = require('./dom');
22

33
const create_draw_ctx = ctx => {
44
const rnd = x => Math.round(x * 10) / 10;
@@ -116,9 +116,9 @@ const add_label = (el, settings) => {
116116
const size = settings.size;
117117
const font = 'bold ' + settings.mSize * 0.01 * size + 'px ' + settings.fontname;
118118

119-
const {create_canvas, dpr} = require('./dom');
120-
const ratio = settings.ratio || dpr;
121-
const ctx = create_canvas(size, ratio).getContext('2d');
119+
const dom = require('./dom');
120+
const ratio = settings.ratio || dom.dpr;
121+
const ctx = dom.create_canvas(size, ratio).getContext('2d');
122122
ctx.strokeStyle = settings.back;
123123
ctx.lineWidth = settings.mSize * 0.01 * size * 0.1;
124124
ctx.fillStyle = settings.fontcolor;
@@ -176,7 +176,7 @@ const create_svg_qrcode = (qr, settings) => {
176176
const mode = settings.mode;
177177

178178
const svg_el = create_svg_el('svg', {
179-
xmlns: 'http://www.w3.org/2000/svg',
179+
xmlns: SVG_NS,
180180
width: size,
181181
height: size,
182182
viewBox: `0 0 ${size} ${size}`

src/lib/dom.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ const canvas_to_img = canvas => {
3838
};
3939

4040
module.exports = {
41-
create_svg_el,
41+
dpr,
42+
SVG_NS,
4243
get_attr,
44+
create_el,
45+
create_svg_el,
4346
create_canvas,
44-
canvas_to_img,
45-
dpr
47+
canvas_to_img
4648
};

0 commit comments

Comments
 (0)