Personalized Work Efficiency Booster

Personalized Work Efficiency Booster

Session Goal & Duration

Choose Your Efficiency Strategy

Active Session

Session Goal(s):

    Chosen Strategy:

    Quick Distraction Log

    Distractions Logged: 0

      Session Review

      Goal Completion:

        Strategy Effectiveness

        Strategy Used:

        Personal Metrics & Reflections

        Distractions Logged: 0

        Efficiency Booster Insights

        • Complete the review to see insights.

        Work: ${pwebSession.strategyConfig.work} min, Break: ${pwebSession.strategyConfig.break} min

        `; pomodoroAreaEl.style.display = 'block'; pwebIsPomodoroWorkTime = true; pwebPomodoroCycleCount = 0; pwebSetTimer(pwebSession.strategyConfig.work * 60); document.getElementById('pweb-active-current-interval').textContent = `Current Interval: Work (Cycle ${pwebPomodoroCycleCount + 1})`; document.getElementById('pweb-timer-startpause').textContent = "Start"; break; case 'eat_the_frog': strategyDetailsEl.innerHTML = `

        Your "Frog": ${pwebSession.strategyConfig.frogTask}

        Focus on completing this first!

        `; break; case 'distraction_management': strategyDetailsEl.innerHTML = `

        Focus: Actively manage distractions.

        ${pwebSession.strategyConfig.distraction1 ? `

        1. ${pwebSession.strategyConfig.distraction1}

        `:''} ${pwebSession.strategyConfig.distraction2 ? `

        2. ${pwebSession.strategyConfig.distraction2}

        `:''}`; break; case 'custom': strategyDetailsEl.innerHTML = `

        Your Focus: ${pwebSession.strategyConfig.description}

        `; break; default: strategyNameEl.textContent = "None / Custom (if not specified)"; break; } document.getElementById('pweb-distraction-count').textContent = pwebSession.distractions.length; document.getElementById('pweb-distraction-log-list').innerHTML = '
      • No distractions logged yet for this session.
      • '; } function pwebToggleActiveGoal(goalId) { const goal = pwebSession.goals.find(g => g.id === goalId); if (goal) { const checkbox = document.getElementById(`active-check-${goal.id}`); goal.completed = checkbox.checked; // Optionally re-render or just style the label const label = checkbox.nextElementSibling; if (label) label.style.textDecoration = goal.completed ? 'line-through' : 'none'; } } function pwebLogDistraction() { const note = document.getElementById('pweb-distraction-note').value.trim(); pwebSession.distractions.push({ time: new Date(), note: note }); document.getElementById('pweb-distraction-count').textContent = pwebSession.distractions.length; const logListEl = document.getElementById('pweb-distraction-log-list'); if (pwebSession.distractions.length === 1 && logListEl.firstChild.textContent.includes("No distractions")) { logListEl.innerHTML = ''; // Clear "No distractions" message } const li = document.createElement('li'); const timeStr = new Date().toLocaleTimeString([], {hour:'2-digit', minute:'2-digit'}); li.textContent = `[${timeStr}] ${note || "Distraction logged"}`; logListEl.appendChild(li); document.getElementById('pweb-distraction-note').value = ''; } // Pomodoro Timer Logic function pwebUpdateTimerDisplay() { const minutes = Math.floor(pwebTimerSecondsRemaining / 60); const seconds = pwebTimerSecondsRemaining % 60; document.getElementById('pweb-active-timer-display').textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; } function pwebSetTimer(seconds) { pwebTimerSecondsRemaining = seconds; pwebUpdateTimerDisplay(); } function pwebToggleTimer() { const button = document.getElementById('pweb-timer-startpause'); if (pwebTimerInterval) { // Timer is running, so pause clearInterval(pwebTimerInterval); pwebTimerInterval = null; button.textContent = "Resume"; } else { // Timer is paused or not started if (pwebTimerSecondsRemaining <=0) { // If timer ended, reset to current block type pwebIsPomodoroWorkTime ? pwebSetTimer(pwebSession.strategyConfig.work * 60) : pwebSetTimer(pwebSession.strategyConfig.break * 60); } pwebTimerInterval = setInterval(() => { pwebTimerSecondsRemaining--; pwebUpdateTimerDisplay(); if (pwebTimerSecondsRemaining <= 0) { pwebClearTimer(); button.textContent = "Start Next"; // Or just "Start" if auto-advancing (not implemented here) // Alert or visual cue for block end - not doing audio document.getElementById('pweb-active-timer-display').textContent = "00:00 - Block Ended!"; } }, 1000); button.textContent = "Pause"; } } function pwebClearTimer() { clearInterval(pwebTimerInterval); pwebTimerInterval = null; } function pwebResetCurrentBlock() { pwebClearTimer(); pwebIsPomodoroWorkTime ? pwebSetTimer(pwebSession.strategyConfig.work * 60) : pwebSetTimer(pwebSession.strategyConfig.break * 60); document.getElementById('pweb-timer-startpause').textContent = "Start"; } function pwebSkipToNext() { pwebClearTimer(); pwebIsPomodoroWorkTime = !pwebIsPomodoroWorkTime; if(pwebIsPomodoroWorkTime) pwebPomodoroCycleCount++; // New work cycle starts const intervalType = pwebIsPomodoroWorkTime ? "Work" : "Break"; const duration = pwebIsPomodoroWorkTime ? pwebSession.strategyConfig.work : pwebSession.strategyConfig.break; document.getElementById('pweb-active-current-interval').textContent = `Current Interval: ${intervalType} ${pwebIsPomodoroWorkTime ? `(Cycle ${pwebPomodoroCycleCount + 1})` : ''}`; pwebSetTimer(duration * 60); document.getElementById('pweb-timer-startpause').textContent = "Start"; } // Session Review (Tab 3) function pwebEndSession() { pwebClearTimer(); // Stop timer if running pwebPrepareReviewTab(); pwebOpenTab(null, 'pweb-review'); } function pwebPrepareReviewTab() { if (!pwebSession.date) { // Ensure session was started document.getElementById('pweb-review-session-info').textContent = "No active session data. Please plan and start a session first."; document.getElementById('pweb-review-goal-list').innerHTML = ''; document.getElementById('pweb-review-distraction-count').textContent = '0'; document.getElementById('pweb-booster-insights-list').innerHTML = '
      • No session data to analyze.
      • '; return; } pwebSession.review.generated = true; // Mark that review tab is prepared document.getElementById('pweb-review-session-info').textContent = `Reviewing session from ${new Date(pwebSession.date+"T00:00:00").toLocaleDateString()} (Duration: ${pwebSession.duration} min).`; const reviewGoalListEl = document.getElementById('pweb-review-goal-list'); reviewGoalListEl.innerHTML = ''; pwebSession.goals.forEach(goal => { const li = document.createElement('li'); li.innerHTML = ` `; reviewGoalListEl.appendChild(li); }); document.getElementById('pweb-review-strategy-used').textContent = document.getElementById('pweb-strategy-select').selectedOptions[0].text; document.getElementById('pweb-review-distraction-count').textContent = pwebSession.distractions.length; // Reset review form fields (or load saved if implementing persistence for review itself) document.getElementById('pweb-review-strategy-rating').value = '3'; document.getElementById('pweb-review-strategy-worked').value = ''; document.getElementById('pweb-review-strategy-challenging').value = ''; document.getElementById('pweb-review-focus').value = '3'; document.getElementById('pweb-review-efficiency').value = '3'; // Generate insights after review input (or preliminary ones, then update) pwebGenerateBoosterInsights(); // Call this to initially populate, then again if review inputs change } function pwebGenerateBoosterInsights() { // Can be called from review form onchange if desired, or just once pwebSession.review.strategyRating = parseInt(document.getElementById('pweb-review-strategy-rating').value); pwebSession.review.strategyWorked = document.getElementById('pweb-review-strategy-worked').value.trim(); pwebSession.review.strategyChallenging = document.getElementById('pweb-review-strategy-challenging').value.trim(); pwebSession.review.focusRating = parseInt(document.getElementById('pweb-review-focus').value); pwebSession.review.efficiencyRating = parseInt(document.getElementById('pweb-review-efficiency').value); let insights = []; const goalsCompleted = pwebSession.goals.filter(g => g.completed).length; const totalGoals = pwebSession.goals.length; if(pwebSession.review.strategyRating >= 4 && pwebSession.review.focusRating >=4){ insights.push(`The chosen strategy ('${document.getElementById('pweb-strategy-select').selectedOptions[0].text}') combined with your high focus seems very effective for you!`); } else if (pwebSession.review.strategyRating <= 2) { insights.push(`It seems the chosen strategy ('${document.getElementById('pweb-strategy-select').selectedOptions[0].text}') wasn't very effective. Consider why (see your 'challenges' notes) and perhaps try a different one next time.`); } if(pwebSession.distractions.length > 3 && pwebSession.review.focusRating <=2){ insights.push(`The ${pwebSession.distractions.length} distractions logged likely impacted your focus. Prioritizing a distraction minimization plan could be beneficial.`); } else if (pwebSession.distractions.length <= 1 && pwebSession.review.focusRating >= 4) { insights.push("Excellent job minimizing distractions and maintaining focus!"); } if(totalGoals > 0 && goalsCompleted === totalGoals && pwebSession.review.efficiencyRating >=4){ insights.push("Congratulations on completing all your session goals efficiently!"); } else if (totalGoals > 0 && goalsCompleted < totalGoals / 2) { insights.push("Less than half of the session goals were completed. Reflect on whether the goals were too ambitious for the session, if the strategy needs adjustment, or if external factors played a role."); } if (pwebSession.strategy === 'eat_the_frog' && pwebSession.strategyConfig.frogTask) { const frogGoal = pwebSession.goals.find(g => g.text.toLowerCase().includes(pwebSession.strategyConfig.frogTask.toLowerCase())); if (frogGoal && frogGoal.completed) { insights.push("You successfully 'ate the frog'! Tackling the most challenging task first often sets a productive tone for the rest of the session."); } else if (frogGoal && !frogGoal.completed){ insights.push("The 'frog' task remained incomplete. It might need to be broken down further or be the sole focus of a future dedicated session."); } } if (insights.length === 0) { insights.push("Reflect on your ratings and notes to draw personal conclusions. Consistent use of this tool can help identify patterns over time."); } const insightsListEl = document.getElementById('pweb-booster-insights-list'); insightsListEl.innerHTML = ''; insights.forEach(insight => { const li = document.createElement('li'); li.textContent = insight; insightsListEl.appendChild(li); }); pwebSession.review.insightsGenerated = insights; // Store generated insights } // Add event listeners to review form elements to regenerate insights on change ['pweb-review-strategy-rating', 'pweb-review-strategy-worked', 'pweb-review-strategy-challenging', 'pweb-review-focus', 'pweb-review-efficiency'].forEach(id => { const el = document.getElementById(id); if(el) el.addEventListener('change', pwebGenerateBoosterInsights); }); // PDF Download function pwebDownloadPDFReport() { if (!pwebSession.date || !pwebSession.review.generated) { alert("Please complete a session and its review before downloading a report."); return; } // Ensure insights are based on latest review inputs pwebGenerateBoosterInsights(); let pdfHTML = `

        Work Efficiency Session Report

        `; pdfHTML += `

        Date: ${new Date(pwebSession.date+"T00:00:00").toLocaleDateString()} | Duration: ${pwebSession.duration} min

        `; pdfHTML += `

        1. Session Plan

        `; pdfHTML += `

        Goal(s):

          `; pwebSession.goals.forEach(g => pdfHTML += `
        • ${g.text}
        • `); pdfHTML += `
        `; pdfHTML += `

        Chosen Strategy: ${document.getElementById('pweb-strategy-select').selectedOptions[0].text}

        `; let strategyConfigText = ''; switch(pwebSession.strategy) { case 'pomodoro': strategyConfigText = `Work: ${pwebSession.strategyConfig.work} min, Break: ${pwebSession.strategyConfig.break} min`; break; case 'eat_the_frog': strategyConfigText = `Frog Task: ${pwebSession.strategyConfig.frogTask}`; break; case 'distraction_management': strategyConfigText = `Plan: ${pwebSession.strategyConfig.distraction1 ? '1. '+pwebSession.strategyConfig.distraction1 : ''} ${pwebSession.strategyConfig.distraction2 ? '
        2. '+pwebSession.strategyConfig.distraction2 : ''}`; break; case 'custom': strategyConfigText = `Focus: ${pwebSession.strategyConfig.description}`; break; } if(strategyConfigText) pdfHTML += `

        Configuration: ${strategyConfigText}

        `; pdfHTML += `

        2. Session Execution & Review

        `; pdfHTML += `

        Goal Completion:

          `; pwebSession.goals.forEach(g => pdfHTML += `
        • ${g.text} - ${g.completed ? 'Completed' : 'Not Completed'}
        • `); pdfHTML += `
        `; pdfHTML += `

        Distractions Logged: ${pwebSession.distractions.length}

        `; if(pwebSession.distractions.length > 0) { pdfHTML += `
          `; pwebSession.distractions.forEach(d => pdfHTML += `
        • [${new Date(d.time).toLocaleTimeString([],{hour:'2-digit', minute:'2-digit'})}] ${d.note || 'Distraction'}
        • `); pdfHTML += `
        `; } pdfHTML += `

        Strategy Effectiveness Rating: ${pwebSession.review.strategyRating}/5

        `; pdfHTML += `

        What worked well with strategy:
        ${pwebSession.review.strategyWorked.replace(/\n/g, '
        ') || "N/A"}

        `; pdfHTML += `

        What was challenging with strategy:
        ${pwebSession.review.strategyChallenging.replace(/\n/g, '
        ') || "N/A"}

        `; pdfHTML += `

        Personal Focus Rating: ${pwebSession.review.focusRating}/5

        `; pdfHTML += `

        Perceived Efficiency Rating: ${pwebSession.review.efficiencyRating}/5

        `; pdfHTML += `

        3. Efficiency Booster Insights

          `; if (pwebSession.review.insightsGenerated && pwebSession.review.insightsGenerated.length > 0) { pwebSession.review.insightsGenerated.forEach(insight => pdfHTML += `
        • ${insight}
        • `); } else { pdfHTML += `
        • No specific automated insights generated. Refer to your reflections.
        • `; } pdfHTML += `
        `; const pdfContainer = document.getElementById('pweb-report-content-for-pdf'); pdfContainer.innerHTML = pdfHTML; const opt = { margin: [0.6, 0.5, 0.6, 0.5], filename: `Efficiency_Report_${pwebSession.date}.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. Check console for details."); }); }
        Scroll to Top