0
|
1 <!doctype html>
|
|
2 <head>
|
|
3 <meta charset="utf-8">
|
|
4 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
|
5 <title>QR Code Generator</title>
|
|
6
|
|
7 <style type="text/css">
|
|
8 * {
|
|
9 position: relative;
|
|
10 box-sizing: border-box;
|
|
11 }
|
|
12
|
|
13 html {
|
|
14 height: 100%;
|
|
15 margin: 0;
|
|
16 padding: 0;
|
|
17 font-family: sans-serif;
|
|
18 font-size: 12px;
|
|
19 }
|
|
20
|
|
21 body {
|
|
22 margin: 0;
|
|
23 padding: 10px;
|
|
24 height: 100%;
|
|
25 }
|
|
26
|
|
27 .inputbox {
|
|
28 width: 100%;
|
|
29 margin-bottom: 10px;
|
|
30 resize: vertical;
|
|
31 font-family: monospace;
|
|
32 }
|
|
33
|
|
34 .page {
|
|
35 width: 100%;
|
|
36 height: 100%;
|
|
37 max-width: 600px;
|
|
38 margin: 0 auto;
|
|
39 display: flex;
|
|
40 flex-direction: column;
|
|
41 padding: 10px;
|
|
42 }
|
|
43
|
|
44 .page__main {
|
|
45 flex: 1;
|
|
46 }
|
|
47
|
1
|
48 .outputbox {
|
|
49 will-change: opacity;
|
|
50 }
|
|
51
|
|
52 .outputbox.js-hidden {
|
|
53 opacity: 0;
|
|
54 }
|
|
55
|
0
|
56 .title {
|
|
57 font-size: 16px;
|
|
58 }
|
|
59 </style>
|
|
60 </head>
|
|
61 <body>
|
|
62 <div class="page">
|
|
63 <div class="page__main">
|
|
64 <h1>QR Code Generator</h1>
|
|
65
|
|
66 <p>
|
2
|
67 Type something and get its QR code (almost) immediately.
|
0
|
68 </p>
|
|
69
|
|
70 <textarea class="inputbox js-qr-input" rows="4" autofocus></textarea>
|
|
71
|
1
|
72 <div class="outputbox js-qr-output"></div>
|
0
|
73 </div>
|
|
74
|
|
75 <div>
|
|
76 <hr>
|
|
77
|
|
78 <a href="https://bitbucket.org/nanaya1/qr-html">Source</a>
|
|
79 </div>
|
|
80 </div>
|
|
81
|
|
82 <script src="qrcode.min.js"></script>
|
2
|
83 <script src="lodash.min.js"></script>
|
0
|
84
|
|
85 <script>
|
3
|
86 var inputDom = document.getElementsByClassName("js-qr-input")[0]
|
2
|
87 var outputDom = document.getElementsByClassName("js-qr-output")[0]
|
|
88 var qr = new QRCode(outputDom)
|
0
|
89
|
3
|
90 var refreshCode = function() {
|
|
91 var text = inputDom.value
|
0
|
92
|
|
93 if (text !== "") {
|
2
|
94 qr.makeCode(text)
|
|
95 outputDom.classList.remove('js-hidden')
|
1
|
96 } else {
|
2
|
97 outputDom.classList.add('js-hidden')
|
0
|
98 }
|
2
|
99 }
|
|
100
|
3
|
101 inputDom.addEventListener('input', _.debounce(refreshCode, 100))
|
|
102 refreshCode()
|
0
|
103 </script>
|
|
104 </body>
|