After-Work Hours Usage Optimizer

After-Work Hours Usage Optimizer

Your Available After-Work Hours

Weekdays

Weekends

Weekly Time Allocation Goals (Hours per Week)

Custom Categories

Please define your availability and goals in the first tab, then click "Generate Summary & View Report".

`; awhOpenTab(null, 'awh-summary-report'); awhUpdateNavButtons(); return; } const allocatedCategories = []; let totalAllocatedHours = 0; // Predefined categories awhPredefinedCategoriesList.forEach(cat => { const hoursInput = document.getElementById(`awh-cat-${cat.id}`); if (hoursInput) { const hours = parseFloat(hoursInput.value) || 0; if (hours > 0) { // Only include if hours are allocated allocatedCategories.push({ name: cat.name, hours: hours }); totalAllocatedHours += hours; } } }); // Custom categories for (let i = 1; i <= awhCustomCategoryCounter; i++) { const nameInput = document.getElementById(`awh-custom-cat-name-${i}`); const hoursInput = document.getElementById(`awh-custom-cat-hours-${i}`); if (nameInput && hoursInput) { // Check if row still exists const name = nameInput.value.trim(); const hours = parseFloat(hoursInput.value) || 0; if (name && hours > 0) { allocatedCategories.push({ name: name, hours: hours }); totalAllocatedHours += hours; } } } const balanceHours = awhTotalAvailableWeeklyHours - totalAllocatedHours; let optimizationMessage = ""; if (balanceHours > 0) { optimizationMessage = `You have ${balanceHours.toFixed(1)} hours unallocated. Consider assigning this time to your goals or adding new ones!`; } else if (balanceHours < 0) { optimizationMessage = `You are over-allocated by ${Math.abs(balanceHours).toFixed(1)} hours. Review your allocations to fit your available time.`; } else if (totalAllocatedHours > 0) { optimizationMessage = "Great job! Your allocated time perfectly matches your available after-work hours."; } else { optimizationMessage = "You haven't allocated any time to your goals yet. Start by setting some targets!"; } let reportHTML = `

Your After-Work Hours Plan

Available Time Summary

Total Available Personal Hours/Week: ${awhTotalAvailableWeeklyHours.toFixed(1)} hours
Weekday Schedule: ${document.getElementById('awh-num-weekdays').value} days, from ${document.getElementById('awh-weekday-start').value || 'N/A'} to ${document.getElementById('awh-weekday-end').value || 'N/A'}
Weekend Hours: Saturday: ${document.getElementById('awh-saturday-hours').value}h, Sunday: ${document.getElementById('awh-sunday-hours').value}h

Time Allocation Goals

`; if (allocatedCategories.length > 0) { reportHTML += ` `; allocatedCategories.forEach(cat => { const percentage = totalAllocatedHours > 0 ? ((cat.hours / totalAllocatedHours) * 100).toFixed(1) : 0; reportHTML += ` `; }); reportHTML += `
Category / Activity Planned Hours/Week % of Total Allocated
${cat.name} ${cat.hours.toFixed(1)} ${percentage}%
Total Allocated Hours ${totalAllocatedHours.toFixed(1)} 100%
`; } else { reportHTML += "

No time allocated to specific goals yet.

"; } reportHTML += `
`; reportHTML += `

Optimization Summary

Time Balance (Available - Planned): ${balanceHours.toFixed(1)} hours
Recommendation: ${optimizationMessage}
`; document.getElementById('awh-report-content-display').innerHTML = reportHTML; awhOpenTab(null, 'awh-summary-report'); awhUpdateNavButtons(); } function awhDownloadPDF() { const reportContentElement = document.getElementById('awh-report-content-display'); if (reportContentElement.innerHTML.includes("Please define your availability")) { alert("Please generate a report first before downloading the PDF."); return; } const pdfContentClone = reportContentElement.cloneNode(true); const pdfContainer = document.getElementById('awh-report-content-for-pdf'); pdfContainer.innerHTML = ''; pdfContainer.appendChild(pdfContentClone); const opt = { margin: [0.5, 0.5, 0.5, 0.5], // inches filename: 'After_Work_Hours_Plan.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true, logging: false }, jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }, pagebreak: { mode: ['avoid-all', 'css', 'legacy'] } }; html2pdf().from(pdfContainer).set(opt).save().then(() => { pdfContainer.innerHTML = ''; }).catch(err => { console.error("Error generating PDF:", err); pdfContainer.innerHTML = ''; alert("An error occurred while generating the PDF."); }); } // Initialize document.addEventListener('DOMContentLoaded', () => { awhPopulatePredefinedCategories(); awhAddCustomCategoryRow(); // Add one empty custom category row to start awhUpdateNavButtons(); awhOpenTab(null, 'awh-define-time'); // Ensure correct tab is active visually });
Scroll to Top