Community Dashboard

Community Dashboard

Population

15,750

Median Household Income

$72,300

Local Businesses

128

Announcements

Annual Summer Festival

Join us on August 15th at Central Park for a day of fun, food, and music!

Road Closure Notice

Main Street will be closed between 1st and 3rd Ave on July 20th for repaving.

Upcoming Events

Date Event Location
July 25, 2025 Farmer's Market Town Square
August 5, 2025 Outdoor Movie Night Community Park

${escapeHTML(content)}

`; } }); } // Update Events const eventItems = document.querySelectorAll('#manage-events-list .event-item'); const eventsTableBody = document.getElementById('events-table-body'); if (eventsTableBody) { eventsTableBody.innerHTML = ''; // Clear existing events eventItems.forEach(item => { const date = item.querySelector('.input-event-date').value; const name = item.querySelector('.input-event-name').value; const location = item.querySelector('.input-event-location').value; if (date && name && location) { eventsTableBody.innerHTML += ` ${escapeHTML(date)} ${escapeHTML(name)} ${escapeHTML(location)} `; } }); } // Switch back to the dashboard to show the updates switchTab('dashboard'); alert('Dashboard has been updated!'); // Using a simple alert for feedback }; // Function to handle PDF download window.downloadPDF = async function() { const { jsPDF } = window.jspdf; const dashboardContent = document.getElementById('dashboard-content-to-print'); if (!dashboardContent) return; // Use html2canvas to capture the dashboard content as an image const canvas = await html2canvas(dashboardContent, { scale: 2, // Improve resolution useCORS: true }); const imgData = canvas.toDataURL('image/png'); // Create a new PDF document const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgWidth = canvas.width; const imgHeight = canvas.height; const ratio = imgWidth / imgHeight; let finalImgWidth = pdfWidth - 20; // with margin let finalImgHeight = finalImgWidth / ratio; // Check if the image height exceeds the page height if (finalImgHeight > pdfHeight - 20) { finalImgHeight = pdfHeight - 20; finalImgWidth = finalImgHeight * ratio; } const x = (pdfWidth - finalImgWidth) / 2; const y = 10; // Top margin pdf.addImage(imgData, 'PNG', x, y, finalImgWidth, finalImgHeight); pdf.save('Community-Dashboard-Report.pdf'); }; // --- UTILITY FUNCTIONS --- // Simple HTML escaping function to prevent XSS function escapeHTML(str) { const p = document.createElement('p'); p.appendChild(document.createTextNode(str)); return p.innerHTML; } // --- INITIALIZATION --- switchTab(currentTab); // Set the initial tab view });
Scroll to Top