Workplace Anti-Discrimination Policy Generator

Specify who employees should report concerns to.

Federal US protected characteristics (race, color, religion, sex, national origin, age, disability, genetic information) are included by default.

${companyName} prohibits retaliation against any individual who reports discrimination or harassment in good faith, or who participates in an investigation of such reports. Retaliation is a serious violation of this policy and will be subject to disciplinary action, up to and including termination.

5. Disciplinary Action

Any employee found to have engaged in discrimination, harassment, or retaliation in violation of this policy will be subject to disciplinary action, up to and including termination of employment.

6. Policy Dissemination

This policy will be communicated to all employees and made readily available. All employees are expected to comply with this policy.

`; // Display the policy policyOutputDiv.innerHTML = policyHTML; policyOutputDiv.style.display = 'block'; // Enable download button downloadButton.disabled = false; } // --- Download PDF Function --- function downloadPDF() { if (policyOutputDiv.style.display === 'none' || !policyOutputDiv.innerHTML) { showError("Please generate the policy first."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', // portrait unit: 'pt', // points format: 'a4' // A4 paper size }); const companyName = companyNameInput.value.trim() || "Company"; // Fallback const pdfFileName = `${companyName.replace(/[^a-z0-9]/gi, '_')}_${pdfConfig.fileNamePrefix}.pdf`; const pageHeight = doc.internal.pageSize.height; const pageWidth = doc.internal.pageSize.width; const usableWidth = pageWidth - pdfConfig.margins.left - pdfConfig.margins.right; let currentY = pdfConfig.margins.top; // --- Helper function to add text and handle page breaks --- function addFormattedText(text, options) { doc.setFont(options.font || 'helvetica', options.fontStyle || 'normal'); doc.setFontSize(options.fontSize || pdfConfig.fontSizes.text); doc.setTextColor(options.color || '#000000'); const lines = doc.splitTextToSize(text, usableWidth); lines.forEach(line => { if (currentY + options.fontSize > pageHeight - pdfConfig.margins.bottom) { doc.addPage(); currentY = pdfConfig.margins.top; // Optionally add headers/footers on new pages here } doc.text(line, pdfConfig.margins.left, currentY); currentY += options.fontSize + (options.lineSpacing || pdfConfig.lineSpacing); }); // Add extra space after the block of text (e.g., after a paragraph) currentY += options.paragraphSpacing || 0; } // --- Add content to PDF --- // 1. Document Title addFormattedText(pdfConfig.title + ' for ' + companyName, { fontSize: pdfConfig.fontSizes.title, color: pdfConfig.themeColor, fontStyle: 'bold', lineSpacing: pdfConfig.lineSpacing * 1.5, // More spacing for title paragraphSpacing: pdfConfig.paragraphSpacing * 2 }); // 2. Parse HTML Content (Simplified Approach) // Get headings and paragraphs from the generated policy const policyElements = policyOutputDiv.querySelectorAll('h3, p, li'); policyElements.forEach(el => { let text = el.innerText.trim(); let options = { fontSize: pdfConfig.fontSizes.text, lineSpacing: pdfConfig.lineSpacing, paragraphSpacing: pdfConfig.paragraphSpacing, color: '#333333' // Default text color }; if (el.tagName === 'H3') { options.fontSize = pdfConfig.fontSizes.heading; options.fontStyle = 'bold'; options.color = pdfConfig.themeColor; // Use theme color for headings options.paragraphSpacing = pdfConfig.paragraphSpacing * 1.5; // More space after heading // Remove numbering like "1. " if present text = text.replace(/^\d+\.\s*/, ''); } else if (el.tagName === 'LI') { text = `- ${text}`; // Add bullet point options.paragraphSpacing = 1; // Less spacing for list items } if(text) { // Ensure text content exists addFormattedText(text, options); } }); // --- Save PDF --- doc.save(pdfFileName); } // --- Show Error Message --- function showError(message) { errorMessageDiv.textContent = message; errorMessageDiv.style.display = 'block'; policyOutputDiv.style.display = 'none'; // Hide output on error downloadButton.disabled = true; // Disable download on error } // --- Event Listeners --- generateButton.addEventListener('click', generatePolicy); downloadButton.addEventListener('click', downloadPDF); }); // End DOMContentLoaded
Scroll to Top