Advanced Police Incident Report Generator Report Preview
Scan to Share Report
QR Code will appear here
`);
printWindow.document.close();
}// Download as PDF
function downloadPDF() {
if (!previewContainer.innerHTML) {
alert(currentLanguage === 'en'
? 'Please generate a report first.'
: 'Por favor, genere un reporte primero.');
return;
}
// Create a new PDF document
const pdf = new jsPDF('p', 'mm', 'a4');
// Add report content
pdf.html(previewContainer, {
callback: function(pdf) {
pdf.save('police-incident-report.pdf');
},
margin: [15, 15, 15, 15],
autoPaging: 'text',
width: 180,
windowWidth: previewContainer.scrollWidth
});
}// Download as TXT
function downloadTXT() {
if (!previewContainer.innerHTML) {
alert(currentLanguage === 'en'
? 'Please generate a report first.'
: 'Por favor, genere un reporte primero.');
return;
}
const content = previewContainer.innerText;
const blob = new Blob([content], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'incident-report.txt';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}// Copy report to clipboard
function copyToClipboard() {
if (!previewContainer.innerHTML) {
alert(currentLanguage === 'en'
? 'Please generate a report first.'
: 'Por favor, genere un reporte primero.');
return;
}
// Create a temporary textarea to copy text content
const tempTextArea = document.createElement('textarea');
tempTextArea.value = previewContainer.innerText;
document.body.appendChild(tempTextArea);
tempTextArea.select();
document.execCommand('copy');
document.body.removeChild(tempTextArea);
alert(currentLanguage === 'en'
? 'Report copied to clipboard!'
: '¡Reporte copiado al portapapeles!');
}// Share via WhatsApp
function shareViaWhatsApp() {
if (!previewContainer.innerHTML) {
alert(currentLanguage === 'en'
? 'Please generate a report first.'
: 'Por favor, genere un reporte primero.');
return;
}
const content = previewContainer.innerText;
const encodedContent = encodeURIComponent(content);
const whatsappUrl = `https://wa.me/?text=${encodedContent}`;
window.open(whatsappUrl, '_blank');
}// Share via Email
function shareViaEmail() {
if (!previewContainer.innerHTML) {
alert(currentLanguage === 'en'
? 'Please generate a report first.'
: 'Por favor, genere un reporte primero.');
return;
}
const subject = currentLanguage === 'en'
? 'Police Incident Report'
: 'Informe Policial de Incidente';
const body = previewContainer.innerText;
const mailtoUrl = `mailto:?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
window.location.href = mailtoUrl;
}// Generate QR Code
function generateQRCode() {
if (!previewContainer.innerHTML) {
alert(currentLanguage === 'en'
? 'Please generate a report first.'
: 'Por favor, genere un reporte primero.');
return;
}
const content = previewContainer.innerText;
// Clear previous QR code
document.getElementById('qrcode').innerHTML = '';
// Generate new QR code
new QRCode(document.getElementById('qrcode'), {
text: content,
width: 180,
height: 180,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
qrContainer.style.display = 'block';
}// Toggle dark mode
function toggleDarkMode() {
isDarkMode = !isDarkMode;
document.body.classList.toggle('dark-mode', isDarkMode);
modeToggle.textContent = isDarkMode ? '☀️' : '🌙';
localStorage.setItem('darkMode', isDarkMode);
}// Toggle language
function toggleLanguage() {
currentLanguage = currentLanguage === 'en' ? 'es' : 'en';
localStorage.setItem('language', currentLanguage);
updateLanguage();
generateReport();
}// Update language content
function updateLanguage() {
const lang = languageContent[currentLanguage];
document.getElementById('title').textContent = lang.title;
document.getElementById('subtitle').textContent = lang.subtitle;
document.getElementById('formTitle').textContent = lang.formTitle;
document.getElementById('nameLabel').textContent = lang.nameLabel;
document.getElementById('phoneLabel').textContent = lang.phoneLabel;
document.getElementById('emailLabel').textContent = lang.emailLabel;
document.getElementById('datetimeLabel').textContent = lang.datetimeLabel;
document.getElementById('locationLabel').textContent = lang.locationLabel;
document.getElementById('typeLabel').textContent = lang.typeLabel;
document.getElementById('otherLabel').textContent = lang.otherLabel;
document.getElementById('suspectLabel').textContent = lang.suspectLabel;
document.getElementById('descriptionLabel').textContent = lang.descriptionLabel;
document.getElementById('witnessLabel').textContent = lang.witnessLabel;
document.getElementById('reportNumLabel').textContent = lang.reportNumLabel;
document.getElementById('anonymousLabel').textContent = lang.anonymousLabel;
document.getElementById('signatureLabel').textContent = lang.signatureLabel;
document.getElementById('generateText').textContent = lang.generateText;
document.getElementById('resetText').textContent = lang.resetText;
document.getElementById('previewTitle').textContent = lang.previewTitle;
document.getElementById('printText').textContent = lang.printText;
document.getElementById('pdfText').textContent = lang.pdfText;
document.getElementById('copyText').textContent = lang.copyText;
document.getElementById('txtText').textContent = lang.txtText;
document.getElementById('whatsappText').textContent = lang.whatsappText;
document.getElementById('emailText').textContent = lang.emailText;
document.getElementById('qrText').textContent = lang.qrText;
document.getElementById('stickyGenerateText').textContent = lang.stickyGenerateText;
document.getElementById('qrTitle').textContent = lang.qrTitle;
}// Toggle sticky button visibility
function toggleStickyButton() {
if (window.innerWidth < 992) {
stickyGenerateBtn.style.display = (window.scrollY > 300) ? 'flex' : 'none';
} else {
stickyGenerateBtn.style.display = 'none';
}
}// Initialize from localStorage
function initFromStorage() {
// Dark mode
const savedDarkMode = localStorage.getItem('darkMode') === 'true';
if (savedDarkMode) {
document.body.classList.add('dark-mode');
modeToggle.textContent = '☀️';
isDarkMode = true;
}
// Language
const savedLanguage = localStorage.getItem('language');
if (savedLanguage && (savedLanguage === 'en' || savedLanguage === 'es')) {
currentLanguage = savedLanguage;
}
}// Initialize
initFromStorage();