Focus Enhancement Tool
Set your goal, work in focused intervals, and manage distractions.
What is Your Main Objective?
Clearly defining your goal is the first step to achieving it. Be specific.
Pomodoro Timer
25:00
Your Focus Session Summary
Focus Goal
Distraction Log
Whenever a distracting thought pops up, log it here to deal with later.
No distractions logged yet. Great focus!
`; } else { listContainer.innerHTML = distractions.map((item, index) => `
${item}
`).join('');
}
};
const handleAddDistraction = (e) => {
e.preventDefault();
const input = getElement('distraction-input');
if (input.value.trim()) {
distractions.push(input.value.trim());
renderDistractions();
input.value = '';
}
};
const prepareReviewData = () => {
const goalReview = getElement('review-goal');
const focusGoal = getElement('focus-goal').value;
if (goalReview) {
goalReview.textContent = focusGoal.trim() || "No goal was set.";
}
};
const generatePDF = () => {
const content = getElement('pdf-content');
if (!content) return;
html2canvas(content, { scale: 2 }).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const ratio = canvas.width / canvas.height;
const pdfImgWidth = pdfWidth - 20;
const pdfImgHeight = pdfImgWidth / ratio;
pdf.addImage(imgData, 'PNG', 10, 10, pdfImgWidth, pdfImgHeight);
pdf.save('Focus_Session_Summary.pdf');
});
};
// --- Event Listeners ---
tabs.forEach(tab => {
tab.addEventListener('click', () => {
currentTab = parseInt(tab.dataset.tab);
if (currentTab === 3) prepareReviewData();
updateTabView();
});
});
if (prevBtn) prevBtn.addEventListener('click', () => {
if (currentTab > 1) { currentTab--; updateTabView(); }
});
if (nextBtn) nextBtn.addEventListener('click', () => {
if (currentTab < 3) { currentTab++; if (currentTab === 3) prepareReviewData(); updateTabView(); }
});
if (downloadPdfBtn) downloadPdfBtn.addEventListener('click', generatePDF);
// Timer controls
getElement('start-timer-btn').addEventListener('click', startTimer);
getElement('pause-timer-btn').addEventListener('click', pauseTimer);
getElement('reset-timer-btn').addEventListener('click', resetTimer);
getElement('timer-mode-work').addEventListener('click', () => switchMode('work'));
getElement('timer-mode-break').addEventListener('click', () => switchMode('break'));
// Distraction Log
getElement('distraction-form').addEventListener('submit', handleAddDistraction);
getElement('distraction-list').addEventListener('click', (e) => {
if (e.target.classList.contains('delete-distraction-btn')) {
const index = parseInt(e.target.dataset.index);
distractions.splice(index, 1);
renderDistractions();
}
});
// --- Initial Setup ---
updateTabView();
updateTimerDisplay();
renderDistractions();
});
