File size: 25,131 Bytes
dc21927
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
<!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 Pro</title>
    <script src="https://cdn.jsdelivr.net/npm/qrcode@1.5.1/build/qrcode.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 10px;
        }

        .container {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            padding: 30px;
            max-width: 500px;
            width: 100%;
            animation: slideUp 0.8s ease-out;
        }

        @keyframes slideUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .header {
            text-align: center;
            margin-bottom: 25px;
        }

        .title {
            font-size: 28px;
            font-weight: 700;
            background: linear-gradient(135deg, #667eea, #764ba2);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            margin-bottom: 8px;
        }

        .subtitle {
            color: #666;
            font-size: 14px;
        }

        .category-selector {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
            gap: 8px;
            margin-bottom: 20px;
        }

        .category-btn {
            padding: 10px 8px;
            border: none;
            border-radius: 12px;
            background: #f8f9ff;
            color: #666;
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
        }

        .category-btn:hover {
            background: #e8f0ff;
            transform: translateY(-2px);
        }

        .category-btn.active {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
        }

        .category-icon {
            font-size: 16px;
        }

        .input-group {
            margin-bottom: 15px;
        }

        .input-label {
            display: block;
            margin-bottom: 6px;
            font-weight: 600;
            color: #333;
            font-size: 13px;
        }

        .input-field {
            width: 100%;
            padding: 12px 16px;
            border: 2px solid #e9ecef;
            border-radius: 12px;
            font-size: 14px;
            transition: all 0.3s ease;
            background: #fafbff;
        }

        .input-field:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
            background: white;
        }

        .input-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
        }

        .customization {
            background: #f8f9ff;
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 20px;
        }

        .custom-title {
            font-weight: 600;
            color: #333;
            margin-bottom: 15px;
            font-size: 14px;
        }

        .color-controls {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            gap: 15px;
            margin-bottom: 15px;
        }

        .color-group {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .color-input {
            width: 40px;
            height: 40px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }

        .size-control {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 10px;
        }

        .size-slider {
            flex: 1;
            height: 6px;
            background: #e9ecef;
            border-radius: 3px;
            outline: none;
            cursor: pointer;
        }

        .generate-btn {
            width: 100%;
            padding: 15px;
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            border: none;
            border-radius: 12px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-bottom: 20px;
        }

        .generate-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
        }

        .generate-btn:active {
            transform: translateY(0);
        }

        .qr-output {
            text-align: center;
            padding: 20px;
            background: white;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
        }

        .qr-canvas {
            max-width: 100%;
            border-radius: 8px;
            margin-bottom: 15px;
        }

        .download-controls {
            display: flex;
            gap: 10px;
            justify-content: center;
            flex-wrap: wrap;
        }

        .download-btn {
            padding: 10px 20px;
            border: 2px solid #667eea;
            background: white;
            color: #667eea;
            border-radius: 8px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .download-btn:hover {
            background: #667eea;
            color: white;
        }

        .hidden {
            display: none;
        }

        .error {
            color: #e74c3c;
            font-size: 12px;
            margin-top: 5px;
        }

        @media (max-width: 480px) {
            .container {
                padding: 20px;
                margin: 10px;
            }
            
            .category-selector {
                grid-template-columns: repeat(3, 1fr);
            }
            
            .input-row {
                grid-template-columns: 1fr;
            }
            
            .color-controls {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1 class="title">QR Generator Pro</h1>
            <p class="subtitle">Create professional QR codes with advanced customization</p>
        </div>

        <div class="category-selector">
            <button class="category-btn active" data-type="text">
                <span class="category-icon">📝</span>
                <span>Text</span>
            </button>
            <button class="category-btn" data-type="url">
                <span class="category-icon">🔗</span>
                <span>URL</span>
            </button>
            <button class="category-btn" data-type="email">
                <span class="category-icon">✉️</span>
                <span>Email</span>
            </button>
            <button class="category-btn" data-type="phone">
                <span class="category-icon">📞</span>
                <span>Phone</span>
            </button>
            <button class="category-btn" data-type="sms">
                <span class="category-icon">💬</span>
                <span>SMS</span>
            </button>
            <button class="category-btn" data-type="wifi">
                <span class="category-icon">📶</span>
                <span>WiFi</span>
            </button>
            <button class="category-btn" data-type="vcard">
                <span class="category-icon">👤</span>
                <span>vCard</span>
            </button>
            <button class="category-btn" data-type="location">
                <span class="category-icon">📍</span>
                <span>Location</span>
            </button>
            <button class="category-btn" data-type="event">
                <span class="category-icon">📅</span>
                <span>Event</span>
            </button>
        </div>

        <div id="input-forms">
            <!-- Text Form -->
            <div id="text-form" class="form-section">
                <div class="input-group">
                    <label class="input-label">Enter your text</label>
                    <textarea class="input-field" id="text-input" rows="3" placeholder="Type your message here..."></textarea>
                </div>
            </div>

            <!-- URL Form -->
            <div id="url-form" class="form-section hidden">
                <div class="input-group">
                    <label class="input-label">Website URL</label>
                    <input type="url" class="input-field" id="url-input" placeholder="https://example.com">
                </div>
            </div>

            <!-- Email Form -->
            <div id="email-form" class="form-section hidden">
                <div class="input-group">
                    <label class="input-label">Email Address</label>
                    <input type="email" class="input-field" id="email-input" placeholder="user@example.com">
                </div>
                <div class="input-group">
                    <label class="input-label">Subject (Optional)</label>
                    <input type="text" class="input-field" id="email-subject" placeholder="Email subject">
                </div>
                <div class="input-group">
                    <label class="input-label">Message (Optional)</label>
                    <textarea class="input-field" id="email-body" rows="2" placeholder="Email message"></textarea>
                </div>
            </div>

            <!-- Phone Form -->
            <div id="phone-form" class="form-section hidden">
                <div class="input-group">
                    <label class="input-label">Phone Number</label>
                    <input type="tel" class="input-field" id="phone-input" placeholder="+1234567890">
                </div>
            </div>

            <!-- SMS Form -->
            <div id="sms-form" class="form-section hidden">
                <div class="input-group">
                    <label class="input-label">Phone Number</label>
                    <input type="tel" class="input-field" id="sms-phone" placeholder="+1234567890">
                </div>
                <div class="input-group">
                    <label class="input-label">Message</label>
                    <textarea class="input-field" id="sms-message" rows="2" placeholder="SMS message"></textarea>
                </div>
            </div>

            <!-- WiFi Form -->
            <div id="wifi-form" class="form-section hidden">
                <div class="input-group">
                    <label class="input-label">Network Name (SSID)</label>
                    <input type="text" class="input-field" id="wifi-ssid" placeholder="My WiFi Network">
                </div>
                <div class="input-row">
                    <div class="input-group">
                        <label class="input-label">Password</label>
                        <input type="text" class="input-field" id="wifi-password" placeholder="password123">
                    </div>
                    <div class="input-group">
                        <label class="input-label">Security</label>
                        <select class="input-field" id="wifi-security">
                            <option value="WPA">WPA/WPA2</option>
                            <option value="WEP">WEP</option>
                            <option value="nopass">None</option>
                        </select>
                    </div>
                </div>
            </div>

            <!-- vCard Form -->
            <div id="vcard-form" class="form-section hidden">
                <div class="input-row">
                    <div class="input-group">
                        <label class="input-label">First Name</label>
                        <input type="text" class="input-field" id="vcard-firstname" placeholder="John">
                    </div>
                    <div class="input-group">
                        <label class="input-label">Last Name</label>
                        <input type="text" class="input-field" id="vcard-lastname" placeholder="Doe">
                    </div>
                </div>
                <div class="input-group">
                    <label class="input-label">Organization</label>
                    <input type="text" class="input-field" id="vcard-org" placeholder="Company Name">
                </div>
                <div class="input-row">
                    <div class="input-group">
                        <label class="input-label">Phone</label>
                        <input type="tel" class="input-field" id="vcard-phone" placeholder="+1234567890">
                    </div>
                    <div class="input-group">
                        <label class="input-label">Email</label>
                        <input type="email" class="input-field" id="vcard-email" placeholder="john@example.com">
                    </div>
                </div>
            </div>

            <!-- Location Form -->
            <div id="location-form" class="form-section hidden">
                <div class="input-row">
                    <div class="input-group">
                        <label class="input-label">Latitude</label>
                        <input type="number" class="input-field" id="location-lat" placeholder="40.7128" step="any">
                    </div>
                    <div class="input-group">
                        <label class="input-label">Longitude</label>
                        <input type="number" class="input-field" id="location-lng" placeholder="-74.0060" step="any">
                    </div>
                </div>
            </div>

            <!-- Event Form -->
            <div id="event-form" class="form-section hidden">
                <div class="input-group">
                    <label class="input-label">Event Title</label>
                    <input type="text" class="input-field" id="event-title" placeholder="Meeting with Team">
                </div>
                <div class="input-row">
                    <div class="input-group">
                        <label class="input-label">Start Date</label>
                        <input type="datetime-local" class="input-field" id="event-start">
                    </div>
                    <div class="input-group">
                        <label class="input-label">End Date</label>
                        <input type="datetime-local" class="input-field" id="event-end">
                    </div>
                </div>
                <div class="input-group">
                    <label class="input-label">Location (Optional)</label>
                    <input type="text" class="input-field" id="event-location" placeholder="Conference Room A">
                </div>
            </div>
        </div>

        <div class="customization">
            <div class="custom-title">🎨 Customization</div>
            <div class="color-controls">
                <div class="color-group">
                    <input type="color" class="color-input" id="fg-color" value="#000000">
                    <span>Foreground</span>
                </div>
                <div class="color-group">
                    <input type="color" class="color-input" id="bg-color" value="#ffffff">
                    <span>Background</span>
                </div>
            </div>
            <div class="size-control">
                <span>Size:</span>
                <input type="range" class="size-slider" id="size-slider" min="128" max="400" value="256">
                <span id="size-display">256px</span>
            </div>
        </div>

        <button class="generate-btn" onclick="generateQR()">
            Generate QR Code
        </button>

        <div id="qr-output" class="qr-output hidden">
            <canvas id="qr-canvas" class="qr-canvas"></canvas>
            <div class="download-controls">
                <button class="download-btn" onclick="downloadQR('png')">PNG</button>
                <button class="download-btn" onclick="downloadQR('jpg')">JPG</button>
                <button class="download-btn" onclick="downloadQR('svg')">SVG</button>
            </div>
        </div>
    </div>

    <script>
        let currentType = 'text';
        let currentQRData = '';

        // Category switching
        document.querySelectorAll('.category-btn').forEach(btn => {
            btn.addEventListener('click', () => {
                document.querySelectorAll('.category-btn').forEach(b => b.classList.remove('active'));
                btn.classList.add('active');
                
                const type = btn.dataset.type;
                currentType = type;
                
                document.querySelectorAll('.form-section').forEach(form => form.classList.add('hidden'));
                document.getElementById(`${type}-form`).classList.remove('hidden');
            });
        });

        // Size slider
        document.getElementById('size-slider').addEventListener('input', (e) => {
            document.getElementById('size-display').textContent = e.target.value + 'px';
        });

        function generateQRData() {
            switch (currentType) {
                case 'text':
                    return document.getElementById('text-input').value;
                
                case 'url':
                    const url = document.getElementById('url-input').value;
                    return url.startsWith('http') ? url : `https://${url}`;
                
                case 'email':
                    const email = document.getElementById('email-input').value;
                    const subject = document.getElementById('email-subject').value;
                    const body = document.getElementById('email-body').value;
                    let mailto = `mailto:${email}`;
                    const params = [];
                    if (subject) params.push(`subject=${encodeURIComponent(subject)}`);
                    if (body) params.push(`body=${encodeURIComponent(body)}`);
                    if (params.length) mailto += '?' + params.join('&');
                    return mailto;
                
                case 'phone':
                    return `tel:${document.getElementById('phone-input').value}`;
                
                case 'sms':
                    const smsPhone = document.getElementById('sms-phone').value;
                    const smsMessage = document.getElementById('sms-message').value;
                    return `sms:${smsPhone}${smsMessage ? `?body=${encodeURIComponent(smsMessage)}` : ''}`;
                
                case 'wifi':
                    const ssid = document.getElementById('wifi-ssid').value;
                    const password = document.getElementById('wifi-password').value;
                    const security = document.getElementById('wifi-security').value;
                    return `WIFI:T:${security};S:${ssid};P:${password};;`;
                
                case 'vcard':
                    const firstName = document.getElementById('vcard-firstname').value;
                    const lastName = document.getElementById('vcard-lastname').value;
                    const org = document.getElementById('vcard-org').value;
                    const phone = document.getElementById('vcard-phone').value;
                    const vcardEmail = document.getElementById('vcard-email').value;
                    
                    return `BEGIN:VCARD
VERSION:3.0
FN:${firstName} ${lastName}
N:${lastName};${firstName};;;
ORG:${org}
TEL:${phone}
EMAIL:${vcardEmail}
END:VCARD`;
                
                case 'location':
                    const lat = document.getElementById('location-lat').value;
                    const lng = document.getElementById('location-lng').value;
                    return `geo:${lat},${lng}`;
                
                case 'event':
                    const title = document.getElementById('event-title').value;
                    const start = document.getElementById('event-start').value;
                    const end = document.getElementById('event-end').value;
                    const location = document.getElementById('event-location').value;
                    
                    const formatDate = (dateStr) => {
                        return new Date(dateStr).toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z';
                    };
                    
                    return `BEGIN:VEVENT
SUMMARY:${title}
DTSTART:${formatDate(start)}
DTEND:${formatDate(end)}
LOCATION:${location}
END:VEVENT`;
                
                default:
                    return '';
            }
        }

        function generateQR() {
            const data = generateQRData();
            
            if (!data.trim()) {
                alert('Please enter some data to generate QR code');
                return;
            }

            currentQRData = data;
            const canvas = document.getElementById('qr-canvas');
            const fgColor = document.getElementById('fg-color').value;
            const bgColor = document.getElementById('bg-color').value;
            const size = parseInt(document.getElementById('size-slider').value);

            QRCode.toCanvas(canvas, data, {
                width: size,
                height: size,
                color: {
                    dark: fgColor,
                    light: bgColor
                },
                errorCorrectionLevel: 'M',
                margin: 2
            }, (error) => {
                if (error) {
                    console.error(error);
                    alert('Error generating QR code');
                } else {
                    document.getElementById('qr-output').classList.remove('hidden');
                    canvas.scrollIntoView({ behavior: 'smooth', block: 'center' });
                }
            });
        }

        function downloadQR(format) {
            const canvas = document.getElementById('qr-canvas');
            
            if (format === 'svg') {
                // Generate SVG version
                QRCode.toString(currentQRData, {
                    type: 'svg',
                    width: parseInt(document.getElementById('size-slider').value),
                    color: {
                        dark: document.getElementById('fg-color').value,
                        light: document.getElementById('bg-color').value
                    }
                }, (err, string) => {
                    if (!err) {
                        const blob = new Blob([string], { type: 'image/svg+xml' });
                        const url = URL.createObjectURL(blob);
                        const a = document.createElement('a');
                        a.href = url;
                        a.download = `qrcode.svg`;
                        a.click();
                        URL.revokeObjectURL(url);
                    }
                });
            } else {
                // PNG or JPG
                const mimeType = format === 'png' ? 'image/png' : 'image/jpeg';
                const url = canvas.toDataURL(mimeType, 0.9);
                const a = document.createElement('a');
                a.href = url;
                a.download = `qrcode.${format}`;
                a.click();
            }
        }

        // Auto-generate on input for better UX
        document.addEventListener('input', (e) => {
            if (e.target.classList.contains('input-field') || e.target.id === 'size-slider') {
                // Debounce auto-generation
                clearTimeout(window.autoGenTimeout);
                window.autoGenTimeout = setTimeout(() => {
                    const data = generateQRData();
                    if (data.trim()) {
                        generateQR();
                    }
                }, 500);
            }
        });

        // Initialize with sample data
        document.getElementById('text-input').value = 'Hello, World! 👋';
        generateQR();
    </script>
</body>
</html>