-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqr.html
More file actions
633 lines (556 loc) · 22 KB
/
qr.html
File metadata and controls
633 lines (556 loc) · 22 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Qr code generator</title>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- EasyQRCodeJS Library -->
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
-webkit-tap-highlight-color: transparent;
}
body {
background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
color: #fff;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: flex-start;
padding: 20px 15px;
overflow-x: hidden;
}
.app-container {
width: 100%;
max-width: 500px;
background: rgba(25, 25, 35, 0.7);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.1);
padding: 25px 20px;
border-radius: 25px;
box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
margin-bottom: 30px;
}
.header {
text-align: center;
margin-bottom: 20px;
}
.app-title {
font-size: 24px;
font-weight: 700;
background: linear-gradient(135deg, #00f2fe, #4facfe);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.app-subtitle {
font-size: 12px;
color: #a0a0b5;
}
/* === INPUTS & FORMS === */
.input-group {
margin-bottom: 15px;
}
.input-label {
font-size: 13px;
font-weight: 500;
color: #b5b5c5;
margin-bottom: 6px;
display: block;
}
.custom-input,
.custom-select {
width: 100%;
padding: 12px 15px;
border-radius: 12px;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
color: #fff;
font-size: 14px;
outline: none;
transition: 0.3s;
margin-bottom: 10px;
}
.custom-input:focus,
.custom-select:focus {
border-color: #4facfe;
background: rgba(255, 255, 255, 0.08);
}
.custom-select option {
background: #1e1e2d;
color: #fff;
}
/* Hide dynamic sections initially */
.dynamic-section {
display: none;
animation: fadeIn 0.3s ease;
}
.dynamic-section.active {
display: block;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(-5px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* === ACCORDION SETTINGS === */
details {
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 12px;
margin-bottom: 15px;
padding: 5px 15px;
}
summary {
font-size: 14px;
font-weight: 600;
color: #4facfe;
padding: 10px 0;
cursor: pointer;
outline: none;
display: flex;
justify-content: space-between;
align-items: center;
list-style: none;
}
summary::-webkit-details-marker {
display: none;
}
summary::after {
content: '▼';
font-size: 10px;
transition: 0.3s;
}
details[open] summary::after {
transform: rotate(180deg);
}
.settings-content {
padding-bottom: 15px;
}
/* Settings Grid */
.settings-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}
.color-item {
display: flex;
align-items: center;
gap: 10px;
background: rgba(255, 255, 255, 0.05);
padding: 8px;
border-radius: 10px;
}
.color-item input[type="color"] {
width: 30px;
height: 30px;
border: none;
border-radius: 6px;
cursor: pointer;
background: transparent;
padding: 0;
}
.color-item span {
font-size: 12px;
}
/* Checkbox */
.checkbox-label {
display: flex;
align-items: center;
gap: 10px;
font-size: 13px;
cursor: pointer;
margin-top: 10px;
}
.checkbox-label input {
width: 16px;
height: 16px;
accent-color: #4facfe;
cursor: pointer;
}
/* Logo Buttons */
.logo-controls {
display: flex;
gap: 10px;
margin-top: 15px;
}
.btn-outline {
flex: 1;
padding: 10px;
border: 1px dashed #4facfe;
color: #4facfe;
background: rgba(79, 172, 254, 0.05);
border-radius: 10px;
cursor: pointer;
font-size: 13px;
font-weight: 500;
text-align: center;
transition: 0.3s;
display: block;
}
.btn-outline:hover {
background: rgba(79, 172, 254, 0.15);
}
.btn-danger {
border-color: #ff4b4b;
color: #ff4b4b;
background: rgba(255, 75, 75, 0.05);
}
.btn-danger:hover {
background: rgba(255, 75, 75, 0.15);
}
#logo-input {
display: none;
}
/* === PREVIEW === */
.qr-preview-box {
background: #ffffff;
padding: 20px;
border-radius: 20px;
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 20px;
min-height: 240px;
position: relative;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
overflow: hidden;
background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f0f0f0 75%), linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
background-size: 20px 20px;
background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}
#qrcode {
display: flex;
justify-content: center;
align-items: center;
z-index: 2;
}
.empty-text {
color: #888;
font-size: 14px;
position: absolute;
font-weight: 500;
z-index: 1;
}
/* === PRIMARY BUTTON === */
.btn-primary {
width: 100%;
padding: 15px;
border: none;
border-radius: 12px;
background: linear-gradient(135deg, #00f2fe, #4facfe);
color: #fff;
font-size: 15px;
font-weight: 600;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
gap: 8px;
box-shadow: 0 8px 15px rgba(79, 172, 254, 0.25);
}
.btn-primary svg {
width: 20px;
height: 20px;
stroke: currentColor;
fill: none;
stroke-width: 2;
}
/* Mobile Adjustments */
@media (max-width: 400px) {
.settings-grid {
grid-template-columns: 1fr;
}
.logo-controls {
flex-direction: column;
}
}
</style>
</head>
<body>
<div class="app-container">
<div class="header">
<div class="app-title">Qr code generator</div>
<div class="app-subtitle">Generate 7 Types of Advanced QR Codes</div>
</div>
<!-- QR DATA TYPE SELECTOR -->
<div class="input-group">
<label class="input-label">Select QR Type</label>
<select id="qr-type" class="custom-select" onchange="switchQRType()">
<option value="url">🌐 Link / URL</option>
<option value="text">📝 Normal Text</option>
<option value="wifi">📶 Wi-Fi Network</option>
<option value="whatsapp">💬 WhatsApp Message</option>
<option value="vcard">👤 Contact (vCard)</option>
<option value="email">✉️ Email</option>
<option value="sms">📱 SMS</option>
</select>
</div>
<!-- DYNAMIC INPUT SECTIONS -->
<!-- 1. URL / Text -->
<div id="type-text" class="dynamic-section active">
<input type="text" id="val-text" class="custom-input" placeholder="Enter Link or Text here..." oninput="generateQR()">
</div>
<!-- 2. Wi-Fi -->
<div id="type-wifi" class="dynamic-section">
<input type="text" id="val-wifi-ssid" class="custom-input" placeholder="Network Name (SSID)" oninput="generateQR()">
<input type="text" id="val-wifi-pass" class="custom-input" placeholder="Password" oninput="generateQR()">
<select id="val-wifi-enc" class="custom-select" onchange="generateQR()">
<option value="WPA">WPA/WPA2</option>
<option value="WEP">WEP</option>
<option value="nopass">No Password</option>
</select>
</div>
<!-- 3. WhatsApp -->
<div id="type-whatsapp" class="dynamic-section">
<input type="number" id="val-wa-phone" class="custom-input" placeholder="Phone with Country Code (e.g. 919876543210)" oninput="generateQR()">
<input type="text" id="val-wa-msg" class="custom-input" placeholder="Default Message (Optional)" oninput="generateQR()">
</div>
<!-- 4. vCard (Contact) -->
<div id="type-vcard" class="dynamic-section">
<input type="text" id="val-vc-name" class="custom-input" placeholder="Full Name" oninput="generateQR()">
<input type="number" id="val-vc-phone" class="custom-input" placeholder="Phone Number" oninput="generateQR()">
<input type="email" id="val-vc-email" class="custom-input" placeholder="Email Address" oninput="generateQR()">
<input type="text" id="val-vc-company" class="custom-input" placeholder="Company Name" oninput="generateQR()">
</div>
<!-- 5. Email -->
<div id="type-email" class="dynamic-section">
<input type="email" id="val-em-to" class="custom-input" placeholder="To Email" oninput="generateQR()">
<input type="text" id="val-em-sub" class="custom-input" placeholder="Subject" oninput="generateQR()">
<input type="text" id="val-em-msg" class="custom-input" placeholder="Message Body" oninput="generateQR()">
</div>
<!-- 6. SMS -->
<div id="type-sms" class="dynamic-section">
<input type="number" id="val-sms-phone" class="custom-input" placeholder="Phone Number" oninput="generateQR()">
<input type="text" id="val-sms-msg" class="custom-input" placeholder="SMS Text" oninput="generateQR()">
</div>
<!-- === ADVANCED SETTINGS ACCORDION === -->
<details>
<summary>🎨 Colors & Logo Settings</summary>
<div class="settings-content">
<div class="settings-grid">
<div class="color-item"><input type="color" id="color-qr" value="#000000" onchange="generateQR()"><span>QR Dots</span></div>
<div class="color-item"><input type="color" id="color-bg" value="#ffffff" onchange="generateQR()"><span>Background</span></div>
<div class="color-item"><input type="color" id="color-eye-out" value="#000000" onchange="generateQR()"><span>Eye Frame</span></div>
<div class="color-item"><input type="color" id="color-eye-in" value="#000000" onchange="generateQR()"><span>Eye Center</span></div>
</div>
<label class="checkbox-label">
<input type="checkbox" id="trans-bg" onchange="generateQR()"> Transparent Background (PNG)
</label>
<!-- Logo Section -->
<div class="logo-controls">
<label class="btn-outline">
<input type="file" id="logo-input" accept="image/*" onchange="handleLogoUpload(event)">
📸 Upload Logo
</label>
<button class="btn-outline btn-danger" onclick="removeLogo()">🗑️ Remove Logo</button>
</div>
</div>
</details>
<details>
<summary>⚙️ Technical Settings</summary>
<div class="settings-content settings-grid">
<div>
<label class="input-label">Error Correction</label>
<select id="err-level" class="custom-select" onchange="generateQR()">
<option value="H">Level H (Best for Logos)</option>
<option value="Q">Level Q</option>
<option value="M">Level M</option>
<option value="L">Level L (Basic)</option>
</select>
</div>
<div>
<label class="input-label">Margin Size</label>
<select id="margin-size" class="custom-select" onchange="generateQR()">
<option value="15">Normal</option>
<option value="0">No Margin</option>
<option value="30">Large</option>
</select>
</div>
</div>
</details>
<details>
<summary>💾 Export Format</summary>
<div class="settings-content settings-grid">
<div>
<label class="input-label">File Name</label>
<input type="text" id="file-name" class="custom-input" placeholder="Pro_QR_Code" value="Pro_QR_Code">
</div>
<div>
<label class="input-label">Format</label>
<select id="file-format" class="custom-select">
<option value="png">PNG (Best)</option>
<option value="jpeg">JPG</option>
<option value="webp">WEBP</option>
</select>
</div>
</div>
</details>
<!-- PREVIEW AREA -->
<div class="qr-preview-box">
<span class="empty-text" id="empty-msg">Waiting for input...</span>
<div id="qrcode"></div>
</div>
<!-- DOWNLOAD BUTTON -->
<button class="btn-primary" onclick="downloadQR()">
<svg viewBox="0 0 24 24">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
<polyline points="7 10 12 15 17 10"></polyline>
<line x1="12" y1="15" x2="12" y2="3"></line>
</svg>
Download QR Code
</button>
</div>
<script>
let qrCodeInstance = null;
let customLogo = null;
const qrContainer = document.getElementById("qrcode");
const emptyMsg = document.getElementById("empty-msg");
// 1. Switch Data Type Forms
function switchQRType() {
document.querySelectorAll('.dynamic-section').forEach(el => el.classList.remove('active'));
const type = document.getElementById('qr-type').value;
if (['url', 'text'].includes(type)) {
document.getElementById('type-text').classList.add('active');
} else {
document.getElementById(`type-${type}`).classList.add('active');
}
generateQR();
}
// 2. Handle Logo
function handleLogoUpload(event) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
customLogo = e.target.result;
generateQR();
}
reader.readAsDataURL(file);
}
}
function removeLogo() {
customLogo = null;
document.getElementById('logo-input').value = "";
generateQR();
}
// 3. Compile Data String based on Type
function getQRDataString() {
const type = document.getElementById('qr-type').value;
if (type === 'url' || type === 'text') {
return document.getElementById('val-text').value.trim();
}
if (type === 'wifi') {
const ssid = document.getElementById('val-wifi-ssid').value.trim();
const pass = document.getElementById('val-wifi-pass').value.trim();
const enc = document.getElementById('val-wifi-enc').value;
if (!ssid) return "";
return `WIFI:T:${enc};S:${ssid};P:${pass};;`;
}
if (type === 'whatsapp') {
const phone = document.getElementById('val-wa-phone').value.trim();
const msg = document.getElementById('val-wa-msg').value.trim();
if (!phone) return "";
return `https://wa.me/${phone}?text=${encodeURIComponent(msg)}`;
}
if (type === 'vcard') {
const name = document.getElementById('val-vc-name').value.trim();
const phone = document.getElementById('val-vc-phone').value.trim();
const email = document.getElementById('val-vc-email').value.trim();
const comp = document.getElementById('val-vc-company').value.trim();
if (!name && !phone) return "";
return `BEGIN:VCARD\nVERSION:3.0\nFN:${name}\nTEL:${phone}\nEMAIL:${email}\nORG:${comp}\nEND:VCARD`;
}
if (type === 'email') {
const to = document.getElementById('val-em-to').value.trim();
const sub = document.getElementById('val-em-sub').value.trim();
const msg = document.getElementById('val-em-msg').value.trim();
if (!to) return "";
return `mailto:${to}?subject=${encodeURIComponent(sub)}&body=${encodeURIComponent(msg)}`;
}
if (type === 'sms') {
const phone = document.getElementById('val-sms-phone').value.trim();
const msg = document.getElementById('val-sms-msg').value.trim();
if (!phone) return "";
return `smsto:${phone}:${msg}`;
}
return "";
}
// 4. Generate the QR Code
function generateQR() {
const qrData = getQRDataString();
qrContainer.innerHTML = ""; // Clear Old QR
if (!qrData) {
emptyMsg.style.display = "block";
return;
}
emptyMsg.style.display = "none";
// Fetch Settings
const cQR = document.getElementById('color-qr').value;
const cBG = document.getElementById('color-bg').value;
const cEyeOut = document.getElementById('color-eye-out').value;
const cEyeIn = document.getElementById('color-eye-in').value;
const isTrans = document.getElementById('trans-bg').checked;
const errLvl = document.getElementById('err-level').value;
const margin = parseInt(document.getElementById('margin-size').value);
// EasyQRCodeJS Options
let options = {
text: qrData,
width: 250,
height: 250,
colorDark: cQR,
colorLight: isTrans ? "rgba(0,0,0,0)" : cBG,
correctLevel: QRCode.CorrectLevel[errLvl],
quietZone: margin,
quietZoneColor: isTrans ? "rgba(0,0,0,0)" : cBG,
// Advanced Eyes Styling
PO: cEyeOut, // Position Outer
PI: cEyeIn, // Position Inner
};
// Add Logo if exists
if (customLogo) {
options.logo = customLogo;
options.logoWidth = 60;
options.logoHeight = 60;
options.logoBackgroundColor = "#ffffff";
options.logoBackgroundTransparent = false;
}
// Create QR
qrCodeInstance = new QRCode(qrContainer, options);
}
// 5. Download QR Image
function downloadQR() {
const qrData = getQRDataString();
if (!qrData) {
alert("Please enter data to generate QR code first!");
return;
}
setTimeout(() => {
const canvas = qrContainer.querySelector("canvas");
if (canvas) {
const format = document.getElementById('file-format').value;
let filename = document.getElementById('file-name').value.trim() || "Pro_QR_Code";
const dataUrl = canvas.toDataURL(`image/${format}`, 1.0);
const link = document.createElement("a");
link.download = `${filename}.${format}`;
link.href = dataUrl;
link.click();
} else {
alert("Error exporting QR. Please wait a second and try again.");
}
}, 300); // Small delay to ensure render is complete
}
</script>
</body>
</html>