0
|
1 <!doctype html>
|
|
2 <head>
|
|
3 <meta charset="utf-8">
|
5
|
4 <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
0
|
5 <title>QR Code Generator</title>
|
|
6
|
|
7 <style type="text/css">
|
|
8 * {
|
|
9 box-sizing: border-box;
|
|
10 }
|
|
11
|
|
12 html {
|
|
13 height: 100%;
|
|
14 margin: 0;
|
|
15 padding: 0;
|
7
|
16 font-family: Arial, sans-serif;
|
0
|
17 font-size: 12px;
|
|
18 }
|
|
19
|
|
20 body {
|
|
21 margin: 0;
|
14
|
22 padding: 8px;
|
0
|
23 height: 100%;
|
|
24 }
|
|
25
|
|
26 .inputbox {
|
|
27 width: 100%;
|
14
|
28 margin-bottom: 8px;
|
0
|
29 resize: vertical;
|
7
|
30 font-family: Courier New, monospace;
|
5
|
31 /* prevent ios zoom */
|
|
32 font-size: 16px;
|
0
|
33 }
|
|
34
|
|
35 .page {
|
|
36 width: 100%;
|
7
|
37 min-height: 100%;
|
0
|
38 max-width: 600px;
|
|
39 margin: 0 auto;
|
14
|
40 display: grid;
|
|
41 grid-template-rows: 1fr auto;
|
|
42 gap: 8px;
|
0
|
43 }
|
|
44
|
14
|
45 .page__footer {
|
|
46 border-top: 1px solid #333;
|
|
47 padding-top: 8px;
|
0
|
48 }
|
|
49
|
1
|
50 .outputbox {
|
14
|
51 max-width: 256px;
|
1
|
52 }
|
|
53
|
11
|
54 .outputbox > canvas {
|
|
55 display: none;
|
|
56 }
|
|
57
|
10
|
58 .outputbox > img {
|
|
59 max-width: 100%;
|
|
60 }
|
|
61
|
0
|
62 .title {
|
|
63 font-size: 16px;
|
|
64 }
|
|
65 </style>
|
|
66 </head>
|
|
67 <body>
|
|
68 <div class="page">
|
|
69 <div class="page__main">
|
|
70 <h1>QR Code Generator</h1>
|
|
71
|
|
72 <p>
|
2
|
73 Type something and get its QR code (almost) immediately.
|
0
|
74 </p>
|
|
75
|
|
76 <textarea class="inputbox js-qr-input" rows="4" autofocus></textarea>
|
|
77
|
1
|
78 <div class="outputbox js-qr-output"></div>
|
0
|
79 </div>
|
|
80
|
14
|
81 <div class="page__footer">
|
12
|
82 <a href="https://hg.sr.ht/~nanaya/qr-html">Source</a>
|
0
|
83 </div>
|
|
84 </div>
|
|
85
|
|
86 <script src="qrcode.min.js"></script>
|
|
87
|
|
88 <script>
|
9
|
89 var inputDom = document.querySelector(".js-qr-input")
|
|
90 var outputDom = document.querySelector(".js-qr-output")
|
14
|
91 var qr = new QRCode(outputDom, { correctLevel: QRCode.CorrectLevel.L, width: 256, height: 256 })
|
0
|
92
|
4
|
93 var runTimeout = null
|
|
94
|
3
|
95 var refreshCode = function() {
|
|
96 var text = inputDom.value
|
0
|
97
|
14
|
98 if (text === "") {
|
|
99 outputDom.style.display = 'none';
|
|
100 } else {
|
|
101 outputDom.style.display = 'block';
|
2
|
102 qr.makeCode(text)
|
0
|
103 }
|
2
|
104 }
|
|
105
|
14
|
106 inputDom.addEventListener('input', refreshCode)
|
3
|
107 refreshCode()
|
0
|
108 </script>
|
|
109 </body>
|