QR Code Generator Pro

Professional file sharing with custom QR codes

Mobile Ready Customizable Secure Analytics

Choose QR Code Type

File Upload

URL / Website

Wi-Fi Access

Contact (vCard)

Email

Location

Calendar Event

SMS Message

Upload Your File

Upload files and generate QR codes for easy sharing

Drop files here or choose upload method

Support for PDF, Word, Excel, Images and more (Max: 100 MB)

PDF DOCX XLSX JPG PNG +More

Quick Settings

Password Protection
Auto-expire in 7 days

Powered by

🚀 Creative Aspirant – Unlock Creativity & Productivity

Professional QR Code Generator with advanced features

QR Code

QR Code

Generated by Creative Aspirant QR Generator

Right-click and "Save as PDF" or use Ctrl+P to save as PDF

`); // Focus the new window and trigger print dialog pdfWindow.focus(); setTimeout(() => { pdfWindow.print(); }, 500); showToast('QR code PDF opened! Use Ctrl+P to save 📄', 'success'); } catch (error) { console.error('PDF download error:', error); showToast('Failed to download PDF', 'error'); } } // Initialize when DOM is ready document.addEventListener('DOMContentLoaded', function() { initializeApp(); setupScrollAds(); // Setup QR data button listeners document.getElementById('qr-copy-data-btn').addEventListener('click', copyQRData); document.getElementById('qr-test-data-btn').addEventListener('click', testQRData); // Setup download button listeners setupDownloadButtons(); }); // Also initialize when all scripts are loaded window.addEventListener('load', function() { console.log('Window loaded, checking QR libraries...'); checkQRLibraries(); }); function checkQRLibraries() { console.log('QR Library Check:', { QRCode: typeof QRCode !== 'undefined', QRCode_toCanvas: typeof QRCode !== 'undefined' && typeof QRCode.toCanvas === 'function', QRCode_toDataURL: typeof QRCode !== 'undefined' && typeof QRCode.toDataURL === 'function' }); // Test QR generation with a simple example if (typeof QRCode !== 'undefined') { console.log('QR Code library loaded successfully'); } else { console.warn('QR Code library not loaded, will use fallback methods'); } } function initializeApp() { populateElements(); setupEventListeners(); updateUploadButton(); initializeTabs(); initializeToggles(); initializeColorPresets(); initializeQRTypeSelector(); } function populateElements() { // AdSense Protection: Ensure we're only selecting elements within our isolated container const qrRoot = document.querySelector('.qr-app-isolation-layer'); if (!qrRoot) { console.error('QR Tool isolation container missing! AdSense may have interfered.'); return; } function safeGetElement(id) { const element = qrRoot.querySelector('#' + id); if (element) { element.setAttribute('data-qr-protected', 'true'); element.setAttribute('data-adsense-ignore', 'true'); } return element; } elements = { // Upload elements uploadSection: safeGetElement('content-upload'), resultsSection: safeGetElement('qr-results-section'), dropZone: safeGetElement('qr-drop-zone'), fileInput: safeGetElement('qr-file-input'), uploadBtn: safeGetElement('qr-upload-btn'), uploadBtnText: safeGetElement('qr-upload-btn-text'), uploadProgress: safeGetElement('qr-upload-progress'), progressBar: safeGetElement('qr-progress-bar'), progressText: safeGetElement('qr-progress-text'), // QR Code elements qrCodeContainer: safeGetElement('qr-code-container'), shareLink: safeGetElement('qr-share-link'), downloadShareLink: safeGetElement('qr-download-share-link'), copyBtn: safeGetElement('qr-copy-btn'), copyDownloadBtn: safeGetElement('qr-copy-download-btn'), fileDetails: safeGetElement('qr-file-details'), uploadAnotherBtn: safeGetElement('qr-upload-another-btn'), shareSocialBtn: safeGetElement('qr-share-social-btn'), toastContainer: document.getElementById('qr-toast-container'), // Settings elements qrSize: document.getElementById('qr-size'), qrColor: document.getElementById('qr-color'), qrBgColor: document.getElementById('qr-bg-color'), // Tab elements tabs: { upload: document.getElementById('tab-upload'), customize: document.getElementById('tab-customize'), privacy: document.getElementById('tab-privacy'), share: document.getElementById('tab-share'), analytics: document.getElementById('tab-analytics') }, tabContents: { upload: document.getElementById('content-upload'), customize: document.getElementById('content-customize'), privacy: document.getElementById('content-privacy'), share: document.getElementById('content-share'), analytics: document.getElementById('content-analytics') } }; } // Utility Functions function formatFileSize(bytes) { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; } function getSimpleFileType(contentType, filename) { const ext = filename.toLowerCase().split('.').pop(); // Map complex MIME types to simple names const typeMap = { 'application/pdf': 'PDF Document', 'application/msword': 'Word Document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'Word Document', 'application/vnd.ms-excel': 'Excel Spreadsheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'Excel Spreadsheet', 'application/vnd.ms-powerpoint': 'PowerPoint Presentation', 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'PowerPoint Presentation', 'text/plain': 'Text File', 'image/jpeg': 'JPEG Image', 'image/png': 'PNG Image', 'image/gif': 'GIF Image', 'application/zip': 'ZIP Archive' }; // First try exact MIME type match if (typeMap[contentType]) { return typeMap[contentType]; } // Then try by extension const extMap = { 'pdf': 'PDF Document', 'doc': 'Word Document', 'docx': 'Word Document', 'xls': 'Excel Spreadsheet', 'xlsx': 'Excel Spreadsheet', 'ppt': 'PowerPoint Presentation', 'pptx': 'PowerPoint Presentation', 'txt': 'Text File', 'jpg': 'JPEG Image', 'jpeg': 'JPEG Image', 'png': 'PNG Image', 'gif': 'GIF Image', 'zip': 'ZIP Archive' }; return extMap[ext] || (ext ? `${ext.toUpperCase()} File` : 'Unknown File'); } function getFileIcon(fileName) { const ext = fileName.toLowerCase().split('.').pop(); const icons = { pdf: '📄', doc: '📝', docx: '📝', xls: '📊', xlsx: '📊', ppt: '📈', pptx: '📈', jpg: '🖼️', jpeg: '🖼️', png: '🖼️', gif: '🖼️', svg: '🖼️', txt: '📋', zip: '🗜️', rar: '🗜️' }; return icons[ext] || '📁'; } function showToast(message, type = 'success') { // AdSense Protection: Check if container exists and is ours if (!elements.toastContainer || !document.querySelector('.qr-app-isolation-layer').contains(elements.toastContainer)) { console.warn('Toast container missing or compromised by external scripts'); return; } const toast = document.createElement('div'); toast.className = `qr-${type}-toast text-white px-6 py-4 rounded-xl shadow-2xl qr-fade-in flex items-center`; toast.setAttribute('data-qr-element', 'toast'); toast.setAttribute('data-adsense-ignore', 'true'); toast.innerHTML = ` ${message} `; elements.toastContainer.appendChild(toast); setTimeout(() => { toast.style.opacity = '0'; setTimeout(() => toast.remove(), 300); }, 4000); } // Tab Management function initializeTabs() { Object.entries(elements.tabs).forEach(([key, tab]) => { tab.addEventListener('click', () => switchTab(key)); }); } function switchTab(activeTab) { // Update tab buttons Object.entries(elements.tabs).forEach(([key, tab]) => { if (key === activeTab) { tab.className = tab.className.replace('qr-tab-inactive', 'qr-tab-active'); } else { tab.className = tab.className.replace('qr-tab-active', 'qr-tab-inactive'); } }); // Update tab contents Object.entries(elements.tabContents).forEach(([key, content]) => { if (key === activeTab) { content.classList.remove('hidden'); content.classList.add('qr-slide-up'); } else { content.classList.add('hidden'); content.classList.remove('qr-slide-up'); } }); } // Toggle switches function initializeToggles() { const toggles = document.querySelectorAll('.qr-toggle-switch'); toggles.forEach(toggle => { toggle.addEventListener('click', () => { toggle.classList.toggle('active'); handleToggleChange(toggle); }); }); } function handleToggleChange(toggle) { const toggleId = toggle.id; const isActive = toggle.classList.contains('active'); // Handle specific toggle behaviors if (toggleId === 'password-toggle' || toggleId === 'privacy-password-toggle') { const passwordInput = document.getElementById(toggleId.replace('toggle', 'input')); if (passwordInput) { passwordInput.style.display = isActive ? 'block' : 'none'; } } if (toggleId === 'download-limit-toggle') { const limitInput = document.getElementById('download-limit-input'); if (limitInput) { limitInput.style.display = isActive ? 'block' : 'none'; } } if (toggleId === 'email-notify-toggle') { const emailInput = document.getElementById('email-notify-input'); if (emailInput) { emailInput.style.display = isActive ? 'block' : 'none'; } } } // Color presets function initializeColorPresets() { const presets = document.querySelectorAll('.color-preset'); presets.forEach(preset => { preset.addEventListener('click', () => { const fgColor = preset.dataset.fg; const bgColor = preset.dataset.bg; document.getElementById('advanced-fg-color').value = fgColor; document.getElementById('advanced-bg-color').value = bgColor; qrSettings.fgColor = fgColor; qrSettings.bgColor = bgColor; if (currentUploadResult) { updateQRPreview(); } }); }); } // File validation function validateFile(file) { if (file.size > MAX_FILE_SIZE) { showToast(`File size must be less than ${formatFileSize(MAX_FILE_SIZE)}`, 'error'); return false; } const dangerousExts = ['exe', 'bat', 'cmd', 'scr', 'js', 'vbs', 'ps1']; const ext = file.name.toLowerCase().split('.').pop(); if (dangerousExts.includes(ext)) { showToast('This file type is not allowed for security reasons', 'error'); return false; } return true; } function updateUploadButton() { if (selectedFile) { elements.uploadBtn.disabled = false; elements.uploadBtnText.innerHTML = `Upload ${selectedFile.name}`; } else { elements.uploadBtn.disabled = true; elements.uploadBtnText.innerHTML = 'Select a file to upload'; } } // Enhanced QR Code generation with multiple fallbacks function generateQRCode(text, container = elements.qrCodeContainer) { console.log('Generating QR code for:', text); console.log('QR Settings:', qrSettings); console.log('Available QR libraries:', { QRCode: typeof QRCode !== 'undefined', window_QRCode: typeof window.QRCode !== 'undefined', qrcode: typeof qrcode !== 'undefined' }); container.innerHTML = ''; // Method 1: Try the main QRCode library if (typeof QRCode !== 'undefined' && QRCode.toCanvas) { try { const options = { width: qrSettings.size, height: qrSettings.size, margin: qrSettings.margin, color: { dark: qrSettings.fgColor, light: qrSettings.bgColor }, errorCorrectionLevel: qrSettings.errorCorrectionLevel }; QRCode.toCanvas(text, options, (error, canvas) => { if (error) { console.error('QRCode.toCanvas error:', error); tryFallbackQRGeneration(text, container); } else { canvas.className = 'rounded-lg shadow-lg'; container.appendChild(canvas); currentQrCode = canvas; // Store QR data for downloads window.currentQRData = text; window.lastGeneratedQR = text; console.log('QR Code generated successfully with QRCode.toCanvas'); } }); return; } catch (error) { console.error('QRCode.toCanvas exception:', error); } } // Method 2: Try alternative QR generation tryFallbackQRGeneration(text, container); } function tryFallbackQRGeneration(text, container) { console.log('Trying fallback QR generation methods...'); // Method 2A: Try QRCode.toDataURL if (typeof QRCode !== 'undefined' && QRCode.toDataURL) { try { const options = { width: qrSettings.size, height: qrSettings.size, margin: qrSettings.margin, color: { dark: qrSettings.fgColor, light: qrSettings.bgColor }, errorCorrectionLevel: qrSettings.errorCorrectionLevel }; QRCode.toDataURL(text, options, (error, url) => { if (error) { console.error('QRCode.toDataURL error:', error); tryManualQRGeneration(text, container); } else { const img = document.createElement('img'); img.src = url; img.className = 'rounded-lg shadow-lg'; img.style.maxWidth = qrSettings.size + 'px'; img.style.maxHeight = qrSettings.size + 'px'; container.appendChild(img); currentQrCode = img; // Store QR data for downloads window.currentQRData = text; window.lastGeneratedQR = text; console.log('QR Code generated successfully with QRCode.toDataURL'); } }); return; } catch (error) { console.error('QRCode.toDataURL exception:', error); } } // Method 2B: Try manual QR generation tryManualQRGeneration(text, container); } function tryManualQRGeneration(text, container) { console.log('Trying manual QR generation...'); // Method 3: Create canvas manually and use API service as fallback try { const canvas = document.createElement('canvas'); const size = qrSettings.size; canvas.width = size; canvas.height = size; canvas.className = 'rounded-lg shadow-lg'; const ctx = canvas.getContext('2d'); // Use QR Server API as fallback const qrApiUrl = `https://api.qrserver.com/v1/create-qr-code/?size=${size}x${size}&data=${encodeURIComponent(text)}&color=${qrSettings.fgColor.replace('#', '')}&bgcolor=${qrSettings.bgColor.replace('#', '')}&margin=10&ecc=${qrSettings.errorCorrectionLevel}`; const img = new Image(); img.crossOrigin = 'anonymous'; img.onload = function() { ctx.drawImage(img, 0, 0, size, size); container.appendChild(canvas); currentQrCode = canvas; // Store QR data for downloads window.currentQRData = text; window.lastGeneratedQR = text; console.log('QR Code generated successfully with API fallback'); }; img.onerror = function() { console.error('QR API fallback failed'); showQRError(container); }; img.src = qrApiUrl; } catch (error) { console.error('Manual QR generation failed:', error); showQRError(container); } } function showQRError(container) { container.innerHTML = `

QR Generation Failed

Libraries failed to load

`; } // Global retry function window.retryQRGeneration = function() { if (currentUploadResult) { const shareUrl = `${WORKER_URL}/view/${currentUploadResult.id}`; generateQRCode(shareUrl); } }; function updateQRPreview() { if (currentUploadResult) { const shareUrl = `${WORKER_URL}/view/${currentUploadResult.id}`; const previewContainer = document.getElementById('qr-preview-container').querySelector('div'); generateQRCode(shareUrl, previewContainer); } } // File upload async function uploadFile() { if (!selectedFile) return; elements.uploadBtn.disabled = true; elements.uploadProgress.classList.remove('hidden'); elements.progressBar.style.width = '0%'; elements.progressText.textContent = 'Preparing upload...'; try { const formData = new FormData(); formData.append('file', selectedFile); // Add privacy settings to upload formData.append('privacySettings', JSON.stringify(privacySettings)); const xhr = new XMLHttpRequest(); xhr.upload.addEventListener('progress', (e) => { if (e.lengthComputable) { const percentComplete = (e.loaded / e.total) * 100; elements.progressBar.style.width = percentComplete + '%'; elements.progressText.textContent = `Uploading... ${Math.round(percentComplete)}%`; } }); xhr.addEventListener('load', () => { if (xhr.status === 200) { try { const result = JSON.parse(xhr.responseText); console.log('Upload result:', result); elements.progressText.textContent = 'Upload complete!'; showToast('File uploaded successfully! 🎉'); showResults(result); } catch (parseError) { console.error('Failed to parse response:', xhr.responseText); showToast('Upload completed but response format error', 'error'); } } else { throw new Error(`Upload failed: ${xhr.statusText} - ${xhr.responseText}`); } }); xhr.addEventListener('error', () => { throw new Error('Upload failed: Network error'); }); xhr.open('POST', `${WORKER_URL}/upload`); xhr.send(formData); } catch (error) { console.error('Upload error:', error); showToast('Upload failed. Please try again.', 'error'); elements.uploadBtn.disabled = false; elements.uploadProgress.classList.add('hidden'); } } function showResults(uploadResult) { currentUploadResult = uploadResult; const shareUrl = `${WORKER_URL}/view/${uploadResult.id}`; const downloadUrl = `${WORKER_URL}/download/${uploadResult.id}`; elements.shareLink.value = shareUrl; elements.downloadShareLink.value = downloadUrl; generateQRCode(shareUrl); // Show link section and hide data section for file uploads document.getElementById('qr-links-section').classList.remove('hidden'); document.getElementById('qr-data-section').classList.add('hidden'); // Update file details elements.fileDetails.innerHTML = `
Name: ${getFileIcon(uploadResult.filename)} ${uploadResult.filename}
Size: ${formatFileSize(uploadResult.size)}
Type: ${getSimpleFileType(uploadResult.contentType, uploadResult.filename)}
Uploaded: ${new Date().toLocaleDateString()}
Files are publicly accessible via the generated link
`; // Update share tab with links document.getElementById('view-link').value = shareUrl; document.getElementById('download-link').value = downloadUrl; // Update share QR code const shareQrContainer = document.getElementById('share-qr-container').querySelector('div'); generateQRCode(shareUrl, shareQrContainer); elements.resultsSection.classList.remove('hidden'); elements.resultsSection.scrollIntoView({ behavior: 'smooth' }); } function resetUploadForm() { selectedFile = null; currentUploadResult = null; elements.fileInput.value = ''; elements.uploadProgress.classList.add('hidden'); elements.resultsSection.classList.add('hidden'); updateUploadButton(); switchTab('upload'); } // QR Type Management Functions function initializeQRTypeSelector() { const typeCards = document.querySelectorAll('.qr-type-card'); const contentHeader = { icon: document.getElementById('qr-content-icon'), title: document.getElementById('qr-content-title'), subtitle: document.getElementById('qr-content-subtitle') }; const typeConfig = { file: { icon: 'fas fa-file-upload', color: 'text-blue-600', title: 'Upload Your File', subtitle: 'Upload files and generate QR codes for easy sharing' }, url: { icon: 'fas fa-link', color: 'text-green-600', title: 'URL / Website QR Code', subtitle: 'Generate QR codes for single or multiple website links' }, wifi: { icon: 'fas fa-wifi', color: 'text-purple-600', title: 'Wi-Fi QR Code', subtitle: 'Create auto-connect WiFi QR codes for easy sharing' }, contact: { icon: 'fas fa-address-card', color: 'text-orange-600', title: 'Contact vCard QR Code', subtitle: 'Share contact information that saves directly to phones' }, email: { icon: 'fas fa-envelope', color: 'text-red-600', title: 'Email QR Code', subtitle: 'Pre-fill email drafts with recipient, subject, and body' }, location: { icon: 'fas fa-map-marker-alt', color: 'text-teal-600', title: 'Location QR Code', subtitle: 'Share GPS coordinates that open in maps' }, calendar: { icon: 'fas fa-calendar-alt', color: 'text-indigo-600', title: 'Calendar Event QR Code', subtitle: 'Create events that add directly to calendars' }, sms: { icon: 'fas fa-sms', color: 'text-pink-600', title: 'SMS QR Code', subtitle: 'Pre-fill text messages with phone number and content' } }; typeCards.forEach(card => { card.addEventListener('click', () => { // Remove active class from all cards typeCards.forEach(c => c.classList.remove('active')); // Add active class to clicked card card.classList.add('active'); const type = card.dataset.type; const config = typeConfig[type]; // Update header contentHeader.icon.className = config.icon + ' text-4xl ' + config.color + ' mb-3'; contentHeader.title.textContent = config.title; contentHeader.subtitle.textContent = config.subtitle; // Show/hide content sections document.querySelectorAll('.qr-content-type').forEach(content => { content.classList.add('hidden'); }); document.getElementById('content-' + type).classList.remove('hidden'); // Auto-scroll to input section with smooth animation setTimeout(() => { const inputSection = document.getElementById('qr-content-header'); if (inputSection) { inputSection.scrollIntoView({ behavior: 'smooth', block: 'start', inline: 'nearest' }); } }, 100); }); }); // Initialize generate buttons document.getElementById('generate-url-qr').addEventListener('click', generateURLQR); document.getElementById('generate-wifi-qr').addEventListener('click', generateWiFiQR); document.getElementById('generate-contact-qr').addEventListener('click', generateContactQR); document.getElementById('generate-email-qr').addEventListener('click', generateEmailQR); document.getElementById('generate-location-qr').addEventListener('click', generateLocationQR); document.getElementById('generate-calendar-qr').addEventListener('click', generateCalendarQR); document.getElementById('generate-sms-qr').addEventListener('click', generateSMSQR); // Initialize location map buttons document.getElementById('use-my-location-btn').addEventListener('click', getCurrentLocation); document.getElementById('open-in-maps-btn').addEventListener('click', openInGoogleMaps); } // QR Results Display for Non-File QR Codes function showQRResults(qrData, qrType, details) { // Generate QR Code for main container generateQRCode(qrData); // Also generate QR Code for preview container (QR Code Download section) const previewContainer = document.getElementById('qr-preview-container'); if (previewContainer) { const previewDiv = previewContainer.querySelector('div') || previewContainer; generateQRCode(qrData, previewDiv); } // Update file details section with QR type info elements.fileDetails.innerHTML = `
QR Type: ${getQRTypeIcon(qrType)} ${qrType}
Data Length: ${qrData.length} characters
Generated: ${new Date().toLocaleDateString()}
${details ? `
${details}
` : ''}
`; // Hide link section and show data section for non-file QR codes document.getElementById('qr-links-section').classList.add('hidden'); document.getElementById('qr-data-section').classList.remove('hidden'); // Update QR data display document.getElementById('qr-data-display').value = qrData; // Clear file links elements.shareLink.value = ''; elements.downloadShareLink.value = ''; document.getElementById('view-link').value = ''; document.getElementById('download-link').value = ''; // Show results section elements.resultsSection.classList.remove('hidden'); elements.resultsSection.scrollIntoView({ behavior: 'smooth' }); currentUploadResult = null; // Clear file upload result // Store current QR data for copy/test functions window.currentQRData = qrData; window.currentQRType = qrType; } function getQRTypeIcon(qrType) { const icons = { 'URL': '🔗', 'Wi-Fi': '📶', 'Contact': '👤', 'Email': '📧', 'Location': '📍', 'Calendar': '📅', 'SMS': '📱' }; return icons[qrType] || '📋'; } // QR Generation Functions async function generateURLQR() { const urlInput = document.getElementById('url-input').value.trim(); const shortenUrls = document.getElementById('shorten-urls').checked; if (!urlInput) { showToast('Please enter at least one URL', 'error'); return; } const urls = urlInput.split('\n').filter(url => url.trim()); let qrData; if (urls.length === 1) { qrData = urls[0].trim(); } else { // For multiple URLs, create a simple list qrData = urls.join('\n'); } try { const details = urls.length > 1 ? `Contains ${urls.length} URLs` : 'Single URL QR code'; showQRResults(qrData, 'URL', details); showToast('URL QR Code generated successfully!', 'success'); } catch (error) { showToast('Failed to generate QR code', 'error'); } } async function generateWiFiQR() { const ssid = document.getElementById('wifi-ssid').value.trim(); const password = document.getElementById('wifi-password').value; const security = document.getElementById('wifi-security').value; const hidden = document.getElementById('wifi-hidden').checked; if (!ssid) { showToast('Please enter WiFi network name (SSID)', 'error'); return; } let wifiString = `WIFI:T:${security};S:${ssid};P:${password};H:${hidden ? 'true' : 'false'};;`; try { const details = `Network: ${ssid} | Security: ${security}${password ? ' (Password Protected)' : ''}`; showQRResults(wifiString, 'Wi-Fi', details); showToast('WiFi QR Code generated successfully!', 'success'); } catch (error) { showToast('Failed to generate QR code', 'error'); } } async function generateContactQR() { const firstName = document.getElementById('contact-firstname').value.trim(); const lastName = document.getElementById('contact-lastname').value.trim(); const phone = document.getElementById('contact-phone').value.trim(); const email = document.getElementById('contact-email').value.trim(); const organization = document.getElementById('contact-organization').value.trim(); const website = document.getElementById('contact-website').value.trim(); if (!firstName && !lastName && !phone && !email) { showToast('Please fill in at least name, phone, or email', 'error'); return; } const vCard = `BEGIN:VCARD VERSION:3.0 FN:${firstName} ${lastName} N:${lastName};${firstName};;; ${phone ? `TEL:${phone}` : ''} ${email ? `EMAIL:${email}` : ''} ${organization ? `ORG:${organization}` : ''} ${website ? `URL:${website}` : ''} END:VCARD`; try { const details = `Contact: ${firstName} ${lastName}${organization ? ` (${organization})` : ''}`; showQRResults(vCard, 'Contact', details); showToast('Contact QR Code generated successfully!', 'success'); } catch (error) { showToast('Failed to generate QR code', 'error'); } } async function generateEmailQR() { const to = document.getElementById('email-to').value.trim(); const subject = document.getElementById('email-subject').value.trim(); const body = document.getElementById('email-body').value.trim(); if (!to) { showToast('Please enter recipient email address', 'error'); return; } let mailtoString = `mailto:${to}`; const params = []; if (subject) params.push(`subject=${encodeURIComponent(subject)}`); if (body) params.push(`body=${encodeURIComponent(body)}`); if (params.length > 0) { mailtoString += '?' + params.join('&'); } try { const details = `To: ${to}${subject ? ` | Subject: ${subject}` : ''}`; showQRResults(mailtoString, 'Email', details); showToast('Email QR Code generated successfully!', 'success'); } catch (error) { showToast('Failed to generate QR code', 'error'); } } async function generateLocationQR() { const latitude = document.getElementById('location-latitude').value.trim(); const longitude = document.getElementById('location-longitude').value.trim(); const locationName = document.getElementById('location-name').value.trim(); if (!latitude || !longitude) { showToast('Please enter both latitude and longitude', 'error'); return; } let geoString = `geo:${latitude},${longitude}`; if (locationName) { geoString += `?q=${encodeURIComponent(locationName)}`; } try { const details = `Coordinates: ${latitude}, ${longitude}${locationName ? ` | Name: ${locationName}` : ''}`; showQRResults(geoString, 'Location', details); showToast('Location QR Code generated successfully!', 'success'); } catch (error) { showToast('Failed to generate QR code', 'error'); } } // Google Maps Integration for Location function getCurrentLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( (position) => { document.getElementById('location-latitude').value = position.coords.latitude.toFixed(6); document.getElementById('location-longitude').value = position.coords.longitude.toFixed(6); showToast('Location detected successfully!', 'success'); }, (error) => { showToast('Could not get your location. Please enter manually.', 'error'); } ); } else { showToast('Geolocation is not supported by this browser.', 'error'); } } function openInGoogleMaps() { const latitude = document.getElementById('location-latitude').value.trim(); const longitude = document.getElementById('location-longitude').value.trim(); if (!latitude || !longitude) { showToast('Please enter coordinates first', 'error'); return; } const mapsUrl = `https://www.google.com/maps?q=${latitude},${longitude}`; window.open(mapsUrl, '_blank'); } async function generateCalendarQR() { const title = document.getElementById('calendar-title').value.trim(); const startDate = document.getElementById('calendar-start').value; const endDate = document.getElementById('calendar-end').value; const location = document.getElementById('calendar-location').value.trim(); const description = document.getElementById('calendar-description').value.trim(); if (!title || !startDate) { showToast('Please enter event title and start date', 'error'); return; } const start = new Date(startDate).toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z'; const end = endDate ? new Date(endDate).toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z' : ''; const calendarString = `BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT SUMMARY:${title} DTSTART:${start} ${end ? `DTEND:${end}` : ''} ${location ? `LOCATION:${location}` : ''} ${description ? `DESCRIPTION:${description}` : ''} END:VEVENT END:VCALENDAR`; try { const eventDate = new Date(startDate).toLocaleDateString(); const details = `Event: ${title} | Date: ${eventDate}${location ? ` | Location: ${location}` : ''}`; showQRResults(calendarString, 'Calendar', details); showToast('Calendar QR Code generated successfully!', 'success'); } catch (error) { showToast('Failed to generate QR code', 'error'); } } async function generateSMSQR() { const phone = document.getElementById('sms-phone').value.trim(); const message = document.getElementById('sms-message').value.trim(); if (!phone) { showToast('Please enter phone number', 'error'); return; } let smsString = `sms:${phone}`; if (message) { smsString += `?body=${encodeURIComponent(message)}`; } try { const details = `To: ${phone}${message ? ` | Message: ${message.substring(0, 50)}${message.length > 50 ? '...' : ''}` : ''}`; showQRResults(smsString, 'SMS', details); showToast('SMS QR Code generated successfully!', 'success'); } catch (error) { showToast('Failed to generate QR code', 'error'); } } // Event Listeners function setupEventListeners() { // File input elements.dropZone.addEventListener('click', () => elements.fileInput.click()); elements.fileInput.addEventListener('change', handleFileSelect); // Drag and drop elements.dropZone.addEventListener('dragover', handleDragOver); elements.dropZone.addEventListener('dragleave', handleDragLeave); elements.dropZone.addEventListener('drop', handleFileDrop); // Upload elements.uploadBtn.addEventListener('click', uploadFile); // Copy buttons elements.copyBtn.addEventListener('click', () => copyToClipboard(elements.shareLink.value, 'View link copied!')); elements.copyDownloadBtn.addEventListener('click', () => copyToClipboard(elements.downloadShareLink.value, 'Download link copied!')); // Other buttons elements.uploadAnotherBtn.addEventListener('click', resetUploadForm); elements.shareSocialBtn.addEventListener('click', () => { switchTab('share'); // Scroll to Advanced Sharing Options setTimeout(() => { const shareSection = document.getElementById('content-share'); if (shareSection) { shareSection.scrollIntoView({ behavior: 'smooth', block: 'start', inline: 'nearest' }); } }, 100); }); // Settings elements.qrSize.addEventListener('change', updateQRSettings); elements.qrColor.addEventListener('change', updateQRSettings); elements.qrBgColor.addEventListener('change', updateQRSettings); // Share tab buttons setupShareButtons(); setupCustomizationControls(); setupBatchUpload(); setupCameraUpload(); setupPrivacyControls(); setupAnalytics(); } function handleFileSelect(e) { if (e.target.files.length > 0) { const file = e.target.files[0]; if (validateFile(file)) { selectedFile = file; updateUploadButton(); } } } function handleDragOver(e) { e.preventDefault(); elements.dropZone.classList.add('dragover'); } function handleDragLeave() { elements.dropZone.classList.remove('dragover'); } function handleFileDrop(e) { e.preventDefault(); elements.dropZone.classList.remove('dragover'); const files = e.dataTransfer.files; if (files.length > 0) { const file = files[0]; if (validateFile(file)) { selectedFile = file; updateUploadButton(); } } } function updateQRSettings() { qrSettings.size = parseInt(elements.qrSize.value); qrSettings.fgColor = elements.qrColor.value; qrSettings.bgColor = elements.qrBgColor.value; if (currentUploadResult) { const shareUrl = `${WORKER_URL}/view/${currentUploadResult.id}`; generateQRCode(shareUrl); } } async function copyToClipboard(text, message = 'Copied to clipboard!') { try { await navigator.clipboard.writeText(text); showToast(message); } catch (error) { // Fallback for older browsers const textArea = document.createElement('textarea'); textArea.value = text; document.body.appendChild(textArea); textArea.select(); document.execCommand('copy'); document.body.removeChild(textArea); showToast(message); } } // Share functionality function setupShareButtons() { const shareButtons = { 'copy-view-link': () => copyToClipboard(document.getElementById('view-link').value, 'View link copied!'), 'copy-download-link': () => copyToClipboard(document.getElementById('download-link').value, 'Download link copied!'), 'share-twitter': () => shareOnSocial('twitter'), 'share-facebook': () => shareOnSocial('facebook'), 'share-linkedin': () => shareOnSocial('linkedin'), 'share-whatsapp': () => shareOnSocial('whatsapp'), 'send-email': () => sendEmailShare() }; Object.entries(shareButtons).forEach(([id, handler]) => { const button = document.getElementById(id); if (button) { button.addEventListener('click', handler); } }); } async function sendEmailShare() { const recipientEmail = document.getElementById('recipient-email')?.value; const message = document.getElementById('email-message')?.value; const statusDiv = document.getElementById('email-status'); // Check if we have either file upload or QR code data if (!currentUploadResult && !window.currentQRData) { showToast('Please generate a QR code first', 'error'); return; } if (!recipientEmail) { showToast('Please enter recipient email', 'error'); return; } // Validate email format const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!emailRegex.test(recipientEmail)) { showToast('Please enter a valid email address', 'error'); return; } statusDiv.className = 'mt-2 text-sm text-blue-600'; statusDiv.textContent = 'Sending email...'; statusDiv.classList.remove('hidden'); try { let shareUrl, subject, defaultMessage; if (currentUploadResult) { // File upload sharing shareUrl = `${WORKER_URL}/view/${currentUploadResult.id}`; subject = `File shared: ${currentUploadResult.filename}`; defaultMessage = `I've shared a file with you using Creative Aspirant QR Code Generator. Click the link below to access it.`; } else if (window.currentQRData) { // QR Code sharing shareUrl = window.currentQRData; subject = `${window.currentQRType} QR Code shared`; defaultMessage = `I've created a ${window.currentQRType} QR Code for you using Creative Aspirant QR Code Generator. Details: ${window.currentQRData.substring(0, 100)}${window.currentQRData.length > 100 ? '...' : ''}`; } const emailData = { to: recipientEmail, subject: subject, message: message || defaultMessage, fileUrl: shareUrl, fileName: currentUploadResult?.filename || `${window.currentQRType} QR Code` }; const response = await fetch(`${WORKER_URL}/send-email`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(emailData) }); const result = await response.json(); if (response.ok && result.success) { statusDiv.className = 'mt-2 text-sm text-green-600'; statusDiv.textContent = '✅ Email sent successfully!'; showToast('Email sent successfully!'); // Clear form document.getElementById('recipient-email').value = ''; document.getElementById('email-message').value = ''; setTimeout(() => { statusDiv.classList.add('hidden'); }, 5000); } else { throw new Error(result.error || 'Email sending failed'); } } catch (error) { console.error('Email sending error:', error); statusDiv.className = 'mt-2 text-sm text-red-600'; statusDiv.textContent = '❌ Failed to send email'; showToast('Failed to send email: ' + error.message, 'error'); } } function shareOnSocial(platform) { // Check if we have either file upload or QR code data if (!currentUploadResult && !window.currentQRData) { showToast('Please generate a QR code first', 'error'); return; } let shareUrl, text; if (currentUploadResult) { // File upload sharing shareUrl = `${WORKER_URL}/view/${currentUploadResult.id}`; text = `Check out this file I shared: ${currentUploadResult.filename}`; } else if (window.currentQRData) { // QR Code sharing - share the QR data directly or create a shareable message if (window.currentQRType === 'URL') { shareUrl = window.currentQRData; text = `Check out this link I found!`; } else { shareUrl = window.currentQRData; text = `I created a ${window.currentQRType} QR Code using Creative Aspirant QR Generator!`; } } const urls = { twitter: `https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}&url=${encodeURIComponent(shareUrl)}`, facebook: `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`, linkedin: `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(shareUrl)}`, whatsapp: `https://wa.me/?text=${encodeURIComponent(text + ' ' + shareUrl)}` }; if (urls[platform]) { window.open(urls[platform], '_blank', 'width=600,height=400'); showToast(`Opening ${platform.charAt(0).toUpperCase() + platform.slice(1)}...`, 'success'); } } // Customization controls function setupCustomizationControls() { // Advanced color controls const advancedFg = document.getElementById('advanced-fg-color'); const advancedBg = document.getElementById('advanced-bg-color'); const customSize = document.getElementById('custom-qr-size'); const errorCorrection = document.getElementById('error-correction'); const borderSize = document.getElementById('border-size'); const borderValue = document.getElementById('border-value'); const applyBtn = document.getElementById('apply-customization'); if (advancedFg) advancedFg.addEventListener('change', updateAdvancedSettings); if (advancedBg) advancedBg.addEventListener('change', updateAdvancedSettings); if (customSize) customSize.addEventListener('change', updateAdvancedSettings); if (errorCorrection) errorCorrection.addEventListener('change', updateAdvancedSettings); if (borderSize) { borderSize.addEventListener('input', () => { borderValue.textContent = borderSize.value; updateAdvancedSettings(); }); } if (applyBtn) applyBtn.addEventListener('click', applyCustomization); } function updateAdvancedSettings() { const advancedFg = document.getElementById('advanced-fg-color'); const advancedBg = document.getElementById('advanced-bg-color'); const customSize = document.getElementById('custom-qr-size'); const errorCorrection = document.getElementById('error-correction'); const borderSize = document.getElementById('border-size'); if (advancedFg) qrSettings.fgColor = advancedFg.value; if (advancedBg) qrSettings.bgColor = advancedBg.value; if (customSize) qrSettings.size = parseInt(customSize.value); if (errorCorrection) qrSettings.errorCorrectionLevel = errorCorrection.value; if (borderSize) qrSettings.margin = parseInt(borderSize.value); updateQRPreview(); } function applyCustomization() { if (currentUploadResult) { const shareUrl = `${WORKER_URL}/view/${currentUploadResult.id}`; generateQRCode(shareUrl); showToast('QR code updated with new settings!'); } else { showToast('Please upload a file first', 'error'); } } // Batch Upload Functions function setupBatchUpload() { const batchBtn = document.getElementById('batch-upload-btn'); const batchInput = document.getElementById('qr-batch-input'); if (batchBtn) { batchBtn.addEventListener('click', () => batchInput.click()); } if (batchInput) { batchInput.addEventListener('change', handleBatchFileSelect); } } function handleBatchFileSelect(e) { selectedFiles = Array.from(e.target.files).filter(validateFile); if (selectedFiles.length > 0) { showBatchProgress(); uploadBatchFiles(); } } function showBatchProgress() { const container = document.getElementById('batch-progress-container'); const filesList = document.getElementById('batch-files-list'); container.classList.remove('hidden'); filesList.innerHTML = ''; selectedFiles.forEach((file, index) => { const fileDiv = document.createElement('div'); fileDiv.className = 'flex justify-between items-center p-2 bg-white rounded border'; fileDiv.innerHTML = ` ${getFileIcon(file.name)} ${file.name}
Waiting
`; filesList.appendChild(fileDiv); }); } async function uploadBatchFiles() { const results = []; let completed = 0; for (let i = 0; i < selectedFiles.length; i++) { const file = selectedFiles[i]; const statusSpan = document.getElementById(`batch-status-${i}`); const progressBar = document.getElementById(`batch-progress-${i}`); try { statusSpan.textContent = 'Uploading...'; statusSpan.className = 'text-xs text-blue-600'; const result = await uploadSingleFile(file, (progress) => { progressBar.style.width = progress + '%'; }); results.push(result); statusSpan.textContent = '✓ Done'; statusSpan.className = 'text-xs text-green-600'; progressBar.style.width = '100%'; } catch (error) { statusSpan.textContent = '✗ Failed'; statusSpan.className = 'text-xs text-red-600'; console.error(`Upload failed for ${file.name}:`, error); } completed++; const overallProgress = (completed / selectedFiles.length) * 100; document.getElementById('batch-overall-bar').style.width = overallProgress + '%'; document.getElementById('batch-overall-progress').textContent = Math.round(overallProgress) + '%'; } uploadedFiles = [...uploadedFiles, ...results]; showToast(`Batch upload completed! ${results.length} files uploaded.`); updateAnalytics(); } function uploadSingleFile(file, progressCallback) { return new Promise((resolve, reject) => { const formData = new FormData(); formData.append('file', file); const xhr = new XMLHttpRequest(); xhr.upload.addEventListener('progress', (e) => { if (e.lengthComputable) { const percentage = (e.loaded / e.total) * 100; progressCallback(percentage); } }); xhr.addEventListener('load', () => { if (xhr.status === 200) { const result = JSON.parse(xhr.responseText); resolve(result); } else { reject(new Error(`Upload failed: ${xhr.statusText}`)); } }); xhr.addEventListener('error', () => { reject(new Error('Network error')); }); xhr.open('POST', `${WORKER_URL}/upload`); xhr.send(formData); }); } // Camera Upload Functions function setupCameraUpload() { const cameraBtn = document.getElementById('camera-upload-btn'); const cameraInput = document.getElementById('qr-camera-input'); if (cameraBtn) { cameraBtn.addEventListener('click', () => { if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { cameraInput.click(); } else { showToast('Camera not supported on this device', 'error'); } }); } if (cameraInput) { cameraInput.addEventListener('change', handleCameraCapture); } } function handleCameraCapture(e) { if (e.target.files.length > 0) { const file = e.target.files[0]; if (validateFile(file)) { selectedFile = file; updateUploadButton(); showToast('Photo captured! Ready to upload.'); } } } // Privacy Controls function setupPrivacyControls() { const applyBtn = document.getElementById('apply-privacy-settings'); if (applyBtn) { applyBtn.addEventListener('click', applyPrivacySettings); } } function applyPrivacySettings() { // Collect all privacy settings const passwordToggle = document.getElementById('privacy-password-toggle'); const downloadToggle = document.getElementById('download-limit-toggle'); const emailToggle = document.getElementById('email-notify-toggle'); privacySettings.passwordProtected = passwordToggle?.classList.contains('active') || false; privacySettings.downloadLimit = downloadToggle?.classList.contains('active') || false; privacySettings.emailNotification = emailToggle?.classList.contains('active') || false; if (privacySettings.passwordProtected) { privacySettings.password = document.getElementById('privacy-password')?.value || ''; } if (privacySettings.downloadLimit) { privacySettings.maxDownloads = parseInt(document.getElementById('max-downloads')?.value || '10'); } privacySettings.expirationTime = document.getElementById('expiration-time')?.value || '7d'; if (privacySettings.emailNotification) { privacySettings.notificationEmail = document.getElementById('notification-email')?.value || ''; } showToast('Privacy settings applied successfully!'); console.log('Privacy settings:', privacySettings); } // Analytics Functions function setupAnalytics() { const refreshBtn = document.getElementById('refresh-analytics'); const exportBtn = document.getElementById('export-analytics'); if (refreshBtn) { refreshBtn.addEventListener('click', updateAnalytics); } if (exportBtn) { exportBtn.addEventListener('click', exportAnalytics); } // Initialize analytics updateAnalytics(); } function updateAnalytics() { // Show "Coming Soon" for analytics (will be implemented when tool becomes popular) // Update main metrics document.getElementById('total-scans').textContent = 'Coming Soon'; document.getElementById('total-downloads').textContent = 'Coming Soon'; document.getElementById('unique-visitors').textContent = 'Coming Soon'; document.getElementById('avg-time').textContent = 'Coming Soon'; // Update change indicators document.getElementById('scans-change').textContent = 'Coming Soon'; document.getElementById('downloads-change').textContent = 'Coming Soon'; document.getElementById('visitors-change').textContent = 'Coming Soon'; document.getElementById('time-change').textContent = 'Coming Soon'; } function exportAnalytics() { // Check if analytics are available if (document.getElementById('total-scans').textContent === 'Coming Soon') { showToast('Analytics not available yet. Coming soon when tool becomes popular!', 'info'); return; } const data = { exportDate: new Date().toISOString(), totalScans: document.getElementById('total-scans').textContent, totalDownloads: document.getElementById('total-downloads').textContent, uniqueVisitors: document.getElementById('unique-visitors').textContent, avgTime: document.getElementById('avg-time').textContent, uploadedFiles: uploadedFiles.length }; const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `qr-analytics-${new Date().toISOString().split('T')[0]}.json`; a.click(); URL.revokeObjectURL(url); showToast('Analytics exported successfully!'); } // Logo upload handling function setupLogoUpload() { const logoUpload = document.getElementById('logo-upload'); const logoSize = document.getElementById('logo-size'); const logoSizeValue = document.getElementById('logo-size-value'); const applyLogoBtn = document.getElementById('apply-logo-settings'); const removeLogo = document.getElementById('remove-logo'); if (logoUpload) { logoUpload.addEventListener('change', handleLogoUpload); } if (logoSize) { logoSize.addEventListener('input', () => { qrSettings.logoSize = parseInt(logoSize.value); logoSizeValue.textContent = logoSize.value; }); } if (applyLogoBtn) { applyLogoBtn.addEventListener('click', applyLogoToQR); } if (removeLogo) { removeLogo.addEventListener('click', removeLogoFromQR); } } function handleLogoUpload(e) { const file = e.target.files[0]; if (file && file.type.startsWith('image/')) { if (file.size > 100 * 1024) { // 100KB limit showToast('Logo file too large. Please choose a file under 100KB.', 'error'); return; } const reader = new FileReader(); reader.onload = function(event) { logoImage = event.target.result; showLogoPreview(file.name, logoImage); showToast('Logo uploaded successfully! Click "Apply Logo to QR Code" to update.'); }; reader.readAsDataURL(file); } } function showLogoPreview(fileName, imageSrc) { const preview = document.getElementById('logo-preview'); const previewImg = document.getElementById('logo-preview-img'); const previewName = document.getElementById('logo-preview-name'); previewImg.src = imageSrc; previewName.textContent = fileName; preview.classList.remove('hidden'); } function applyLogoToQR() { if (!logoImage) { showToast('Please upload a logo first', 'error'); return; } if (currentUploadResult) { const shareUrl = `${WORKER_URL}/view/${currentUploadResult.id}`; generateQRCodeWithLogo(shareUrl); } else if (document.getElementById('qr-text-content')?.value) { const textContent = document.getElementById('qr-text-content').value; generateQRCodeWithLogo(textContent); } else { showToast('Please upload a file or enter text first', 'error'); } } function removeLogoFromQR() { logoImage = null; document.getElementById('logo-preview').classList.add('hidden'); document.getElementById('logo-upload').value = ''; showToast('Logo removed'); // Regenerate QR without logo if (currentUploadResult) { const shareUrl = `${WORKER_URL}/view/${currentUploadResult.id}`; generateQRCode(shareUrl); } else if (document.getElementById('qr-text-content')?.value) { const textContent = document.getElementById('qr-text-content').value; generateQRCode(textContent); } } function generateQRCodeWithLogo(text, targetContainer = null) { console.log('Generating QR code with logo for:', text); // Find the correct container const container = targetContainer || elements.qrCodeContainer || document.getElementById('qr-preview-container')?.querySelector('div') || document.querySelector('#qr-preview-container div') || document.querySelector('[id*="qr-result"]'); if (!container) { console.error('QR container not found'); showToast('QR display container not found', 'error'); return; } console.log('Using container:', container); container.innerHTML = '

Generating QR with logo...
'; // Create canvas for QR with logo const canvas = document.createElement('canvas'); const size = qrSettings.size || 300; canvas.width = size; canvas.height = size; const ctx = canvas.getContext('2d'); // Use fallback QR generation method const qrApiUrl = `https://api.qrserver.com/v1/create-qr-code/?size=${size}x${size}&data=${encodeURIComponent(text)}&color=${qrSettings.fgColor.replace('#', '')}&bgcolor=${qrSettings.bgColor.replace('#', '')}&margin=${qrSettings.margin}&ecc=${qrSettings.errorCorrectionLevel}`; const qrImg = new Image(); qrImg.crossOrigin = 'anonymous'; qrImg.onload = function() { // Draw QR code on canvas ctx.drawImage(qrImg, 0, 0, size, size); // Add logo if available if (logoImage) { const logoImg = new Image(); logoImg.onload = function() { const logoSize = (size * (qrSettings.logoSize || 20)) / 100; const logoX = (size - logoSize) / 2; const logoY = (size - logoSize) / 2; // Add background if enabled if (qrSettings.logoBackground) { ctx.fillStyle = qrSettings.bgColor || '#ffffff'; ctx.fillRect(logoX - 5, logoY - 5, logoSize + 10, logoSize + 10); } // Draw logo ctx.drawImage(logoImg, logoX, logoY, logoSize, logoSize); // Add to container canvas.className = 'rounded-lg shadow-lg mx-auto'; container.innerHTML = ''; container.appendChild(canvas); currentQrCode = canvas; showToast('QR code with logo generated successfully! ✨'); }; logoImg.onerror = function() { console.error('Logo image load failed'); // Still show QR without logo canvas.className = 'rounded-lg shadow-lg mx-auto'; container.innerHTML = ''; container.appendChild(canvas); currentQrCode = canvas; showToast('QR code generated (logo failed to load)', 'warning'); }; logoImg.src = logoImage; } else { // No logo, just show QR canvas.className = 'rounded-lg shadow-lg mx-auto'; container.innerHTML = ''; container.appendChild(canvas); currentQrCode = canvas; showToast('QR code generated successfully!'); } }; qrImg.onerror = function() { console.error('QR API generation failed'); container.innerHTML = '

QR generation failed
'; showToast('QR code generation failed', 'error'); }; qrImg.src = qrApiUrl; } // Text QR functionality function setupTextQR() { const qrTypeFile = document.getElementById('qr-type-file'); const qrTypeText = document.getElementById('qr-type-text'); const textQrSection = document.getElementById('text-qr-section'); const generateTextQr = document.getElementById('generate-text-qr'); const textPresets = document.querySelectorAll('.text-preset'); const textContent = document.getElementById('qr-text-content'); if (qrTypeFile) { qrTypeFile.addEventListener('click', () => { qrTypeFile.classList.add('active'); qrTypeText.classList.remove('active'); textQrSection.classList.add('hidden'); }); } if (qrTypeText) { qrTypeText.addEventListener('click', () => { qrTypeText.classList.add('active'); qrTypeFile.classList.remove('active'); textQrSection.classList.remove('hidden'); }); } if (generateTextQr) { generateTextQr.addEventListener('click', generateTextQRCode); } textPresets.forEach(preset => { preset.addEventListener('click', () => { const text = preset.getAttribute('data-text'); if (textContent) { textContent.value = text; } }); }); } function generateTextQRCode() { const textContent = document.getElementById('qr-text-content').value.trim(); if (!textContent) { showToast('Please enter some text content', 'error'); return; } if (textContent.length > 2000) { showToast('Text too long. Maximum 2000 characters allowed.', 'error'); return; } // Find the QR preview container in the customize tab const container = document.getElementById('qr-preview-container')?.querySelector('div') || document.querySelector('#content-customize .qr-feature-card:last-child div:last-child'); if (!container) { showToast('QR preview container not found', 'error'); console.error('Could not find QR preview container'); return; } console.log('Generating text QR for:', textContent); console.log('Using container:', container); // Use logo if available, otherwise regular QR if (logoImage) { generateQRCodeWithLogo(textContent, container); } else { generateQRCode(textContent, container); showToast('Text QR code generated successfully! 🎉'); } } // Initialize all features document.addEventListener('DOMContentLoaded', function() { setupLogoUpload(); setupTextQR(); }); // Setup scroll-triggered ads function setupScrollAds() { const scrollAds = document.querySelectorAll('.scroll-ad'); const observerOptions = { threshold: 0.3, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); } }); }, observerOptions); scrollAds.forEach(ad => { observer.observe(ad); }); } })();

Advanced QR Code Generator

📶 WiFi QR Codes 👤 vCard Contact 🌐 URL & Links 📧 Email QR 📍 Location GPS 📅 Calendar Events 💬 SMS Messages 📁 File Upload ✨ Logo Embedding 🔒 Password Protection
8+ QR Code Types
100MB Max File Size
180+ Countries Served
Free Forever Plan

🎯 8 Powerful QR Code Types for Every Need

📶

WiFi QR Codes

Generate WiFi QR codes with SSID, password, and encryption type (WPA/WEP/Open). Guests can connect instantly by scanning – no manual password entry required.

👤

Contact vCard QR Codes

Create digital business cards with contact information, phone numbers, email addresses, company details, and website URLs. Automatically saves to phone contacts.

🌐

URL & Website QR Codes

Convert any website URL into a QR code for instant access. Perfect for marketing campaigns, social media sharing, and driving traffic to your website.

📧

Email QR Codes

Pre-fill email drafts with recipient, subject, and message content. Users can send emails instantly with a single scan – perfect for customer support and feedback.

📍

Location & GPS QR Codes

Share precise GPS coordinates and locations. Includes Google Maps integration, “Use My Location” feature, and direct navigation to any address or landmark.

📅

Calendar Event QR Codes

Create calendar events with title, date, time, location, and description. Users can add events to their calendar apps (Google Calendar, Outlook, Apple Calendar) instantly.

💬

SMS Message QR Codes

Pre-fill SMS messages with phone number and text content. Perfect for customer service, marketing campaigns, and quick communication setup.

📁

File Upload QR Codes

Upload and share any file type (PDF, Word, Excel, images, etc.) up to 100MB. Includes password protection, download limits, and secure cloud storage via Cloudflare R2.

⚡ Advanced Features & Customization

🎨

Custom Logo Integration

Add your brand logo to any QR code type. Upload images, adjust size and positioning, preview in real-time, and create professional branded QR codes that maintain scannability.

🔐

Advanced Security Features

Password protection, download limits, auto-expiration dates, and encrypted file storage. Perfect for sensitive business documents and exclusive content sharing.

📊

Analytics Dashboard

Comprehensive analytics with scan tracking, geographic distribution, device types, peak usage times, and user engagement patterns. Export data for further analysis.

⚡

Batch Processing

Generate multiple QR codes simultaneously with batch upload functionality. Perfect for businesses managing large campaigns or multiple file shares efficiently.

🎨

Full Visual Customization

Customize colors, sizes (100×100 to 2000×2000), formats (PNG, SVG, PDF), error correction levels, margins, and borders. Create QR codes that match your brand perfectly.

📱

Mobile Camera Integration

Capture and share files directly from your mobile camera. Mobile-optimized interface with responsive design ensures perfect functionality on all devices.

💼 Perfect for Every Use Case

🏢

Business & Marketing

Share brochures, price lists, product catalogs, and marketing materials. Track engagement and optimize your marketing campaigns with detailed analytics.

🎓

Education & Training

Distribute course materials, assignments, and resources. Password-protect sensitive content and track student access patterns.

🎪

Events & Conferences

Share schedules, speaker bios, presentation slides, and networking materials. Perfect for contactless information sharing at events.

👥

Personal Use

Share photos, documents, contact information, and personal files with friends and family. Easy, secure, and convenient file sharing solution.

✨ Key Benefits & Features

🚀 8 QR Code Types

  • ✅ WiFi QR Codes: SSID, password, encryption type (WPA/WEP/Open)
  • ✅ vCard Contact: Digital business cards with all contact info
  • ✅ URL QR Codes: Direct website links and social media
  • ✅ Email QR Codes: Pre-filled email drafts with recipients
  • ✅ Location GPS: Precise coordinates with Google Maps integration
  • ✅ Calendar Events: Add to Google Calendar, Outlook, Apple Calendar
  • ✅ SMS Messages: Pre-filled text messages with phone numbers
  • ✅ File Upload: Share documents, images, and files up to 100MB

📊 Advanced Features

  • ✅ Logo Embedding: Add custom logos and branding to any QR type
  • ✅ Password Protection: Secure files with authentication
  • ✅ Analytics Dashboard: Track scans, locations, and engagement
  • ✅ Batch Processing: Generate multiple QR codes simultaneously
  • ✅ Mobile Camera: Direct camera integration for quick uploads
  • ✅ Custom Colors & Sizes: Full visual customization options
  • ✅ Multiple Formats: PNG, SVG, PDF output formats
  • ✅ Global CDN: Fast access worldwide via Cloudflare

⚙️ Technical Specifications

📁 File Support & QR Types

  • QR Types: WiFi, vCard, URL, Email, Location, Calendar, SMS, Files
  • Documents: PDF, Word, Excel, PowerPoint
  • Images: JPG, PNG, GIF, WebP, SVG
  • Text Files: TXT, CSV, JSON, XML
  • Max Size: 100 MB per file

🎨 QR Customization

  • Formats: PNG, SVG, PDF
  • Sizes: 100×100 to 2000×2000 pixels
  • Colors: Custom foreground & background
  • Error Correction: Low, Medium, Quartile, High

🔒 Security Features

  • Encryption: TLS 1.3 in transit
  • Storage: Cloudflare R2 secure storage
  • Access Control: Password & download limits
  • Privacy: Auto-deletion & secure URLs

❓ Frequently Asked Questions

How do I create WiFi QR codes for guests? +
Select “WiFi Access” from the QR type options, then enter your network SSID (name), password, and encryption type (WPA/WEP/Open). Guests can scan the QR code to automatically connect to your WiFi without manually entering credentials. Perfect for businesses, restaurants, and home use.
How do I add a logo to my QR code? +
Simply upload your logo image using the “Logo Upload” feature in the customization panel. You can adjust the logo size, position, and background settings. Our tool automatically optimizes the logo placement while maintaining QR code scannability for all QR code types.
Can I password protect my QR codes? +
Yes! Enable password protection in the Privacy & Security settings. Users will need to enter the correct password to access your shared content. You can also set download limits and auto-expiration dates for additional security.
What QR code types are available? +
We support 8 different QR code types: WiFi (SSID, password, encryption), Contact vCard (digital business cards), URL/Website links, Email (pre-filled drafts), Location/GPS coordinates, Calendar Events, SMS Messages, and File Upload (PDF, Word, Excel, images, etc.). Maximum file size is 100 MB per upload.
How do I track QR code analytics? +
Access the Analytics Dashboard to view detailed statistics including scan counts, geographic distribution, device types, peak usage times, and engagement metrics. All data is updated in real-time.
Can I generate multiple QR codes at once? +
Yes! Use the Batch Operations feature to upload and process multiple files simultaneously. Perfect for businesses or campaigns that need to generate many QR codes quickly and efficiently.
Is my data secure and private? +
Absolutely! All files are encrypted during transmission using TLS 1.3 and stored securely on Cloudflare’s global network. You can add password protection, set expiration dates, and control access to ensure your data remains private.

🛠️ Explore More Creative Tools

Discover our complete suite of professional tools designed to boost your productivity and creativity. From text generators to design tools, we’ve got everything you need.

🔧 How It Works – Simple 4-Step Process

1

Choose QR Type

Choose from 8 QR code types or upload any file from your device. Supports mobile camera capture and 50+ file formats up to 100 MB.

2

Customize Your QR

Add your logo, choose colors, set security options like password protection, and configure privacy settings to match your needs.

3

Generate & Download

Instantly generate your professional QR code in multiple formats (PNG, SVG, PDF). Download high-resolution versions for any use case.

4

Share & Track

Share your QR code anywhere and track its performance with detailed analytics. Monitor scans, locations, and engagement in real-time.

🌟 The Ultimate QR Code Solution for Modern Businesses

In today’s digital landscape, QR codes have become essential tools for seamless information sharing and contactless interactions. Our advanced QR code generator supports 8 different QR code types – from WiFi network sharing and digital business cards to GPS locations and calendar events – providing a comprehensive solution for businesses, educators, marketers, and individuals who demand professional-grade features.

🚀 8 QR Code Types for Every Need

Our platform supports WiFi QR codes for instant network access, vCard contact QR codes for digital business cards, URL QR codes for website sharing, Email QR codes with pre-filled drafts, Location QR codes with GPS coordinates and Google Maps integration, Calendar Event QR codes for automatic scheduling, SMS QR codes for pre-filled messages, and File Upload QR codes for secure document sharing up to 100MB with logo embedding and password protection.

🔒 Enterprise-Grade Security

Security is paramount in today’s digital world. Our QR code generator includes advanced security features such as password protection, download limits, auto-expiration, and encrypted file storage. Whether you’re sharing sensitive business documents or personal files, you can trust that your content remains secure and accessible only to authorized users.

📊 Data-Driven Insights

Make informed decisions with our comprehensive analytics dashboard. Track QR code performance, understand user behavior, monitor geographic distribution, and identify peak usage times. This valuable data helps you optimize your campaigns, improve user experience, and maximize the impact of your QR code initiatives.

🌍 Global Accessibility and Performance

Powered by Cloudflare’s global content delivery network, our QR codes provide lightning-fast access to your shared content from anywhere in the world. With 99.9% uptime guarantee and servers in over 180 countries, your audience can access your content quickly and reliably, regardless of their location.

Leave a Comment