martiantrader commited on
Commit
5883f8a
·
verified ·
1 Parent(s): 3579b06

add more features for generating qr codes

Browse files
Files changed (1) hide show
  1. index.html +188 -14
index.html CHANGED
@@ -4,8 +4,25 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>QRGenX - Free QR Code Generator</title>
7
- <script src="https://cdn.tailwindcss.com"></script>
8
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  <style>
10
  .qr-placeholder {
11
  background-image:
@@ -106,10 +123,25 @@
106
  <i class="fas fa-user"></i>
107
  Contact
108
  </button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  </div>
110
  </div>
111
-
112
- <!-- URL Input (Default) -->
113
  <div id="urlInput" class="content-input">
114
  <label for="qrContent" class="block text-sm font-medium text-gray-700 mb-2">Website URL</label>
115
  <div class="flex">
@@ -147,7 +179,6 @@
147
  </div>
148
  </div>
149
  </div>
150
-
151
  <!-- Contact Input -->
152
  <div id="contactInput" class="content-input hidden">
153
  <div class="space-y-4">
@@ -165,8 +196,68 @@
165
  </div>
166
  </div>
167
  </div>
168
-
169
- <!-- Design Options -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  <div class="pt-4 border-t border-gray-200">
171
  <h3 class="text-lg font-medium text-gray-800 mb-4">Design Options</h3>
172
 
@@ -430,7 +521,6 @@
430
  generateQRCode();
431
  }
432
  }
433
-
434
  // Generate QR code
435
  function generateQRCode() {
436
  let content = '';
@@ -485,9 +575,61 @@
485
  if (email) content += `EMAIL:${email}\n`;
486
  content += 'END:VCARD';
487
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488
  }
489
-
490
- // Get design options
491
  const qrColor = document.getElementById('qrColor').value;
492
  const bgColor = document.getElementById('bgColor').value;
493
  const errorCorrection = document.getElementById('errorCorrection').value;
@@ -637,9 +779,20 @@
637
  if (email) content += `EMAIL:${email}\n`;
638
  content += 'END:VCARD';
639
  break;
 
 
 
 
 
 
 
 
 
 
 
 
640
  }
641
-
642
- QRCode.toString(content, {
643
  type: 'svg',
644
  color: {
645
  dark: document.getElementById('qrColor').value,
@@ -698,9 +851,30 @@
698
  pdfContent += `Email: ${document.getElementById('contactEmail').value}\n`;
699
  }
700
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
701
  }
702
-
703
- if (pdfContent) {
704
  pdf.setFontSize(10);
705
  pdf.setTextColor(100);
706
  pdf.text(pdfContent,
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>QRGenX - Free QR Code Generator</title>
7
+ <script src="https://cdn.tailwindcss.com">
8
+ // Get current location
9
+ function getCurrentLocation() {
10
+ if (navigator.geolocation) {
11
+ navigator.geolocation.getCurrentPosition(
12
+ function(position) {
13
+ document.getElementById('locationLatitude').value = position.coords.latitude.toFixed(6);
14
+ document.getElementById('locationLongitude').value = position.coords.longitude.toFixed(6);
15
+ },
16
+ function(error) {
17
+ showError("Unable to get current location: " + error.message);
18
+ }
19
+ );
20
+ } else {
21
+ showError("Geolocation is not supported by this browser");
22
+ }
23
+ }
24
+ </script>
25
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
26
  <style>
27
  .qr-placeholder {
28
  background-image:
 
123
  <i class="fas fa-user"></i>
124
  Contact
125
  </button>
126
+ <button type="button" data-type="email" class="qr-type-btn py-2 px-4 border rounded-lg font-medium flex items-center justify-center gap-2" onclick="setActiveType(this)">
127
+ <i class="fas fa-envelope"></i>
128
+ Email
129
+ </button>
130
+ <button type="button" data-type="sms" class="qr-type-btn py-2 px-4 border rounded-lg font-medium flex items-center justify-center gap-2" onclick="setActiveType(this)">
131
+ <i class="fas fa-comment"></i>
132
+ SMS
133
+ </button>
134
+ <button type="button" data-type="phone" class="qr-type-btn py-2 px-4 border rounded-lg font-medium flex items-center justify-center gap-2" onclick="setActiveType(this)">
135
+ <i class="fas fa-phone"></i>
136
+ Phone
137
+ </button>
138
+ <button type="button" data-type="location" class="qr-type-btn py-2 px-4 border rounded-lg font-medium flex items-center justify-center gap-2" onclick="setActiveType(this)">
139
+ <i class="fas fa-map-marker-alt"></i>
140
+ Location
141
+ </button>
142
  </div>
143
  </div>
144
+ <!-- URL Input (Default) -->
 
145
  <div id="urlInput" class="content-input">
146
  <label for="qrContent" class="block text-sm font-medium text-gray-700 mb-2">Website URL</label>
147
  <div class="flex">
 
179
  </div>
180
  </div>
181
  </div>
 
182
  <!-- Contact Input -->
183
  <div id="contactInput" class="content-input hidden">
184
  <div class="space-y-4">
 
196
  </div>
197
  </div>
198
  </div>
199
+
200
+ <!-- Email Input -->
201
+ <div id="emailInput" class="content-input hidden">
202
+ <div class="space-y-4">
203
+ <div>
204
+ <label for="emailTo" class="block text-sm font-medium text-gray-700 mb-2">Recipient Email</label>
205
+ <input type="email" id="emailTo" name="emailTo" placeholder="recipient@example.com" class="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500">
206
+ </div>
207
+ <div>
208
+ <label for="emailSubject" class="block text-sm font-medium text-gray-700 mb-2">Subject</label>
209
+ <input type="text" id="emailSubject" name="emailSubject" placeholder="Email Subject" class="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500">
210
+ </div>
211
+ <div>
212
+ <label for="emailBody" class="block text-sm font-medium text-gray-700 mb-2">Message</label>
213
+ <textarea id="emailBody" name="emailBody" rows="3" placeholder="Your message here..." class="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500"></textarea>
214
+ </div>
215
+ </div>
216
+ </div>
217
+
218
+ <!-- SMS Input -->
219
+ <div id="smsInput" class="content-input hidden">
220
+ <div class="space-y-4">
221
+ <div>
222
+ <label for="smsNumber" class="block text-sm font-medium text-gray-700 mb-2">Phone Number</label>
223
+ <input type="tel" id="smsNumber" name="smsNumber" placeholder="+1234567890" class="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500">
224
+ </div>
225
+ <div>
226
+ <label for="smsMessage" class="block text-sm font-medium text-gray-700 mb-2">Message</label>
227
+ <textarea id="smsMessage" name="smsMessage" rows="3" placeholder="Your SMS message..." class="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500"></textarea>
228
+ </div>
229
+ </div>
230
+ </div>
231
+
232
+ <!-- Phone Input -->
233
+ <div id="phoneInput" class="content-input hidden">
234
+ <div>
235
+ <label for="phoneNumber" class="block text-sm font-medium text-gray-700 mb-2">Phone Number</label>
236
+ <input type="tel" id="phoneNumber" name="phoneNumber" placeholder="+1234567890" class="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500">
237
+ </div>
238
+ </div>
239
+
240
+ <!-- Location Input -->
241
+ <div id="locationInput" class="content-input hidden">
242
+ <div class="space-y-4">
243
+ <div class="grid grid-cols-2 gap-4">
244
+ <div>
245
+ <label for="locationLatitude" class="block text-sm font-medium text-gray-700 mb-2">Latitude</label>
246
+ <input type="number" id="locationLatitude" name="locationLatitude" step="0.000001" placeholder="40.7128" class="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500">
247
+ </div>
248
+ <div>
249
+ <label for="locationLongitude" class="block text-sm font-medium text-gray-700 mb-2">Longitude</label>
250
+ <input type="number" id="locationLongitude" name="locationLongitude" step="0.000001" placeholder="-74.0060" class="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500">
251
+ </div>
252
+ </div>
253
+ <div>
254
+ <button type="button" onclick="getCurrentLocation()" class="w-full py-2 px-4 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-gray-50 hover:bg-gray-100 flex items-center justify-center gap-2">
255
+ <i class="fas fa-location-arrow"></i> Use Current Location
256
+ </button>
257
+ </div>
258
+ </div>
259
+ </div>
260
+ <!-- Design Options -->
261
  <div class="pt-4 border-t border-gray-200">
262
  <h3 class="text-lg font-medium text-gray-800 mb-4">Design Options</h3>
263
 
 
521
  generateQRCode();
522
  }
523
  }
 
524
  // Generate QR code
525
  function generateQRCode() {
526
  let content = '';
 
575
  if (email) content += `EMAIL:${email}\n`;
576
  content += 'END:VCARD';
577
  break;
578
+ case 'email':
579
+ const emailTo = document.getElementById('emailTo').value;
580
+ const emailSubject = document.getElementById('emailSubject').value || '';
581
+ const emailBody = document.getElementById('emailBody').value || '';
582
+
583
+ if (!emailTo) {
584
+ showError("Please enter a recipient email address");
585
+ return;
586
+ }
587
+
588
+ content = `mailto:${emailTo}`;
589
+ if (emailSubject || emailBody) {
590
+ content += '?';
591
+ if (emailSubject) content += `subject=${encodeURIComponent(emailSubject)}`;
592
+ if (emailSubject && emailBody) content += '&';
593
+ if (emailBody) content += `body=${encodeURIComponent(emailBody)}`;
594
+ }
595
+ break;
596
+ case 'sms':
597
+ const smsNumber = document.getElementById('smsNumber').value;
598
+ const smsMessage = document.getElementById('smsMessage').value || '';
599
+
600
+ if (!smsNumber) {
601
+ showError("Please enter a phone number");
602
+ return;
603
+ }
604
+
605
+ content = `smsto:${smsNumber}`;
606
+ if (smsMessage) {
607
+ content += `:${encodeURIComponent(smsMessage)}`;
608
+ }
609
+ break;
610
+ case 'phone':
611
+ const phoneNumber = document.getElementById('phoneNumber').value;
612
+
613
+ if (!phoneNumber) {
614
+ showError("Please enter a phone number");
615
+ return;
616
+ }
617
+
618
+ content = `tel:${phoneNumber}`;
619
+ break;
620
+ case 'location':
621
+ const latitude = document.getElementById('locationLatitude').value;
622
+ const longitude = document.getElementById('locationLongitude').value;
623
+
624
+ if (!latitude || !longitude) {
625
+ showError("Please enter both latitude and longitude coordinates");
626
+ return;
627
+ }
628
+
629
+ content = `geo:${latitude},${longitude}`;
630
+ break;
631
  }
632
+ // Get design options
 
633
  const qrColor = document.getElementById('qrColor').value;
634
  const bgColor = document.getElementById('bgColor').value;
635
  const errorCorrection = document.getElementById('errorCorrection').value;
 
779
  if (email) content += `EMAIL:${email}\n`;
780
  content += 'END:VCARD';
781
  break;
782
+ case 'email':
783
+ content = document.getElementById('emailTo').value;
784
+ break;
785
+ case 'sms':
786
+ content = document.getElementById('smsNumber').value;
787
+ break;
788
+ case 'phone':
789
+ content = document.getElementById('phoneNumber').value;
790
+ break;
791
+ case 'location':
792
+ content = `${document.getElementById('locationLatitude').value},${document.getElementById('locationLongitude').value}`;
793
+ break;
794
  }
795
+ QRCode.toString(content, {
 
796
  type: 'svg',
797
  color: {
798
  dark: document.getElementById('qrColor').value,
 
851
  pdfContent += `Email: ${document.getElementById('contactEmail').value}\n`;
852
  }
853
  break;
854
+ case 'email':
855
+ pdfContent += `To: ${document.getElementById('emailTo').value}\n`;
856
+ if (document.getElementById('emailSubject').value) {
857
+ pdfContent += `Subject: ${document.getElementById('emailSubject').value}\n`;
858
+ }
859
+ if (document.getElementById('emailBody').value) {
860
+ pdfContent += `Message: ${document.getElementById('emailBody').value}\n`;
861
+ }
862
+ break;
863
+ case 'sms':
864
+ pdfContent += `To: ${document.getElementById('smsNumber').value}\n`;
865
+ if (document.getElementById('smsMessage').value) {
866
+ pdfContent += `Message: ${document.getElementById('smsMessage').value}\n`;
867
+ }
868
+ break;
869
+ case 'phone':
870
+ pdfContent += `Phone: ${document.getElementById('phoneNumber').value}\n`;
871
+ break;
872
+ case 'location':
873
+ pdfContent += `Latitude: ${document.getElementById('locationLatitude').value}\n`;
874
+ pdfContent += `Longitude: ${document.getElementById('locationLongitude').value}\n`;
875
+ break;
876
  }
877
+ if (pdfContent) {
 
878
  pdf.setFontSize(10);
879
  pdf.setTextColor(100);
880
  pdf.text(pdfContent,