School Event Announcement Writer
Configure event details in the Data Configuration tab and click "Generate Announcement."
Copied to clipboard!
Error: Please enter the Event Name and Purpose.
'; return; } var announcementHtml = `${data.name.toUpperCase()}
A Message for ${data.audience}
We are thrilled to announce our upcoming event, ${data.name}!
Event Summary
${data.purpose}
Key Details
- Date: ${data.date}
- Time: ${data.time}
- Location: ${data.location}
Logistical Notes
${data.logistics}
Required Items
${parseItems(data.requiredItems)}Contact Information
If you have any questions, please contact: ${data.contact}
`; announcementOutputDiv.innerHTML = announcementHtml; }; generateBtn.addEventListener("click", function() { generateAnnouncement(); showTab(1); // Switch to Dashboard }); // --- Utility: Show Toast Message --- var toastTimer; var showToast = function(message) { clearTimeout(toastTimer); copyToast.textContent = message; copyToast.style.display = "block"; toastTimer = setTimeout(function() { copyToast.style.display = "none"; }, 2000); }; // --- Copy Text --- copyBtn.addEventListener("click", function() { var textToCopy = announcementOutputDiv.innerText; var tempTextArea = document.createElement("textarea"); tempTextArea.value = textToCopy; document.body.appendChild(tempTextArea); tempTextArea.select(); try { document.execCommand("copy"); showToast("Copied to clipboard!"); } catch (err) { console.error("SEA Copy Error:", err); showToast("Failed to copy."); } document.body.removeChild(tempTextArea); }); // --- PDF Download --- pdfBtn.addEventListener("click", function() { var jsPDF = window.jspdf.jsPDF; var eventSlug = eventNameInput.value.replace(/[^a-zA-Z0-9\s]/g, '').replace(/\s/g, '_') || 'Event'; var fileName = `${eventSlug}_Announcement.pdf`; html2canvas(exportArea, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }).then(function(canvas) { var imgData = canvas.toDataURL('image/png'); var doc = new jsPDF({ orientation: 'p', unit: 'pt', format: 'letter' }); var pdfWidth = doc.internal.pageSize.getWidth(); var pdfHeight = doc.internal.pageSize.getHeight(); var imgProps = doc.getImageProperties(imgData); var imgWidth = imgProps.width; var imgHeight = imgProps.height; var margin = 40; var usableWidth = pdfWidth - (2 * margin); var ratio = usableWidth / imgWidth; var scaledHeight = imgHeight * ratio; // Handle multi-page if content exceeds page height if (scaledHeight > pdfHeight - (2 * margin)) { var pageHeight = pdfHeight - (2 * margin); var heightLeft = scaledHeight; var position = 0; while (heightLeft > 0) { doc.addImage(imgData, 'PNG', margin, position + margin, usableWidth, scaledHeight); heightLeft -= pageHeight; position -= pageHeight; if (heightLeft > 0) { doc.addPage(); } } } else { // Single page doc.addImage(imgData, 'PNG', margin, margin, usableWidth, scaledHeight); } doc.save(fileName); }).catch(function(err) { console.error("SEA PDF Error:", err); // alert("An error occurred while generating the PDF."); // Per spec }); }); // --- Initial Load --- generateAnnouncement(); // Generate with defaults showTab(0); // Start on Config tab });