`;
showNotification("Error generating content.");
} finally {
generateBtn.disabled = false;
generateBtn.textContent = 'Generate Content';
}
}
function renderContent() {
if (!generatedContent) return;
resultsContainer.innerHTML = `
`;
}
// --- UTILITY FUNCTIONS ---
function showNotification(message) {
notification.textContent = message;
notification.classList.remove('opacity-0');
setTimeout(() => notification.classList.add('opacity-0'), 2000);
}
function copyToClipboard(text, message) {
navigator.clipboard.writeText(text).then(() => showNotification(message));
}
copyBtn.addEventListener('click', () => {
if (!generatedContent) {
showNotification("Nothing to copy.");
return;
}
const textToCopy = `Our Story\n${generatedContent.our_story}\n\nOur Mission\n${generatedContent.our_mission}\n\nWhat We Do\n${generatedContent.what_we_do}`;
copyToClipboard(textToCopy, 'Content copied!');
});
// --- PDF GENERATION ---
async function generatePdfReport() {
if (!generatedContent) {
showNotification("No content to export.");
return;
}
downloadPdfBtn.disabled = true;
downloadPdfBtn.textContent = '...';
const reportHtml = `
`;
const pdfTemplate = document.getElementById('pdf-template');
pdfTemplate.innerHTML = reportHtml;
pdfTemplate.classList.remove('invisible');
try {
const { jsPDF } = window.jspdf;
const canvas = await html2canvas(pdfTemplate.querySelector('.pdf-page'), { scale: 2 });
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth(), pdfHeight = (canvas.height * pdfWidth) / canvas.width;
pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight);
pdf.save(`About_Us_${inputsData.name.replace(/\s+/g, '_')}.pdf`);
} catch (e) { console.error('PDF Generation Error:', e); } finally {
downloadPdfBtn.disabled = false;
downloadPdfBtn.textContent = 'Download PDF';
pdfTemplate.classList.add('invisible');
pdfTemplate.innerHTML = '';
}
}
// --- EVENT LISTENERS ---
generateBtn.addEventListener('click', generateContent);
downloadPdfBtn.addEventListener('click', generatePdfReport);
});
Our Story
${generatedContent.our_story}
Our Mission
${generatedContent.our_mission}
What We Do
${generatedContent.what_we_do}
About Us: Company Story & Brand Narrative
For: ${inputsData.name}
Our Story
${generatedContent.our_story}
Our Mission
${generatedContent.our_mission}
What We Do
${generatedContent.what_we_do}
