`;
calendarDiv.appendChild(card);
});
// Move to plan tab
const tabs = document.querySelectorAll('.sport-tab-btn');
tabs[1].click();
}
/* --- PDF GENERATION --- */
function sportGeneratePDF() {
const name = document.getElementById('ath-name').value || "Athlete";
const level = document.getElementById('ath-level').value;
const goal = document.getElementById('ath-goal').value;
const days = document.getElementById('ath-days').value;
const warmup = document.getElementById('cfg-warmup').value;
const phase = document.getElementById('cfg-phase').value;
// Re-generate the week plan data for the PDF table
let weekPlan = sportTemplates[goal][days] || sportTemplates[goal]["3"];
const dayNames = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
let rowsHtml = "";
weekPlan.forEach((activity, index) => {
const details = sportGetActivityDetails(activity);
rowsHtml += `
${dayNames[index]}
${activity}
${details.type}
${details.rpe}
`;
});
const content = `
`;
const element = document.createElement('div');
element.innerHTML = content;
const opt = {
margin: 0.5,
filename: `TrainingPlan_${name.replace(/\s+/g, '_')}.pdf`,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
};
if (window.html2pdf) {
html2pdf().set(opt).from(element).save();
} else {
alert("PDF Library is loading. Please try again in 2 seconds.");
}
}
Sports Science Training Plan
Periodized Microcycle Report
| Athlete: ${name} | Level: ${level} |
| Goal: ${goal} | Phase: ${phase} |
Training Schedule
| Day | Session Focus | Type | Intensity (RPE) |
|---|
Warm-Up Protocol:
${warmup}
${warmup}
Generated via Sports Science Plan Generator. Consult a physician before beginning any exercise program.
