Compare commits
7 Commits
aeb1d62895
...
v1.0.5
| Author | SHA1 | Date | |
|---|---|---|---|
| 9abdd10ada | |||
| e66d9b4d25 | |||
| 285ac7a7c9 | |||
| 9e35a2603c | |||
| f5e4a16aff | |||
| 9014f086d6 | |||
| d4f2af179f |
26
README.md
26
README.md
@@ -4,7 +4,7 @@ A powerful task management and focus timer plugin for [Obsidian](https://obsidia
|
|||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
## 🎯 Overview
|
## 🎯 Overview
|
||||||
|
|
||||||
@@ -46,6 +46,7 @@ Focus Task brings the power of time-boxed task management directly into your Obs
|
|||||||
- **Streak Counter**: Build momentum with consecutive productive days
|
- **Streak Counter**: Build momentum with consecutive productive days
|
||||||
- **Time Comparison**: Compare estimated vs. actual time to improve planning
|
- **Time Comparison**: Compare estimated vs. actual time to improve planning
|
||||||
- **Pomodoro Count**: Track total pomodoros completed
|
- **Pomodoro Count**: Track total pomodoros completed
|
||||||
|
- **Daily Note Logging**: Automatically log completed tasks to your daily notes with timestamps and performance metrics
|
||||||
|
|
||||||
### 🎨 User Experience
|
### 🎨 User Experience
|
||||||
- **Status Bar Timer**: timer that stays visible while you work
|
- **Status Bar Timer**: timer that stays visible while you work
|
||||||
@@ -136,7 +137,7 @@ Best for: Tracking time on open-ended tasks
|
|||||||
| Short Break | Length of short breaks | 5 min |
|
| Short Break | Length of short breaks | 5 min |
|
||||||
| Long Break | Length of long breaks | 15 min |
|
| Long Break | Length of long breaks | 15 min |
|
||||||
| Long Break Interval | Pomodoros before a long break | 4 |
|
| Long Break Interval | Pomodoros before a long break | 4 |
|
||||||
| Auto-start Breaks | Automatically start break timer | Off |
|
| Auto-start Breaks | Automatically start break timer | On |
|
||||||
|
|
||||||
### General
|
### General
|
||||||
| Setting | Description | Default |
|
| Setting | Description | Default |
|
||||||
@@ -146,6 +147,27 @@ Best for: Tracking time on open-ended tasks
|
|||||||
| Enable Celebrations | Show celebration messages | On |
|
| Enable Celebrations | Show celebration messages | On |
|
||||||
| Show Floating Timer | Display draggable timer widget | On |
|
| Show Floating Timer | Display draggable timer widget | On |
|
||||||
|
|
||||||
|
### Daily Note Integration
|
||||||
|
|
||||||
|
| Setting | Description | Default |
|
||||||
|
|---------|-------------|---------|
|
||||||
|
| Log to Daily Note | Automatically log completed tasks to your daily note | Off |
|
||||||
|
|
||||||
|
When enabled, completed tasks are automatically appended to your daily note with:
|
||||||
|
|
||||||
|
- Task name and list category
|
||||||
|
- Time spent vs. estimated time
|
||||||
|
- Completion timestamp
|
||||||
|
- Performance indicator (under/over/on target)
|
||||||
|
|
||||||
|
**Example entry:**
|
||||||
|
|
||||||
|
```
|
||||||
|
- [x] Write project proposal | 💼 Work | ⏱️ 45min / 30min (15min over estimate) | ✅ 14:30
|
||||||
|
```
|
||||||
|
|
||||||
|
**Requirements:** The core "Daily Notes" plugin must be enabled in Obsidian settings. Focus Task respects your Daily Notes configuration (folder, date format, and template).
|
||||||
|
|
||||||
### Lists
|
### Lists
|
||||||
Customize your task lists with:
|
Customize your task lists with:
|
||||||
- Custom names
|
- Custom names
|
||||||
|
|||||||
127
main.js
127
main.js
@@ -43,7 +43,7 @@ var DEFAULT_SETTINGS = {
|
|||||||
{ id: "personal", name: "Personal", color: "#22c55e", icon: "\u{1F3E0}" },
|
{ id: "personal", name: "Personal", color: "#22c55e", icon: "\u{1F3E0}" },
|
||||||
{ id: "learning", name: "Learning", color: "#f59e0b", icon: "\u{1F4DA}" }
|
{ id: "learning", name: "Learning", color: "#f59e0b", icon: "\u{1F4DA}" }
|
||||||
],
|
],
|
||||||
autoStartBreak: false,
|
autoStartBreak: true,
|
||||||
tickSoundEnabled: false,
|
tickSoundEnabled: false,
|
||||||
// Daily note logging
|
// Daily note logging
|
||||||
logToDaily: false
|
logToDaily: false
|
||||||
@@ -319,9 +319,11 @@ var FocusTaskView = class extends import_obsidian2.ItemView {
|
|||||||
const activeCard = activeSection.createEl("div", { cls: "focus-task-active-card" });
|
const activeCard = activeSection.createEl("div", { cls: "focus-task-active-card" });
|
||||||
if (this.plugin.isBreakMode) {
|
if (this.plugin.isBreakMode) {
|
||||||
activeCard.addClass("focus-task-break-card");
|
activeCard.addClass("focus-task-break-card");
|
||||||
activeCard.createEl("div", { cls: "focus-task-active-label", text: "\u2615 BREAK TIME" });
|
const breakLabel = this.plugin.currentTimerSeconds > 0 ? "\u2615 BREAK TIME" : "\u2728 BREAK COMPLETE";
|
||||||
|
activeCard.createEl("div", { cls: "focus-task-active-label", text: breakLabel });
|
||||||
} else {
|
} else {
|
||||||
activeCard.createEl("div", { cls: "focus-task-active-label", text: "\u{1F3AF} FOCUSING ON" });
|
const workLabel = this.plugin.currentTimerSeconds > 0 ? "\u{1F3AF} FOCUSING ON" : "\u{1F345} POMODORO COMPLETE";
|
||||||
|
activeCard.createEl("div", { cls: "focus-task-active-label", text: workLabel });
|
||||||
}
|
}
|
||||||
activeCard.createEl("div", { cls: "focus-task-active-task-name", text: task.text });
|
activeCard.createEl("div", { cls: "focus-task-active-task-name", text: task.text });
|
||||||
const timerDisplay = activeCard.createEl("div", { cls: "focus-task-timer-display" });
|
const timerDisplay = activeCard.createEl("div", { cls: "focus-task-timer-display" });
|
||||||
@@ -348,25 +350,62 @@ var FocusTaskView = class extends import_obsidian2.ItemView {
|
|||||||
this.actualTimeEl = timeInfo.createEl("span", { text: `Actual: ${this.plugin.formatTimeHuman(task.actualMinutes)}` });
|
this.actualTimeEl = timeInfo.createEl("span", { text: `Actual: ${this.plugin.formatTimeHuman(task.actualMinutes)}` });
|
||||||
}
|
}
|
||||||
const controls = activeCard.createEl("div", { cls: "focus-task-active-controls" });
|
const controls = activeCard.createEl("div", { cls: "focus-task-active-controls" });
|
||||||
this.pauseBtnEl = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-secondary" });
|
|
||||||
this.pauseBtnEl.innerHTML = this.plugin.isTimerRunning ? "\u23F8 Pause" : "\u25B6 Resume";
|
|
||||||
this.pauseBtnEl.addEventListener("click", () => this.plugin.toggleTimer());
|
|
||||||
if (!this.plugin.isBreakMode) {
|
|
||||||
const completeBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-success" });
|
|
||||||
completeBtn.innerHTML = "\u2713 Complete";
|
|
||||||
completeBtn.addEventListener("click", () => this.plugin.completeTask(task.id));
|
|
||||||
}
|
|
||||||
const stopBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-danger" });
|
|
||||||
stopBtn.innerHTML = "\u2715 Stop";
|
|
||||||
stopBtn.addEventListener("click", () => this.plugin.stopTimer());
|
|
||||||
if (this.plugin.isBreakMode) {
|
if (this.plugin.isBreakMode) {
|
||||||
const skipBreakBtn = controls.createEl("button", { cls: "focus-task-btn" });
|
if (this.plugin.currentTimerSeconds > 0) {
|
||||||
skipBreakBtn.innerHTML = "\u23ED Skip Break";
|
this.pauseBtnEl = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-secondary" });
|
||||||
skipBreakBtn.addEventListener("click", () => {
|
this.pauseBtnEl.innerHTML = this.plugin.isTimerRunning ? "\u23F8 Pause" : "\u25B6 Resume";
|
||||||
this.plugin.isBreakMode = false;
|
this.pauseBtnEl.addEventListener("click", () => this.plugin.toggleTimer());
|
||||||
this.plugin.stopTimer();
|
const skipBreakBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-primary" });
|
||||||
this.refresh();
|
skipBreakBtn.innerHTML = "\u23ED Skip Break";
|
||||||
});
|
skipBreakBtn.addEventListener("click", () => {
|
||||||
|
this.plugin.isBreakMode = false;
|
||||||
|
this.plugin.startPomodoro(task.id);
|
||||||
|
});
|
||||||
|
const stopBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-danger" });
|
||||||
|
stopBtn.innerHTML = "\u2715 Stop";
|
||||||
|
stopBtn.addEventListener("click", () => {
|
||||||
|
this.plugin.isBreakMode = false;
|
||||||
|
this.plugin.stopTimer();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const resumeWorkBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-success" });
|
||||||
|
resumeWorkBtn.innerHTML = "\u25B6 Resume Work";
|
||||||
|
resumeWorkBtn.addEventListener("click", () => {
|
||||||
|
this.plugin.isBreakMode = false;
|
||||||
|
this.plugin.startPomodoro(task.id);
|
||||||
|
});
|
||||||
|
const stopBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-danger" });
|
||||||
|
stopBtn.innerHTML = "\u2715 Stop";
|
||||||
|
stopBtn.addEventListener("click", () => {
|
||||||
|
this.plugin.isBreakMode = false;
|
||||||
|
this.plugin.stopTimer();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.plugin.currentTimerSeconds > 0) {
|
||||||
|
this.pauseBtnEl = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-secondary" });
|
||||||
|
this.pauseBtnEl.innerHTML = this.plugin.isTimerRunning ? "\u23F8 Pause" : "\u25B6 Resume";
|
||||||
|
this.pauseBtnEl.addEventListener("click", () => this.plugin.toggleTimer());
|
||||||
|
const completeBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-success" });
|
||||||
|
completeBtn.innerHTML = "\u2713 Complete";
|
||||||
|
completeBtn.addEventListener("click", () => this.plugin.completeTask(task.id));
|
||||||
|
const stopBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-danger" });
|
||||||
|
stopBtn.innerHTML = "\u2715 Stop";
|
||||||
|
stopBtn.addEventListener("click", () => this.plugin.stopTimer());
|
||||||
|
} else {
|
||||||
|
const startBreakBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-secondary" });
|
||||||
|
startBreakBtn.innerHTML = "\u2615 Start Break";
|
||||||
|
startBreakBtn.addEventListener("click", () => this.plugin.startBreak());
|
||||||
|
const continueBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-primary" });
|
||||||
|
continueBtn.innerHTML = "\u25B6 Continue Working";
|
||||||
|
continueBtn.addEventListener("click", () => this.plugin.startPomodoro(task.id));
|
||||||
|
const completeBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-success" });
|
||||||
|
completeBtn.innerHTML = "\u2713 Complete";
|
||||||
|
completeBtn.addEventListener("click", () => this.plugin.completeTask(task.id));
|
||||||
|
const stopBtn = controls.createEl("button", { cls: "focus-task-btn focus-task-btn-danger" });
|
||||||
|
stopBtn.innerHTML = "\u2715 Stop";
|
||||||
|
stopBtn.addEventListener("click", () => this.plugin.stopTimer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -499,6 +538,7 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
|
|||||||
this.pomodoroCount = 0;
|
this.pomodoroCount = 0;
|
||||||
// Focus time tracking (in seconds for accuracy)
|
// Focus time tracking (in seconds for accuracy)
|
||||||
this.focusSecondsToday = 0;
|
this.focusSecondsToday = 0;
|
||||||
|
this.secondsWorkedOnCurrentTask = 0;
|
||||||
// Status bar element
|
// Status bar element
|
||||||
this.statusBarEl = null;
|
this.statusBarEl = null;
|
||||||
}
|
}
|
||||||
@@ -671,11 +711,13 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
|
|||||||
this.isBreakMode = false;
|
this.isBreakMode = false;
|
||||||
this.currentTimerSeconds = 0;
|
this.currentTimerSeconds = 0;
|
||||||
this.isTimerRunning = true;
|
this.isTimerRunning = true;
|
||||||
|
this.secondsWorkedOnCurrentTask = task.actualMinutes * 60;
|
||||||
this.refreshView();
|
this.refreshView();
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
this.timerInterval = window.setInterval(() => {
|
this.timerInterval = window.setInterval(() => {
|
||||||
this.currentTimerSeconds++;
|
this.currentTimerSeconds++;
|
||||||
task.actualMinutes = Math.floor(this.currentTimerSeconds / 60);
|
this.secondsWorkedOnCurrentTask++;
|
||||||
|
task.actualMinutes = Math.floor(this.secondsWorkedOnCurrentTask / 60);
|
||||||
this.focusSecondsToday++;
|
this.focusSecondsToday++;
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
this.updateTimerDisplay();
|
this.updateTimerDisplay();
|
||||||
@@ -698,14 +740,14 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
|
|||||||
this.isBreakMode = false;
|
this.isBreakMode = false;
|
||||||
this.currentTimerSeconds = this.settings.pomodoroWorkMinutes * 60;
|
this.currentTimerSeconds = this.settings.pomodoroWorkMinutes * 60;
|
||||||
this.isTimerRunning = true;
|
this.isTimerRunning = true;
|
||||||
|
this.secondsWorkedOnCurrentTask = task.actualMinutes * 60;
|
||||||
this.refreshView();
|
this.refreshView();
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
let secondsWorked = 0;
|
|
||||||
this.timerInterval = window.setInterval(() => {
|
this.timerInterval = window.setInterval(() => {
|
||||||
this.currentTimerSeconds--;
|
this.currentTimerSeconds--;
|
||||||
if (!this.isBreakMode) {
|
if (!this.isBreakMode) {
|
||||||
secondsWorked++;
|
this.secondsWorkedOnCurrentTask++;
|
||||||
task.actualMinutes = Math.floor(secondsWorked / 60);
|
task.actualMinutes = Math.floor(this.secondsWorkedOnCurrentTask / 60);
|
||||||
this.focusSecondsToday++;
|
this.focusSecondsToday++;
|
||||||
}
|
}
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
@@ -716,6 +758,14 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
|
|||||||
}, 1e3);
|
}, 1e3);
|
||||||
}
|
}
|
||||||
handlePomodoroEnd() {
|
handlePomodoroEnd() {
|
||||||
|
if (this.timerInterval) {
|
||||||
|
window.clearInterval(this.timerInterval);
|
||||||
|
this.timerInterval = null;
|
||||||
|
}
|
||||||
|
this.currentTimerSeconds = 0;
|
||||||
|
this.isTimerRunning = false;
|
||||||
|
this.updateStatusBar();
|
||||||
|
this.updateTimerDisplay();
|
||||||
if (!this.isBreakMode) {
|
if (!this.isBreakMode) {
|
||||||
this.pomodoroCount++;
|
this.pomodoroCount++;
|
||||||
this.data.pomodorosCompleted++;
|
this.data.pomodorosCompleted++;
|
||||||
@@ -726,20 +776,20 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
|
|||||||
if (this.settings.autoStartBreak) {
|
if (this.settings.autoStartBreak) {
|
||||||
this.startBreak();
|
this.startBreak();
|
||||||
} else {
|
} else {
|
||||||
this.stopTimer();
|
this.refreshView();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.settings.enableSounds) {
|
if (this.settings.enableSounds) {
|
||||||
this.playAlertSound();
|
this.playAlertSound();
|
||||||
}
|
}
|
||||||
new import_obsidian3.Notice("\u26A1 Break over! Ready to focus?");
|
new import_obsidian3.Notice("\u26A1 Break over! Ready to focus?");
|
||||||
this.isBreakMode = false;
|
this.refreshView();
|
||||||
this.stopTimer();
|
|
||||||
}
|
}
|
||||||
this.saveAllData();
|
this.saveAllData();
|
||||||
}
|
}
|
||||||
startBreak() {
|
startBreak() {
|
||||||
this.isBreakMode = true;
|
this.isBreakMode = true;
|
||||||
|
this.isTimerRunning = true;
|
||||||
const isLongBreak = this.pomodoroCount % this.settings.longBreakInterval === 0;
|
const isLongBreak = this.pomodoroCount % this.settings.longBreakInterval === 0;
|
||||||
this.currentTimerSeconds = (isLongBreak ? this.settings.longBreakMinutes : this.settings.pomodoroBreakMinutes) * 60;
|
this.currentTimerSeconds = (isLongBreak ? this.settings.longBreakMinutes : this.settings.pomodoroBreakMinutes) * 60;
|
||||||
new import_obsidian3.Notice(isLongBreak ? "\u2615 Long break time!" : "\u2615 Short break time!");
|
new import_obsidian3.Notice(isLongBreak ? "\u2615 Long break time!" : "\u2615 Short break time!");
|
||||||
@@ -767,7 +817,8 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
|
|||||||
this.timerInterval = window.setInterval(() => {
|
this.timerInterval = window.setInterval(() => {
|
||||||
this.currentTimerSeconds--;
|
this.currentTimerSeconds--;
|
||||||
if (task && !this.isBreakMode) {
|
if (task && !this.isBreakMode) {
|
||||||
task.actualMinutes = Math.floor((this.settings.pomodoroWorkMinutes * 60 - this.currentTimerSeconds) / 60);
|
this.secondsWorkedOnCurrentTask++;
|
||||||
|
task.actualMinutes = Math.floor(this.secondsWorkedOnCurrentTask / 60);
|
||||||
this.focusSecondsToday++;
|
this.focusSecondsToday++;
|
||||||
}
|
}
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
@@ -795,6 +846,7 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
|
|||||||
}
|
}
|
||||||
this.isTimerRunning = false;
|
this.isTimerRunning = false;
|
||||||
this.activeTaskId = null;
|
this.activeTaskId = null;
|
||||||
|
this.secondsWorkedOnCurrentTask = 0;
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
this.saveAllData();
|
this.saveAllData();
|
||||||
this.refreshView();
|
this.refreshView();
|
||||||
@@ -924,9 +976,20 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
|
|||||||
formatDailyNoteDate(format) {
|
formatDailyNoteDate(format) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const year = now.getFullYear();
|
const year = now.getFullYear();
|
||||||
const month = (now.getMonth() + 1).toString().padStart(2, "0");
|
const month = now.getMonth() + 1;
|
||||||
const day = now.getDate().toString().padStart(2, "0");
|
const day = now.getDate();
|
||||||
return format.replace("YYYY", year.toString()).replace("YY", year.toString().slice(-2)).replace("MM", month).replace("M", (now.getMonth() + 1).toString()).replace("DD", day).replace("D", now.getDate().toString()).replace("dddd", now.toLocaleDateString("en-US", { weekday: "long" })).replace("ddd", now.toLocaleDateString("en-US", { weekday: "short" })).replace("MMMM", now.toLocaleDateString("en-US", { month: "long" })).replace("MMM", now.toLocaleDateString("en-US", { month: "short" }));
|
let result = format;
|
||||||
|
result = result.replace(/YYYY/g, year.toString());
|
||||||
|
result = result.replace(/YY/g, year.toString().slice(-2));
|
||||||
|
result = result.replace(/MMMM/g, now.toLocaleDateString("en-US", { month: "long" }));
|
||||||
|
result = result.replace(/MMM/g, now.toLocaleDateString("en-US", { month: "short" }));
|
||||||
|
result = result.replace(/MM/g, month.toString().padStart(2, "0"));
|
||||||
|
result = result.replace(/(?<![A-Za-z])M(?![A-Za-z])/g, month.toString());
|
||||||
|
result = result.replace(/dddd/g, now.toLocaleDateString("en-US", { weekday: "long" }));
|
||||||
|
result = result.replace(/ddd/g, now.toLocaleDateString("en-US", { weekday: "short" }));
|
||||||
|
result = result.replace(/DD/g, day.toString().padStart(2, "0"));
|
||||||
|
result = result.replace(/(?<![A-Za-z])D(?![A-Za-z])/g, day.toString());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
async getOrCreateDailyNote() {
|
async getOrCreateDailyNote() {
|
||||||
const { vault } = this.app;
|
const { vault } = this.app;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "focus-task",
|
"id": "focus-task",
|
||||||
"name": "Focus Task",
|
"name": "Focus Task",
|
||||||
"version": "1.0.3",
|
"version": "1.0.5",
|
||||||
"minAppVersion": "0.15.0",
|
"minAppVersion": "0.15.0",
|
||||||
"description": "A Blitzit-inspired task management and focus timer plugin. Plan your day, track time with Pomodoro technique, and crush your tasks with satisfying checkoffs.",
|
"description": "A Blitzit-inspired task management and focus timer plugin. Plan your day, track time with Pomodoro technique, and crush your tasks with satisfying checkoffs.",
|
||||||
"author": "Crib",
|
"author": "Crib",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "focus-task",
|
"name": "focus-task",
|
||||||
"version": "1.0.3",
|
"version": "1.0.5",
|
||||||
"description": "A Blitzit-inspired task management and focus timer plugin for Obsidian",
|
"description": "A Blitzit-inspired task management and focus timer plugin for Obsidian",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
114
src/main.ts
114
src/main.ts
@@ -36,9 +36,10 @@ export default class FocusTaskPlugin extends Plugin {
|
|||||||
isBreakMode: boolean = false;
|
isBreakMode: boolean = false;
|
||||||
activeTaskId: string | null = null;
|
activeTaskId: string | null = null;
|
||||||
pomodoroCount: number = 0;
|
pomodoroCount: number = 0;
|
||||||
|
|
||||||
// Focus time tracking (in seconds for accuracy)
|
// Focus time tracking (in seconds for accuracy)
|
||||||
private focusSecondsToday: number = 0;
|
private focusSecondsToday: number = 0;
|
||||||
|
private secondsWorkedOnCurrentTask: number = 0;
|
||||||
|
|
||||||
// Status bar element
|
// Status bar element
|
||||||
statusBarEl: HTMLElement | null = null;
|
statusBarEl: HTMLElement | null = null;
|
||||||
@@ -263,6 +264,7 @@ export default class FocusTaskPlugin extends Plugin {
|
|||||||
this.isBreakMode = false;
|
this.isBreakMode = false;
|
||||||
this.currentTimerSeconds = 0;
|
this.currentTimerSeconds = 0;
|
||||||
this.isTimerRunning = true;
|
this.isTimerRunning = true;
|
||||||
|
this.secondsWorkedOnCurrentTask = task.actualMinutes * 60;
|
||||||
|
|
||||||
// Full refresh to show the active task card
|
// Full refresh to show the active task card
|
||||||
this.refreshView();
|
this.refreshView();
|
||||||
@@ -271,7 +273,8 @@ export default class FocusTaskPlugin extends Plugin {
|
|||||||
// Start interval (count up mode - stopwatch)
|
// Start interval (count up mode - stopwatch)
|
||||||
this.timerInterval = window.setInterval(() => {
|
this.timerInterval = window.setInterval(() => {
|
||||||
this.currentTimerSeconds++;
|
this.currentTimerSeconds++;
|
||||||
task.actualMinutes = Math.floor(this.currentTimerSeconds / 60);
|
this.secondsWorkedOnCurrentTask++;
|
||||||
|
task.actualMinutes = Math.floor(this.secondsWorkedOnCurrentTask / 60);
|
||||||
|
|
||||||
// Track focus time
|
// Track focus time
|
||||||
this.focusSecondsToday++;
|
this.focusSecondsToday++;
|
||||||
@@ -303,23 +306,23 @@ export default class FocusTaskPlugin extends Plugin {
|
|||||||
this.currentTimerSeconds = this.settings.pomodoroWorkMinutes * 60;
|
this.currentTimerSeconds = this.settings.pomodoroWorkMinutes * 60;
|
||||||
this.isTimerRunning = true;
|
this.isTimerRunning = true;
|
||||||
|
|
||||||
|
// Initialize from existing actual time to preserve progress across breaks
|
||||||
|
this.secondsWorkedOnCurrentTask = task.actualMinutes * 60;
|
||||||
|
|
||||||
// Full refresh to show the active task card
|
// Full refresh to show the active task card
|
||||||
this.refreshView();
|
this.refreshView();
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
|
|
||||||
// Track seconds worked for accurate focus time
|
|
||||||
let secondsWorked = 0;
|
|
||||||
|
|
||||||
this.timerInterval = window.setInterval(() => {
|
this.timerInterval = window.setInterval(() => {
|
||||||
this.currentTimerSeconds--;
|
this.currentTimerSeconds--;
|
||||||
|
|
||||||
if (!this.isBreakMode) {
|
if (!this.isBreakMode) {
|
||||||
secondsWorked++;
|
this.secondsWorkedOnCurrentTask++;
|
||||||
task.actualMinutes = Math.floor(secondsWorked / 60);
|
task.actualMinutes = Math.floor(this.secondsWorkedOnCurrentTask / 60);
|
||||||
// Increment focus time by 1 second
|
// Increment focus time by 1 second
|
||||||
this.focusSecondsToday++;
|
this.focusSecondsToday++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Light update - only timer display, no full refresh
|
// Light update - only timer display, no full refresh
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
this.updateTimerDisplay();
|
this.updateTimerDisplay();
|
||||||
@@ -331,45 +334,61 @@ export default class FocusTaskPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handlePomodoroEnd() {
|
handlePomodoroEnd() {
|
||||||
|
// Stop the timer interval to prevent going into negative
|
||||||
|
if (this.timerInterval) {
|
||||||
|
window.clearInterval(this.timerInterval);
|
||||||
|
this.timerInterval = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set timer to 0 to ensure it doesn't show negative
|
||||||
|
this.currentTimerSeconds = 0;
|
||||||
|
this.isTimerRunning = false;
|
||||||
|
|
||||||
|
// Update displays immediately
|
||||||
|
this.updateStatusBar();
|
||||||
|
this.updateTimerDisplay();
|
||||||
|
|
||||||
if (!this.isBreakMode) {
|
if (!this.isBreakMode) {
|
||||||
// Work session ended
|
// Work session ended
|
||||||
this.pomodoroCount++;
|
this.pomodoroCount++;
|
||||||
this.data.pomodorosCompleted++;
|
this.data.pomodorosCompleted++;
|
||||||
|
|
||||||
if (this.settings.enableSounds) {
|
if (this.settings.enableSounds) {
|
||||||
this.playAlertSound();
|
this.playAlertSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
new Notice('🍅 Pomodoro complete! Time for a break.');
|
new Notice('🍅 Pomodoro complete! Time for a break.');
|
||||||
|
|
||||||
if (this.settings.autoStartBreak) {
|
if (this.settings.autoStartBreak) {
|
||||||
this.startBreak();
|
this.startBreak();
|
||||||
} else {
|
} else {
|
||||||
this.stopTimer();
|
this.refreshView();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Break ended
|
// Break ended - keep timer at 0 until user resumes
|
||||||
if (this.settings.enableSounds) {
|
if (this.settings.enableSounds) {
|
||||||
this.playAlertSound();
|
this.playAlertSound();
|
||||||
}
|
}
|
||||||
new Notice('⚡ Break over! Ready to focus?');
|
new Notice('⚡ Break over! Ready to focus?');
|
||||||
this.isBreakMode = false;
|
|
||||||
this.stopTimer();
|
// Keep the break card visible with timer at 0:00
|
||||||
|
this.refreshView();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.saveAllData();
|
this.saveAllData();
|
||||||
}
|
}
|
||||||
|
|
||||||
startBreak() {
|
startBreak() {
|
||||||
this.isBreakMode = true;
|
this.isBreakMode = true;
|
||||||
|
this.isTimerRunning = true;
|
||||||
const isLongBreak = this.pomodoroCount % this.settings.longBreakInterval === 0;
|
const isLongBreak = this.pomodoroCount % this.settings.longBreakInterval === 0;
|
||||||
this.currentTimerSeconds = (isLongBreak ? this.settings.longBreakMinutes : this.settings.pomodoroBreakMinutes) * 60;
|
this.currentTimerSeconds = (isLongBreak ? this.settings.longBreakMinutes : this.settings.pomodoroBreakMinutes) * 60;
|
||||||
|
|
||||||
new Notice(isLongBreak ? '☕ Long break time!' : '☕ Short break time!');
|
new Notice(isLongBreak ? '☕ Long break time!' : '☕ Short break time!');
|
||||||
|
|
||||||
// Full refresh to show break state
|
// Full refresh to show break state
|
||||||
this.refreshView();
|
this.refreshView();
|
||||||
|
|
||||||
if (!this.timerInterval) {
|
if (!this.timerInterval) {
|
||||||
this.timerInterval = window.setInterval(() => {
|
this.timerInterval = window.setInterval(() => {
|
||||||
this.currentTimerSeconds--;
|
this.currentTimerSeconds--;
|
||||||
@@ -382,7 +401,7 @@ export default class FocusTaskPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,11 +415,12 @@ export default class FocusTaskPlugin extends Plugin {
|
|||||||
// Resume
|
// Resume
|
||||||
this.isTimerRunning = true;
|
this.isTimerRunning = true;
|
||||||
const task = this.data.tasks.find(t => t.id === this.activeTaskId);
|
const task = this.data.tasks.find(t => t.id === this.activeTaskId);
|
||||||
|
|
||||||
this.timerInterval = window.setInterval(() => {
|
this.timerInterval = window.setInterval(() => {
|
||||||
this.currentTimerSeconds--;
|
this.currentTimerSeconds--;
|
||||||
if (task && !this.isBreakMode) {
|
if (task && !this.isBreakMode) {
|
||||||
task.actualMinutes = Math.floor((this.settings.pomodoroWorkMinutes * 60 - this.currentTimerSeconds) / 60);
|
this.secondsWorkedOnCurrentTask++;
|
||||||
|
task.actualMinutes = Math.floor(this.secondsWorkedOnCurrentTask / 60);
|
||||||
// Track focus time
|
// Track focus time
|
||||||
this.focusSecondsToday++;
|
this.focusSecondsToday++;
|
||||||
}
|
}
|
||||||
@@ -415,7 +435,7 @@ export default class FocusTaskPlugin extends Plugin {
|
|||||||
} else {
|
} else {
|
||||||
new Notice('No active task. Select a task first.');
|
new Notice('No active task. Select a task first.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Full refresh to update pause/resume button state
|
// Full refresh to update pause/resume button state
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
this.refreshView();
|
this.refreshView();
|
||||||
@@ -426,16 +446,17 @@ export default class FocusTaskPlugin extends Plugin {
|
|||||||
window.clearInterval(this.timerInterval);
|
window.clearInterval(this.timerInterval);
|
||||||
this.timerInterval = null;
|
this.timerInterval = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.activeTaskId) {
|
if (this.activeTaskId) {
|
||||||
const task = this.data.tasks.find(t => t.id === this.activeTaskId);
|
const task = this.data.tasks.find(t => t.id === this.activeTaskId);
|
||||||
if (task) {
|
if (task) {
|
||||||
task.isActive = false;
|
task.isActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isTimerRunning = false;
|
this.isTimerRunning = false;
|
||||||
this.activeTaskId = null;
|
this.activeTaskId = null;
|
||||||
|
this.secondsWorkedOnCurrentTask = 0;
|
||||||
this.updateStatusBar();
|
this.updateStatusBar();
|
||||||
this.saveAllData();
|
this.saveAllData();
|
||||||
this.refreshView();
|
this.refreshView();
|
||||||
@@ -598,21 +619,32 @@ export default class FocusTaskPlugin extends Plugin {
|
|||||||
formatDailyNoteDate(format: string): string {
|
formatDailyNoteDate(format: string): string {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const year = now.getFullYear();
|
const year = now.getFullYear();
|
||||||
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
const month = now.getMonth() + 1;
|
||||||
const day = now.getDate().toString().padStart(2, '0');
|
const day = now.getDate();
|
||||||
|
|
||||||
// Handle common date format tokens
|
// Use placeholders to avoid replacement conflicts
|
||||||
return format
|
// Replace longer tokens first, use unique placeholders
|
||||||
.replace('YYYY', year.toString())
|
let result = format;
|
||||||
.replace('YY', year.toString().slice(-2))
|
|
||||||
.replace('MM', month)
|
// Year tokens
|
||||||
.replace('M', (now.getMonth() + 1).toString())
|
result = result.replace(/YYYY/g, year.toString());
|
||||||
.replace('DD', day)
|
result = result.replace(/YY/g, year.toString().slice(-2));
|
||||||
.replace('D', now.getDate().toString())
|
|
||||||
.replace('dddd', now.toLocaleDateString('en-US', { weekday: 'long' }))
|
// Month tokens (longer first)
|
||||||
.replace('ddd', now.toLocaleDateString('en-US', { weekday: 'short' }))
|
result = result.replace(/MMMM/g, now.toLocaleDateString('en-US', { month: 'long' }));
|
||||||
.replace('MMMM', now.toLocaleDateString('en-US', { month: 'long' }))
|
result = result.replace(/MMM/g, now.toLocaleDateString('en-US', { month: 'short' }));
|
||||||
.replace('MMM', now.toLocaleDateString('en-US', { month: 'short' }));
|
result = result.replace(/MM/g, month.toString().padStart(2, '0'));
|
||||||
|
// Only replace standalone M, not part of other tokens
|
||||||
|
result = result.replace(/(?<![A-Za-z])M(?![A-Za-z])/g, month.toString());
|
||||||
|
|
||||||
|
// Day tokens (longer first)
|
||||||
|
result = result.replace(/dddd/g, now.toLocaleDateString('en-US', { weekday: 'long' }));
|
||||||
|
result = result.replace(/ddd/g, now.toLocaleDateString('en-US', { weekday: 'short' }));
|
||||||
|
result = result.replace(/DD/g, day.toString().padStart(2, '0'));
|
||||||
|
// Only replace standalone D, not part of other tokens
|
||||||
|
result = result.replace(/(?<![A-Za-z])D(?![A-Za-z])/g, day.toString());
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getOrCreateDailyNote(): Promise<TFile | null> {
|
async getOrCreateDailyNote(): Promise<TFile | null> {
|
||||||
@@ -965,4 +997,4 @@ class FocusTaskSettingTab extends PluginSettingTab {
|
|||||||
</p>
|
</p>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export const DEFAULT_SETTINGS: FocusTaskSettings = {
|
|||||||
{ id: 'personal', name: 'Personal', color: '#22c55e', icon: '🏠' },
|
{ id: 'personal', name: 'Personal', color: '#22c55e', icon: '🏠' },
|
||||||
{ id: 'learning', name: 'Learning', color: '#f59e0b', icon: '📚' },
|
{ id: 'learning', name: 'Learning', color: '#f59e0b', icon: '📚' },
|
||||||
],
|
],
|
||||||
autoStartBreak: false,
|
autoStartBreak: true,
|
||||||
tickSoundEnabled: false,
|
tickSoundEnabled: false,
|
||||||
// Daily note logging
|
// Daily note logging
|
||||||
logToDaily: false,
|
logToDaily: false,
|
||||||
|
|||||||
98
src/view.ts
98
src/view.ts
@@ -145,9 +145,11 @@ export class FocusTaskView extends ItemView {
|
|||||||
|
|
||||||
if (this.plugin.isBreakMode) {
|
if (this.plugin.isBreakMode) {
|
||||||
activeCard.addClass('focus-task-break-card');
|
activeCard.addClass('focus-task-break-card');
|
||||||
activeCard.createEl('div', { cls: 'focus-task-active-label', text: '☕ BREAK TIME' });
|
const breakLabel = this.plugin.currentTimerSeconds > 0 ? '☕ BREAK TIME' : '✨ BREAK COMPLETE';
|
||||||
|
activeCard.createEl('div', { cls: 'focus-task-active-label', text: breakLabel });
|
||||||
} else {
|
} else {
|
||||||
activeCard.createEl('div', { cls: 'focus-task-active-label', text: '🎯 FOCUSING ON' });
|
const workLabel = this.plugin.currentTimerSeconds > 0 ? '🎯 FOCUSING ON' : '🍅 POMODORO COMPLETE';
|
||||||
|
activeCard.createEl('div', { cls: 'focus-task-active-label', text: workLabel });
|
||||||
}
|
}
|
||||||
|
|
||||||
activeCard.createEl('div', { cls: 'focus-task-active-task-name', text: task.text });
|
activeCard.createEl('div', { cls: 'focus-task-active-task-name', text: task.text });
|
||||||
@@ -186,29 +188,77 @@ export class FocusTaskView extends ItemView {
|
|||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
const controls = activeCard.createEl('div', { cls: 'focus-task-active-controls' });
|
const controls = activeCard.createEl('div', { cls: 'focus-task-active-controls' });
|
||||||
|
|
||||||
this.pauseBtnEl = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-secondary' });
|
|
||||||
this.pauseBtnEl.innerHTML = this.plugin.isTimerRunning ? '⏸ Pause' : '▶ Resume';
|
|
||||||
this.pauseBtnEl.addEventListener('click', () => this.plugin.toggleTimer());
|
|
||||||
|
|
||||||
if (!this.plugin.isBreakMode) {
|
|
||||||
const completeBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-success' });
|
|
||||||
completeBtn.innerHTML = '✓ Complete';
|
|
||||||
completeBtn.addEventListener('click', () => this.plugin.completeTask(task.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
const stopBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-danger' });
|
|
||||||
stopBtn.innerHTML = '✕ Stop';
|
|
||||||
stopBtn.addEventListener('click', () => this.plugin.stopTimer());
|
|
||||||
|
|
||||||
if (this.plugin.isBreakMode) {
|
if (this.plugin.isBreakMode) {
|
||||||
const skipBreakBtn = controls.createEl('button', { cls: 'focus-task-btn' });
|
// Break mode controls
|
||||||
skipBreakBtn.innerHTML = '⏭ Skip Break';
|
if (this.plugin.currentTimerSeconds > 0) {
|
||||||
skipBreakBtn.addEventListener('click', () => {
|
// Break is still counting down
|
||||||
this.plugin.isBreakMode = false;
|
this.pauseBtnEl = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-secondary' });
|
||||||
this.plugin.stopTimer();
|
this.pauseBtnEl.innerHTML = this.plugin.isTimerRunning ? '⏸ Pause' : '▶ Resume';
|
||||||
this.refresh();
|
this.pauseBtnEl.addEventListener('click', () => this.plugin.toggleTimer());
|
||||||
});
|
|
||||||
|
const skipBreakBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-primary' });
|
||||||
|
skipBreakBtn.innerHTML = '⏭ Skip Break';
|
||||||
|
skipBreakBtn.addEventListener('click', () => {
|
||||||
|
this.plugin.isBreakMode = false;
|
||||||
|
this.plugin.startPomodoro(task.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
const stopBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-danger' });
|
||||||
|
stopBtn.innerHTML = '✕ Stop';
|
||||||
|
stopBtn.addEventListener('click', () => {
|
||||||
|
this.plugin.isBreakMode = false;
|
||||||
|
this.plugin.stopTimer();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Break timer finished - show resume button
|
||||||
|
const resumeWorkBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-success' });
|
||||||
|
resumeWorkBtn.innerHTML = '▶ Resume Work';
|
||||||
|
resumeWorkBtn.addEventListener('click', () => {
|
||||||
|
this.plugin.isBreakMode = false;
|
||||||
|
this.plugin.startPomodoro(task.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
const stopBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-danger' });
|
||||||
|
stopBtn.innerHTML = '✕ Stop';
|
||||||
|
stopBtn.addEventListener('click', () => {
|
||||||
|
this.plugin.isBreakMode = false;
|
||||||
|
this.plugin.stopTimer();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Work mode controls
|
||||||
|
if (this.plugin.currentTimerSeconds > 0) {
|
||||||
|
// Work session still running
|
||||||
|
this.pauseBtnEl = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-secondary' });
|
||||||
|
this.pauseBtnEl.innerHTML = this.plugin.isTimerRunning ? '⏸ Pause' : '▶ Resume';
|
||||||
|
this.pauseBtnEl.addEventListener('click', () => this.plugin.toggleTimer());
|
||||||
|
|
||||||
|
const completeBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-success' });
|
||||||
|
completeBtn.innerHTML = '✓ Complete';
|
||||||
|
completeBtn.addEventListener('click', () => this.plugin.completeTask(task.id));
|
||||||
|
|
||||||
|
const stopBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-danger' });
|
||||||
|
stopBtn.innerHTML = '✕ Stop';
|
||||||
|
stopBtn.addEventListener('click', () => this.plugin.stopTimer());
|
||||||
|
} else {
|
||||||
|
// Work session finished - show break and completion options
|
||||||
|
const startBreakBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-secondary' });
|
||||||
|
startBreakBtn.innerHTML = '☕ Start Break';
|
||||||
|
startBreakBtn.addEventListener('click', () => this.plugin.startBreak());
|
||||||
|
|
||||||
|
const continueBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-primary' });
|
||||||
|
continueBtn.innerHTML = '▶ Continue Working';
|
||||||
|
continueBtn.addEventListener('click', () => this.plugin.startPomodoro(task.id));
|
||||||
|
|
||||||
|
const completeBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-success' });
|
||||||
|
completeBtn.innerHTML = '✓ Complete';
|
||||||
|
completeBtn.addEventListener('click', () => this.plugin.completeTask(task.id));
|
||||||
|
|
||||||
|
const stopBtn = controls.createEl('button', { cls: 'focus-task-btn focus-task-btn-danger' });
|
||||||
|
stopBtn.innerHTML = '✕ Stop';
|
||||||
|
stopBtn.addEventListener('click', () => this.plugin.stopTimer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
"1.0.3": "0.15.0"
|
"1.0.4": "0.15.0",
|
||||||
|
"1.0.5": "0.15.0"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user