forked from IAmDarkest/QR__CODE__GENERATOR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQR__CODE__GENERATOR.html
187 lines (82 loc) · 2.49 KB
/
QR__CODE__GENERATOR.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!DOCTYPE html>
<html>
<head>
<!-- Include Bootstrap for styling -->
<link rel="stylesheet" href=
pp
"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<style>
.qr-code {
max-width: 200px;
margin: 10px;
}
</style>
<title>QR Code Generator</title>
</head>
<body>
<div class="container-fluid">
<div class="text-center">
<!-- Get a Placeholder image initially,
this will change according to the
data entered later -->
<img src=
"https://chart.googleapis.com/chart?cht=qr&chl=Hello+World&chs=160x160&chld=L|0"
class="qr-code img-thumbnail img-responsive" />
</div>
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2"
for="content">
Content:
</label>
<div class="col-sm-10">
<!-- Input box to enter the
required data -->
<input type="text" size="60"
maxlength="60" class="form-control"
id="content" placeholder="Enter content" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<!-- Button to generate QR Code for
the entered data -->
<button type="button" class=
"btn btn-default" id="generate">
Generate
</button>
</div>
</div>
</div>
</div>
<script src=
"https://code.jquery.com/jquery-3.5.1.js">
</script>
<script>
// Function to HTML encode the text
// This creates a new hidden element,
// inserts the given text into it
// and outputs it out as HTML
function htmlEncode(value) {
return $('<div/>').text(value)
.html();
}
$(function () {
// Specify an onclick function
// for the generate button
$('#generate').click(function () {
// Generate the link that would be
// used to generate the QR Code
// with the given data
let finalURL =
'https://chart.googleapis.com/chart?cht=qr&chl=' +
htmlEncode($('#content').val()) +
'&chs=160x160&chld=L|0'
// Replace the src of the image with
// the QR code image
$('.qr-code').attr('src', finalURL);
});
});
</script>
</body>
</html>