@ -1016,18 +1016,52 @@ input.invalid, select.invalid, textarea.invalid {
body += 'Versie: ' + CONFIG.version + '\n';
body += 'Versie: ' + CONFIG.version + '\n';
body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
body += 'Datum: ' + formatDateTime(new Date()) + '\n\n';
// Collect photos separately
const photos = [];
Object.entries(data).forEach(([key, value]) => {
Object.entries(data).forEach(([key, value]) => {
if (value & & value !== '' & & !key.includes('foto') & & !key.includes('photo')) {
if (value & & value !== '') {
// Check if this is a photo (base64 image)
if (typeof value === 'string' & & value.startsWith('data:image/')) {
const label = document.querySelector(`label[for="${key}"]`);
const labelText = label ? label.textContent.replace('*', '').trim() : key;
// Extract extension from data URL (e.g., data:image/jpeg;base64,...)
const mimeMatch = value.match(/data:image\/([a-z]+);/);
const ext = mimeMatch ? mimeMatch[1] : 'jpg';
photos.push({
name: labelText,
extension: ext,
data: value
});
} else {
const label = document.querySelector(`label[for="${key}"]`);
const label = document.querySelector(`label[for="${key}"]`);
const labelText = label ? label.textContent.replace('*', '').trim() : key;
const labelText = label ? label.textContent.replace('*', '').trim() : key;
const displayValue = Array.isArray(value) ? value.join(', ') : value;
const displayValue = Array.isArray(value) ? value.join(', ') : value;
body += labelText + ': ' + displayValue + '\n';
body += labelText + ': ' + displayValue + '\n';
}
}
}
});
});
body += '\n========================\n';
body += '\n========================\n';
body += 'Let op: Foto\'s kunnen niet via mailto worden verzonden.\n';
body += 'Gebruik CSV export voor complete data inclusief foto\'s.';
// Add photos section if there are any
if (photos.length > 0) {
body += '\nFOTO BIJLAGEN (BASE64)\n';
body += '========================\n';
body += 'Onderstaande foto\'s zijn gecodeerd in base64 formaat.\n';
body += 'Kopieer de tekst tussen START en EINDE naar een base64 decoder\n';
body += 'of gebruik een online tool zoals base64-image.de\n\n';
photos.forEach((photo, index) => {
const filename = photo.name.replace(/[^a-zA-Z0-9]/g, '_') + '.' + photo.extension;
body += '--- FOTO ' + (index + 1) + ': ' + filename + ' ---\n';
body += '>>> START BASE64 >>>\n';
body += photo.data + '\n';
body += '< < < EINDE BASE64 < < < \ n \ n ' ;
});
} else {
body += 'Geen foto\'s toegevoegd aan dit formulier.\n';
}
const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
const mailto = 'mailto:' + encodeURIComponent(CONFIG.export.mailto.to) +
'?subject=' + encodeURIComponent(subject) +
'?subject=' + encodeURIComponent(subject) +
@ -1039,6 +1073,12 @@ input.invalid, select.invalid, textarea.invalid {
button.disabled = false;
button.disabled = false;
}
}
// Check if mailto URL is too long (most clients support ~2000 chars)
if (mailto.length > 100000) {
showToast('Email te groot door foto. Gebruik CSV export.', 'error');
return;
}
window.location.href = mailto;
window.location.href = mailto;
}, 50);
}, 50);
};
};