feat: todos os qr codes com os campos funcionais!!! (falta apenas o dinamico)
This commit is contained in:
parent
9634176e18
commit
ee160135af
@ -103,7 +103,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="mb-3" id="content-group">
|
||||
<label class="form-label fw-semibold">
|
||||
<i class="fas fa-edit"></i> @Localizer["Content"]
|
||||
</label>
|
||||
@ -253,12 +253,183 @@
|
||||
VERSION:3.0
|
||||
CHARSET=UTF-8
|
||||
Preencha os campos acima para ver o preview...
|
||||
END:VCARD</pre>
|
||||
END:VCARD
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- WiFi Interface (dynamic) -->
|
||||
<div id="wifi-interface" class="mb-3" style="display: none;">
|
||||
<div class="alert alert-info">
|
||||
<i class="fas fa-wifi"></i>
|
||||
<strong>@Localizer["WiFiQRTitle"]</strong> - @Localizer["WiFiQRDescription"]
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label fw-semibold">@Localizer["NetworkName"] *</label>
|
||||
<input type="text" id="wifi-ssid" name="wifi-ssid" class="form-control" placeholder="NomeDaSuaRede" required>
|
||||
<div class="invalid-feedback">@Localizer["NetworkNameRequired"]</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label fw-semibold">@Localizer["SecurityType"]</label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="wifi-security" id="wifi-security-wpa" value="WPA" checked>
|
||||
<label class="form-check-label" for="wifi-security-wpa">@Localizer["WPARecommended"]</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="wifi-security" id="wifi-security-wep" value="WEP">
|
||||
<label class="form-check-label" for="wifi-security-wep">@Localizer["WEPLegacy"]</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="wifi-security" id="wifi-security-nopass" value="nopass">
|
||||
<label class="form-check-label" for="wifi-security-nopass">@Localizer["OpenNetwork"]</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3" id="wifi-password-group">
|
||||
<label class="form-label fw-semibold">@Localizer["NetworkPassword"] *</label>
|
||||
<div class="input-group">
|
||||
<input type="password" id="wifi-password" name="wifi-password" class="form-control" placeholder="SenhaDaSuaRede" required>
|
||||
<button class="btn btn-outline-secondary" type="button" id="toggle-password">
|
||||
<i class="fas fa-eye"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="invalid-feedback">@Localizer["PasswordRequiredForSecure"]</div>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="wifi-hidden" name="wifi-hidden">
|
||||
<label class="form-check-label" for="wifi-hidden">@Localizer["HiddenNetwork"]</label>
|
||||
</div>
|
||||
|
||||
<div class="wifi-preview">
|
||||
<h6 class="fw-bold text-success mb-2">
|
||||
<i class="fas fa-eye"></i> @Localizer["WiFiPreviewTitle"]
|
||||
</h6>
|
||||
<div class="card bg-light">
|
||||
<div class="card-body">
|
||||
<pre id="wifi-preview-text" class="mb-0 small text-muted">WIFI:T:WPA;S:;P:;H:false;;</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- WiFi Interface (dynamic) -->
|
||||
<div id="wifi-interface" class="mb-3" style="display: none;">
|
||||
<div class="alert alert-info">
|
||||
<i class="fas fa-wifi"></i>
|
||||
<strong>@Localizer["WiFiQRTitle"]</strong> - @Localizer["WiFiQRDescription"]
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label fw-semibold">@Localizer["NetworkName"] *</label>
|
||||
<input type="text" id="wifi-ssid2" class="form-control" placeholder="NomeDaSuaRede" required>
|
||||
<div class="invalid-feedback">@Localizer["NetworkNameRequired"]</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label fw-semibold">@Localizer["SecurityType"]</label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="wifi-security" id="wifi-security-wpa2" value="WPA" checked>
|
||||
<label class="form-check-label" for="wifi-security-wpa">@Localizer["WPARecommended"]</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="wifi-security" id="wifi-security-wep2" value="WEP">
|
||||
<label class="form-check-label" for="wifi-security-wep">@Localizer["WEPLegacy"]</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="wifi-security" id="wifi-security-nopass2" value="nopass">
|
||||
<label class="form-check-label" for="wifi-security-nopass">@Localizer["OpenNetwork"]</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3" id="wifi-password-group">
|
||||
<label class="form-label fw-semibold">@Localizer["NetworkPassword"] *</label>
|
||||
<div class="input-group">
|
||||
<input type="password" id="wifi-password2" class="form-control" placeholder="SenhaDaSuaRede" required>
|
||||
<button class="btn btn-outline-secondary" type="button" id="toggle-password2">
|
||||
<i class="fas fa-eye"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="invalid-feedback">@Localizer["PasswordRequiredForSecure"]</div>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="wifi-hidden2">
|
||||
<label class="form-check-label" for="wifi-hidden">@Localizer["HiddenNetwork"]</label>
|
||||
</div>
|
||||
|
||||
<div class="wifi-preview">
|
||||
<h6 class="fw-bold text-success mb-2">
|
||||
<i class="fas fa-eye"></i> @Localizer["WiFiPreviewTitle"]
|
||||
</h6>
|
||||
<div class="card bg-light">
|
||||
<div class="card-body">
|
||||
<pre id="wifi-preview-text" class="mb-0 small text-muted">WIFI:T:WPA;S:;P:;H:false;;</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SMS Interface (dynamic) -->
|
||||
<div id="sms-interface" class="mb-3" style="display: none;">
|
||||
<div class="alert alert-info">
|
||||
<strong>QR Code SMS:</strong> Permite enviar SMS automático com número e mensagem pré-definidos.
|
||||
Compatível com Android, iOS e dispositivos modernos.
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label fw-semibold">Número do Celular *</label>
|
||||
<input type="tel" id="sms-number" name="sms-number" class="form-control" placeholder="11999998888" required>
|
||||
<small class="text-muted">Apenas números (DDD + número, sem espaços)</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label fw-semibold">Mensagem *</label>
|
||||
<textarea id="sms-message" name="sms-message" class="form-control" rows="3" placeholder="Sua mensagem aqui..." required></textarea>
|
||||
<small class="text-muted">Mensagem que será pré-preenchida no SMS</small>
|
||||
</div>
|
||||
|
||||
<div class="sms-preview">
|
||||
<h6>️ Preview do SMS</h6>
|
||||
<pre id="sms-preview-text" class="bg-light p-3 rounded">SMSTO::</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Email Interface (dynamic) -->
|
||||
<div id="email-interface" class="mb-3" style="display: none;">
|
||||
<div class="alert alert-info">
|
||||
<strong>QR Code Email:</strong> Permite enviar email automático com destinatário, assunto e mensagem pré-definidos.
|
||||
Compatível com Android, iOS e dispositivos modernos.
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label fw-semibold">Email Destinatário *</label>
|
||||
<input type="email" id="email-to" name="email-to" class="form-control" placeholder="contato@empresa.com" required>
|
||||
<small class="text-muted">Email que receberá a mensagem</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label fw-semibold">Assunto *</label>
|
||||
<input type="text" id="email-subject" name="email-subject" class="form-control" placeholder="Assunto do email" required>
|
||||
<small class="text-muted">Linha de assunto do email</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label fw-semibold">Mensagem</label>
|
||||
<textarea id="email-body" name="email-body" class="form-control" rows="4" placeholder="Corpo da mensagem..."></textarea>
|
||||
<small class="text-muted">Corpo da mensagem (opcional)</small>
|
||||
</div>
|
||||
|
||||
<div class="email-preview">
|
||||
<h6>️ Preview do Email</h6>
|
||||
<pre id="email-preview-text" class="bg-light p-3 rounded">mailto:?subject=&body=</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Advanced customization (collapsible) -->
|
||||
<div class="accordion mb-3" id="customization-accordion">
|
||||
<div class="accordion-item">
|
||||
|
||||
@ -106,16 +106,21 @@ class QRRapidoGenerator {
|
||||
});
|
||||
});
|
||||
|
||||
// VCard fields validation
|
||||
const vcardFields = ['vcard-name', 'vcard-mobile', 'vcard-email'];
|
||||
vcardFields.forEach(fieldId => {
|
||||
const field = document.getElementById(fieldId);
|
||||
if (field) {
|
||||
field.addEventListener('input', () => {
|
||||
this.updateGenerateButton();
|
||||
});
|
||||
// Add listeners to all relevant fields to update button state
|
||||
const fieldsToWatch = [
|
||||
'qr-content', 'vcard-name', 'vcard-mobile', 'vcard-email',
|
||||
'wifi-ssid', 'wifi-password', 'sms-number', 'sms-message',
|
||||
'email-to', 'email-subject', 'email-body'
|
||||
];
|
||||
fieldsToWatch.forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) {
|
||||
el.addEventListener('input', () => this.updateGenerateButton());
|
||||
}
|
||||
});
|
||||
document.querySelectorAll('input[name="wifi-security"]').forEach(radio => {
|
||||
radio.addEventListener('change', () => this.updateGenerateButton());
|
||||
});
|
||||
|
||||
// Language selector
|
||||
document.querySelectorAll('[data-lang]').forEach(link => {
|
||||
@ -431,6 +436,27 @@ class QRRapidoGenerator {
|
||||
this.showError('Erro na validação do VCard: ' + error.message);
|
||||
return false;
|
||||
}
|
||||
} else if (qrType === 'wifi') {
|
||||
const errors = window.wifiGenerator.validateWiFiData();
|
||||
if (errors.length > 0) {
|
||||
this.showError(errors.join('<br>'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (qrType === 'sms') {
|
||||
const errors = window.smsGenerator.validateSMSData();
|
||||
if (errors.length > 0) {
|
||||
this.showError(errors.join('<br>'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (qrType === 'email') {
|
||||
const errors = window.emailGenerator.validateEmailData();
|
||||
if (errors.length > 0) {
|
||||
this.showError(errors.join('<br>'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Normal validation for other types
|
||||
@ -454,6 +480,62 @@ class QRRapidoGenerator {
|
||||
const quickStyle = document.querySelector('input[name="quick-style"]:checked')?.value || 'classic';
|
||||
const styleSettings = this.getStyleSettings(quickStyle);
|
||||
|
||||
if (type === 'wifi') {
|
||||
const wifiContent = window.wifiGenerator.generateWiFiString();
|
||||
return {
|
||||
data: {
|
||||
type: 'text', // WiFi is treated as text in the backend
|
||||
content: wifiContent,
|
||||
quickStyle: quickStyle,
|
||||
primaryColor: document.getElementById('primary-color').value || (styleSettings.primaryColor || '#000000'),
|
||||
backgroundColor: document.getElementById('bg-color').value || (styleSettings.backgroundColor || '#FFFFFF'),
|
||||
size: parseInt(document.getElementById('qr-size').value),
|
||||
margin: parseInt(document.getElementById('qr-margin').value),
|
||||
cornerStyle: document.getElementById('corner-style')?.value || 'square',
|
||||
optimizeForSpeed: true,
|
||||
language: this.currentLang
|
||||
},
|
||||
isMultipart: false,
|
||||
endpoint: '/api/QR/GenerateRapid'
|
||||
};
|
||||
} else if (type === 'sms') {
|
||||
const smsContent = window.smsGenerator.generateSMSString();
|
||||
return {
|
||||
data: {
|
||||
type: 'text',
|
||||
content: smsContent,
|
||||
quickStyle: quickStyle,
|
||||
primaryColor: document.getElementById('primary-color').value || (styleSettings.primaryColor || '#000000'),
|
||||
backgroundColor: document.getElementById('bg-color').value || (styleSettings.backgroundColor || '#FFFFFF'),
|
||||
size: parseInt(document.getElementById('qr-size').value),
|
||||
margin: parseInt(document.getElementById('qr-margin').value),
|
||||
cornerStyle: document.getElementById('corner-style')?.value || 'square',
|
||||
optimizeForSpeed: true,
|
||||
language: this.currentLang
|
||||
},
|
||||
isMultipart: false,
|
||||
endpoint: '/api/QR/GenerateRapid'
|
||||
};
|
||||
} else if (type === 'email') {
|
||||
const emailContent = window.emailGenerator.generateEmailString();
|
||||
return {
|
||||
data: {
|
||||
type: 'text',
|
||||
content: emailContent,
|
||||
quickStyle: quickStyle,
|
||||
primaryColor: document.getElementById('primary-color').value || (styleSettings.primaryColor || '#000000'),
|
||||
backgroundColor: document.getElementById('bg-color').value || (styleSettings.backgroundColor || '#FFFFFF'),
|
||||
size: parseInt(document.getElementById('qr-size').value),
|
||||
margin: parseInt(document.getElementById('qr-margin').value),
|
||||
cornerStyle: document.getElementById('corner-style')?.value || 'square',
|
||||
optimizeForSpeed: true,
|
||||
language: this.currentLang
|
||||
},
|
||||
isMultipart: false,
|
||||
endpoint: '/api/QR/GenerateRapid'
|
||||
};
|
||||
}
|
||||
|
||||
// Handle VCard type
|
||||
if (type === 'vcard') {
|
||||
if (window.vcardGenerator) {
|
||||
@ -729,7 +811,7 @@ class QRRapidoGenerator {
|
||||
'wifi': 'Nombre de red;Contraseña;Tipo de seguridad (WPA/WEP)',
|
||||
'vcard': 'Nombre;Teléfono;Email;Empresa',
|
||||
'sms': 'Número;Mensaje',
|
||||
'email': 'email@ejemplo.com;Asunto;Mensaje'
|
||||
'email': 'email@ejemplo.com;Asunto;Mensagem'
|
||||
}
|
||||
};
|
||||
|
||||
@ -1207,29 +1289,51 @@ class QRRapidoGenerator {
|
||||
}
|
||||
|
||||
enableContentFields(type) {
|
||||
const qrContent = document.getElementById('qr-content');
|
||||
const contentGroup = document.getElementById('content-group');
|
||||
const vcardInterface = document.getElementById('vcard-interface');
|
||||
const wifiInterface = document.getElementById('wifi-interface');
|
||||
const smsInterface = document.getElementById('sms-interface');
|
||||
const emailInterface = document.getElementById('email-interface');
|
||||
|
||||
// Hide all interfaces by default
|
||||
if (vcardInterface) vcardInterface.style.display = 'none';
|
||||
if (wifiInterface) wifiInterface.style.display = 'none';
|
||||
if (smsInterface) smsInterface.style.display = 'none';
|
||||
if (emailInterface) emailInterface.style.display = 'none';
|
||||
if (contentGroup) contentGroup.style.display = 'block';
|
||||
|
||||
if (type === 'vcard') {
|
||||
// Para vCard, ocultar textarea e mostrar interface específica
|
||||
if (qrContent) {
|
||||
qrContent.style.display = 'none';
|
||||
qrContent.removeAttribute('required');
|
||||
}
|
||||
if (contentGroup) contentGroup.style.display = 'none';
|
||||
if (vcardInterface) {
|
||||
vcardInterface.style.display = 'block';
|
||||
this.enableVCardFields();
|
||||
}
|
||||
} else if (type === 'wifi') {
|
||||
// Para WiFi, ocultar textarea e mostrar interface específica
|
||||
if (contentGroup) contentGroup.style.display = 'none';
|
||||
if (wifiInterface) {
|
||||
wifiInterface.style.display = 'block';
|
||||
}
|
||||
} else if (type === 'sms') {
|
||||
// Para SMS, ocultar textarea e mostrar interface específica
|
||||
if (contentGroup) contentGroup.style.display = 'none';
|
||||
if (smsInterface) {
|
||||
smsInterface.style.display = 'block';
|
||||
}
|
||||
} else if (type === 'email') {
|
||||
// Para Email, ocultar textarea e mostrar interface específica
|
||||
if (contentGroup) contentGroup.style.display = 'none';
|
||||
if (emailInterface) {
|
||||
emailInterface.style.display = 'block';
|
||||
}
|
||||
} else {
|
||||
// Para outros tipos, mostrar textarea
|
||||
if (contentGroup) contentGroup.style.display = 'block';
|
||||
const qrContent = document.getElementById('qr-content');
|
||||
if(qrContent) {
|
||||
qrContent.style.display = 'block';
|
||||
qrContent.setAttribute('required', 'required');
|
||||
qrContent.disabled = false;
|
||||
}
|
||||
if (vcardInterface) {
|
||||
vcardInterface.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1324,29 +1428,36 @@ class QRRapidoGenerator {
|
||||
const generateBtn = document.getElementById('generate-btn');
|
||||
if (!generateBtn) return;
|
||||
|
||||
let shouldEnable = false;
|
||||
let isValid = false;
|
||||
const type = this.selectedType;
|
||||
|
||||
// Verificar se tem tipo selecionado
|
||||
if (this.selectedType) {
|
||||
if (this.selectedType === 'vcard') {
|
||||
// Para vCard, validar campos obrigatórios
|
||||
shouldEnable = this.validateVCardFields();
|
||||
} else {
|
||||
// Para outros tipos, validar conteúdo
|
||||
if (type === 'url' || type === 'text') {
|
||||
const content = document.getElementById('qr-content')?.value || '';
|
||||
shouldEnable = this.validateContent(content);
|
||||
isValid = content.trim().length >= 3;
|
||||
} else if (type === 'vcard') {
|
||||
isValid = this.validateVCardFields();
|
||||
} else if (type === 'wifi') {
|
||||
const data = window.wifiGenerator.collectWiFiData();
|
||||
isValid = data.ssid.trim() !== '';
|
||||
if (data.security !== 'nopass' && !data.password.trim()) {
|
||||
isValid = false;
|
||||
}
|
||||
} else if (type === 'sms') {
|
||||
const data = window.smsGenerator.collectSMSData();
|
||||
isValid = data.number.trim() !== '' && data.message.trim() !== '';
|
||||
} else if (type === 'email') {
|
||||
const data = window.emailGenerator.collectEmailData();
|
||||
isValid = data.to.trim() !== '' && data.subject.trim() !== '';
|
||||
}
|
||||
|
||||
generateBtn.disabled = !shouldEnable;
|
||||
generateBtn.disabled = !isValid;
|
||||
|
||||
// Feedback visual
|
||||
if (shouldEnable) {
|
||||
generateBtn.classList.remove('btn-secondary');
|
||||
if (isValid) {
|
||||
generateBtn.classList.remove('btn-secondary', 'disabled');
|
||||
generateBtn.classList.add('btn-primary');
|
||||
} else {
|
||||
generateBtn.classList.remove('btn-primary');
|
||||
generateBtn.classList.add('btn-secondary');
|
||||
generateBtn.classList.add('btn-secondary', 'disabled');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1369,7 +1480,7 @@ class QRRapidoGenerator {
|
||||
// Garantir que o conteúdo seja tratado como UTF-8
|
||||
try {
|
||||
// Verificar se há caracteres especiais
|
||||
const hasSpecialChars = /[^\x00-\x7F]/.test(content);
|
||||
const hasSpecialChars = /[^ | ||||