Log Work Session & Pace

Define/Select Task

Your Tasks:

    Log Work Session Details

    Recent Work Sessions

    DateTaskDurationPaceDifficultyEnergyFocusInt.Actions

    Pace Analysis & Insights

    Pacing Strategies & Action Planning

    Common Pacing Strategies

    My Pace Improvement Plan

    Settings

    Pace Score Calculation Weights (0-5)

    Adjust how much each factor influences the illustrative Pace Efficiency Score.

    Data Management

    ${s.desc}

    `; libEl.appendChild(card); }); document.getElementById('wpo-paceActionPlanNotes').value = wpo_paceActionPlan; } function wpo_saveActionPlanNotes() { wpo_paceActionPlan = document.getElementById('wpo-paceActionPlanNotes').value; wpo_saveData(); alert("Action plan notes saved!"); } // --- Settings Tab --- function wpo_loadSettingsToForm() { document.getElementById('wpo-weightJustRightPace').value = wpo_scoreWeights.justRightPace; document.getElementById('wpo-weightFocusLevel').value = wpo_scoreWeights.focusLevel; document.getElementById('wpo-weightInterruptions').value = wpo_scoreWeights.interruptions; } function wpo_saveScoreWeights() { wpo_scoreWeights.justRightPace = parseFloat(document.getElementById('wpo-weightJustRightPace').value) || 3; wpo_scoreWeights.focusLevel = parseFloat(document.getElementById('wpo-weightFocusLevel').value) || 2; wpo_scoreWeights.interruptions = parseFloat(document.getElementById('wpo-weightInterruptions').value) || 1; wpo_saveData(); alert("Score weights saved!"); } function wpo_clearAllTasks(){if(confirm("Clear ALL task definitions? Sessions logged against them will show 'Unknown Task'.")){wpo_definedTasks=[]; wpo_saveData(); wpo_initLogSessionTab(); alert("Task definitions cleared.");}} function wpo_clearAllSessions(){if(confirm("Clear ALL logged work sessions? This cannot be undone.")){wpo_workSessions=[]; wpo_saveData(); wpo_initLogSessionTab(); alert("All session logs cleared.");}} // --- PDF Download --- document.getElementById('wpo-downloadPdfBtn').onclick = async () => { const range = wpo_getReportDateRange(); const resultsArea = document.getElementById('wpo-analysisResultsArea'); if (!range || !resultsArea || resultsArea.style.display === 'none') { alert("Please generate an analysis first."); return; } const { jsPDF } = window.jspdf; const pdf = new jsPDF('p', 'mm', 'a4'); let currentY = 15; const margin = 15; const contentWidth = pdf.internal.pageSize.getWidth() - 2*margin; pdf.setFontSize(18); pdf.setTextColor('#FD7E14'); pdf.text("Work Pace Analysis Report", pdf.internal.pageSize.getWidth() / 2, currentY, { align: 'center' }); currentY += 8; pdf.setFontSize(10); pdf.setTextColor('#C65E0A'); const periodText = document.getElementById('wpo-analysisPeriodDisplay').textContent.replace('Analysis for: ',''); pdf.text(`Period: ${periodText}`, pdf.internal.pageSize.getWidth() / 2, currentY, { align: 'center'}); currentY += 10; pdf.setFontSize(11); pdf.setTextColor('#343A40'); pdf.text(`Total Work Time: ${document.getElementById('wpo-metricTotalTime').textContent}`, margin, currentY); currentY += 6; pdf.text(`Sessions Logged: ${document.getElementById('wpo-metricSessionsLogged').textContent}`, margin, currentY); currentY += 6; pdf.text(`Time at "Just Right" Pace: ${document.getElementById('wpo-metricJustRightPace').textContent}`, margin, currentY); currentY += 6; pdf.text(`Pace Efficiency Score: ${document.getElementById('wpo-metricPaceScore').textContent}/100`, margin, currentY); currentY += 8; // Charts const chartsToCapture = [ { canvasId: 'wpo-paceDistributionChart', title: "Pace Distribution (by Time)" }, { canvasId: 'wpo-interruptionsPaceChart', title: "Interruptions vs. Pace (Avg. Interruptions)" } ]; for (const chartInfo of chartsToCapture) { if (currentY > pdf.internal.pageSize.getHeight() - 65 ) { pdf.addPage(); currentY = margin; } const chartCanvas = document.getElementById(chartInfo.canvasId); const chartKey = Object.keys(wpo_charts).find(k => chartInfo.canvasId.toLowerCase().includes(k.toLowerCase())); const chartInstance = chartKey ? wpo_charts[chartKey] : null; if (chartInstance && chartInstance.data && chartInstance.data.datasets[0].data.some(d => parseFloat(d) > 0)) { pdf.setFontSize(12); pdf.setTextColor('#FD7E14'); pdf.text(chartInfo.title + ":", margin, currentY); currentY += 5; try { const chartImgData = chartCanvas.toDataURL('image/png', 1.0); const imgProps = pdf.getImageProperties(chartImgData); let pdfImgWidth = contentWidth * 0.8; let pdfImgHeight = (imgProps.height * pdfImgWidth) / imgProps.width; const maxChartHeight = 60; if (pdfImgHeight > maxChartHeight) { pdfImgHeight = maxChartHeight; pdfImgWidth = (imgProps.width * pdfImgHeight) / imgProps.height; } if (pdfImgWidth > contentWidth) { pdfImgWidth = contentWidth; pdfImgHeight = (imgProps.height * pdfImgWidth) / imgProps.width; if(pdfImgHeight > maxChartHeight) pdfImgHeight = maxChartHeight;} pdf.addImage(chartImgData, 'PNG', margin + (contentWidth - pdfImgWidth)/2 , currentY, pdfImgWidth, pdfImgHeight, undefined, 'FAST'); currentY += pdfImgHeight + 7; } catch(e) { console.error("PDF chart error for " + chartInfo.title, e); currentY +=5; } } } // Key Insights if (currentY > pdf.internal.pageSize.getHeight() - 30) { pdf.addPage(); currentY = margin; } pdf.setFontSize(12); pdf.setTextColor('#FD7E14'); pdf.text("Key Pace Insights:", margin, currentY); currentY += 6; pdf.setFontSize(9); pdf.setTextColor('#343A40'); const insightsItems = document.getElementById('wpo-paceInsightsList').getElementsByTagName('li'); if (insightsItems.length > 0 && !insightsItems[0].textContent.includes("logging sessions")) { Array.from(insightsItems).slice(0,5).forEach(item => { // Max 5 insights if (currentY > pdf.internal.pageSize.getHeight() - 10) { pdf.addPage(); currentY = margin; } const itemLines = pdf.splitTextToSize(`- ${item.textContent}`, contentWidth - 5); pdf.text(itemLines, margin + 5, currentY); currentY += (itemLines.length * 4) + 1; }); } else { pdf.text("- No specific insights for this period.", margin+5, currentY); currentY +=5;} currentY += 3; // Action Plan Notes if (wpo_paceActionPlan) { if (currentY > pdf.internal.pageSize.getHeight() - 30) { pdf.addPage(); currentY = margin; } pdf.setFontSize(12); pdf.setTextColor('#FD7E14'); pdf.text("My Pace Improvement Plan Notes:", margin, currentY); currentY += 6; pdf.setFontSize(9); pdf.setTextColor('#343A40'); const planLines = pdf.splitTextToSize(wpo_paceActionPlan, contentWidth); pdf.text(planLines, margin, currentY); } pdf.save(`Work_Pace_Analysis_${range.start}_to_${range.end}.pdf`); }; // --- Initial Load --- document.addEventListener('DOMContentLoaded', () => { wpo_loadSettingsToForm(); // Load settings first for score calculation defaults wpo_openTab(null, wpo_tabs[0]); const firstTabButton = document.querySelector(`.wpo-tab-button[onclick*="'${wpo_tabs[0]}'"]`); if (firstTabButton) firstTabButton.classList.add('active'); else console.error("First tab button not found for initial activation."); wpo_updateNavButtons(); });
    Scroll to Top