-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.html
178 lines (154 loc) · 4.55 KB
/
generate.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>QR Code Generator</title>
<link rel="manifest" href="manifest.json">
<link rel="icon" href="qr-code.png" type="image/png" />
<style>
body{
font-family: 'Roboto', sans-serif;
background :linear-gradient(45deg, #06c8ef 0% 10%, black 10% 12% , #1396b7 12% 13%,#eeff00 13% 14%,black 14% 16%,#1396b7 16% 18%,black 18% 22%,#1396b7 22% 26%,black 26% 27%,#1396b7 27% 29%,black 29% 31%,#1396b7 31% 65%,black 65% 65.5% ,#eeff00 66% 67% ,black 67% 68%,#eeff00 68% 70%,black 70% 71%,#eeff00 71% 85%,black 85% 86%, #eeff00 86% 100%);
color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(10px);
padding: 50px 40px;
border-radius: 15px;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
text-align: center;
animation: fadeIn 1s ease-in-out;
max-width: 400px;
width: 100%;
}
.container h1 {
font-size: 2em;
margin-bottom: 30px;
color: #fff;
letter-spacing: 1px;
text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.5);
}
.qr-form {
display: flex;
flex-direction: column;
gap: 1.2rem;
width: 100%;
max-width: 400px;
margin: 0 auto;
}
.qr-form input {
padding: 0.8rem 1rem;
border: 2px solid #ddd;
border-radius: 8px;
font-size: 1rem;
transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
.qr-form input:focus {
border-color: #007bff;
box-shadow: 0 0 8px rgba(0, 123, 255, 0.5);
outline: none;
}
.qr-form button {
padding: 0.8rem 1.5rem;
background: linear-gradient(135deg, #007bff, #0056b3);
color: #fff;
border: none;
width:250px;
border-radius: 50px;
cursor: pointer;
font-size:0.8rem;
font-weight: bold;
text-transform: uppercase;
transition: transform 0.3s, background 0.3s ease-in-out;
margin: 0 auto; /* Center the button */
}
.qr-form button:hover {
background: linear-gradient(135deg, #0056b3, #003d80);
transform: scale(1.05);
}
.qr-code {
margin-left:4rem;
margin-top: 2rem;
width: 256px;
height: 256px;
border: 3px dotted black;
border-radius: 10px; /* Smooth corners */
}
.qr-code:hover {
transform: scale(1.01); /* Slight rotation and zoom on hover */
}
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(-20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
</style>
</head>
<body>
<div class="container">
<h1>Generate Your QR Code</h1>
<form id="qr-generation-form" class="qr-form">
<input type="text" id="qr-content" name="qr-code-content" placeholder="Enter QR content" autocomplete="off">
<button type="submit">Generate</button>
<div id="qr-code" class="qr-code"></div>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
<script>
let qrContentInput = document.getElementById("qr-content");
let qrGenerationForm = document.getElementById("qr-generation-form");
let qrCode;
function generateQrCode(qrContent) {
let qrCodeInstance = new QRCode("qr-code", {
text: qrContent,
width: 256,
height: 256,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H,
});
// Store the canvas element
let canvas = document.querySelector("#qr-code canvas");
return canvas;
}
qrGenerationForm.addEventListener("submit", function (event) {
event.preventDefault();
let qrContent = qrContentInput.value;
if (qrCode == null) {
qrCode = generateQrCode(qrContent);
} else {
// Regenerate the QR code
let canvas = generateQrCode(qrContent);
qrCode = canvas; // Update the qrCode variable with the new canvas
}
});
$(document).ready(function () {
$("#qr-code").on('click', function () {
if (qrCode) {
var imageData = qrCode.toDataURL("image/png");
// Create a downloadable link
var newData = imageData.replace(/^data:image\/png/, "data:application/octet-stream");
var link = document.createElement('a');
link.download = 'qr_code.png';
link.href = newData;
link.click(); // Trigger download
}
});
});
</script>
</body>
</html>
</html>