${data.senderName} ${data.senderAddress}
VIA CERTIFIED MAIL
${data.recipientName} ${data.recipientAddress}
Date: ${new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}
Re: Cease and Desist from ${data.infringementType}
Dear ${data.recipientName},
This letter is to demand that you immediately cease and desist from your unlawful ${data.infringementType}. We have determined that on or about ${data.infringementDate}, you engaged in the following infringing activity: ${data.infringementDescription}.
We demand that you immediately cease these activities and provide written assurance within ten (10) days that you will comply. Failure to do so will result in us pursuing all available legal remedies.
Sincerely,
${data.senderName}
`
},
promissoryNote: {
name: 'Promissory Note',
steps: [
{ id: 'parties', title: 'Lender & Borrower' },
{ id: 'terms', title: 'Loan Terms' },
{ id: 'preview', title: 'Preview & Download' }
],
generatePreviewText: (data) => `
PROMISSORY NOTE
For value received, ${data.borrowerName} ("Borrower") promises to pay to ${data.lenderName} ("Lender") the principal sum of $${parseFloat(data.principalAmount || 0).toFixed(2)}, together with interest thereon at a rate of ${data.interestRate}% per annum.
1. PAYMENT. This note shall be due and payable in full on or before ${data.dueDate}.
2. GOVERNING LAW. This Note shall be governed by the laws of the State of ${data.governingState}.
IN WITNESS WHEREOF, the Borrower has executed this Promissory Note as of the date first written above.
_________________________
${data.borrowerName}
`
}
},
init() {
this.cacheDom();
this.render();
this.bindEvents();
},
cacheDom() {
this.dom = {
navList: document.getElementById('nav-list'),
contentArea: document.getElementById('content-area'),
prevBtn: document.getElementById('prev-btn'),
nextBtn: document.getElementById('next-btn'),
};
},
bindEvents() {
this.dom.nextBtn.addEventListener('click', this.nextStep.bind(this));
this.dom.prevBtn.addEventListener('click', this.prevStep.bind(this));
},
collectData() {
const inputs = this.dom.contentArea.querySelectorAll('input, textarea, select');
inputs.forEach(input => {
this.formData[input.id] = input.value;
});
},
render() {
this.dom.contentArea.innerHTML = '';
if (!this.documentType) {
this.renderDocSelection();
} else {
this.renderNav();
this.renderStepContent();
}
this.updateButtons();
},
renderDocSelection() {
this.dom.navList.innerHTML = `
Select Document `;
let selectionHTML = `
Choose a Document Type `;
for (const key in this.templates) {
selectionHTML += `
${this.templates[key].name}
`;
}
selectionHTML += `
`;
this.dom.contentArea.innerHTML = selectionHTML;
},
renderNav() {
const steps = this.templates[this.documentType].steps;
this.dom.navList.innerHTML = steps.map((step, index) => `
${step.title}
`).join('');
},
renderStepContent() {
const step = this.templates[this.documentType].steps[this.currentStep];
let contentHTML = `
${step.title} `;
switch (`${this.documentType}-${step.id}`) {
case 'ceaseAndDesist-sender':
contentHTML += `
`;
break;
case 'ceaseAndDesist-recipient':
contentHTML += `
`;
break;
case 'ceaseAndDesist-infringement':
contentHTML += `
`;
break;
case 'promissoryNote-parties':
contentHTML += `
`;
break;
case 'promissoryNote-terms':
contentHTML += `
`;
break;
case 'ceaseAndDesist-preview':
case 'promissoryNote-preview':
contentHTML += `
${this.templates[this.documentType].generatePreviewText(this.formData)}
Download as PDF
`;
document.getElementById('navigation-buttons').style.display = 'none'; // Hide nav buttons on preview
break;
}
this.dom.contentArea.innerHTML = contentHTML;
// Re-populate form data for current step
for (const key in this.formData) {
const el = document.getElementById(key);
if (el) el.value = this.formData[key];
}
// Re-bind PDF button if it exists
const pdfBtn = document.getElementById('download-pdf-btn');
if (pdfBtn) pdfBtn.addEventListener('click', this.generatePdf.bind(this));
},
updateButtons() {
this.dom.prevBtn.classList.toggle('hidden', this.currentStep === 0 && this.documentType === null);
this.dom.nextBtn.textContent = (this.documentType && this.currentStep === this.templates[this.documentType].steps.length - 2) ? 'Generate Preview' : 'Next';
},
nextStep() {
if (!this.documentType) {
const selected = document.querySelector('input[name="docType"]:checked');
if (selected) {
this.documentType = selected.value;
this.loadSampleData();
this.render();
} else {
alert('Please select a document type.');
}
return;
}
this.collectData();
const totalSteps = this.templates[this.documentType].steps.length;
if (this.currentStep < totalSteps - 1) {
this.currentStep++;
document.getElementById('navigation-buttons').style.display = 'flex';
this.render();
}
},
prevStep() {
this.collectData();
if (this.currentStep > 0) {
this.currentStep--;
document.getElementById('navigation-buttons').style.display = 'flex';
this.render();
} else {
this.documentType = null;
this.formData = {};
this.render();
}
},
loadSampleData() {
if (this.documentType === 'ceaseAndDesist') {
this.formData = {
senderName: 'John Doe',
senderAddress: '123 Main St, Anytown, USA 12345',
recipientName: 'Jane Smith',
recipientAddress: '456 Oak Ave, Otherville, USA 54321',
infringementType: 'Trademark Infringement',
infringementDate: '2025-08-15',
infringementDescription: 'The unauthorized use of our registered trademark "InnovateLogo" on your website and marketing materials.'
};
}
},
generatePdf() {
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({ unit: 'pt', format: 'a4' });
const preview = document.getElementById('preview-area');
const text = preview.innerText;
pdf.setFont('times', 'normal');
pdf.setFontSize(12);
const margin = 72; // 1 inch
const pageWidth = pdf.internal.pageSize.getWidth();
const textLines = pdf.splitTextToSize(text, pageWidth - (2 * margin));
pdf.text(textLines, margin, margin);
pdf.save(`${this.templates[this.documentType].name.replace(/\s+/g, '-')}.pdf`);
}
};
app.init();
});