@bobfrankston/rmfmail 1.0.467
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +429 -0
- package/bin/build-icon-ico.js +283 -0
- package/bin/lean-accounts.js +172 -0
- package/bin/mailx.js +1580 -0
- package/bin/mailx.js.map +1 -0
- package/bin/mailx.ts +1549 -0
- package/bin/postinstall.js +39 -0
- package/bin/postinstall.js.map +1 -0
- package/bin/postinstall.ts +41 -0
- package/bin/tsconfig.json +10 -0
- package/client/.gitattributes +10 -0
- package/client/.msger-window.json +1 -0
- package/client/android.html +226 -0
- package/client/app.js +3400 -0
- package/client/app.js.map +1 -0
- package/client/app.ts +3190 -0
- package/client/components/address-book.js +199 -0
- package/client/components/address-book.js.map +1 -0
- package/client/components/address-book.ts +204 -0
- package/client/components/alarms.js +299 -0
- package/client/components/alarms.js.map +1 -0
- package/client/components/alarms.ts +276 -0
- package/client/components/calendar-sidebar.js +508 -0
- package/client/components/calendar-sidebar.js.map +1 -0
- package/client/components/calendar-sidebar.ts +474 -0
- package/client/components/calendar.js +217 -0
- package/client/components/calendar.js.map +1 -0
- package/client/components/calendar.ts +211 -0
- package/client/components/context-menu.js +80 -0
- package/client/components/context-menu.js.map +1 -0
- package/client/components/context-menu.ts +95 -0
- package/client/components/folder-picker.js +119 -0
- package/client/components/folder-picker.js.map +1 -0
- package/client/components/folder-picker.ts +127 -0
- package/client/components/folder-tree.js +1093 -0
- package/client/components/folder-tree.js.map +1 -0
- package/client/components/folder-tree.ts +1069 -0
- package/client/components/message-list.js +1140 -0
- package/client/components/message-list.js.map +1 -0
- package/client/components/message-list.ts +1129 -0
- package/client/components/message-viewer.js +1291 -0
- package/client/components/message-viewer.js.map +1 -0
- package/client/components/message-viewer.ts +1257 -0
- package/client/components/outbox-view.js +104 -0
- package/client/components/outbox-view.js.map +1 -0
- package/client/components/outbox-view.ts +102 -0
- package/client/components/tasks.js +261 -0
- package/client/components/tasks.js.map +1 -0
- package/client/components/tasks.ts +234 -0
- package/client/compose/compose.css +560 -0
- package/client/compose/compose.html +52 -0
- package/client/compose/compose.js +1289 -0
- package/client/compose/compose.js.map +1 -0
- package/client/compose/compose.ts +1231 -0
- package/client/compose/editor.js +616 -0
- package/client/compose/editor.js.map +1 -0
- package/client/compose/editor.ts +599 -0
- package/client/compose/ghost-text.js +122 -0
- package/client/compose/ghost-text.js.map +1 -0
- package/client/compose/ghost-text.ts +140 -0
- package/client/favicon.svg +11 -0
- package/client/icon.ico +0 -0
- package/client/icon.png +0 -0
- package/client/index.html +230 -0
- package/client/lib/android-bootstrap.js +9 -0
- package/client/lib/android-bootstrap.js.map +1 -0
- package/client/lib/android-bootstrap.ts +9 -0
- package/client/lib/api-client.js +378 -0
- package/client/lib/api-client.js.map +1 -0
- package/client/lib/api-client.ts +439 -0
- package/client/lib/local-service.js +603 -0
- package/client/lib/local-service.js.map +1 -0
- package/client/lib/local-service.ts +646 -0
- package/client/lib/local-store.js +214 -0
- package/client/lib/local-store.js.map +1 -0
- package/client/lib/local-store.ts +283 -0
- package/client/lib/mailxapi.js +304 -0
- package/client/lib/message-state.js +132 -0
- package/client/lib/message-state.js.map +1 -0
- package/client/lib/message-state.ts +160 -0
- package/client/package.json +16 -0
- package/client/styles/components.css +2049 -0
- package/client/styles/layout.css +332 -0
- package/client/styles/variables.css +85 -0
- package/client/tsconfig.json +19 -0
- package/package.json +124 -0
- package/packages/mailx-api/.gitattributes +10 -0
- package/packages/mailx-api/index.d.ts +10 -0
- package/packages/mailx-api/index.d.ts.map +1 -0
- package/packages/mailx-api/index.js +322 -0
- package/packages/mailx-api/index.js.map +1 -0
- package/packages/mailx-api/index.ts +283 -0
- package/packages/mailx-api/package.json +27 -0
- package/packages/mailx-api/tsconfig.json +9 -0
- package/packages/mailx-api/tsconfig.tsbuildinfo +1 -0
- package/packages/mailx-compose/.gitattributes +10 -0
- package/packages/mailx-compose/index.d.ts +21 -0
- package/packages/mailx-compose/index.d.ts.map +1 -0
- package/packages/mailx-compose/index.js +61 -0
- package/packages/mailx-compose/index.js.map +1 -0
- package/packages/mailx-compose/index.ts +85 -0
- package/packages/mailx-compose/package.json +18 -0
- package/packages/mailx-compose/tsconfig.json +9 -0
- package/packages/mailx-core/index.d.ts +139 -0
- package/packages/mailx-core/index.d.ts.map +1 -0
- package/packages/mailx-core/index.js +403 -0
- package/packages/mailx-core/index.js.map +1 -0
- package/packages/mailx-core/index.ts +424 -0
- package/packages/mailx-core/ipc.d.ts +13 -0
- package/packages/mailx-core/ipc.d.ts.map +1 -0
- package/packages/mailx-core/ipc.js +56 -0
- package/packages/mailx-core/ipc.js.map +1 -0
- package/packages/mailx-core/ipc.ts +62 -0
- package/packages/mailx-core/package.json +18 -0
- package/packages/mailx-core/tsconfig.json +9 -0
- package/packages/mailx-host/.gitattributes +10 -0
- package/packages/mailx-host/index.d.ts +21 -0
- package/packages/mailx-host/index.d.ts.map +1 -0
- package/packages/mailx-host/index.js +29 -0
- package/packages/mailx-host/index.js.map +1 -0
- package/packages/mailx-host/index.ts +38 -0
- package/packages/mailx-host/package.json +23 -0
- package/packages/mailx-host/tsconfig.json +9 -0
- package/packages/mailx-host/types-shim.d.ts +14 -0
- package/packages/mailx-imap/.gitattributes +10 -0
- package/packages/mailx-imap/index.d.ts +442 -0
- package/packages/mailx-imap/index.d.ts.map +1 -0
- package/packages/mailx-imap/index.js +3684 -0
- package/packages/mailx-imap/index.js.map +1 -0
- package/packages/mailx-imap/index.ts +3652 -0
- package/packages/mailx-imap/package-lock.json +131 -0
- package/packages/mailx-imap/package.json +28 -0
- package/packages/mailx-imap/providers/gmail-api.d.ts +8 -0
- package/packages/mailx-imap/providers/gmail-api.d.ts.map +1 -0
- package/packages/mailx-imap/providers/gmail-api.js +8 -0
- package/packages/mailx-imap/providers/gmail-api.js.map +1 -0
- package/packages/mailx-imap/providers/gmail-api.ts +8 -0
- package/packages/mailx-imap/providers/outlook-api.ts +7 -0
- package/packages/mailx-imap/providers/types.d.ts +9 -0
- package/packages/mailx-imap/providers/types.d.ts.map +1 -0
- package/packages/mailx-imap/providers/types.js +9 -0
- package/packages/mailx-imap/providers/types.js.map +1 -0
- package/packages/mailx-imap/providers/types.ts +9 -0
- package/packages/mailx-imap/tsconfig.json +9 -0
- package/packages/mailx-imap/tsconfig.tsbuildinfo +1 -0
- package/packages/mailx-send/.gitattributes +10 -0
- package/packages/mailx-send/README.md +217 -0
- package/packages/mailx-send/cli-queue.d.ts +11 -0
- package/packages/mailx-send/cli-queue.d.ts.map +1 -0
- package/packages/mailx-send/cli-queue.js +59 -0
- package/packages/mailx-send/cli-queue.js.map +1 -0
- package/packages/mailx-send/cli-queue.ts +62 -0
- package/packages/mailx-send/cli-send.d.ts +17 -0
- package/packages/mailx-send/cli-send.d.ts.map +1 -0
- package/packages/mailx-send/cli-send.js +75 -0
- package/packages/mailx-send/cli-send.js.map +1 -0
- package/packages/mailx-send/cli-send.ts +83 -0
- package/packages/mailx-send/cli.d.ts +22 -0
- package/packages/mailx-send/cli.d.ts.map +1 -0
- package/packages/mailx-send/cli.js +115 -0
- package/packages/mailx-send/cli.js.map +1 -0
- package/packages/mailx-send/cli.ts +126 -0
- package/packages/mailx-send/index.d.ts +77 -0
- package/packages/mailx-send/index.d.ts.map +1 -0
- package/packages/mailx-send/index.js +264 -0
- package/packages/mailx-send/index.js.map +1 -0
- package/packages/mailx-send/index.ts +333 -0
- package/packages/mailx-send/mailsend/README.md +133 -0
- package/packages/mailx-send/mailsend/cli.d.ts +12 -0
- package/packages/mailx-send/mailsend/cli.d.ts.map +1 -0
- package/packages/mailx-send/mailsend/cli.js +70 -0
- package/packages/mailx-send/mailsend/cli.js.map +1 -0
- package/packages/mailx-send/mailsend/cli.ts +81 -0
- package/packages/mailx-send/mailsend/index.d.ts +77 -0
- package/packages/mailx-send/mailsend/index.d.ts.map +1 -0
- package/packages/mailx-send/mailsend/index.js +264 -0
- package/packages/mailx-send/mailsend/index.js.map +1 -0
- package/packages/mailx-send/mailsend/index.ts +333 -0
- package/packages/mailx-send/mailsend/package-lock.json +65 -0
- package/packages/mailx-send/mailsend/package.json +26 -0
- package/packages/mailx-send/mailsend/tsconfig.json +21 -0
- package/packages/mailx-send/package-lock.json +65 -0
- package/packages/mailx-send/package.json +37 -0
- package/packages/mailx-send/tsconfig.json +21 -0
- package/packages/mailx-server/.gitattributes +10 -0
- package/packages/mailx-server/index.d.ts +8 -0
- package/packages/mailx-server/index.d.ts.map +1 -0
- package/packages/mailx-server/index.js +397 -0
- package/packages/mailx-server/index.js.map +1 -0
- package/packages/mailx-server/index.ts +429 -0
- package/packages/mailx-server/package.json +28 -0
- package/packages/mailx-server/tsconfig.json +9 -0
- package/packages/mailx-server/tsconfig.tsbuildinfo +1 -0
- package/packages/mailx-service/google-sync.d.ts +96 -0
- package/packages/mailx-service/google-sync.d.ts.map +1 -0
- package/packages/mailx-service/google-sync.js +153 -0
- package/packages/mailx-service/google-sync.js.map +1 -0
- package/packages/mailx-service/google-sync.ts +238 -0
- package/packages/mailx-service/index.d.ts +366 -0
- package/packages/mailx-service/index.d.ts.map +1 -0
- package/packages/mailx-service/index.js +2589 -0
- package/packages/mailx-service/index.js.map +1 -0
- package/packages/mailx-service/index.ts +2512 -0
- package/packages/mailx-service/jsonrpc.d.ts +25 -0
- package/packages/mailx-service/jsonrpc.d.ts.map +1 -0
- package/packages/mailx-service/jsonrpc.js +238 -0
- package/packages/mailx-service/jsonrpc.js.map +1 -0
- package/packages/mailx-service/jsonrpc.ts +268 -0
- package/packages/mailx-service/package.json +22 -0
- package/packages/mailx-service/tsconfig.json +9 -0
- package/packages/mailx-settings/.gitattributes +10 -0
- package/packages/mailx-settings/cloud.d.ts +47 -0
- package/packages/mailx-settings/cloud.d.ts.map +1 -0
- package/packages/mailx-settings/cloud.js +408 -0
- package/packages/mailx-settings/cloud.js.map +1 -0
- package/packages/mailx-settings/cloud.ts +393 -0
- package/packages/mailx-settings/index.d.ts +140 -0
- package/packages/mailx-settings/index.d.ts.map +1 -0
- package/packages/mailx-settings/index.js +872 -0
- package/packages/mailx-settings/index.js.map +1 -0
- package/packages/mailx-settings/index.ts +908 -0
- package/packages/mailx-settings/package.json +20 -0
- package/packages/mailx-settings/tsconfig.json +9 -0
- package/packages/mailx-settings/tsconfig.tsbuildinfo +1 -0
- package/packages/mailx-store/.gitattributes +10 -0
- package/packages/mailx-store/db.d.ts +346 -0
- package/packages/mailx-store/db.d.ts.map +1 -0
- package/packages/mailx-store/db.js +1796 -0
- package/packages/mailx-store/db.js.map +1 -0
- package/packages/mailx-store/db.ts +2007 -0
- package/packages/mailx-store/file-store.d.ts +36 -0
- package/packages/mailx-store/file-store.d.ts.map +1 -0
- package/packages/mailx-store/file-store.js +80 -0
- package/packages/mailx-store/file-store.js.map +1 -0
- package/packages/mailx-store/file-store.ts +82 -0
- package/packages/mailx-store/index.d.ts +7 -0
- package/packages/mailx-store/index.d.ts.map +1 -0
- package/packages/mailx-store/index.js +7 -0
- package/packages/mailx-store/index.js.map +1 -0
- package/packages/mailx-store/index.ts +7 -0
- package/packages/mailx-store/package.json +19 -0
- package/packages/mailx-store/tsconfig.json +9 -0
- package/packages/mailx-store/tsconfig.tsbuildinfo +1 -0
- package/packages/mailx-store-web/android-bootstrap.d.ts +16 -0
- package/packages/mailx-store-web/android-bootstrap.d.ts.map +1 -0
- package/packages/mailx-store-web/android-bootstrap.js +1247 -0
- package/packages/mailx-store-web/android-bootstrap.js.map +1 -0
- package/packages/mailx-store-web/android-bootstrap.ts +1262 -0
- package/packages/mailx-store-web/db.d.ts +132 -0
- package/packages/mailx-store-web/db.d.ts.map +1 -0
- package/packages/mailx-store-web/db.js +642 -0
- package/packages/mailx-store-web/db.js.map +1 -0
- package/packages/mailx-store-web/db.ts +756 -0
- package/packages/mailx-store-web/gmail-api-web.d.ts +11 -0
- package/packages/mailx-store-web/gmail-api-web.d.ts.map +1 -0
- package/packages/mailx-store-web/gmail-api-web.js +11 -0
- package/packages/mailx-store-web/gmail-api-web.js.map +1 -0
- package/packages/mailx-store-web/gmail-api-web.ts +11 -0
- package/packages/mailx-store-web/imap-web-provider.d.ts +33 -0
- package/packages/mailx-store-web/imap-web-provider.d.ts.map +1 -0
- package/packages/mailx-store-web/imap-web-provider.js +140 -0
- package/packages/mailx-store-web/imap-web-provider.js.map +1 -0
- package/packages/mailx-store-web/imap-web-provider.ts +156 -0
- package/packages/mailx-store-web/index.d.ts +10 -0
- package/packages/mailx-store-web/index.d.ts.map +1 -0
- package/packages/mailx-store-web/index.js +10 -0
- package/packages/mailx-store-web/index.js.map +1 -0
- package/packages/mailx-store-web/index.ts +10 -0
- package/packages/mailx-store-web/main-thread-host.d.ts +15 -0
- package/packages/mailx-store-web/main-thread-host.d.ts.map +1 -0
- package/packages/mailx-store-web/main-thread-host.js +292 -0
- package/packages/mailx-store-web/main-thread-host.js.map +1 -0
- package/packages/mailx-store-web/main-thread-host.ts +322 -0
- package/packages/mailx-store-web/package.json +23 -0
- package/packages/mailx-store-web/provider-types.d.ts +7 -0
- package/packages/mailx-store-web/provider-types.d.ts.map +1 -0
- package/packages/mailx-store-web/provider-types.js +7 -0
- package/packages/mailx-store-web/provider-types.js.map +1 -0
- package/packages/mailx-store-web/provider-types.ts +7 -0
- package/packages/mailx-store-web/sql-wasm-esm.js +10 -0
- package/packages/mailx-store-web/sql.js.d.ts +29 -0
- package/packages/mailx-store-web/sync-manager.d.ts +68 -0
- package/packages/mailx-store-web/sync-manager.d.ts.map +1 -0
- package/packages/mailx-store-web/sync-manager.js +506 -0
- package/packages/mailx-store-web/sync-manager.js.map +1 -0
- package/packages/mailx-store-web/sync-manager.ts +508 -0
- package/packages/mailx-store-web/tsconfig.json +10 -0
- package/packages/mailx-store-web/web-jsonrpc.d.ts +20 -0
- package/packages/mailx-store-web/web-jsonrpc.d.ts.map +1 -0
- package/packages/mailx-store-web/web-jsonrpc.js +102 -0
- package/packages/mailx-store-web/web-jsonrpc.js.map +1 -0
- package/packages/mailx-store-web/web-jsonrpc.ts +116 -0
- package/packages/mailx-store-web/web-message-store.d.ts +16 -0
- package/packages/mailx-store-web/web-message-store.d.ts.map +1 -0
- package/packages/mailx-store-web/web-message-store.js +89 -0
- package/packages/mailx-store-web/web-message-store.js.map +1 -0
- package/packages/mailx-store-web/web-message-store.ts +97 -0
- package/packages/mailx-store-web/web-service.d.ts +111 -0
- package/packages/mailx-store-web/web-service.d.ts.map +1 -0
- package/packages/mailx-store-web/web-service.js +542 -0
- package/packages/mailx-store-web/web-service.js.map +1 -0
- package/packages/mailx-store-web/web-service.ts +616 -0
- package/packages/mailx-store-web/web-settings.d.ts +83 -0
- package/packages/mailx-store-web/web-settings.d.ts.map +1 -0
- package/packages/mailx-store-web/web-settings.js +491 -0
- package/packages/mailx-store-web/web-settings.js.map +1 -0
- package/packages/mailx-store-web/web-settings.ts +522 -0
- package/packages/mailx-store-web/worker-bundle.js +6838 -0
- package/packages/mailx-store-web/worker-entry.d.ts +8 -0
- package/packages/mailx-store-web/worker-entry.d.ts.map +1 -0
- package/packages/mailx-store-web/worker-entry.js +187 -0
- package/packages/mailx-store-web/worker-entry.js.map +1 -0
- package/packages/mailx-store-web/worker-entry.ts +215 -0
- package/packages/mailx-store-web/worker-tcp-transport.d.ts +28 -0
- package/packages/mailx-store-web/worker-tcp-transport.d.ts.map +1 -0
- package/packages/mailx-store-web/worker-tcp-transport.js +98 -0
- package/packages/mailx-store-web/worker-tcp-transport.js.map +1 -0
- package/packages/mailx-store-web/worker-tcp-transport.ts +101 -0
- package/packages/mailx-types/.gitattributes +10 -0
- package/packages/mailx-types/index.d.ts +319 -0
- package/packages/mailx-types/index.d.ts.map +1 -0
- package/packages/mailx-types/index.js +243 -0
- package/packages/mailx-types/index.js.map +1 -0
- package/packages/mailx-types/index.ts +498 -0
- package/packages/mailx-types/package.json +16 -0
- package/packages/mailx-types/tsconfig.json +9 -0
- package/packages/mailx-types/tsconfig.tsbuildinfo +1 -0
- package/todo.json +13 -0
- package/tsconfig.base.json +31 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tasks pane — goal is "better than Thunderbird" on tasks.
|
|
3
|
+
*
|
|
4
|
+
* Phase-1 features (this commit):
|
|
5
|
+
* - Local-only task store with priority, due-date, snooze, tags, notes
|
|
6
|
+
* - Inline edit, drag-to-reorder by priority, mark complete with strikethrough
|
|
7
|
+
* - Filter by status (active/completed/all), tag, due-soon
|
|
8
|
+
* - "Snooze until" (defer-to-date) — Thunderbird Lightning has nothing here
|
|
9
|
+
* - Quick add from email subject (composeInit-style, hooked from message viewer
|
|
10
|
+
* right-click later)
|
|
11
|
+
*
|
|
12
|
+
* Phase-2 (later):
|
|
13
|
+
* - Google Tasks sync (oauthsupport scope ready)
|
|
14
|
+
* - CalDAV VTODO interop
|
|
15
|
+
* - Task-from-email contextmenu
|
|
16
|
+
* - Reminders that share the calendar/mail alarm subsystem
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
interface Task {
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
notes?: string;
|
|
23
|
+
priority: 0 | 1 | 2 | 3; // 0=none, 1=low, 2=med, 3=high
|
|
24
|
+
due?: number; // ms epoch, 0/undefined = no due
|
|
25
|
+
snoozeUntil?: number; // ms epoch — hide from active list until this passes
|
|
26
|
+
tags?: string[];
|
|
27
|
+
completed?: number; // ms epoch when marked done
|
|
28
|
+
createdAt: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const STORE_KEY = "mailx-tasks-v1";
|
|
32
|
+
let isOpen = false;
|
|
33
|
+
|
|
34
|
+
function loadTasks(): Task[] {
|
|
35
|
+
try {
|
|
36
|
+
const raw = localStorage.getItem(STORE_KEY);
|
|
37
|
+
if (!raw) return [];
|
|
38
|
+
const arr = JSON.parse(raw);
|
|
39
|
+
return Array.isArray(arr) ? arr : [];
|
|
40
|
+
} catch { return []; }
|
|
41
|
+
}
|
|
42
|
+
function saveTasks(tasks: Task[]): void {
|
|
43
|
+
try { localStorage.setItem(STORE_KEY, JSON.stringify(tasks)); } catch { /* */ }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function openTasks(): Promise<void> {
|
|
47
|
+
if (isOpen) return;
|
|
48
|
+
isOpen = true;
|
|
49
|
+
|
|
50
|
+
const backdrop = document.createElement("div");
|
|
51
|
+
backdrop.className = "mailx-modal-backdrop";
|
|
52
|
+
const panel = document.createElement("div");
|
|
53
|
+
panel.className = "mailx-modal mailx-modal-wide";
|
|
54
|
+
panel.innerHTML = `
|
|
55
|
+
<div class="mailx-modal-title">
|
|
56
|
+
<span class="mailx-modal-title-text">Tasks</span>
|
|
57
|
+
<button type="button" class="mailx-modal-close" id="tk-close" title="Close (Esc)" aria-label="Close">×</button>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="tk-toolbar">
|
|
60
|
+
<input type="text" id="tk-quickadd" class="mailx-modal-input" placeholder="Add task — Enter to commit, prefix !!=high !=med ?=low, @tag, due:YYYY-MM-DD" autocomplete="off">
|
|
61
|
+
</div>
|
|
62
|
+
<div class="tk-filters">
|
|
63
|
+
<button type="button" class="tk-filter-btn" data-filter="active">Active</button>
|
|
64
|
+
<button type="button" class="tk-filter-btn" data-filter="due-soon">Due soon</button>
|
|
65
|
+
<button type="button" class="tk-filter-btn" data-filter="completed">Completed</button>
|
|
66
|
+
<button type="button" class="tk-filter-btn" data-filter="all">All</button>
|
|
67
|
+
<span class="tk-spacer"></span>
|
|
68
|
+
<span id="tk-count" class="tk-count"></span>
|
|
69
|
+
</div>
|
|
70
|
+
<div class="tk-list" id="tk-list"></div>
|
|
71
|
+
<div class="mailx-modal-buttons">
|
|
72
|
+
<span class="mailx-modal-spacer"></span>
|
|
73
|
+
<span class="cal-source-note">Local-only · Google Tasks sync pending</span>
|
|
74
|
+
<button type="button" class="mailx-modal-btn" data-action="close">Close</button>
|
|
75
|
+
</div>`;
|
|
76
|
+
backdrop.appendChild(panel);
|
|
77
|
+
document.body.appendChild(backdrop);
|
|
78
|
+
|
|
79
|
+
const quickAdd = panel.querySelector<HTMLInputElement>("#tk-quickadd")!;
|
|
80
|
+
const listEl = panel.querySelector<HTMLElement>("#tk-list")!;
|
|
81
|
+
const countEl = panel.querySelector<HTMLElement>("#tk-count")!;
|
|
82
|
+
|
|
83
|
+
let tasks = loadTasks();
|
|
84
|
+
let filter: "active" | "due-soon" | "completed" | "all" = "active";
|
|
85
|
+
|
|
86
|
+
const setFilter = (f: typeof filter) => {
|
|
87
|
+
filter = f;
|
|
88
|
+
panel.querySelectorAll<HTMLButtonElement>(".tk-filter-btn").forEach(b =>
|
|
89
|
+
b.classList.toggle("tk-filter-active", b.dataset.filter === f));
|
|
90
|
+
render();
|
|
91
|
+
};
|
|
92
|
+
panel.querySelectorAll<HTMLButtonElement>(".tk-filter-btn").forEach(b =>
|
|
93
|
+
b.addEventListener("click", () => setFilter(b.dataset.filter as typeof filter)));
|
|
94
|
+
setFilter("active");
|
|
95
|
+
|
|
96
|
+
const parseQuickAdd = (line: string): Task => {
|
|
97
|
+
const t: Task = {
|
|
98
|
+
id: `tk-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
99
|
+
title: "", priority: 0, createdAt: Date.now(),
|
|
100
|
+
};
|
|
101
|
+
const tags: string[] = [];
|
|
102
|
+
const words = line.split(/\s+/);
|
|
103
|
+
const titleParts: string[] = [];
|
|
104
|
+
for (const w of words) {
|
|
105
|
+
if (w === "!!") { t.priority = 3; continue; }
|
|
106
|
+
if (w === "!") { t.priority = 2; continue; }
|
|
107
|
+
if (w === "?") { t.priority = 1; continue; }
|
|
108
|
+
if (w.startsWith("@") && w.length > 1) { tags.push(w.slice(1)); continue; }
|
|
109
|
+
const dueMatch = w.match(/^due:(\S+)$/i);
|
|
110
|
+
if (dueMatch) {
|
|
111
|
+
const parsed = Date.parse(dueMatch[1]);
|
|
112
|
+
if (!isNaN(parsed)) t.due = parsed;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
titleParts.push(w);
|
|
116
|
+
}
|
|
117
|
+
t.title = titleParts.join(" ").trim();
|
|
118
|
+
if (tags.length) t.tags = tags;
|
|
119
|
+
return t;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
quickAdd.addEventListener("keydown", (e) => {
|
|
123
|
+
if (e.key !== "Enter") return;
|
|
124
|
+
const v = quickAdd.value.trim();
|
|
125
|
+
if (!v) return;
|
|
126
|
+
const t = parseQuickAdd(v);
|
|
127
|
+
if (!t.title) { alert("Task needs a title."); return; }
|
|
128
|
+
tasks.push(t);
|
|
129
|
+
saveTasks(tasks);
|
|
130
|
+
quickAdd.value = "";
|
|
131
|
+
render();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const render = () => {
|
|
135
|
+
const now = Date.now();
|
|
136
|
+
let visible = tasks.slice();
|
|
137
|
+
if (filter === "active") visible = visible.filter(t => !t.completed && (!t.snoozeUntil || t.snoozeUntil <= now));
|
|
138
|
+
else if (filter === "completed") visible = visible.filter(t => !!t.completed);
|
|
139
|
+
else if (filter === "due-soon") visible = visible.filter(t => !t.completed && t.due && t.due <= now + 7 * 86400_000);
|
|
140
|
+
// Sort: priority desc, then due asc (none last), then created asc.
|
|
141
|
+
visible.sort((a, b) => {
|
|
142
|
+
if ((b.priority || 0) !== (a.priority || 0)) return (b.priority || 0) - (a.priority || 0);
|
|
143
|
+
const ad = a.due || Number.MAX_SAFE_INTEGER;
|
|
144
|
+
const bd = b.due || Number.MAX_SAFE_INTEGER;
|
|
145
|
+
if (ad !== bd) return ad - bd;
|
|
146
|
+
return a.createdAt - b.createdAt;
|
|
147
|
+
});
|
|
148
|
+
countEl.textContent = `${visible.length} of ${tasks.length}`;
|
|
149
|
+
if (visible.length === 0) {
|
|
150
|
+
listEl.innerHTML = `<div class="tk-empty">Nothing matches the ${filter} filter.</div>`;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const dueLabel = (ms?: number): string => {
|
|
154
|
+
if (!ms) return "";
|
|
155
|
+
const d = new Date(ms);
|
|
156
|
+
const today = new Date(); today.setHours(0,0,0,0);
|
|
157
|
+
const dt = new Date(ms); dt.setHours(0,0,0,0);
|
|
158
|
+
const days = Math.round((dt.getTime() - today.getTime()) / 86400_000);
|
|
159
|
+
if (days < 0) return `${-days}d overdue`;
|
|
160
|
+
if (days === 0) return "today";
|
|
161
|
+
if (days === 1) return "tomorrow";
|
|
162
|
+
if (days < 7) return `${days}d`;
|
|
163
|
+
return d.toLocaleDateString();
|
|
164
|
+
};
|
|
165
|
+
const prioLabel = (p: number): string => p === 3 ? "‼" : p === 2 ? "!" : p === 1 ? "·" : "";
|
|
166
|
+
listEl.innerHTML = visible.map(t => `
|
|
167
|
+
<div class="tk-row${t.completed ? " tk-done" : ""}" data-id="${t.id}">
|
|
168
|
+
<input type="checkbox" class="tk-check" ${t.completed ? "checked" : ""}>
|
|
169
|
+
<span class="tk-prio tk-prio-${t.priority}">${prioLabel(t.priority)}</span>
|
|
170
|
+
<span class="tk-title" contenteditable="plaintext-only">${escapeHtml(t.title)}</span>
|
|
171
|
+
${t.tags?.length ? `<span class="tk-tags">${t.tags.map(x => `#${escapeHtml(x)}`).join(" ")}</span>` : ""}
|
|
172
|
+
<span class="tk-due${t.due && t.due < now && !t.completed ? " tk-overdue" : ""}">${dueLabel(t.due)}</span>
|
|
173
|
+
<button type="button" class="tk-snooze" title="Snooze 1d / 1w (right-click)">⏰</button>
|
|
174
|
+
<button type="button" class="tk-del" title="Delete">×</button>
|
|
175
|
+
</div>`).join("");
|
|
176
|
+
listEl.querySelectorAll<HTMLElement>(".tk-row").forEach(row => {
|
|
177
|
+
const id = row.dataset.id!;
|
|
178
|
+
const t = tasks.find(x => x.id === id)!;
|
|
179
|
+
row.querySelector<HTMLInputElement>(".tk-check")!.addEventListener("change", (e) => {
|
|
180
|
+
const ck = e.target as HTMLInputElement;
|
|
181
|
+
t.completed = ck.checked ? Date.now() : undefined;
|
|
182
|
+
saveTasks(tasks); render();
|
|
183
|
+
});
|
|
184
|
+
row.querySelector<HTMLButtonElement>(".tk-del")!.addEventListener("click", () => {
|
|
185
|
+
if (!confirm(`Delete task "${t.title}"?`)) return;
|
|
186
|
+
tasks = tasks.filter(x => x.id !== id);
|
|
187
|
+
saveTasks(tasks); render();
|
|
188
|
+
});
|
|
189
|
+
row.querySelector<HTMLButtonElement>(".tk-snooze")!.addEventListener("click", () => {
|
|
190
|
+
t.snoozeUntil = Date.now() + 86400_000; // 1d
|
|
191
|
+
saveTasks(tasks); render();
|
|
192
|
+
});
|
|
193
|
+
row.querySelector<HTMLButtonElement>(".tk-snooze")!.addEventListener("contextmenu", (e) => {
|
|
194
|
+
e.preventDefault();
|
|
195
|
+
t.snoozeUntil = Date.now() + 7 * 86400_000; // 1w
|
|
196
|
+
saveTasks(tasks); render();
|
|
197
|
+
});
|
|
198
|
+
const titleEl = row.querySelector<HTMLElement>(".tk-title")!;
|
|
199
|
+
titleEl.addEventListener("blur", () => {
|
|
200
|
+
const v = (titleEl.textContent || "").trim();
|
|
201
|
+
if (v && v !== t.title) { t.title = v; saveTasks(tasks); }
|
|
202
|
+
});
|
|
203
|
+
titleEl.addEventListener("keydown", (e) => {
|
|
204
|
+
if (e.key === "Enter") { e.preventDefault(); titleEl.blur(); }
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const close = () => {
|
|
210
|
+
backdrop.remove();
|
|
211
|
+
document.removeEventListener("keydown", onKey, true);
|
|
212
|
+
isOpen = false;
|
|
213
|
+
};
|
|
214
|
+
// Esc always closes. Earlier guard blocked Esc when focus was in the
|
|
215
|
+
// quickadd input, which made the panel feel stuck — user hits Esc to
|
|
216
|
+
// dismiss and nothing happens. Blur-on-Esc before close is the right
|
|
217
|
+
// behavior: the close handler is idempotent and the input loses focus
|
|
218
|
+
// when the backdrop goes away anyway.
|
|
219
|
+
const onKey = (e: KeyboardEvent) => {
|
|
220
|
+
if (e.key === "Escape") {
|
|
221
|
+
e.stopPropagation(); e.preventDefault(); close();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
document.addEventListener("keydown", onKey, true);
|
|
225
|
+
panel.querySelector<HTMLButtonElement>("#tk-close")!.addEventListener("click", close);
|
|
226
|
+
panel.querySelector<HTMLButtonElement>('[data-action="close"]')!.addEventListener("click", close);
|
|
227
|
+
backdrop.addEventListener("mousedown", (e) => { if (e.target === backdrop) close(); });
|
|
228
|
+
|
|
229
|
+
quickAdd.focus();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function escapeHtml(s: string): string {
|
|
233
|
+
return s.replace(/[&<>"']/g, c => ({ "&": "&", "<": "<", ">": ">", "\"": """, "'": "'" }[c]!));
|
|
234
|
+
}
|