Smart Office Communication Assistant
Compose Your Message
Select a Template
Meeting Request
A professional request to schedule a meeting.
Project Update
A concise update on the status of a project.
Out of Office
An automatic reply for when you are away.
Thank You
A simple note to express gratitude.
Review and Export
Subject: ${subject || 'Not set'}
${body || 'No message body.'}
`;
};
/**
* Generates and downloads a professional PDF of the message.
*/
const downloadPDF = () => {
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
const recipient = document.getElementById('recipient').value;
const subject = document.getElementById('subject').value;
const body = document.getElementById('messageBody').value;
doc.setFontSize(16);
doc.text(`Subject: ${subject}`, 14, 22);
doc.setFontSize(12);
doc.text(`To: ${recipient}`, 14, 32);
const splitBody = doc.splitTextToSize(body, 180);
doc.text(splitBody, 14, 42);
doc.save(`${subject.replace(/\s+/g, '_')}.pdf`);
};
// --- Event Listeners ---
prevBtn.addEventListener('click', () => changeTab(currentTab - 1));
nextBtn.addEventListener('click', () => changeTab(currentTab + 1));
pdfDownloadBtn.addEventListener('click', downloadPDF);
document.querySelectorAll('.template-card').forEach(card => {
card.addEventListener('click', () => {
const template = templates[card.dataset.template];
document.getElementById('subject').value = template.subject;
document.getElementById('messageBody').value = template.body;
changeTab(0); // Go back to compose tab
});
});
// --- Initial Setup ---
const initializeTool = () => {
updateNavButtons();
};
initializeTool();
});
