User Manual Outline/Template Generator
Structure software documentation, technical guides, or operational manuals.
Manual Metadata
Preliminary/Appendix Items
Comma separated list. Appears before Chapter 1.
Comma separated list. Appears after final chapter.
Add New Chapter / Section
Current Outline Structure
User Manual Outline
Version: | Audience:
1. Preliminary Sections
2. Core Content (Chapters)
3. Appendix
No content added yet. Start by defining a Chapter Title above.
'; return; } chapters.forEach((chapter, chapterIndex) => { const chapterNum = chapterIndex + 1; // Render Chapter const chapterDiv = document.createElement('div'); chapterDiv.className = 'umog-list-item bg-gray-100 border-l-4 border-blue-500'; chapterDiv.innerHTML = ` ${chapterNum}. ${escapeHtml(chapter.title)} `; managerDiv.appendChild(chapterDiv); // Get Sections for this Chapter const sections = outlineStructure.filter(item => item.type === 'section' && item.chapterId === chapter.id); sections.forEach((section, sectionIndex) => { const sectionNum = `${chapterNum}.${sectionIndex + 1}`; // Render Section const sectionDiv = document.createElement('div'); sectionDiv.className = 'umog-list-item ml-6 bg-white border-l-2 border-gray-300'; sectionDiv.innerHTML = ` ${sectionNum} - ${escapeHtml(section.title)} `; managerDiv.appendChild(sectionDiv); // Get Subsections for this Section const subsections = outlineStructure.filter(item => item.type === 'subsection' && item.sectionIndex === section.id); subsections.forEach((subsection, subIndex) => { const subNum = `${sectionNum}.${subIndex + 1}`; // Render Subsection const subDiv = document.createElement('div'); subDiv.className = 'umog-list-item ml-12 bg-gray-50'; subDiv.innerHTML = ` ${subNum} - ${escapeHtml(subsection.title)} `; managerDiv.appendChild(subDiv); }); }); }); // Ensure IDs reflect the numbering in the final structure umogRenumberOutline(); } // Renumbering function to fix chapter/section numbering in titles function umogRenumberOutline() { const chapters = outlineStructure.filter(item => item.type === 'chapter').sort((a,b) => a.id - b.id); chapters.forEach((chapter, chapterIndex) => { const chapterNum = chapterIndex + 1; const sections = outlineStructure.filter(item => item.type === 'section' && item.chapterId === chapter.id).sort((a,b) => a.id - b.id); sections.forEach((section, sectionIndex) => { const sectionNum = sectionIndex + 1; const newSectionTitle = `${chapterNum}.${sectionNum} - ${section.title.split('-').slice(1).join('-').trim()}`; section.title = newSectionTitle; const subsections = outlineStructure.filter(item => item.type === 'subsection' && item.sectionIndex === section.id).sort((a,b) => a.id - b.id); subsections.forEach((subsection, subIndex) => { const subNum = subIndex + 1; const newSubTitle = `${chapterNum}.${sectionNum}.${subNum} - ${subsection.title.split('-').slice(1).join('-').trim()}`; subsection.title = newSubTitle; }); }); }); } // --- Preview Generation (Tab 3) --- window.umogUpdatePreview = function() { // Renumber one last time before display umogRenumberOutline(); // Metadata document.getElementById('disp-product-name').textContent = document.getElementById('umog-product-name').value || "Manual"; document.getElementById('disp-version').textContent = document.getElementById('umog-version').value || "N/A"; document.getElementById('disp-audience').textContent = document.getElementById('umog-audience').value || "N/A"; const preSections = (document.getElementById('umog-pre-sections').value || "Introduction, Safety").split(',').map(s => s.trim()).filter(s => s); const appSections = (document.getElementById('umog-app-sections').value || "Troubleshooting, Index").split(',').map(s => s.trim()).filter(s => s); const dispPreliminary = document.getElementById('disp-preliminary'); const dispCoreContent = document.getElementById('disp-core-content'); const dispAppendix = document.getElementById('disp-appendix'); // Render Preliminary dispPreliminary.innerHTML = preSections.map((s, i) => `${(i === 0 ? "i" : (i === 1 ? "ii" : (i === 2 ? "iii" : s)))}. ${escapeHtml(s)}
`
).join('');
// Render Core Content
dispCoreContent.innerHTML = '';
const chapters = outlineStructure.filter(item => item.type === 'chapter').sort((a,b) => a.id - b.id);
chapters.forEach((chapter, chapterIndex) => {
const chapterNum = chapterIndex + 1;
// Chapter Title
dispCoreContent.innerHTML += `${chapterNum}. ${escapeHtml(chapter.title)}
`;
const sections = outlineStructure.filter(item => item.type === 'section' && item.chapterId === chapter.id);
sections.forEach(section => {
// Section Title
dispCoreContent.innerHTML += `${escapeHtml(section.title)}
`;
const subsections = outlineStructure.filter(item => item.type === 'subsection' && item.sectionIndex === section.id);
subsections.forEach(subsection => {
// Subsection Title
dispCoreContent.innerHTML += `${escapeHtml(subsection.title)}
`;
});
});
dispCoreContent.innerHTML += `Appendix ${String.fromCharCode(65 + i)}: ${escapeHtml(s)}
`
).join('');
};
// --- PDF Download ---
window.umogDownloadPDF = function() {
// Ensure preview is up to date
umogUpdatePreview();
const element = document.getElementById('umog-print-area');
const productName = document.getElementById('umog-product-name').value || "Manual_Outline";
document.body.classList.add('umog-generating-pdf');
const opt = {
margin: [0.75, 0.75],
filename: `${productName.replace(/\s+/g, '_')}_Outline.pdf`,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2, useCORS: true },
jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
};
html2pdf().set(opt).from(element).save().then(() => {
document.body.classList.remove('umog-generating-pdf');
});
};
// Utility: HTML Escape
function escapeHtml(text) {
if (!text) return '';
return text.replace(/[&<>"']/g, function(m) {
switch (m) {
case '&': return '&';
case '<': return '<';
case '>': return '>';
case '"': return '"';
case "'": return ''';
default: return m;
}
});
}
