Heart (Feeling):
${data.heart}
Hands (Willing):
${data.hands}
`;
// 3. Daily Schedule Table
html += `
Daily Lesson Content Structure
| Day |
Content Focus |
Rhythmic Part (Review) |
Artistic Work (Main Lesson Book) |
`;
for (let i = 1; i <= data.duration; i++) {
const topic = content[`day-${i}`] || 'TBD';
let rhythmic = 'Review of previous day\'s story';
let artistic = 'Drawing/writing the new material';
if (i === 1) {
rhythmic = 'Initial verse/greeting';
} else if (i === data.duration) {
artistic = 'Final coloring & block summary';
}
html += `
| ${i} |
${topic} |
${rhythmic} |
${artistic} |
`;
}
html += `
`;
container.innerHTML = html;
}
function mlpgLoadExample() {
if(!confirm("Overwrite current data with an example Ancient History block?")) return;
document.getElementById('inp-subject').value = "Ancient Civilizations (Grade 5)";
document.getElementById('inp-teacher').value = "Ms. J. Harper / Grade 5";
document.getElementById('inp-duration').value = "18";
document.getElementById('inp-head').value = "Understand the chronological order and geographic location of the four great river civilizations (Mesopotamia, Egypt, India, Greece). Grasp the significance of the invention of writing (cuneiform).";
document.getElementById('inp-heart').value = "Develop a feeling for the unique cultural contributions of each civilization. Cultivate reverence for the mystery of Egyptian pyramids and the early morality of Greek mythology.";
document.getElementById('inp-hands').value = "Practice careful copperplate writing and geometric forms. Learn simple weaving or knot-tying (practical connection to ancient crafts). Create accurate colored maps in the main lesson book.";
mlpgGenerateContentRows();
// Fill in example content for the first few days
document.getElementById('content-day-1').value = "Introduction: The four rivers, the turning point from pre-history.";
document.getElementById('content-day-2').value = "Mesopotamia: The Tigris and Euphrates, the myth of Gilgamesh.";
document.getElementById('content-day-3').value = "Cuneiform writing, early laws (Hammurabi's Code).";
document.getElementById('content-day-4').value = "Egypt: The Nile, Pharaohs and the structure of society.";
document.getElementById('content-day-5').value = "The building of the Great Pyramid and the mystery of the Sphinx.";
document.getElementById('content-day-6').value = "Hieroglyphics and the Book of the Dead.";
mlpgRenderPreview();
mlpgSwitchTab('preview');
}
// --- PDF Generation ---
function mlpgGeneratePDF() {
mlpgRenderPreview(); // Final render check
const data = mlpgGetData();
const { jsPDF } = window.jspdf;
const doc = new jsPDF('l', 'mm', 'a4'); // Landscape for the wide table
const waldorfRed = [184, 60, 0];
const waldorfGreen = [5, 150, 105];
const headerBg = [248, 250, 252];
let y = 20;
// 1. Header
doc.setFillColor(waldorfRed[0], waldorfRed[1], waldorfRed[2]);
doc.rect(0, 0, 297, 20, 'F');
doc.setTextColor(255, 255, 255);
doc.setFontSize(18);
doc.text(`Main Lesson Block Plan: ${data.subject}`, 14, 14);
y = 30;
// 2. Metadata & Goals (Structured Text)
doc.setFontSize(10);
doc.setTextColor(0, 0, 0);
doc.setFont("helvetica", "normal");
doc.text(`Teacher/Class: ${data.teacher}`, 14, y);
doc.text(`Duration: ${data.duration} Days`, 140, y);
y += 8;
// Goals Section
const goalsY = y;
const paddingX = 5;
const goalWidth = (297 - 30) / 3;
doc.setFillColor(245, 245, 245);
doc.rect(14, goalsY, goalWidth, 30, 'F');
doc.rect(14 + goalWidth, goalsY, goalWidth, 30, 'F');
doc.rect(14 + goalWidth * 2, goalsY, goalWidth, 30, 'F');
doc.setFontSize(10);
doc.setFont("helvetica", "bold");
doc.setTextColor(waldorfRed[0], waldorfRed[1], waldorfRed[2]);
doc.text("HEAD (Thinking):", 14 + paddingX, goalsY + 5);
doc.text("HEART (Feeling):", 14 + goalWidth + paddingX, goalsY + 5);
doc.text("HANDS (Willing):", 14 + goalWidth * 2 + paddingX, goalsY + 5);
doc.setFontSize(8);
doc.setFont("times", "normal");
doc.setTextColor(50, 50, 50);
let goalsYContent = goalsY + 10;
doc.text(doc.splitTextToSize(data.head, goalWidth - 5), 14 + paddingX, goalsYContent);
doc.text(doc.splitTextToSize(data.heart, goalWidth - 5), 14 + goalWidth + paddingX, goalsYContent);
doc.text(doc.splitTextToSize(data.hands, goalWidth - 5), 14 + goalWidth * 2 + paddingX, goalsYContent);
y = goalsY + 35;
// 3. Daily Schedule Table
doc.setFontSize(12);
doc.setFont("helvetica", "bold");
doc.setTextColor(waldorfGreen[0], waldorfGreen[1], waldorfGreen[2]);
doc.text("Daily Lesson Content and Structure", 14, y);
y += 5;
const tableBody = [];
for (let i = 1; i <= data.duration; i++) {
const topic = data.content[`day-${i}`] || 'TBD';
const rhythmic = i === 1 ? 'Initial verse/greeting' : 'Review of previous day\'s story';
const artistic = i === data.duration ? 'Final coloring & block summary' : 'Drawing/writing the new material';
tableBody.push([
i,
topic,
rhythmic,
artistic
]);
}
doc.autoTable({
startY: y,
head: [['Day', 'Content Focus (New Material)', 'Rhythmic Part (Review/Verse)', 'Artistic Work (Main Lesson Book)']],
body: tableBody,
theme: 'grid',
headStyles: { fillColor: [240, 240, 240], textColor: [50, 50, 50], fontSize: 9 },
styles: { fontSize: 8.5, cellPadding: 2, overflow: 'linebreak' },
columnStyles: {
0: { cellWidth: 10, fontStyle: 'bold', halign: 'center', fillColor: headerBg },
1: { cellWidth: 100, fontStyle: 'bold' },
2: { cellWidth: 70 },
3: { cellWidth: 'auto' }
}
});
doc.save(`ML_Block_Plan_${data.subject.replace(/\s+/g, '_')}.pdf`);
}