jt-workspace-dashboard 0.0.0-stage → 0.1.2-stable
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 +76 -2
- package/dist/dashboard.js +751 -0
- package/package.json +16 -4
package/README.md
CHANGED
|
@@ -1,3 +1,77 @@
|
|
|
1
|
-
#
|
|
1
|
+
# jt-workspace-dashboard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared code for Jeremy's Claude dashboards. Each Claude account has one dashboard page (an artifact) that is only a **shell**: its settings plus one script tag that loads this package from npm. Change the dashboard here, once, and every dashboard picks it up.
|
|
4
|
+
|
|
5
|
+
The dashboard is a **consolidator**: it stores no tasks. To-dos live in Todoist, events in Google Calendar. The page reads and writes them with the viewer's own Claude connectors.
|
|
6
|
+
|
|
7
|
+
## Channels
|
|
8
|
+
|
|
9
|
+
| Channel | Who uses it | When it updates |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `latest` | Personal + Tactus dashboard | Every push to `main` (after tests pass) |
|
|
12
|
+
| `stable` | Pelicargo dashboard | Daily, once a release has been live 24 h. Run the **Publish** workflow by hand ("Run workflow") to ship sooner. |
|
|
13
|
+
|
|
14
|
+
Rollback: revert the bad commit on `main` (a new version is published automatically).
|
|
15
|
+
|
|
16
|
+
Publishing uses npm trusted publishing, linked to `.github/workflows/publish.yml` (keep all publishing in that one file).
|
|
17
|
+
|
|
18
|
+
## Shell config (`window.DASHBOARD_CONFIG`)
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
{
|
|
22
|
+
title: "Dashboard",
|
|
23
|
+
ownerName: "Jeremy",
|
|
24
|
+
labels: { ready: "Paused" }, // optional: Todoist label names (defaults below)
|
|
25
|
+
workspaces: [
|
|
26
|
+
{
|
|
27
|
+
id: "personal", name: "Personal", accent: "#2B8A6E",
|
|
28
|
+
todoist: { projectId: "…" }, // or projectIds: [...]
|
|
29
|
+
sections: { ready: "Paused" }, // display names; ids are fixed
|
|
30
|
+
calendar: { ids: ["primary"], hide: ["Time Blocking"] }, // or false
|
|
31
|
+
updateTask: "trig_…", updateLabel: "Sort inbox",
|
|
32
|
+
features: { handoff: false, meetingAsks: false, showFollowUp: false, chatLink: false }
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The page's database (only used for the update button's status line) is read at `meta/status-<workspace id>`.
|
|
39
|
+
|
|
40
|
+
The page's declared capabilities must include `mcp` with Todoist (`find-tasks`, `find-completed-tasks`, `update-tasks`, `complete-tasks`, `uncomplete-tasks`, `delete-object`), Google Calendar (`list_events`), Claude Code Remote (`fire_trigger`), plus `host:claude_browser` (`preview_start`, `find`) if `chatLink` is on, and `db`.
|
|
41
|
+
|
|
42
|
+
## Todoist conventions
|
|
43
|
+
|
|
44
|
+
**Sections come from labels** (one status label per task; none = To do):
|
|
45
|
+
|
|
46
|
+
| Section id | Default label | Shown as (default) |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| `upcoming` | (no status label) | To do |
|
|
49
|
+
| `today` | `In progress` | In progress |
|
|
50
|
+
| `ready` | `Paused` | Paused / Ready to show |
|
|
51
|
+
| `waiting` | `Waiting` | Waiting on others |
|
|
52
|
+
| `handoff` | `Handoff` | Handoff prep (feature `handoff`) |
|
|
53
|
+
| `later` | `Later` | Later |
|
|
54
|
+
| `meeting` | `Ask` | Under its meeting in the side rail (feature `meetingAsks`) |
|
|
55
|
+
| `done` | completed in Todoist | Completed (last 7 days) |
|
|
56
|
+
|
|
57
|
+
**Task description**, top to bottom (all optional):
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
Waiting on: Jon
|
|
61
|
+
Link: https://… main source (Slack thread, Gmail, Fathom call)
|
|
62
|
+
Figma: https://…
|
|
63
|
+
Chat: https://claude.ai/chat/…
|
|
64
|
+
Meeting: Jeremy-Tactus UX for Ask tasks: the meeting title it belongs to
|
|
65
|
+
One or two lines of note.
|
|
66
|
+
Context:
|
|
67
|
+
- decision or background bullet
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Subtasks** are the checklist; a subtask's description lines are its notes. Subtasks labelled `Question` show in the card's **Questions** fold instead (complete = answered). Priority p1–p3 shows as Urgent / High / Medium.
|
|
71
|
+
|
|
72
|
+
## Develop
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
npm install
|
|
76
|
+
npm test # builds dist/dashboard.js and runs the smoke test for every account setup
|
|
77
|
+
```
|
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
/* Shared dashboard. Each account's page sets window.DASHBOARD_CONFIG, then loads this file.
|
|
2
|
+
The dashboard holds no tasks of its own: it reads and writes them in Todoist (and shows Google Calendar),
|
|
3
|
+
using the viewer's own connectors. See README.md for the config format and the Todoist conventions. */
|
|
4
|
+
(function(){
|
|
5
|
+
"use strict";
|
|
6
|
+
const CFG = window.DASHBOARD_CONFIG || {};
|
|
7
|
+
const WORKSPACES = Array.isArray(CFG.workspaces) && CFG.workspaces.length ? CFG.workspaces : [{id: "main", name: "Dashboard", todoist: {}}];
|
|
8
|
+
const LABELS = Object.assign({today: "In progress", ready: "Paused", waiting: "Waiting", later: "Later", handoff: "Handoff", meeting: "Ask", question: "Question"}, CFG.labels || {});
|
|
9
|
+
const OWNER_NAME = String(CFG.ownerName || "").slice(0, 40);
|
|
10
|
+
const VERSION = "0.1.2-stable";
|
|
11
|
+
|
|
12
|
+
/* ---------- page skeleton ---------- */
|
|
13
|
+
document.title = CFG.title || "Dashboard";
|
|
14
|
+
const styleEl = document.createElement("style"); styleEl.textContent = "/* Layout: header with day summary; tasks in a main column of soft cards, meetings + notes in a side rail. Each card has a left gutter that holds the section dot and the drag handles, so text lines up. */\n:root{\n --bg:#F2F4F7; --surface:#FFFFFF; --fg:#1D2433; --soft:#5B6475; --faint:#98A1B0; --line:#E6E9EE;\n --accent:#3A5BD9; --accent-soft:#E9EEFD; --green:#26946A; --green-soft:#E2F3EB; --amber:#B86E12; --amber-soft:#FBEFDC; --grey:#A3ABB8; --violet:#7B4FD1; --s-todo:#95A2B3; --s-prog:#F2C94C; --s-ready:#4CB782; --s-wait:#F2994A; --s-hand:#26B5CE; --s-later:#BEC2C8; --s-done:#8E9AAF; --wait-soft:#FDEEDF; --wait-text:#A3530F; --line-strong:#D3D8E0; --new:#D6336C;\n --shadow:0 1px 2px rgba(20,30,50,.05),0 4px 16px rgba(20,30,50,.05);\n --font:\"Figtree\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif;\n}\n@media (prefers-color-scheme: dark){:root:not([data-theme=\"light\"]){\n --bg:#111318; --surface:#1A1D24; --fg:#E7EAF0; --soft:#A4ACBA; --faint:#6E7686; --line:#2A2F39;\n --accent:#93A9FF; --accent-soft:#232B47; --green:#5FCB9C; --green-soft:#1A3328; --amber:#E7AA5A; --amber-soft:#3A2C18; --grey:#6E7686; --violet:#B69CF5; --s-todo:#8A8F98; --s-prog:#F2C94C; --s-ready:#4CB782; --s-wait:#F2994A; --s-hand:#26B5CE; --s-later:#5A606B; --s-done:#6A7486; --wait-soft:#3B2716; --wait-text:#F5B07A; --line-strong:#3A404C; --new:#F17FA8;\n --shadow:0 1px 2px rgba(0,0,0,.3); color-scheme:dark}}\n:root[data-theme=\"dark\"]{\n --bg:#111318; --surface:#1A1D24; --fg:#E7EAF0; --soft:#A4ACBA; --faint:#6E7686; --line:#2A2F39;\n --accent:#93A9FF; --accent-soft:#232B47; --green:#5FCB9C; --green-soft:#1A3328; --amber:#E7AA5A; --amber-soft:#3A2C18; --grey:#6E7686; --violet:#B69CF5; --s-todo:#8A8F98; --s-prog:#F2C94C; --s-ready:#4CB782; --s-wait:#F2994A; --s-hand:#26B5CE; --s-later:#5A606B; --s-done:#6A7486; --wait-soft:#3B2716; --wait-text:#F5B07A; --line-strong:#3A404C; --new:#F17FA8;\n --shadow:0 1px 2px rgba(0,0,0,.3); color-scheme:dark}\n*{box-sizing:border-box}\n[hidden]{display:none!important}\nbody{background:var(--bg);color:var(--fg);font-family:var(--font);margin:0;-webkit-font-smoothing:antialiased}\n.wrap{max-width:1060px;margin:0 auto;padding-block:36px 72px;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}\nbutton{font:inherit;cursor:pointer}\n\n/* header */\nheader{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:14px 24px;margin-bottom:24px}\n.kicker{font-size:13px;font-weight:600;color:var(--accent);letter-spacing:.02em;margin-bottom:4px}\nh1{font-size:32px;line-height:1.1;font-weight:800;letter-spacing:-.02em;margin:0;text-wrap:balance}\n.sub{font-size:14px;color:var(--soft);margin-top:6px}\n.pills{display:flex;flex-wrap:wrap;gap:8px}\n.pill{display:inline-flex;align-items:center;gap:7px;font-size:13px;font-weight:600;padding:6px 12px;border-radius:999px;background:var(--surface);box-shadow:var(--shadow);color:var(--fg);font-variant-numeric:tabular-nums}\n.pill i{width:8px;height:8px;border-radius:50%;display:block}\n.head-right{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.link-chats{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:700;padding:9px 18px;border-radius:999px;border:0;background:var(--accent);color:var(--surface);box-shadow:0 2px 8px rgba(58,91,217,.25)}\n.link-chats:hover:not(:disabled){filter:brightness(1.08)}\n.link-chats:disabled{opacity:.85;cursor:default}\n.link-chats svg{width:15px;height:15px}\n.link-chats.busy svg{animation:spin 1s linear infinite}\n@keyframes spin{to{transform:rotate(360deg)}}\n@media (prefers-reduced-motion: reduce){.link-chats.busy svg{animation:none}}\n.clear-new{font:inherit;font-size:13px;font-weight:650;padding:7px 12px;border-radius:999px;border:1px solid var(--line);background:var(--surface);color:var(--new);cursor:pointer}\n.clear-new:hover{border-color:var(--new)}\n.update-wrap{position:relative;display:inline-flex}\n.update-state{font:inherit;font-size:12.5px;color:var(--faint);background:none;border:0;padding:4px 2px;cursor:help;text-decoration:underline dotted;text-underline-offset:3px}\n.update-state:empty{display:none}\n.update-tip{position:absolute;right:0;top:calc(100% + 6px);z-index:30;width:max-content;max-width:min(320px,80vw);background:var(--fg);color:var(--bg);font-size:13px;line-height:1.45;padding:9px 12px;border-radius:10px;box-shadow:0 10px 30px rgba(0,0,0,.2);white-space:pre-line}\n.update-wrap:hover .update-tip:not(:empty),.update-wrap:focus-within .update-tip:not(:empty),.update-tip.show:not(:empty){display:block!important}\n.status{flex-basis:100%;font-size:13px;color:var(--amber)}\n\n/* layout */\n.grid{display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:20px;align-items:start}\n.rail{display:grid;gap:20px;position:sticky;top:calc(16px + env(safe-area-inset-top,0px))}\n.main{display:grid;gap:20px;min-width:0}\n.card{background:var(--surface);border-radius:16px;box-shadow:var(--shadow);padding:18px 20px 12px 46px;position:relative;min-width:0}\n.rail .card{padding:18px 20px 18px 20px}\nh2{font-size:16px;font-weight:700;margin:0 0 8px;display:flex;gap:8px;align-items:center;position:relative}\n.card > h2 .dot{position:absolute;left:-28px;top:50%;width:10px;height:10px;margin-top:-5px;border-radius:50%}\n.count{font-size:12px;font-weight:700;min-width:22px;height:20px;padding:0 7px;border-radius:999px;background:var(--bg);color:var(--soft);display:inline-flex;align-items:center;justify-content:center;font-variant-numeric:tabular-nums}\n.count:empty{display:none}\nh3{font-size:12px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;margin:14px 0 2px;display:flex;align-items:center;gap:8px;position:relative}\nh3 .dot{position:absolute;left:-27px;width:8px;height:8px;border-radius:50%}\n.h-ready{color:var(--green)} .h-waiting{color:var(--amber)}\nul{list-style:none;margin:0;padding:0}\n.empty{font-size:14px;color:var(--faint);padding:10px 0 12px}\n\n/* meetings */\n#meetings{display:grid;gap:8px;margin-top:6px}\n.mtg{display:flex;gap:12px;align-items:center;padding:10px 12px;border-radius:12px;background:var(--accent-soft)}\n.mtg .time{font-size:12.5px;font-weight:700;color:var(--accent);min-width:0;white-space:nowrap;font-variant-numeric:tabular-nums}\n.mtg a,.mtg span.t{color:var(--fg);font-weight:600;font-size:14.5px;text-decoration:none;min-width:0;overflow-wrap:anywhere}\n.mtg a:hover{text-decoration:underline}\n#meetings .empty{padding:4px 0}\n#meetings{gap:14px}\n.mtg-block{display:grid;gap:6px}\n.agenda-h{font-size:11.5px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--soft);margin:6px 0 0 2px}\n.agenda{display:grid;gap:2px}\n.ask{display:flex;align-items:flex-start;gap:10px;padding:6px 2px}\n.check{flex:none;width:20px;height:20px;margin-top:1px;border-radius:6px;border:2px solid var(--grey);background:transparent;padding:0;position:relative}\n.check:hover{border-color:var(--accent);background:var(--accent-soft)}\n.ask .t{flex:1;min-width:0;font-size:14.5px;font-weight:500;line-height:1.4;overflow-wrap:anywhere}\n.ask .n{display:block;font-size:13px;font-weight:400;line-height:1.5;color:var(--soft);margin-top:4px;white-space:pre-line}\n.note{white-space:pre-line}\n.subs{display:grid;gap:2px;margin:8px 0 0}\n.sub{display:flex;align-items:flex-start;gap:9px;font-size:14px;line-height:1.45;color:var(--fg);padding:3px 0}\n.sub .check{width:18px;height:18px;border-radius:5px;margin-top:1px}\n.sub.done span{color:var(--faint);text-decoration:line-through}\n.sub.done .check{background:var(--accent);border-color:var(--accent)}\n.sub.done .check::after{content:\"\";position:absolute;left:50%;top:45%;width:4px;height:8px;border:solid var(--surface);border-width:0 2px 2px 0;transform:translate(-50%,-50%) rotate(45deg)}\n.done-toggle{display:block;border:0;background:none;padding:4px 0 0 27px;font-size:12.5px;font-weight:600;color:var(--faint);cursor:pointer}\n.done-toggle:hover{color:var(--accent)}\n.sub-count{font-size:12px;font-weight:700;color:var(--faint);margin-left:8px;font-variant-numeric:tabular-nums}\n.add-sub{display:block;border:0;background:none;color:var(--faint);font-size:13px;font-weight:600;padding:4px 0 0 27px}\n.add-sub:hover{color:var(--accent)}\n.sub-input{font:inherit;font-size:14px;margin:4px 0 0 27px;width:calc(100% - 27px);padding:6px 9px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--fg)}\n.new-tag{display:inline-block;font-size:10.5px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:#fff;background:var(--new);border-radius:999px;padding:2px 8px;margin-left:8px;vertical-align:2px}\n.sub-new{flex:none;width:7px;height:7px;border-radius:50%;background:var(--new);margin-top:7px}\n.ask .new-tag{margin-left:6px;vertical-align:1px}\n.clamp:not(.open){display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}\n.ctx{margin-top:10px;padding:8px 12px;border-radius:10px;background:var(--bg);cursor:pointer}\n.ctx:hover{background:var(--accent-soft)}\n.ctx.open{padding-bottom:10px}\n.ctx-h{display:flex;align-items:center;gap:6px;width:100%;border:0;background:none;padding:0;cursor:pointer;font-size:11px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:var(--faint);text-align:left}\n.ctx-h svg{width:12px;height:12px;transform:rotate(-90deg);transition:transform .15s}\n.ctx.open .ctx-h svg{transform:none}\n.ctx.open .ctx-h{margin-bottom:6px}\n.sub-wrap{display:block}\n.sub-t.has-notes{cursor:pointer}\n.sub-t.has-notes:hover{color:var(--accent)}\n.sub-tg{flex:none;width:22px;height:22px;margin-left:auto;border:0;border-radius:6px;background:transparent;color:var(--faint);padding:0;display:flex;align-items:center;justify-content:center}\n.sub-tg:hover{background:var(--bg);color:var(--fg)}\n.sub-tg svg{width:12px;height:12px;transform:rotate(-90deg);transition:transform .15s}\n.sub.open .sub-tg svg{transform:none}\n.bullets{list-style:disc;margin:0;padding-left:18px;display:grid;gap:4px;font-size:13.5px;line-height:1.5;color:var(--soft)}\n.bullets li::marker{color:var(--faint)}\n.sub-notes{margin:2px 0 6px 27px;padding:8px 10px;border-radius:8px;background:var(--bg);display:grid;gap:5px}\n.ctx .read-more{position:absolute;left:50%;bottom:8px;transform:translateX(-50%);opacity:0;transition:opacity .12s;background:var(--surface);padding:3px 12px;border-radius:999px;box-shadow:var(--shadow);white-space:nowrap}\n.ctx:hover .read-more,.ctx:focus-within .read-more{opacity:1}\n@media (hover:none){.ctx .read-more{opacity:1}}\n.ctx-body{display:grid;gap:6px}\n.ctx-row{margin:0;font-size:13.5px;line-height:1.5;color:var(--soft);overflow-wrap:anywhere}\n.ctx-src{font-weight:700;color:var(--fg);margin-right:6px}\n.clampbox.clamp:not(.open){display:grid;-webkit-line-clamp:unset;max-height:4.6em;overflow:hidden;-webkit-mask-image:linear-gradient(#000 60%,transparent);mask-image:linear-gradient(#000 60%,transparent)}\n.read-more{display:block;border:0;background:none;color:var(--accent);font-size:12.5px;font-weight:650;padding:2px 0 0;margin:0}\n.read-more:hover{text-decoration:underline}\n.ask .actions{margin:0}\n.ask .actions .more{padding:1px 8px}\n.ask .menu{left:auto;right:0}\n.mini{display:flex;align-items:flex-start;gap:9px;font-size:14px;line-height:20px;padding:4px 2px;color:var(--fg)}\n.mini i{flex:none;width:7px;height:7px;border-radius:50%;margin-top:6.5px}\n.mini .mt{flex:1;min-width:0;overflow-wrap:anywhere}\n.mini .sub2{color:var(--faint);font-size:13px;margin-left:8px}\n\n/* notes */\n.notes textarea{display:block;width:100%;min-height:96px;resize:vertical;font:inherit;font-size:14.5px;line-height:1.55;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:var(--bg);color:var(--fg);margin-top:6px}\n.notes textarea:focus{background:var(--surface)}\n.notes-bar{display:flex;flex-wrap:wrap;gap:10px;align-items:center;justify-content:space-between;margin-top:10px}\n.notes-bar .sub{font-size:12.5px;color:var(--faint);margin:0;flex:1 1 140px}\n.primary{font-size:14px;font-weight:700;padding:9px 16px;border-radius:10px;border:0;background:var(--accent);color:var(--surface)}\n.primary:hover:not(:disabled){filter:brightness(1.08)}\n.primary:disabled{opacity:.5;cursor:default}\n\n/* items */\n.item{position:relative;padding:12px 34px 12px 0;border-top:1px solid var(--line)}\n.chev{position:absolute;right:0;top:10px;width:28px;height:28px;border:0;border-radius:8px;background:transparent;color:var(--faint);padding:0;display:flex;align-items:center;justify-content:center}\n.chev:hover{background:var(--bg);color:var(--fg)}\n.chev svg{width:14px;height:14px;transition:transform .15s}\n.item.collapsed .chev svg{transform:rotate(-90deg)}\n.item.collapsed > .note,.item.collapsed > .read-more,.item.collapsed > .subs,.item.collapsed > .ctx,.item.collapsed > .done-toggle,.item.collapsed > .actions{display:none}\n.item.collapsed{padding-bottom:10px}\n.links{display:flex;flex-wrap:wrap;gap:6px;margin-top:7px}\n.prio{display:inline-flex;align-items:center;gap:5px;font-size:12.5px;font-weight:650;color:var(--soft);padding:3px 9px 3px 7px;border-radius:999px;border:1px solid var(--line);background:var(--surface)}\n.prio svg{width:14px;height:14px;flex:none}\n.prio-urgent{color:#E8590C}\n.link-pill{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;font-weight:650;color:var(--soft);text-decoration:none;padding:3px 10px 3px 8px;border-radius:999px;border:1px solid var(--line);background:var(--surface)}\n.link-pill:hover{color:var(--fg);border-color:var(--faint)}\n.link-pill svg{width:13px;height:13px;flex:none}\n.foldable > h2{cursor:pointer;padding-right:36px;user-select:none}\n.foldable > h2 .chev{top:50%;margin-top:-14px}\n.foldable.collapsed > :not(h2){display:none}\n.foldable.collapsed{padding-bottom:18px}\n.foldable.collapsed > h2{margin-bottom:0}\n.foldable.collapsed > h2 .chev svg{transform:rotate(-90deg)}\nli.item:first-child{border-top-color:transparent}\n.item[draggable=\"true\"]{cursor:pointer}\n.item.grabbing,.item.grabbing *,.item.dragging,.item.dragging *{cursor:grabbing!important}\n.item.dragging{opacity:.4}\n.item.over{box-shadow:0 -2px 0 var(--accent)}\n.handle{position:absolute;left:-42px;top:6px;width:34px;display:flex;flex-direction:column;align-items:center;opacity:0;transition:opacity .12s}\n.item:hover .handle,.item:focus-within .handle{opacity:1}\n.handle button{border:0;background:transparent;color:var(--faint);width:34px;height:22px;padding:0;font-size:11px;line-height:1;border-radius:6px}\n.handle button:hover:not(:disabled){color:var(--fg);background:var(--accent-soft)}\n.handle button:disabled{opacity:.3;cursor:default}\n.grip{cursor:grab;color:var(--faint);font-size:13px;line-height:1;padding:3px 0;user-select:none}\n.title{font-size:15.5px;font-weight:650;color:var(--fg);text-decoration:none;overflow-wrap:anywhere}\na.title:hover{color:var(--accent)}\n.ref{display:inline-block;font-size:11.5px;font-weight:700;color:var(--soft);background:var(--bg);border-radius:6px;padding:2px 7px;margin-left:8px;vertical-align:2px;font-variant-numeric:tabular-nums;letter-spacing:.02em}\n.who{display:inline-block;font-size:12px;font-weight:700;color:var(--amber);background:var(--amber-soft);border-radius:999px;padding:2px 9px;margin-left:8px;vertical-align:2px}\n.note{font-size:14px;line-height:1.5;color:var(--soft);margin:4px 0 0;overflow-wrap:anywhere}\n.actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}\n.actions button{font-size:13px;font-weight:600;padding:5px 12px;border-radius:8px;border:0;background:transparent;color:var(--soft)}\n.actions button.go{background:var(--accent-soft);color:var(--accent)}\n.actions button.go:hover{background:var(--accent);color:var(--surface)}\n.view-toggle{display:inline-flex;background:var(--surface);border-radius:10px;padding:3px;box-shadow:var(--shadow)}\n.view-toggle button{border:0;background:transparent;color:var(--soft);font:inherit;font-size:13px;font-weight:600;padding:5px 11px;border-radius:8px;cursor:pointer}\n.view-toggle button[aria-pressed=\"true\"]{background:var(--accent-soft);color:var(--accent)}\n.board{display:none}\n.active-only .card[data-key=\"upcoming\"],.active-only .card[data-key=\"later\"],.active-only .completed-card{display:none}\n.wrap.board-view{max-width:1520px}\n.board-view .board{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(210px,1fr);gap:12px;overflow-x:auto;min-width:0;padding-bottom:6px;align-items:stretch}\n.board-view .main{display:none}\n.kcol{background:var(--surface);border-radius:16px;box-shadow:var(--shadow);padding:14px 10px 10px;display:flex;flex-direction:column;min-height:240px;min-width:0}\n.kcol h2{font-size:14px;display:flex;gap:8px;align-items:center;margin:0 4px 10px}\n.kcol h2 i{width:9px;height:9px;border-radius:50%;flex:none}\n.kcol ul{display:grid;gap:8px;align-content:start;flex:1;min-height:80px;border-radius:10px;transition:background .15s}\n.kcol ul.over{background:var(--accent-soft)}\n.kcard{background:var(--bg);border-radius:10px;padding:10px 11px;cursor:pointer;display:grid;gap:6px;font-size:14px;min-width:0}\n.kcard:hover{box-shadow:inset 0 0 0 1px var(--line)}\n.drawer-back{position:fixed;inset:0;background:rgba(0,0,0,.28);z-index:40}\n.drawer{position:fixed;top:0;right:0;bottom:0;width:min(480px,100%);background:var(--surface);box-shadow:-14px 0 40px rgba(0,0,0,.18);transform:translateX(105%);transition:transform .2s ease;z-index:41;overflow-y:auto;padding:calc(14px + env(safe-area-inset-top,0px)) 22px calc(28px + env(safe-area-inset-bottom,0px)) 48px}\n.drawer.open{transform:none}\n.drawer-head{display:flex;justify-content:space-between;align-items:center;margin:0 0 6px -26px}\n.drawer-sec{font-size:12px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--soft)}\n.drawer-close{border:0;background:var(--bg);color:var(--soft);width:32px;height:32px;border-radius:8px;display:grid;place-items:center;cursor:pointer}\n.drawer-close svg{width:16px;height:16px}\n.drawer-close:hover{color:var(--fg)}\n#drawerBody .chev{display:none}\n.kcard.dragging{opacity:.4}\n.kref{font-size:11.5px;font-weight:700;color:var(--soft);letter-spacing:.03em}\n.kt{font-weight:600;line-height:1.35;overflow-wrap:anywhere;color:var(--fg)}\n.kmeta{display:flex;flex-wrap:wrap;gap:4px 10px;align-items:center;font-size:12px;color:var(--soft)}\n.kmeta a{color:var(--accent);text-decoration:none;font-weight:600}\n.kmeta a:hover{text-decoration:underline}\n.kmove{font:inherit;font-size:12px;color:var(--soft);background:transparent;border:1px solid var(--line);border-radius:6px;padding:2px 4px;margin-left:auto;max-width:100%}\n.reopen{margin-left:auto;flex:none;border:0;border-radius:8px;padding:3px 9px;font:inherit;font-size:12.5px;font-weight:600;cursor:pointer;background:var(--accent-soft);color:var(--accent)}\n.reopen:hover{background:var(--accent);color:var(--surface)}\n.kick-box{margin-top:8px;display:grid;gap:4px;max-width:460px}\n.kick-row{display:flex;gap:6px;align-items:center}\n.kick-row input{flex:1;min-width:0;margin-left:0}\n.kick-row button{border:0;border-radius:8px;padding:6px 10px;font:inherit;font-size:13px;font-weight:600;cursor:pointer;background:var(--bg);color:var(--soft)}\n.kick-row button.go{background:var(--accent);color:var(--surface)}\n.kick-hint{font-size:12px;color:var(--faint)}\n.actions .more{padding:5px 10px;letter-spacing:1px;font-weight:800}\n.actions .more:hover,.actions .more[aria-expanded=\"true\"]{background:var(--bg);color:var(--fg)}\n.menu-wrap{position:relative;display:inline-block}\n.menu{position:absolute;z-index:20;top:calc(100% + 6px);left:0;min-width:220px;background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 32px rgba(20,30,50,.16);padding:6px;display:grid;gap:2px}\n.actions .menu button{text-align:left;padding:8px 10px;border-radius:8px;font-size:13.5px;font-weight:500;color:var(--fg)}\n.actions .menu button:hover{background:var(--accent-soft)}\n.actions .menu button.danger{color:var(--amber)}\n.actions .menu button.danger:hover{background:var(--amber-soft)}\n\n/* later accordion */\ndetails.later{margin:6px 0 4px;border-top:1px solid var(--line);padding-top:10px}\ndetails.later summary{cursor:pointer;font-size:12px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:var(--soft);padding:4px 0;list-style:none;display:flex;gap:8px;align-items:center;position:relative}\ndetails.later summary::-webkit-details-marker{display:none}\ndetails.later summary::before{content:\"\";position:absolute;left:-29px;width:0;height:0;border-left:6px solid var(--grey);border-top:5px solid transparent;border-bottom:5px solid transparent;transition:transform .15s}\ndetails.later[open] summary::before{transform:rotate(90deg)}\n\n.handle{display:none!important}\n@media (hover:none){\n .handle{display:flex!important;position:static;width:auto;flex-direction:row;gap:6px;opacity:1}\n .handle .grip{display:none}\n .handle button{width:auto;height:auto;font-size:12px;padding:4px 9px;background:var(--bg)}\n .item .handle{float:right;margin-left:8px}\n}\n@media (max-width:880px){\n .grid{grid-template-columns:minmax(0,1fr)}\n .rail{position:static;order:-1}\n}\n@media (max-width:560px){\n h1{font-size:26px}\n .card{padding:16px 16px 10px 34px}\n .card > h2 .dot{left:-21px}\n h3 .dot{left:-20px}\n details.later summary::before{left:-22px}\n}\nbutton:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:2px solid var(--accent);outline-offset:2px}\n.toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(20px + env(safe-area-inset-bottom,0px));background:var(--fg);color:var(--bg);font-size:14px;font-weight:500;padding:11px 16px;border-radius:12px;display:flex;gap:14px;align-items:center;box-shadow:0 10px 30px rgba(0,0,0,.2);max-width:calc(100% - 32px)}\n.toast button{border:0;background:transparent;color:var(--bg);font-weight:700;text-decoration:underline;padding:0}\n@media (prefers-reduced-motion: reduce){*{transition:none!important}}\n/* v2: list view. Sections are plain headers; every item is its own card. */\n.main{gap:26px}\n.main > section.card{background:none;box-shadow:none;padding:0;border-radius:0}\n.main > section.card > h2{font-size:13.5px;font-weight:650;margin:0 0 9px 2px;gap:8px;padding-right:30px}\n.main > section.card > h2 .dot{position:static;width:8px;height:8px;margin:0;flex:none}\n.dot.ring,.kcol h2 i.ring{background:transparent;border:1.6px solid var(--s-later);box-sizing:border-box}\n.main > section.card > h2 .count{background:none;padding:0;min-width:0;height:auto;color:var(--faint);font-weight:500}\n.main > section.card > ul{display:grid;gap:8px}\n.main > section.card > ul > .empty{padding:2px 2px 4px;font-size:13.5px}\n.item{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:11px 14px 12px;display:grid;gap:8px;min-width:0;box-shadow:none}\n.main .item:hover{border-color:var(--line-strong)}\n.item.dragging{opacity:.4}\n.ihead{display:flex;align-items:flex-start;gap:8px;min-width:0}\n.ihead .title{flex:1;min-width:0;font-size:14.5px;font-weight:600;line-height:20px;color:var(--fg);overflow-wrap:anywhere}\n.ihead .title.drag{cursor:grab}\n.ihead .who{flex:none;margin:1px 0 0;font-size:11.5px;font-weight:650;line-height:18px;padding:0 8px;vertical-align:0;background:var(--wait-soft);color:var(--wait-text)}\n.ihead .new-tag{flex:none;margin-top:1px}\n.ihead .menu-wrap{position:relative;flex:none}\n.ihead .more{border:0;background:none;padding:0;width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;color:var(--faint);font-size:16px;font-weight:700;letter-spacing:0;line-height:1;cursor:pointer;border-radius:4px}\n.ihead .more:hover,.ihead .more[aria-expanded=\"true\"]{color:var(--fg);background:none}\n.ihead .menu{left:auto;right:0;top:calc(100% + 4px)}\n.menu button{border:0;background:none;text-align:left;padding:8px 10px;border-radius:8px;font:inherit;font-size:13.5px;font-weight:500;color:var(--fg);cursor:pointer}\n.menu button:hover{background:var(--accent-soft)}\n.menu button.danger{color:var(--wait-text)}\n.menu button.danger:hover{background:var(--wait-soft)}\n.links{margin:0;gap:6px}\n.link-pill,.prio,.chip{display:inline-flex;align-items:center;gap:5px;font-size:12px;font-weight:600;color:var(--soft);text-decoration:none;line-height:18px;padding:1px 9px 1px 7px;border-radius:999px;border:1px solid var(--line);background:var(--surface)}\n.link-pill svg,.chip svg,.prio svg{width:13px;height:13px;flex:none}\n.link-pill:hover{color:var(--fg);border-color:var(--line-strong)}\n.link-pill.icon-only{padding:1px 6px}\n.chip.who{background:var(--wait-soft);color:var(--wait-text);border-color:transparent;padding:1px 9px}\n.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;font-weight:500}\n.item .note{margin:0;font-size:13.5px}\n.subs-box{border-top:1px solid var(--line);padding-top:6px}\n.subs-box .subs{margin:0}\n.sub.done .check{background:var(--faint);border-color:var(--faint)}\n.sub.leaving{opacity:.45;transition:opacity .4s}\n.sub.done .sub-t{color:var(--faint);text-decoration:line-through}\n.done-toggle:hover{color:var(--soft)}\n.folds{display:flex;flex-wrap:wrap;gap:4px 16px;align-items:flex-start}\n.folds .ctx{margin:0;padding:0;background:none;cursor:default}\n.folds .ctx.open{flex-basis:100%;padding:8px 12px 10px;background:var(--bg);border-radius:8px}\n.folds .ctx-h{width:auto;gap:4px;font-size:12.5px;font-weight:600;letter-spacing:0;text-transform:none;color:var(--soft)}\n.folds .ctx-h:hover{color:var(--fg)}\n.folds .ctx-h svg{width:13px;height:13px;transform:none}\n.folds .ctx.open .ctx-h svg{transform:rotate(180deg)}\n.kick-wrap{display:grid;gap:6px}\n.kick-wrap > button.go{width:max-content;border:0;border-radius:8px;padding:5px 11px;font:inherit;font-size:13px;font-weight:600;cursor:pointer;background:var(--accent-soft);color:var(--accent)}\n.kick-wrap > button.go:hover{background:var(--accent);color:var(--surface)}\n.kcol{background:transparent;box-shadow:none;padding:4px 2px}\n.kcol h2 i{width:8px;height:8px}\n.kcard{background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:9px 10px;gap:7px;font-size:13px;cursor:pointer}\n.kcard:hover{box-shadow:none;border-color:var(--line-strong)}\n.kcard .ihead .title{font-size:13.5px;line-height:19px}\n.kcard .link-pill,.kcard .chip,.kcard .prio{font-size:11.5px;padding:0 7px;line-height:18px}\n#drawerBody .item{border:0;padding:0}\n.main > section.card.foldable.collapsed > :not(h2){display:none}\n.main > section.card.foldable.collapsed > h2{margin-bottom:0}\n.sec-sum{display:none;flex:1;min-width:0;font-size:12.5px;font-weight:500;color:var(--faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.main > section.foldable.collapsed .sec-sum{display:block}\n.main > section.card > h2 .count{display:none}\n.cbtn{flex:none;width:20px;height:20px;border:0;background:none;padding:0;display:inline-flex;align-items:center;justify-content:center;color:var(--faint);cursor:pointer;border-radius:4px}\n.cbtn svg{width:15px;height:15px;transition:transform .15s}\n.cbtn:hover{color:var(--fg)}\n.item.collapsed .cbtn svg{transform:rotate(-90deg)}\n.item.collapsed > .note,.item.collapsed > .read-more,.item.collapsed > .subs-box,.item.collapsed > .folds{display:none}\n#drawerBody .cbtn{display:none}\n#drawerBody .item.collapsed > *{display:revert}\n\n/* shared-dashboard additions */\n.ws-row{margin-top:12px}\n.ws-switch button{font-weight:700}\n.ihead .main-check{width:18px;height:18px;border-radius:50%;margin-top:1px}\n.ihead .main-check.on{background:var(--accent);border-color:var(--accent)}\n.item.leaving,.kcard.leaving{opacity:.45;transition:opacity .3s}\n.ver{margin:10px 4px 0;font-size:11.5px;color:var(--faint)}\n"; document.head.appendChild(styleEl);
|
|
15
|
+
const accentEl = document.createElement("style"); document.head.appendChild(accentEl);
|
|
16
|
+
if(!document.querySelector('link[href*="Figtree"]')){
|
|
17
|
+
const l = document.createElement("link"); l.rel = "stylesheet"; l.href = "https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&display=swap"; document.head.appendChild(l);
|
|
18
|
+
}
|
|
19
|
+
const root = document.getElementById("dashboard") || document.body.appendChild(document.createElement("div"));
|
|
20
|
+
root.innerHTML = "<div class=\"wrap\">\n <header>\n <div>\n <div class=\"kicker\" id=\"refreshed\">Hi</div>\n <h1 id=\"date\">Dashboard</h1>\n <div class=\"ws-row\"><div class=\"view-toggle ws-switch\" id=\"wsSwitch\" role=\"group\" aria-label=\"Workspace\" hidden></div></div>\n </div>\n <div class=\"head-right\">\n <div class=\"view-toggle\" role=\"group\" aria-label=\"View\"><button type=\"button\" data-view=\"list\">List</button><button type=\"button\" data-view=\"board\">Board</button></div>\n <div class=\"view-toggle\"><button type=\"button\" id=\"activeOnly\" aria-pressed=\"false\">Active only</button></div>\n <div class=\"view-toggle\"><button type=\"button\" id=\"collapseAll\" title=\"Show just the titles and buttons, or everything\">Collapse all</button></div>\n <button class=\"clear-new\" type=\"button\" id=\"clearNew\" hidden>Clear new</button>\n <span class=\"update-wrap\"><button class=\"update-state\" id=\"updateState\" type=\"button\" aria-describedby=\"updateTip\"></button><span class=\"update-tip\" id=\"updateTip\" role=\"tooltip\" hidden></span></span>\n <button class=\"link-chats\" type=\"button\" id=\"updateBtn\" hidden><svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5v3h-3\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg><span id=\"updateLabel\">Update</span></button>\n </div>\n <div class=\"status\" id=\"status\" hidden></div>\n </header>\n <div class=\"grid\">\n <div class=\"board\" id=\"board\" aria-label=\"Board view\"></div>\n <div class=\"main\" id=\"main\"></div>\n <aside class=\"rail\">\n <section class=\"card\">\n <h2 id=\"railTitle\">Today</h2>\n <ul id=\"meetings\"><li class=\"empty\">Loading today's calendar…</li></ul>\n </section>\n <p class=\"ver\"><span id=\"wsName\"></span> <span id=\"ver\"></span></p>\n </aside>\n </div>\n</div>\n<div class=\"drawer-back\" id=\"drawerBack\" hidden></div>\n<aside class=\"drawer\" id=\"drawer\" role=\"dialog\" aria-modal=\"true\" aria-label=\"Item details\" aria-hidden=\"true\">\n <div class=\"drawer-head\"><span class=\"drawer-sec\" id=\"drawerSec\"></span><button type=\"button\" class=\"drawer-close\" id=\"drawerClose\" aria-label=\"Close details\"><svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M4 4l8 8M12 4l-8 8\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/></svg></button></div>\n <ul id=\"drawerBody\"></ul>\n</aside>\n<div class=\"toast\" id=\"toast\" hidden><span id=\"toastMsg\"></span><button id=\"toastUndo\" type=\"button\">Undo</button></div>\n";
|
|
21
|
+
|
|
22
|
+
const $ = id => document.getElementById(id);
|
|
23
|
+
const SVG = d => '<svg viewBox="0 0 16 16" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">' + d + '</g></svg>';
|
|
24
|
+
const ICON = {
|
|
25
|
+
figma: SVG('<rect x="2.5" y="2.5" width="11" height="11" rx="1.5"/><path d="M2.5 6h11M6 6v7.5"/>'),
|
|
26
|
+
chat: SVG('<path d="M8 2v3.2M8 10.8V14M2 8h3.2M10.8 8H14M3.8 3.8l2.2 2.2M10 10l2.2 2.2M12.2 3.8L10 6M6 10l-2.2 2.2"/>'),
|
|
27
|
+
link: SVG('<path d="M7 9a3 3 0 0 0 4.2 0l2-2a3 3 0 0 0-4.2-4.2l-.6.6M9 7a3 3 0 0 0-4.2 0l-2 2a3 3 0 0 0 4.2 4.2l.6-.6"/>'),
|
|
28
|
+
todo: SVG('<rect x="2.5" y="2.5" width="11" height="11" rx="2.5"/><path d="M5.5 8l1.8 1.8L10.5 6"/>'),
|
|
29
|
+
cal: SVG('<rect x="2.5" y="3.5" width="11" height="10" rx="2"/><path d="M2.5 6.5h11M5.5 2v3M10.5 2v3"/>')
|
|
30
|
+
};
|
|
31
|
+
const CHEV = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
32
|
+
function el(tag, cls, text){ const e = document.createElement(tag); if(cls) e.className = cls; if(text != null) e.textContent = text; return e; }
|
|
33
|
+
function safeUrl(u){ return typeof u === "string" && /^https:\/\//.test(u) ? u : null; }
|
|
34
|
+
const store = (k, d) => { try { return JSON.parse(localStorage.getItem(k) || "null") ?? d; } catch(_){ return d; } };
|
|
35
|
+
const save = (k, v) => { try { localStorage.setItem(k, JSON.stringify(v)); } catch(_){} };
|
|
36
|
+
function setStatus(msg){ const s = $("status"); s.textContent = msg || ""; s.hidden = !msg; }
|
|
37
|
+
|
|
38
|
+
/* ---------- workspace ---------- */
|
|
39
|
+
let WS = null;
|
|
40
|
+
let SECTIONS = [], LABEL = {}, EMPTY = {}, DRAGGABLE = [], PRIMARY = {};
|
|
41
|
+
const feat = k => !!(WS && WS.features && WS.features[k]);
|
|
42
|
+
function wsFromHash(){ const h = (location.hash || "").slice(1); return WORKSPACES.find(w => w.id === h); }
|
|
43
|
+
function pickInitial(){ return wsFromHash() || WORKSPACES.find(w => w.id === store("dash.ws", "")) || WORKSPACES[0]; }
|
|
44
|
+
function applyWorkspace(w){
|
|
45
|
+
WS = w;
|
|
46
|
+
const names = Object.assign({upcoming: "To do", today: "In progress", ready: "Paused", waiting: "Waiting on others", handoff: "Handoff prep", later: "Later"}, w.sections || {});
|
|
47
|
+
LABEL = Object.assign({}, names, {done: "Complete", removed: "Removed"});
|
|
48
|
+
SECTIONS = ["today", "ready", "waiting"].concat(feat("handoff") ? ["handoff"] : [], ["upcoming", "later"]);
|
|
49
|
+
DRAGGABLE = ["today", "upcoming", "later"].concat(feat("handoff") ? ["handoff"] : []);
|
|
50
|
+
EMPTY = {today: "Nothing in progress. Start something from " + names.upcoming + ".", ready: "Nothing in " + names.ready + ".", waiting: "Not waiting on anyone.",
|
|
51
|
+
handoff: "Nothing approved and waiting for a handoff.", upcoming: "Things you haven't started show here.", later: "Nothing parked for later."};
|
|
52
|
+
PRIMARY = {today: [names.ready, "ready"], ready: ["Back to " + names.today.toLowerCase(), "today"], waiting: ["Back to " + names.today.toLowerCase(), "today"],
|
|
53
|
+
handoff: ["Handed off", "done"], upcoming: ["Start", "today"], later: ["Start", "today"], done: ["Reopen", "today"]};
|
|
54
|
+
// accent colour per workspace (light and dark)
|
|
55
|
+
const a = /^#[0-9a-f]{6}$/i.test(w.accent || "") ? w.accent : null;
|
|
56
|
+
accentEl.textContent = a ? ':root{--accent:' + a + ';--accent-soft:color-mix(in srgb,' + a + ' 12%,#fff)}' +
|
|
57
|
+
'@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){--accent:color-mix(in srgb,' + a + ' 55%,#fff);--accent-soft:color-mix(in srgb,' + a + ' 22%,#1A1D24)}}' +
|
|
58
|
+
':root[data-theme="dark"]{--accent:color-mix(in srgb,' + a + ' 55%,#fff);--accent-soft:color-mix(in srgb,' + a + ' 22%,#1A1D24)}' : "";
|
|
59
|
+
save("dash.ws", w.id);
|
|
60
|
+
if(WORKSPACES.length > 1 && location.hash.slice(1) !== w.id){ try { history.replaceState(null, "", "#" + w.id); } catch(_){} }
|
|
61
|
+
buildSections(); renderSwitcher();
|
|
62
|
+
$("railTitle").textContent = w.railTitle || "Today";
|
|
63
|
+
$("activeOnly").title = "Show only " + ["today", "ready", "waiting"].concat(feat("handoff") ? ["handoff"] : []).map(s => LABEL[s]).join(", ");
|
|
64
|
+
$("updateLabel").textContent = w.updateLabel || "Update";
|
|
65
|
+
items = (cache[w.id] || []); statusDoc = null; renderStatus(); watchStatus();
|
|
66
|
+
render();
|
|
67
|
+
loadTasks(); loadCalendar();
|
|
68
|
+
}
|
|
69
|
+
function renderSwitcher(){
|
|
70
|
+
const box = $("wsSwitch"); box.replaceChildren(); box.hidden = WORKSPACES.length < 2;
|
|
71
|
+
WORKSPACES.forEach(w => { const b = el("button", null, w.name || w.id); b.type = "button"; b.setAttribute("aria-pressed", String(w === WS)); b.onclick = () => { if(w !== WS){ closeDrawer(); applyWorkspace(w); } }; box.append(b); });
|
|
72
|
+
$("wsName").textContent = WORKSPACES.length > 1 ? (WS.name || "") : "";
|
|
73
|
+
}
|
|
74
|
+
window.addEventListener("hashchange", () => { const w = wsFromHash(); if(w && w !== WS) applyWorkspace(w); });
|
|
75
|
+
|
|
76
|
+
const SEC_COLOR = {upcoming: "var(--s-todo)", today: "var(--s-prog)", ready: "var(--s-ready)", waiting: "var(--s-wait)", handoff: "var(--s-hand)", later: "ring", done: "var(--s-done)"};
|
|
77
|
+
let foldedSecs = store("brief.foldedSections", []);
|
|
78
|
+
function buildSections(){
|
|
79
|
+
const main = $("main"); main.replaceChildren();
|
|
80
|
+
["upcoming", "today", "ready", "waiting"].concat(feat("handoff") ? ["handoff"] : [], ["later", "completed"]).forEach(key => {
|
|
81
|
+
const sec = key === "completed" ? "done" : key;
|
|
82
|
+
const card = el("section", "card foldable" + (key === "completed" ? " completed-card" : "")); card.dataset.key = key;
|
|
83
|
+
const h = el("h2"); const dot = el("span", "dot"); if(SEC_COLOR[sec] === "ring") dot.classList.add("ring"); else dot.style.background = SEC_COLOR[sec];
|
|
84
|
+
const label = key === "completed" ? "Completed" : LABEL[sec];
|
|
85
|
+
h.append(dot, document.createTextNode(label + " "), Object.assign(el("span", "count"), {id: key === "completed" ? "c-complete" : "c-" + sec}));
|
|
86
|
+
const ul = el("ul"); ul.id = key === "completed" ? "list-complete" : "list-" + sec; if(key !== "completed") ul.dataset.section = sec;
|
|
87
|
+
card.append(h, ul); main.append(card);
|
|
88
|
+
const chev = el("button", "chev"); chev.type = "button"; chev.innerHTML = CHEV;
|
|
89
|
+
const set = c => { card.classList.toggle("collapsed", c); chev.setAttribute("aria-expanded", String(!c)); chev.setAttribute("aria-label", (c ? "Expand " : "Collapse ") + label); };
|
|
90
|
+
set(foldedSecs.includes(key));
|
|
91
|
+
const toggle = () => { const c = !card.classList.contains("collapsed"); foldedSecs = foldedSecs.filter(k => k !== key); if(c) foldedSecs.push(key); save("brief.foldedSections", foldedSecs); set(c); if(!c) requestAnimationFrame(fixClamps); };
|
|
92
|
+
chev.onclick = e => { e.stopPropagation(); toggle(); }; h.addEventListener("click", toggle); h.append(chev);
|
|
93
|
+
if(DRAGGABLE.includes(sec)) wireListDrag(ul);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* ---------- state ---------- */
|
|
98
|
+
let db = null, mcp = null, items = [], canWrite = true, undoState = null, toastTimer = null, refreshTimer = null;
|
|
99
|
+
const cache = {};
|
|
100
|
+
const seenMap = store("pd.seen", {}), orderMap = store("pd.order", {});
|
|
101
|
+
function saveSeen(id, t){ seenMap[id] = t; save("pd.seen", seenMap); }
|
|
102
|
+
function saveOrder(id, o){ orderMap[id] = o; save("pd.order", orderMap); }
|
|
103
|
+
const collapsedIds = new Set(store("brief.collapsed", []));
|
|
104
|
+
function saveCollapsed(){ save("brief.collapsed", [...collapsedIds]); }
|
|
105
|
+
const expanded = new Set();
|
|
106
|
+
function sorted(section){ return items.filter(i => i.section === section).sort((a, b) => (a.order ?? 1e9) - (b.order ?? 1e9) || String(a.title).localeCompare(String(b.title))); }
|
|
107
|
+
|
|
108
|
+
/* ---------- Todoist adapter ---------- */
|
|
109
|
+
const STATUS_KEYS = ["today", "ready", "waiting", "later", "handoff", "meeting"];
|
|
110
|
+
const STATUS_LABELS = STATUS_KEYS.map(k => LABELS[k]);
|
|
111
|
+
const parse = r => {
|
|
112
|
+
const p = r && r.payload; if(p && typeof p === "object") return p;
|
|
113
|
+
const txt = typeof p === "string" ? p : ((r && r.content) || []).filter(c => c.type === "text").map(c => c.text)[0] || "";
|
|
114
|
+
try { return JSON.parse(txt); } catch(_){ const m = txt.match(/\{[\s\S]*\}/); try { return m ? JSON.parse(m[0]) : {}; } catch(_){ return {}; } }
|
|
115
|
+
};
|
|
116
|
+
const td = (tool, input) => mcp.callTool(CFG.todoistServer || "Todoist", tool, input, {cache: false});
|
|
117
|
+
const KEYLINE = /^(Waiting on|Link|Figma|Chat|Meeting):[ \t]*(.*)$/;
|
|
118
|
+
function splitDesc(desc){
|
|
119
|
+
const [head, ctx = ""] = String(desc || "").split(/^Context:[ \t]*$/m);
|
|
120
|
+
const keys = {}, rest = [];
|
|
121
|
+
head.split("\n").forEach(line => { const m = line.match(KEYLINE); if(m) keys[m[1]] = m[2].trim(); else rest.push(line); });
|
|
122
|
+
return {keys, note: rest.join("\n").trim(), ctx};
|
|
123
|
+
}
|
|
124
|
+
function setLine(desc, key, val){
|
|
125
|
+
const [head, ...tail] = String(desc || "").split(/^(?=Context:[ \t]*$)/m);
|
|
126
|
+
const re = new RegExp("^" + key + ":.*(\\n|$)", "m");
|
|
127
|
+
let h = head.replace(re, "");
|
|
128
|
+
if(val) h = key + ": " + val + (h ? "\n" + h : "");
|
|
129
|
+
return (h + (tail.length ? (h && !h.endsWith("\n") ? "\n" : "") + tail.join("") : "")).replace(/\n{3,}/g, "\n\n");
|
|
130
|
+
}
|
|
131
|
+
const slug = s => String(s || "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
132
|
+
function toItem(t, i, kids){
|
|
133
|
+
const labels = Array.isArray(t.labels) ? t.labels : [];
|
|
134
|
+
const {keys, note: noteText, ctx} = splitDesc(t.description);
|
|
135
|
+
const prio = {p1: "Urgent", p2: "High", p3: "Medium"}[t.priority];
|
|
136
|
+
let note = noteText; if(prio) note = prio + " priority. " + note;
|
|
137
|
+
const log = ctx.split("\n").map(x => x.replace(/^\s*[-*]\s*/, "").trim()).filter(Boolean).map(x => ({t: x}));
|
|
138
|
+
const has = k => labels.includes(LABELS[k]);
|
|
139
|
+
const section = has("meeting") ? "meeting" : has("today") ? "today" : has("ready") ? "ready" : has("waiting") ? "waiting" : (has("handoff") && feat("handoff")) ? "handoff" : has("later") ? "later" : "upcoming";
|
|
140
|
+
const dueRaw = t.dueDate || (t.due && (t.due.date || t.due.string)) || "";
|
|
141
|
+
let due = "", overdue = false;
|
|
142
|
+
if(dueRaw){
|
|
143
|
+
const d = new Date(String(dueRaw).length <= 10 ? dueRaw + "T12:00:00" : dueRaw);
|
|
144
|
+
if(!isNaN(d)){ due = d.toLocaleDateString("en-US", {weekday: "short", month: "short", day: "numeric"}); const t0 = new Date(); t0.setHours(0, 0, 0, 0); overdue = d < t0; }
|
|
145
|
+
else due = String(dueRaw);
|
|
146
|
+
}
|
|
147
|
+
const isQ = k => Array.isArray(k.labels) && k.labels.includes(LABELS.question);
|
|
148
|
+
const subtasks = kids.filter(k => !isQ(k)).map(k => ({id: k.id, t: k.content, d: !!k.checked, n: Date.parse(k.addedAt) || 0, seen: !!seenMap[k.id],
|
|
149
|
+
notes: String(k.description || "").split("\n").map(x => x.replace(/^\s*[-*]\s*/, "").trim()).filter(Boolean).map(x => ({t: x}))}));
|
|
150
|
+
const questions = kids.filter(isQ).map(k => ({id: k.id, t: k.content, d: !!k.checked}));
|
|
151
|
+
return {id: t.id, title: t.content, description: String(t.description || ""), labels, section, order: orderMap[t.id] ?? (i + 1), projectId: t.projectId,
|
|
152
|
+
note, log, subtasks, questions, _server: subtasks.concat(questions).map(x => ({id: x.id, d: x.d})),
|
|
153
|
+
waitingOn: keys["Waiting on"] || "", url: safeUrl(keys.Link) || "https://app.todoist.com/app/task/" + t.id, todoistUrl: "https://app.todoist.com/app/task/" + t.id,
|
|
154
|
+
figma: safeUrl(keys.Figma), chat: safeUrl(keys.Chat), meeting: keys.Meeting || "", due, overdue, newAt: Date.parse(t.addedAt) || 0, seenAt: seenMap[t.id] || 0};
|
|
155
|
+
}
|
|
156
|
+
function projectIds(){ const t = WS.todoist || {}; return [].concat(t.projectIds || [], t.projectId || []).filter(Boolean); }
|
|
157
|
+
let loadSeq = 0;
|
|
158
|
+
async function loadTasks(){
|
|
159
|
+
if(!mcp) return;
|
|
160
|
+
const w = WS, seq = ++loadSeq, pids = projectIds();
|
|
161
|
+
if(!pids.length){ setStatus("This workspace has no Todoist project set in its settings."); return; }
|
|
162
|
+
try {
|
|
163
|
+
const results = await Promise.all(pids.map(pid => Promise.all([
|
|
164
|
+
td("find-tasks", {projectId: pid, limit: 100}),
|
|
165
|
+
td("find-completed-tasks", {projectId: pid, limit: 30}).catch(() => null)
|
|
166
|
+
])));
|
|
167
|
+
if(seq !== loadSeq || w !== WS) return;
|
|
168
|
+
const next = [];
|
|
169
|
+
results.forEach(([act, comp]) => {
|
|
170
|
+
const all = parse(act).tasks || [], ids = new Set(all.map(t => t.id));
|
|
171
|
+
const desc = id => all.filter(k => k.parentId === id).flatMap(k => [k, ...desc(k.id)]);
|
|
172
|
+
all.filter(t => !t.parentId || !ids.has(t.parentId)).forEach((t, i) => next.push(toItem(t, i, desc(t.id))));
|
|
173
|
+
const done = comp ? (parse(comp).tasks || []).filter(t => !t.parentId) : [];
|
|
174
|
+
done.forEach(t => next.push({id: t.id, title: t.content, section: "done", _completed: true, labels: t.labels || [], description: String(t.description || ""), touchedAt: Date.parse(t.completedAt) || 0, subtasks: [], questions: [], _server: []}));
|
|
175
|
+
});
|
|
176
|
+
items = next; cache[w.id] = next; setStatus(""); render();
|
|
177
|
+
} catch(e){
|
|
178
|
+
if(w !== WS) return;
|
|
179
|
+
const c = e && e.code;
|
|
180
|
+
setStatus(c === "server_not_connected" || c === "needs_reauth" ? "Connect Todoist in Settings → Connectors to see your to-dos." :
|
|
181
|
+
c === "not_in_manifest" || c === "approval_required" || c === "cancelled" ? "This page needs your OK to read Todoist. Reload and allow it." :
|
|
182
|
+
"Couldn't reach Todoist. Trying again shortly.");
|
|
183
|
+
scheduleRefresh(60000);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function scheduleRefresh(ms){ clearTimeout(refreshTimer); refreshTimer = setTimeout(loadTasks, ms || 1500); }
|
|
187
|
+
|
|
188
|
+
async function write(id, patch){
|
|
189
|
+
const it = items.find(i => i.id === id); if(!it || !mcp) return;
|
|
190
|
+
try {
|
|
191
|
+
for(const key of ["subtasks", "questions"]){
|
|
192
|
+
if(!(key in patch)) continue;
|
|
193
|
+
const server = it._server || [];
|
|
194
|
+
for(const ns of patch[key]){
|
|
195
|
+
const cur = server.find(x => x.id === ns.id); if(!cur || !!cur.d === !!ns.d) continue;
|
|
196
|
+
await td(ns.d ? "complete-tasks" : "uncomplete-tasks", {ids: [ns.id]}); cur.d = !!ns.d;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
let desc = it.description, labels = null;
|
|
200
|
+
if("section" in patch){
|
|
201
|
+
const s = patch.section;
|
|
202
|
+
if(s === "done"){ await td("complete-tasks", {ids: [id]}); it._completed = true; }
|
|
203
|
+
else if(s === "removed"){ await td("delete-object", {type: "task", id}); }
|
|
204
|
+
else {
|
|
205
|
+
if(it._completed){ await td("uncomplete-tasks", {ids: [id]}); it._completed = false; }
|
|
206
|
+
labels = (it.labels || []).filter(l => !STATUS_LABELS.includes(l)); if(LABELS[s]) labels.push(LABELS[s]);
|
|
207
|
+
desc = setLine(desc, "Waiting on", s === "waiting" ? (patch.waitingOn || it.waitingOn) : null);
|
|
208
|
+
desc = setLine(desc, "Meeting", s === "meeting" ? (patch.meeting || it.meeting) : null);
|
|
209
|
+
}
|
|
210
|
+
} else if("waitingOn" in patch) desc = setLine(desc, "Waiting on", patch.waitingOn);
|
|
211
|
+
if("chat" in patch) desc = setLine(desc, "Chat", patch.chat);
|
|
212
|
+
const up = {id};
|
|
213
|
+
if(labels){ up.labels = labels; it.labels = labels; }
|
|
214
|
+
if(desc !== it.description){ up.description = desc; it.description = desc; }
|
|
215
|
+
if(Object.keys(up).length > 1) await td("update-tasks", {tasks: [up]});
|
|
216
|
+
if("order" in patch && patch.order != null && !["done", "removed"].includes(patch.section)){
|
|
217
|
+
saveOrder(id, patch.order);
|
|
218
|
+
if(!("section" in patch)) await td("update-tasks", {tasks: [{id, order: patch.order}]});
|
|
219
|
+
}
|
|
220
|
+
setStatus("");
|
|
221
|
+
} catch(e){
|
|
222
|
+
setStatus(e && (e.code === "server_not_connected" || e.code === "needs_reauth") ? "Reconnect Todoist in Settings → Connectors." : "Couldn't save that change to Todoist. Try again in a moment.");
|
|
223
|
+
}
|
|
224
|
+
scheduleRefresh();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/* ---------- calendar ---------- */
|
|
228
|
+
let dayData = null;
|
|
229
|
+
async function loadCalendar(){
|
|
230
|
+
const c = WS.calendar; const w = WS;
|
|
231
|
+
if(!mcp || c === false){ dayData = {date: isoDay(new Date()), meetings: [], off: true}; renderMeetings(); return; }
|
|
232
|
+
const n = new Date(), tom = new Date(n); tom.setDate(n.getDate() + 1);
|
|
233
|
+
const ids = (c && c.ids) || ["primary"], hide = ((c && c.hide) || []).map(x => String(x).toLowerCase());
|
|
234
|
+
try {
|
|
235
|
+
const lists = await Promise.all(ids.map(id => mcp.callTool(CFG.calendarServer || "Google Calendar", "list_events",
|
|
236
|
+
Object.assign({startTime: isoDay(n) + "T00:00:00", endTime: isoDay(tom) + "T00:00:00", orderBy: "startTime", pageSize: 50}, id === "primary" ? {} : {calendarId: id}), {cache: false})));
|
|
237
|
+
if(w !== WS) return;
|
|
238
|
+
const fmt = s => new Date(s).toLocaleTimeString("en-US", {hour: "numeric", minute: "2-digit"});
|
|
239
|
+
const evs = lists.flatMap(r => { const p = parse(r); return p.events || p.items || []; })
|
|
240
|
+
.filter(e => e && e.status !== "cancelled" && !hide.some(h => String(e.summary || "").toLowerCase().includes(h)))
|
|
241
|
+
.filter(e => !(c && c.acceptedOnly) || !(e.attendees || []).some(a => a.self && a.responseStatus === "declined"))
|
|
242
|
+
.sort((a, b) => String((a.start || {}).dateTime || (a.start || {}).date).localeCompare(String((b.start || {}).dateTime || (b.start || {}).date)));
|
|
243
|
+
dayData = {date: isoDay(n), meetings: evs.map((e, i) => { const st = e.start || {}, en = e.end || {};
|
|
244
|
+
return {id: e.id || "e" + i, title: e.summary || "(No title)", url: e.htmlLink, time: st.dateTime ? fmt(st.dateTime) + (en.dateTime ? " – " + fmt(en.dateTime) : "") : "All day"}; })};
|
|
245
|
+
} catch(e){ if(w !== WS) return; dayData = {date: isoDay(n), meetings: [], error: true}; }
|
|
246
|
+
renderMeetings();
|
|
247
|
+
}
|
|
248
|
+
const isoDay = d => d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0");
|
|
249
|
+
function meetingsList(){ return dayData && Array.isArray(dayData.meetings) ? dayData.meetings : []; }
|
|
250
|
+
const meetingMatches = (ask, m) => { const a = slug(ask), t = slug(m.title); return !!a && (a === t || t.includes(a) || a.includes(t)); };
|
|
251
|
+
|
|
252
|
+
/* ---------- card ---------- */
|
|
253
|
+
function menuOpts(it, section, anchor){
|
|
254
|
+
const opts = [], seen = new Set();
|
|
255
|
+
const add = (label, target, cls) => { const k = typeof target === "string" ? target : label; if(seen.has(k)) return; seen.add(k); opts.push([label, target, cls]); };
|
|
256
|
+
const p = PRIMARY[section]; if(p) add(p[0], p[1]);
|
|
257
|
+
if(section !== "ready") add(LABEL.ready, "ready");
|
|
258
|
+
add(section === "waiting" ? "Change who it's waiting on" : "Waiting on…", () => askWaiting(it, anchor));
|
|
259
|
+
if(feat("handoff") && section !== "handoff") add("Move to " + LABEL.handoff, "handoff");
|
|
260
|
+
if(feat("meetingAsks") && section === "today") meetingsList().forEach(m => opts.push(["Bring up at " + (m.title || "meeting"), {section: "meeting", meeting: m.title}]));
|
|
261
|
+
if(section !== "today") add("Move to " + LABEL.today, "today");
|
|
262
|
+
if(section !== "upcoming") add("Move to " + LABEL.upcoming, "upcoming");
|
|
263
|
+
if(section !== "later") add("Move to " + LABEL.later, "later");
|
|
264
|
+
if(section !== "done") add("Mark complete", "done");
|
|
265
|
+
add("Open in Todoist", () => { try { window.open(it.todoistUrl, "_blank"); } catch(_){} });
|
|
266
|
+
add("Delete", "removed", "danger");
|
|
267
|
+
return opts;
|
|
268
|
+
}
|
|
269
|
+
async function openChat(url){
|
|
270
|
+
try { const w = window.open(url, "_blank"); if(w){ try { w.opener = null; } catch(_){} return; } } catch(_){}
|
|
271
|
+
let copied = false; try { await navigator.clipboard.writeText(url); copied = true; } catch(_){}
|
|
272
|
+
toast(copied ? "Couldn't open the chat here. Its link is copied." : "Couldn't open the chat here: " + url);
|
|
273
|
+
}
|
|
274
|
+
function chipRow(it, opts){
|
|
275
|
+
const o = opts || {};
|
|
276
|
+
const row = el("div", "links"); row.addEventListener("click", () => markSeen(it));
|
|
277
|
+
if(o.who && it.waitingOn) row.append(el("span", "chip who", it.waitingOn));
|
|
278
|
+
const pr = priorityOf(it.note); if(pr) row.append(prioTag(pr.p));
|
|
279
|
+
if(it.due){ const d = el("span", "chip" + (it.overdue ? " who" : "")); d.innerHTML = ICON.cal; d.append(document.createTextNode(it.due)); d.title = it.overdue ? "Overdue" : "Due date"; row.append(d); }
|
|
280
|
+
const pill = (url, label, icon, aria) => { const a = el("a", "link-pill"); a.href = url; a.target = "_blank"; a.rel = "noopener"; a.innerHTML = icon; if(label) a.append(el("span", null, label)); else { a.setAttribute("aria-label", aria); a.classList.add("icon-only"); } row.append(a); };
|
|
281
|
+
const u = safeUrl(it.url); if(u) pill(u, "Link", ICON.link, "Link");
|
|
282
|
+
const f = safeUrl(it.figma), c = safeUrl(it.chat);
|
|
283
|
+
if(f) pill(f, o.compact ? "" : "Figma", ICON.figma, "Figma");
|
|
284
|
+
if(c){ pill(c, o.compact ? "" : "Chat", ICON.chat, "Claude chat"); const a = row.lastChild; a.onclick = e => { e.preventDefault(); e.stopPropagation(); openChat(c); }; }
|
|
285
|
+
const subs = it.subtasks || [];
|
|
286
|
+
if(subs.length){ const n = el("span", "chip"); n.innerHTML = ICON.todo; n.append(document.createTextNode(subs.filter(x => x && x.d).length + "/" + subs.length)); n.title = "To-dos done"; row.append(n); }
|
|
287
|
+
return row.childNodes.length ? row : null;
|
|
288
|
+
}
|
|
289
|
+
function handoffEl(it, section){
|
|
290
|
+
if(!feat("handoff") || section !== "handoff") return null;
|
|
291
|
+
const wrap = el("div", "kick-wrap");
|
|
292
|
+
const b = el("button", "go", "Copy handoff prompt"); b.type = "button"; b.title = "Copies the prompt and opens the task's chat";
|
|
293
|
+
b.onclick = async e => {
|
|
294
|
+
e.stopPropagation();
|
|
295
|
+
const parts = [(it.title || "") + ": write the dev handoff."];
|
|
296
|
+
if(safeUrl(it.url) && it.url !== it.todoistUrl) parts.push("Link: " + it.url);
|
|
297
|
+
if(safeUrl(it.figma)) parts.push("Figma page: " + it.figma);
|
|
298
|
+
parts.push("Todoist task: " + it.todoistUrl);
|
|
299
|
+
parts.push("Use the decisions on the task (subtask notes and context) and in this chat, and draft it here first.");
|
|
300
|
+
const msg = parts.join("\n"); let copied = false;
|
|
301
|
+
try { await navigator.clipboard.writeText(msg); copied = true; } catch(_){}
|
|
302
|
+
const chat = safeUrl(it.chat); let opened = false;
|
|
303
|
+
if(chat){ try { const w = window.open(chat, "_blank"); if(w){ try { w.opener = null; } catch(_){} opened = true; } } catch(_){} }
|
|
304
|
+
toast(!copied ? "Couldn't copy. Prompt: " + msg.replace(/\n/g, " ") : opened ? "Handoff prompt copied. Paste it into the chat." : chat ? "Handoff prompt copied. Open the task's chat and paste it." : "Handoff prompt copied. Paste it into a new chat.");
|
|
305
|
+
};
|
|
306
|
+
wrap.append(b); return wrap;
|
|
307
|
+
}
|
|
308
|
+
function mainCheck(it){
|
|
309
|
+
const c = el("button", "check main-check"); c.type = "button"; c.disabled = !canWrite;
|
|
310
|
+
c.setAttribute("aria-label", "Mark complete: " + (it.title || ""));
|
|
311
|
+
c.title = "Mark complete";
|
|
312
|
+
c.onclick = e => { e.stopPropagation(); const li = c.closest(".item,.kcard"); if(li) li.classList.add("leaving"); c.classList.add("on"); setTimeout(() => change(it, {section: "done"}), li ? 350 : 0); };
|
|
313
|
+
return c;
|
|
314
|
+
}
|
|
315
|
+
function renderItem(it, section){
|
|
316
|
+
const li = el("li", "item"); li.dataset.id = it.id;
|
|
317
|
+
const head = el("div", "ihead");
|
|
318
|
+
if(canWrite) head.append(mainCheck(it));
|
|
319
|
+
const t = el("span", "title", it.title || "Untitled");
|
|
320
|
+
if(DRAGGABLE.includes(section) && canWrite){ t.draggable = true; t.classList.add("drag"); }
|
|
321
|
+
head.append(t);
|
|
322
|
+
if(section === "waiting" && it.waitingOn) head.append(el("span", "who", it.waitingOn));
|
|
323
|
+
if(isNew(it)) head.append(newTag());
|
|
324
|
+
const cb = el("button", "cbtn"); cb.type = "button"; cb.innerHTML = CHEV;
|
|
325
|
+
const set = c => { li.classList.toggle("collapsed", c); cb.setAttribute("aria-expanded", String(!c)); cb.setAttribute("aria-label", (c ? "Show details for " : "Hide details for ") + (it.title || "item")); };
|
|
326
|
+
set(collapsedIds.has(it.id));
|
|
327
|
+
cb.onclick = e => { e.stopPropagation(); const c = !li.classList.contains("collapsed"); if(c) collapsedIds.add(it.id); else collapsedIds.delete(it.id); saveCollapsed(); set(c); updateCollapseAll(); if(!c) requestAnimationFrame(fixClamps); };
|
|
328
|
+
head.append(cb);
|
|
329
|
+
if(canWrite) head.append(moreMenu(it, menuOpts(it, section, head)));
|
|
330
|
+
li.append(head);
|
|
331
|
+
const chips = chipRow(it); if(chips) li.append(chips);
|
|
332
|
+
{ const pr = priorityOf(it.note); const nt = pr ? pr.rest : it.note; if(nt) li.append(noteEl("p", "note", nt, it.id)); }
|
|
333
|
+
const subs = it.subtasks || [];
|
|
334
|
+
if(subs.length){
|
|
335
|
+
const doneN = subs.filter(s => s && s.d).length;
|
|
336
|
+
const box = el("div", "subs-box"), ul = el("ul", "subs");
|
|
337
|
+
const showDone = expanded.has(it.id + ":done");
|
|
338
|
+
subs.forEach((s, i) => {
|
|
339
|
+
if(s.d && !showDone) return;
|
|
340
|
+
let r = el("li", "sub" + (s.d ? " done" : ""));
|
|
341
|
+
const c = el("button", "check"); c.type = "button"; c.disabled = !canWrite; c.setAttribute("aria-label", (s.d ? "Mark not done: " : "Mark done: ") + (s.t || ""));
|
|
342
|
+
c.onclick = e => {
|
|
343
|
+
e.stopPropagation();
|
|
344
|
+
const prev = subs; const next = subs.map((x, j) => j === i ? Object.assign({}, x, {d: !x.d, seen: true}) : x);
|
|
345
|
+
if(isNew(it)){ it.seenAt = Date.now(); saveSeen(it.id, it.seenAt); }
|
|
346
|
+
const commit = () => { it.subtasks = next; render(); write(it.id, {subtasks: next}); if(!s.d) toast("To-do done", {id: it.id, prev: {subtasks: prev}}); };
|
|
347
|
+
if(!s.d && !showDone){ r.classList.add("done", "leaving"); setTimeout(commit, 450); } else commit();
|
|
348
|
+
};
|
|
349
|
+
const sn = (s.notes || []).filter(x => x && x.t);
|
|
350
|
+
const txt = el("span", "sub-t", s.t || "");
|
|
351
|
+
r.append(c, txt);
|
|
352
|
+
if(subIsNew(it, s)){ const dot = el("i", "sub-new"); dot.title = "New"; dot.setAttribute("aria-label", "New"); r.append(dot); }
|
|
353
|
+
if(sn.length){
|
|
354
|
+
const key = it.id + ":s" + i;
|
|
355
|
+
const tg = el("button", "sub-tg"); tg.type = "button"; tg.innerHTML = CHEV;
|
|
356
|
+
const panel = el("div", "sub-notes"); panel.hidden = !expanded.has(key);
|
|
357
|
+
const ulN = el("ul", "bullets"); sn.forEach(x => ulN.append(el("li", null, x.t))); panel.append(ulN);
|
|
358
|
+
const wrap = el("li", "sub-wrap"); const row = el("div", r.className); row.append(...r.childNodes); r = row;
|
|
359
|
+
const sync = () => { const o = !panel.hidden; row.classList.toggle("open", o); tg.setAttribute("aria-expanded", String(o)); tg.setAttribute("aria-label", (o ? "Hide notes for " : "Show notes for ") + (s.t || "")); };
|
|
360
|
+
const toggle = e => { e.stopPropagation(); panel.hidden = !panel.hidden; if(panel.hidden) expanded.delete(key); else expanded.add(key); sync(); markSeen(it, i); };
|
|
361
|
+
tg.onclick = toggle; txt.classList.add("has-notes"); txt.onclick = toggle;
|
|
362
|
+
row.append(tg); row.classList.add("with-notes");
|
|
363
|
+
sync(); wrap.append(row, panel); ul.append(wrap);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
ul.append(r);
|
|
367
|
+
});
|
|
368
|
+
if(ul.childNodes.length) box.append(ul);
|
|
369
|
+
if(doneN){
|
|
370
|
+
const tgl = el("button", "done-toggle", showDone ? "Hide completed" : (doneN === subs.length ? "All to-dos done · show " + doneN : "Show " + doneN + " completed"));
|
|
371
|
+
tgl.type = "button"; tgl.onclick = e => { e.stopPropagation(); const k = it.id + ":done"; if(expanded.has(k)) expanded.delete(k); else expanded.add(k); render(); };
|
|
372
|
+
box.append(tgl);
|
|
373
|
+
}
|
|
374
|
+
li.append(box);
|
|
375
|
+
}
|
|
376
|
+
const folds = el("div", "folds");
|
|
377
|
+
const fold = (key, label, bodyNode) => {
|
|
378
|
+
const box = el("div", "ctx"), h = el("button", "ctx-h"); h.type = "button";
|
|
379
|
+
h.append(document.createTextNode(label)); h.insertAdjacentHTML("beforeend", CHEV);
|
|
380
|
+
const body = el("div", "ctx-body"); body.hidden = !expanded.has(key); body.append(bodyNode);
|
|
381
|
+
const sync = () => { box.classList.toggle("open", !body.hidden); h.setAttribute("aria-expanded", String(!body.hidden)); };
|
|
382
|
+
h.onclick = e => { e.stopPropagation(); markSeen(it); body.hidden = !body.hidden; if(body.hidden) expanded.delete(key); else expanded.add(key); sync(); };
|
|
383
|
+
sync(); box.append(h, body); folds.append(box);
|
|
384
|
+
};
|
|
385
|
+
const qs = (it.questions || []).filter(x => x && x.t);
|
|
386
|
+
if(qs.length){
|
|
387
|
+
const openN = qs.filter(q => !q.d).length, ulQ = el("ul", "subs");
|
|
388
|
+
qs.forEach(q => {
|
|
389
|
+
const r = el("li", "sub" + (q.d ? " done" : ""));
|
|
390
|
+
const c = el("button", "check"); c.type = "button"; c.disabled = !canWrite; c.setAttribute("aria-label", (q.d ? "Mark open: " : "Mark answered: ") + q.t);
|
|
391
|
+
c.onclick = e => { e.stopPropagation(); const next = it.questions.map(x => x === q ? Object.assign({}, x, {d: !x.d}) : x); it.questions = next; render(); write(it.id, {questions: next}); };
|
|
392
|
+
r.append(c, el("span", "sub-t", q.t)); ulQ.append(r);
|
|
393
|
+
});
|
|
394
|
+
fold(it.id + ":qs", openN ? "Questions · " + openN + " open" : "Questions · all answered", ulQ);
|
|
395
|
+
}
|
|
396
|
+
const log = (it.log || []).filter(x => x && x.t);
|
|
397
|
+
if(log.length){ const ulC = el("ul", "bullets"); log.forEach(x => ulC.append(el("li", null, x.t))); fold(it.id + ":log", "Context", ulC); }
|
|
398
|
+
if(folds.childNodes.length) li.append(folds);
|
|
399
|
+
const ho = handoffEl(it, section); if(ho) li.append(ho);
|
|
400
|
+
return li;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/* ---------- new markers ---------- */
|
|
404
|
+
const DAY20 = 20 * 3600 * 1000;
|
|
405
|
+
function isNew(it){ const t = Number(it.newAt) || 0; return t > 0 && t > (Number(it.seenAt) || 0) && Date.now() - t < DAY20; }
|
|
406
|
+
function subIsNew(it, s){ const n = Number(s.n) || 0; return !s.d && !s.seen && n > 0 && n > (Number(it.seenAt) || 0) && Date.now() - n < DAY20; }
|
|
407
|
+
function hasNew(it){ return isNew(it) || (it.subtasks || []).some(s => subIsNew(it, s)); }
|
|
408
|
+
function markSeen(it, subIdx){
|
|
409
|
+
let changed = false;
|
|
410
|
+
if(isNew(it)){ it.seenAt = Date.now(); saveSeen(it.id, it.seenAt); changed = true; }
|
|
411
|
+
if(subIdx != null && it.subtasks && it.subtasks[subIdx] && subIsNew(it, it.subtasks[subIdx])){ it.subtasks[subIdx].seen = true; saveSeen(it.subtasks[subIdx].id, Date.now()); changed = true; }
|
|
412
|
+
if(changed) render();
|
|
413
|
+
}
|
|
414
|
+
function newTag(){ const b = el("span", "new-tag", "New"); b.title = "Added in the last day"; return b; }
|
|
415
|
+
function renderClearNew(){
|
|
416
|
+
const b = $("clearNew"); const n = items.filter(it => !["done", "removed"].includes(it.section) && hasNew(it)).length;
|
|
417
|
+
b.hidden = !n || !canWrite; b.textContent = "Clear new (" + n + ")";
|
|
418
|
+
}
|
|
419
|
+
$("clearNew").onclick = () => {
|
|
420
|
+
const now = Date.now();
|
|
421
|
+
items.filter(it => !["done", "removed"].includes(it.section) && hasNew(it)).forEach(it => { it.seenAt = now; saveSeen(it.id, now); (it.subtasks || []).forEach(x => { x.seen = true; saveSeen(x.id, now); }); });
|
|
422
|
+
render();
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
/* ---------- views ---------- */
|
|
426
|
+
let view = store("brief.view", "list") === "board" ? "board" : "list";
|
|
427
|
+
function setView(v){
|
|
428
|
+
view = v; save("brief.view", v);
|
|
429
|
+
document.querySelector(".wrap").classList.toggle("board-view", v === "board");
|
|
430
|
+
document.querySelectorAll(".view-toggle button[data-view]").forEach(b => b.setAttribute("aria-pressed", String(b.dataset.view === v)));
|
|
431
|
+
if(v === "board") renderBoard();
|
|
432
|
+
}
|
|
433
|
+
document.querySelectorAll(".view-toggle button[data-view]").forEach(b => b.onclick = () => setView(b.dataset.view));
|
|
434
|
+
let activeOnly = store("brief.activeOnly", "0") === "1";
|
|
435
|
+
function setActiveOnly(on){
|
|
436
|
+
activeOnly = on; save("brief.activeOnly", on ? "1" : "0");
|
|
437
|
+
document.querySelector(".wrap").classList.toggle("active-only", on);
|
|
438
|
+
$("activeOnly").setAttribute("aria-pressed", String(on)); renderBoard();
|
|
439
|
+
}
|
|
440
|
+
$("activeOnly").onclick = () => setActiveOnly(!activeOnly);
|
|
441
|
+
const ACTIVE = () => ["today", "ready", "waiting"].concat(feat("handoff") ? ["handoff"] : []);
|
|
442
|
+
let kDrag = null;
|
|
443
|
+
function renderBoard(){
|
|
444
|
+
const board = $("board"); if(!board || view !== "board") return;
|
|
445
|
+
board.replaceChildren();
|
|
446
|
+
const cols = ["upcoming", "today", "ready", "waiting"].concat(feat("handoff") ? ["handoff"] : [], ["later", "done"]);
|
|
447
|
+
cols.filter(sec => !activeOnly || ACTIVE().includes(sec)).forEach(sec => {
|
|
448
|
+
const col = el("section", "kcol"), h = el("h2"), dot = el("i");
|
|
449
|
+
if(SEC_COLOR[sec] === "ring") dot.className = "ring"; else dot.style.background = SEC_COLOR[sec];
|
|
450
|
+
const list = sec === "done" ? doneList() : sorted(sec);
|
|
451
|
+
h.append(dot, document.createTextNode((sec === "done" ? "Completed" : LABEL[sec]) + " "), Object.assign(el("span", "count"), {textContent: list.length || ""}));
|
|
452
|
+
const ul = el("ul"); ul.dataset.section = sec;
|
|
453
|
+
list.forEach(it => {
|
|
454
|
+
const li = el("li", "kcard"); li.dataset.id = it.id; li.draggable = canWrite;
|
|
455
|
+
const head = el("div", "ihead");
|
|
456
|
+
if(canWrite && sec !== "done") head.append(mainCheck(it));
|
|
457
|
+
head.append(el("span", "title", it.title || "Untitled"));
|
|
458
|
+
if(isNew(it)) head.append(newTag());
|
|
459
|
+
if(canWrite) head.append(moreMenu(it, menuOpts(it, sec, head)));
|
|
460
|
+
li.append(head);
|
|
461
|
+
const chips = chipRow(it, {compact: true, who: sec === "waiting"}); if(chips) li.append(chips);
|
|
462
|
+
const hh = handoffEl(it, sec); if(hh) li.append(hh);
|
|
463
|
+
li.addEventListener("click", e => { if(e.target.closest("a,button,input,select,.menu-wrap,.wait-input")) return; openDrawer(it.id); });
|
|
464
|
+
li.addEventListener("dragstart", e => { kDrag = it.id; li.classList.add("dragging"); try { e.dataTransfer.setData("text/plain", it.id); } catch(_){} e.dataTransfer.effectAllowed = "move"; });
|
|
465
|
+
li.addEventListener("dragend", () => { kDrag = null; li.classList.remove("dragging"); board.querySelectorAll("ul.over").forEach(u => u.classList.remove("over")); });
|
|
466
|
+
ul.append(li);
|
|
467
|
+
});
|
|
468
|
+
ul.addEventListener("dragover", e => { if(!kDrag) return; e.preventDefault(); ul.classList.add("over"); });
|
|
469
|
+
ul.addEventListener("dragleave", e => { if(!ul.contains(e.relatedTarget)) ul.classList.remove("over"); });
|
|
470
|
+
ul.addEventListener("drop", e => {
|
|
471
|
+
e.preventDefault(); ul.classList.remove("over");
|
|
472
|
+
const it = items.find(i => i.id === kDrag); if(!it) return;
|
|
473
|
+
const target = e.target.closest(".kcard");
|
|
474
|
+
if(it.section !== sec){ change(it, {section: sec}); return; }
|
|
475
|
+
if(sec === "done") return;
|
|
476
|
+
const ids = sorted(sec).map(i => i.id); ids.splice(ids.indexOf(it.id), 1);
|
|
477
|
+
let to = target ? ids.indexOf(target.dataset.id) : ids.length; if(to < 0) to = ids.length;
|
|
478
|
+
if(target && target.dataset.id !== it.id){ const r = target.getBoundingClientRect(); if(e.clientY > r.top + r.height / 2) to += 1; }
|
|
479
|
+
ids.splice(to, 0, it.id); reorder(sec, ids);
|
|
480
|
+
});
|
|
481
|
+
col.append(h, ul); board.append(col);
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
const doneList = () => items.filter(i => i.section === "done").sort((a, b) => (Number(b.touchedAt) || 0) - (Number(a.touchedAt) || 0));
|
|
485
|
+
|
|
486
|
+
let drawerId = null;
|
|
487
|
+
function openDrawer(id){ drawerId = id; renderDrawer(); $("drawerBack").hidden = false; const d = $("drawer"); d.setAttribute("aria-hidden", "false"); requestAnimationFrame(() => { d.classList.add("open"); $("drawerClose").focus(); }); }
|
|
488
|
+
function closeDrawer(){ drawerId = null; const d = $("drawer"); d.classList.remove("open"); d.setAttribute("aria-hidden", "true"); $("drawerBack").hidden = true; }
|
|
489
|
+
function renderDrawer(){
|
|
490
|
+
if(!drawerId) return;
|
|
491
|
+
const it = items.find(i => i.id === drawerId); if(!it){ closeDrawer(); return; }
|
|
492
|
+
$("drawerSec").textContent = LABEL[it.section] || it.section;
|
|
493
|
+
const li = renderItem(it, it.section); li.classList.remove("collapsed");
|
|
494
|
+
$("drawerBody").replaceChildren(li); requestAnimationFrame(fixClamps);
|
|
495
|
+
}
|
|
496
|
+
$("drawerClose").onclick = closeDrawer; $("drawerBack").onclick = closeDrawer;
|
|
497
|
+
document.addEventListener("keydown", e => { if(e.key === "Escape" && drawerId && !document.querySelector(".menu:not([hidden])")) closeDrawer(); });
|
|
498
|
+
$("drawerBody").addEventListener("click", e => { if(!e.target.closest("a,button,input,textarea,select,summary,.ctx,.menu,.subs")) e.stopPropagation(); }, true);
|
|
499
|
+
|
|
500
|
+
function renderCompleted(){
|
|
501
|
+
const ul = $("list-complete"); if(!ul) return; ul.replaceChildren();
|
|
502
|
+
const list = doneList(); $("c-complete").textContent = list.length || "";
|
|
503
|
+
if(!list.length){ ul.append(el("li", "empty", "Nothing completed in the last week.")); return; }
|
|
504
|
+
list.forEach(it => {
|
|
505
|
+
const li = el("li", "mini"), t = el("span", "mt", it.title || "Untitled"); t.style.flex = "1"; t.style.minWidth = "0"; li.append(t);
|
|
506
|
+
if(canWrite){ const b = el("button", "reopen", "Reopen"); b.type = "button"; b.onclick = e => { e.stopPropagation(); change(it, {section: "today"}); }; li.append(b); }
|
|
507
|
+
ul.append(li);
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
function renderSectionSums(){
|
|
511
|
+
document.querySelectorAll("#main > section.foldable").forEach(card => {
|
|
512
|
+
const key = card.dataset.key, sec = key === "completed" ? "done" : key;
|
|
513
|
+
const list = sec === "done" ? doneList() : sorted(sec), h = card.querySelector("h2");
|
|
514
|
+
let s = h.querySelector(".sec-sum"); if(!s){ s = el("span", "sec-sum"); const c = h.querySelector(".count"); if(c) c.after(s); else h.append(s); }
|
|
515
|
+
const open = sec === "done" ? 0 : list.reduce((n, i) => n + (i.subtasks || []).filter(x => x && !x.d).length, 0);
|
|
516
|
+
s.textContent = !list.length ? "Empty" : list.length + " item" + (list.length === 1 ? "" : "s") + (open ? " · " + open + " open to-do" + (open === 1 ? "" : "s") : "");
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
function listedIds(){ return items.filter(i => SECTIONS.includes(i.section)).map(i => i.id); }
|
|
520
|
+
function updateCollapseAll(){ const b = $("collapseAll"), ids = listedIds(); const all = ids.length > 0 && ids.every(id => collapsedIds.has(id)); b.textContent = all ? "Expand all" : "Collapse all"; b.setAttribute("aria-pressed", String(all)); }
|
|
521
|
+
$("collapseAll").onclick = () => { const ids = listedIds(); const all = ids.length > 0 && ids.every(id => collapsedIds.has(id)); ids.forEach(id => all ? collapsedIds.delete(id) : collapsedIds.add(id)); saveCollapsed(); render(); };
|
|
522
|
+
function priorityOf(note){ const m = /^\s*(urgent|high|medium|low)\s+priority\b[\s.:,;—-]*/i.exec(String(note || "")); return m ? {p: m[1].toLowerCase(), rest: String(note).slice(m[0].length).trim()} : null; }
|
|
523
|
+
function prioTag(p){
|
|
524
|
+
const label = p.charAt(0).toUpperCase() + p.slice(1), s = el("span", "prio prio-" + p); s.title = label + " priority";
|
|
525
|
+
const lit = {low: 1, medium: 2, high: 3}[p] || 0;
|
|
526
|
+
s.innerHTML = p === "urgent"
|
|
527
|
+
? '<svg viewBox="0 0 16 16" aria-hidden="true"><rect x="1" y="1" width="14" height="14" rx="3.5" fill="currentColor"/><path d="M8 4.5v4.2" stroke="#fff" stroke-width="1.8" stroke-linecap="round"/><circle cx="8" cy="11.3" r="1.05" fill="#fff"/></svg>'
|
|
528
|
+
: '<svg viewBox="0 0 16 16" aria-hidden="true">' + [[1.5, 9, 5], [6.5, 6, 8], [11.5, 3, 11]].map(([x, y, h], i) => '<rect x="' + x + '" y="' + y + '" width="3" height="' + h + '" rx="1" fill="currentColor" opacity="' + (i < lit ? 1 : .28) + '"/>').join("") + '</svg>';
|
|
529
|
+
s.append(document.createTextNode(label)); return s;
|
|
530
|
+
}
|
|
531
|
+
function noteEl(tag, cls, text, id){ const n = el(tag, cls + " clamp", text); n.dataset.nid = id; if(expanded.has(id)) n.classList.add("open"); return n; }
|
|
532
|
+
function fixClamps(){
|
|
533
|
+
document.querySelectorAll(".clamp").forEach(n => {
|
|
534
|
+
const next = n.nextElementSibling; if(next && next.classList.contains("read-more")) return;
|
|
535
|
+
const open = n.classList.contains("open"); if(!open && n.scrollHeight <= n.clientHeight + 1) return;
|
|
536
|
+
const b = el("button", "read-more", open ? "Show less" : "Show more"); b.type = "button";
|
|
537
|
+
b.onclick = e => { e.stopPropagation(); const id = n.dataset.nid; const o = n.classList.toggle("open"); if(o) expanded.add(id); else expanded.delete(id); b.textContent = o ? "Show less" : "Show more"; };
|
|
538
|
+
n.after(b);
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
window.addEventListener("resize", () => { document.querySelectorAll(".read-more").forEach(b => b.remove()); fixClamps(); });
|
|
542
|
+
function closeMenus(){ document.querySelectorAll(".menu").forEach(m => m.hidden = true); document.querySelectorAll(".more[aria-expanded='true']").forEach(b => b.setAttribute("aria-expanded", "false")); }
|
|
543
|
+
function moreMenu(it, opts){
|
|
544
|
+
const wrap = el("div", "menu-wrap"), btn = el("button", "more", "⋯"); btn.type = "button"; btn.setAttribute("aria-label", "More actions"); btn.setAttribute("aria-haspopup", "menu"); btn.setAttribute("aria-expanded", "false");
|
|
545
|
+
const menu = el("div", "menu"); menu.setAttribute("role", "menu"); menu.hidden = true;
|
|
546
|
+
opts.forEach(([label, target, cls]) => { const o = el("button", cls || null, label); o.type = "button"; o.setAttribute("role", "menuitem"); o.onclick = e => { e.stopPropagation(); closeMenus(); if(typeof target === "function") return target(); change(it, typeof target === "string" ? {section: target} : Object.assign({}, target)); }; menu.append(o); });
|
|
547
|
+
btn.onclick = e => { e.stopPropagation(); const open = menu.hidden; closeMenus(); menu.hidden = !open; btn.setAttribute("aria-expanded", String(open)); if(open) menu.querySelector("button").focus(); };
|
|
548
|
+
wrap.append(btn, menu); return wrap;
|
|
549
|
+
}
|
|
550
|
+
document.addEventListener("click", closeMenus);
|
|
551
|
+
document.addEventListener("keydown", e => { if(e.key === "Escape") closeMenus(); });
|
|
552
|
+
|
|
553
|
+
function render(){
|
|
554
|
+
SECTIONS.forEach(s => {
|
|
555
|
+
const ul = $("list-" + s); if(!ul) return; ul.replaceChildren();
|
|
556
|
+
const list = sorted(s); if(!list.length) ul.append(el("li", "empty", EMPTY[s]));
|
|
557
|
+
list.forEach(it => ul.append(renderItem(it, s)));
|
|
558
|
+
const c = $("c-" + s); if(c) c.textContent = list.length || "";
|
|
559
|
+
});
|
|
560
|
+
renderCompleted(); renderBoard(); renderSectionSums(); updateCollapseAll(); renderDrawer(); renderMeetings(); renderClearNew();
|
|
561
|
+
requestAnimationFrame(fixClamps);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/* ---------- side rail ---------- */
|
|
565
|
+
function renderAsk(a){
|
|
566
|
+
const li = el("li", "ask");
|
|
567
|
+
const c = el("button", "check"); c.type = "button"; c.setAttribute("aria-label", "Mark done: " + (a.title || "")); c.disabled = !canWrite; c.onclick = () => change(a, {section: "done"});
|
|
568
|
+
const tx = el("span", "t", a.title || "Untitled"); if(isNew(a)) tx.append(newTag()); if(a.note) tx.append(noteEl("span", "n", a.note, a.id));
|
|
569
|
+
li.append(c, tx);
|
|
570
|
+
if(canWrite){ const acts = el("div", "actions"); acts.append(moreMenu(a, [["Move to " + LABEL.today, {section: "today"}], ["Delete", "removed", "danger"]])); li.append(acts); }
|
|
571
|
+
return li;
|
|
572
|
+
}
|
|
573
|
+
function openQuestions(){ const out = []; items.filter(i => SECTIONS.includes(i.section)).forEach(it => (it.questions || []).forEach(q => { if(q && q.t && !q.d) out.push([it, q]); })); return out; }
|
|
574
|
+
function renderQuestion(it, q){
|
|
575
|
+
const li = el("li", "ask"), c = el("button", "check"); c.type = "button"; c.disabled = !canWrite; c.setAttribute("aria-label", "Mark answered: " + q.t);
|
|
576
|
+
c.onclick = () => { const prev = it.questions; const next = prev.map(x => x === q ? Object.assign({}, x, {d: true}) : x); it.questions = next; render(); write(it.id, {questions: next}); toast("Question answered", {id: it.id, prev: {questions: prev}}); };
|
|
577
|
+
const tx = el("span", "t", q.t); tx.append(el("span", "n", it.title || "")); li.append(c, tx); return li;
|
|
578
|
+
}
|
|
579
|
+
function renderMeetings(){
|
|
580
|
+
const ul = $("meetings"); if(!ul) return; ul.replaceChildren();
|
|
581
|
+
if(!dayData){ ul.append(el("li", "empty", "Loading today's calendar…")); return; }
|
|
582
|
+
if(dayData.off){ ul.append(el("li", "empty", "No calendar for this workspace.")); }
|
|
583
|
+
else if(dayData.error){ ul.append(el("li", "empty", "Couldn't load your calendar.")); }
|
|
584
|
+
const m = meetingsList();
|
|
585
|
+
if(!dayData.off && !dayData.error && !m.length) ul.append(el("li", "empty", "Nothing on the calendar today."));
|
|
586
|
+
const asks = items.filter(i => i.section === "meeting");
|
|
587
|
+
const used = new Set();
|
|
588
|
+
const follow = feat("showFollowUp") ? sorted("ready").concat(sorted("waiting")) : [];
|
|
589
|
+
m.forEach((x, idx) => {
|
|
590
|
+
const li = el("li", "mtg-block"), head = el("div", "mtg"); head.append(el("span", "time", x.time || ""));
|
|
591
|
+
const url = safeUrl(x.url), t = el(url ? "a" : "span", "t", x.title || "Meeting"); if(url){ t.href = url; t.target = "_blank"; t.rel = "noopener"; }
|
|
592
|
+
head.append(t); li.append(head);
|
|
593
|
+
const mine = feat("meetingAsks") ? asks.filter(a => !used.has(a.id) && meetingMatches(a.meeting, x)) : [];
|
|
594
|
+
mine.forEach(a => used.add(a.id));
|
|
595
|
+
const qs = feat("meetingAsks") && idx === 0 ? openQuestions() : [];
|
|
596
|
+
if(mine.length || qs.length){ li.append(el("div", "agenda-h", "To ask")); const l = el("ul", "agenda"); mine.forEach(a => l.append(renderAsk(a))); qs.forEach(([it, q]) => l.append(renderQuestion(it, q))); li.append(l); }
|
|
597
|
+
if(follow.length && (mine.length || qs.length || feat("followUpAll"))){
|
|
598
|
+
li.append(el("div", "agenda-h", "Show & follow up")); const l = el("ul", "agenda");
|
|
599
|
+
follow.forEach(d => { const r = el("li", "mini"), dot = el("i"); dot.style.background = d.section === "ready" ? "var(--s-ready)" : "var(--s-wait)"; const mt = el("span", "mt", d.title || "Untitled"); if(d.section === "waiting" && d.waitingOn) mt.append(el("span", "sub2", "waiting on " + d.waitingOn)); r.append(dot, mt); l.append(r); });
|
|
600
|
+
li.append(l);
|
|
601
|
+
}
|
|
602
|
+
ul.append(li);
|
|
603
|
+
});
|
|
604
|
+
const rest = asks.filter(a => !used.has(a.id));
|
|
605
|
+
if(rest.length){ const li = el("li", "mtg-block"); li.append(el("div", "agenda-h", "To ask, later meetings")); const l = el("ul", "agenda"); rest.forEach(a => { const r = renderAsk(a); if(a.meeting) r.querySelector(".t").append(el("span", "n", a.meeting)); l.append(r); }); li.append(l); ul.append(li); }
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/* ---------- actions ---------- */
|
|
609
|
+
function toast(msg, undo){
|
|
610
|
+
undoState = undo || null; $("toastMsg").textContent = msg; $("toastUndo").hidden = !undo; $("toast").hidden = false;
|
|
611
|
+
clearTimeout(toastTimer); toastTimer = setTimeout(() => { $("toast").hidden = true; undoState = null; }, 6000);
|
|
612
|
+
}
|
|
613
|
+
$("toastUndo").onclick = async () => { const u = undoState; $("toast").hidden = true; undoState = null; if(!u) return; const it = items.find(i => i.id === u.id); if(it){ Object.assign(it, u.prev); render(); } await write(u.id, u.prev); };
|
|
614
|
+
function askWaiting(it, anchor){
|
|
615
|
+
const old = anchor.parentNode.querySelector(".wait-input"); if(old){ old.focus(); return; }
|
|
616
|
+
const inp = el("input", "sub-input wait-input"); inp.type = "text"; inp.placeholder = "Waiting on who? Press Enter"; inp.setAttribute("aria-label", "Waiting on who"); inp.value = it.waitingOn || "";
|
|
617
|
+
inp.style.marginLeft = "0"; inp.style.width = "100%"; inp.style.maxWidth = "320px"; inp.onclick = e => e.stopPropagation();
|
|
618
|
+
inp.onkeydown = async e => {
|
|
619
|
+
if(e.key === "Escape"){ inp.remove(); return; } if(e.key !== "Enter") return;
|
|
620
|
+
const who = inp.value.trim().slice(0, 80); if(!who) return;
|
|
621
|
+
const prev = {section: it.section, order: it.order ?? null, waitingOn: it.waitingOn || null};
|
|
622
|
+
const patch = {waitingOn: who}; if(it.section !== "waiting"){ patch.section = "waiting"; patch.order = nextOrder("waiting"); }
|
|
623
|
+
Object.assign(it, patch); render(); toast("Waiting on " + who, {id: it.id, prev}); await write(it.id, patch);
|
|
624
|
+
};
|
|
625
|
+
inp.onblur = () => setTimeout(() => inp.remove(), 150);
|
|
626
|
+
anchor.after(inp); inp.focus();
|
|
627
|
+
}
|
|
628
|
+
function nextOrder(section){ const l = sorted(section); return l.length ? (l[l.length - 1].order ?? l.length) + 1 : 1; }
|
|
629
|
+
async function change(it, patch){
|
|
630
|
+
const prev = {section: it.section, order: it.order ?? null, meeting: it.meeting || null};
|
|
631
|
+
if(patch.section && patch.section !== it.section) patch.order = nextOrder(patch.section);
|
|
632
|
+
Object.assign(it, patch); if(patch.section === "done") it.touchedAt = Date.now(); render();
|
|
633
|
+
const s = patch.section || it.section;
|
|
634
|
+
toast(s === "done" ? "Marked complete" : s === "removed" ? "Deleted from Todoist" : s === "meeting" ? "Added to " + (patch.meeting || "the meeting") : "Moved to " + LABEL[s], s === "removed" ? null : {id: it.id, prev});
|
|
635
|
+
await write(it.id, patch);
|
|
636
|
+
}
|
|
637
|
+
async function reorder(section, ids){
|
|
638
|
+
const writes = []; ids.forEach((id, i) => { const it = items.find(x => x.id === id); if(it && it.order !== i + 1){ it.order = i + 1; writes.push([id, i + 1]); } });
|
|
639
|
+
render(); for(const [id, order] of writes) await write(id, {order});
|
|
640
|
+
}
|
|
641
|
+
let dragId = null;
|
|
642
|
+
function wireListDrag(ul){
|
|
643
|
+
ul.addEventListener("mousedown", e => { if(e.target.closest("button,a")) return; const li = e.target.closest(".item"); if(li && li.draggable) li.classList.add("grabbing"); });
|
|
644
|
+
ul.addEventListener("mouseup", () => ul.querySelectorAll(".grabbing").forEach(x => x.classList.remove("grabbing")));
|
|
645
|
+
ul.addEventListener("dragstart", e => { const li = e.target.closest(".item"); if(!li) return; dragId = li.dataset.id; li.classList.add("dragging"); try { e.dataTransfer.setData("text/plain", dragId); } catch(_){} e.dataTransfer.effectAllowed = "move"; });
|
|
646
|
+
ul.addEventListener("dragend", e => { const li = e.target.closest(".item"); if(li) li.classList.remove("dragging", "grabbing"); ul.querySelectorAll(".over").forEach(x => x.classList.remove("over")); dragId = null; });
|
|
647
|
+
ul.addEventListener("dragover", e => { if(!dragId) return; const li = e.target.closest(".item"); e.preventDefault(); ul.querySelectorAll(".over").forEach(x => x.classList.remove("over")); if(li && li.dataset.id !== dragId) li.classList.add("over"); });
|
|
648
|
+
ul.addEventListener("drop", e => {
|
|
649
|
+
e.preventDefault(); const target = e.target.closest(".item"), section = ul.dataset.section; if(!dragId || !target) return;
|
|
650
|
+
const ids = sorted(section).map(i => i.id); if(!ids.includes(dragId)) return;
|
|
651
|
+
const from = ids.indexOf(dragId); ids.splice(from, 1); let to = ids.indexOf(target.dataset.id); if(to < 0) return; if(from <= to) to += 1;
|
|
652
|
+
ids.splice(to, 0, dragId); reorder(section, ids);
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/* ---------- chat linking (desktop app only, per workspace) ---------- */
|
|
657
|
+
async function linkChats(){
|
|
658
|
+
if(!feat("chatLink")) return 0;
|
|
659
|
+
const text = r => { const p = r && r.payload; if(typeof p === "string") return p; return ((r && r.content) || []).filter(c => c.type === "text").map(c => c.text).join("\n"); };
|
|
660
|
+
const tried = store("dash.chatTried", {});
|
|
661
|
+
const nameOf = it => String(it.title || "").trim();
|
|
662
|
+
const candidates = items.filter(it => nameOf(it).length >= 3 && !it.chat && ["today", "ready", "waiting", "handoff"].includes(it.section) && !(Date.now() - (tried[it.id] || 0) < 3 * 24 * 3600 * 1000));
|
|
663
|
+
const want = [...new Set(candidates.map(it => nameOf(it).toUpperCase()))];
|
|
664
|
+
if(!want.length) return 0;
|
|
665
|
+
const opened = text(await mcp.callTool("host:claude_browser", "preview_start", {url: "https://claude.ai/recents"}));
|
|
666
|
+
const m = opened.match(/tabId\W+([A-Za-z0-9_-]+)/); const tabId = m ? m[1] : undefined;
|
|
667
|
+
const find = async q => text(await mcp.callTool("host:claude_browser", "find", tabId ? {query: q, tabId} : {query: q}, {cache: false}));
|
|
668
|
+
await new Promise(r => setTimeout(r, 2500));
|
|
669
|
+
const found = new Map(); let first = true;
|
|
670
|
+
for(const key of want){
|
|
671
|
+
let out = await find(key);
|
|
672
|
+
if(first && !/href="\/chat\//.test(out) && !/Found [1-9]/.test(out)){ await new Promise(r => setTimeout(r, 2500)); out = await find(key); }
|
|
673
|
+
first = false;
|
|
674
|
+
const esc = key.replace(/[.*+?^${}()|[\]\\\/-]/g, "\\$&").replace(/"/g, '\\\\?"');
|
|
675
|
+
const mm = out.match(new RegExp('link "[^"]*' + esc + '[^"]*" \\[ref_\\d+\\] href="(\\/chat\\/[0-9a-f-]+)"', "i"));
|
|
676
|
+
if(mm) found.set(key, "https://claude.ai" + mm[1]);
|
|
677
|
+
}
|
|
678
|
+
let n = 0;
|
|
679
|
+
for(const it of candidates){
|
|
680
|
+
const url = found.get(nameOf(it).toUpperCase());
|
|
681
|
+
if(!url){ tried[it.id] = Date.now(); continue; }
|
|
682
|
+
it.chat = url; await write(it.id, {chat: url}); n++;
|
|
683
|
+
}
|
|
684
|
+
save("dash.chatTried", tried);
|
|
685
|
+
return n;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/* ---------- update button + status ---------- */
|
|
689
|
+
let statusDoc = null, statusUnsub = null;
|
|
690
|
+
function watchStatus(){
|
|
691
|
+
if(statusUnsub){ try { statusUnsub(); } catch(_){} statusUnsub = null; }
|
|
692
|
+
if(!db) return;
|
|
693
|
+
const w = WS;
|
|
694
|
+
try {
|
|
695
|
+
statusUnsub = db.doc("meta/status-" + w.id).onSnapshot(sn => {
|
|
696
|
+
if(w !== WS) return; const prev = statusDoc; statusDoc = sn.exists ? sn.data() : null; renderStatus();
|
|
697
|
+
if(prev && prev.state === "running" && statusDoc && statusDoc.state !== "running") loadTasks();
|
|
698
|
+
}, () => {});
|
|
699
|
+
} catch(_){}
|
|
700
|
+
}
|
|
701
|
+
function renderStatus(){
|
|
702
|
+
const btn = $("updateBtn"), lbl = $("updateLabel"), st = $("updateState"), s = statusDoc || {};
|
|
703
|
+
btn.hidden = !mcp || !/^trig_[A-Za-z0-9]+$/.test(WS.updateTask || "");
|
|
704
|
+
const running = s.state === "running" && Date.now() - (Number(s.startedAt) || 0) < 20 * 60 * 1000;
|
|
705
|
+
btn.classList.toggle("busy", running);
|
|
706
|
+
if(!btn.dataset.local){ btn.disabled = running; lbl.textContent = running ? (WS.updatingLabel || "Updating…") : (WS.updateLabel || "Update"); }
|
|
707
|
+
const t = ms => new Date(ms).toLocaleTimeString("en-US", {hour: "numeric", minute: "2-digit"});
|
|
708
|
+
const day = ms => { const d = new Date(ms), n = new Date(); return d.toDateString() === n.toDateString() ? t(ms) : d.toLocaleDateString("en-US", {weekday: "short"}) + " " + t(ms); };
|
|
709
|
+
st.textContent = running ? (WS.updatingLabel || "Updating…") : s.state === "done" && s.finishedAt ? "Updated " + day(Number(s.finishedAt)) : s.state === "error" && s.finishedAt ? "Last update had a problem" : "";
|
|
710
|
+
$("updateTip").textContent = s.summary || "";
|
|
711
|
+
}
|
|
712
|
+
$("updateState").addEventListener("click", e => { e.stopPropagation(); $("updateTip").classList.toggle("show"); });
|
|
713
|
+
document.addEventListener("click", () => $("updateTip").classList.remove("show"));
|
|
714
|
+
async function runUpdate(){
|
|
715
|
+
const btn = $("updateBtn"), lbl = $("updateLabel"), w = WS;
|
|
716
|
+
btn.dataset.local = "1"; btn.disabled = true; btn.classList.add("busy");
|
|
717
|
+
let linked = 0;
|
|
718
|
+
try { if(feat("chatLink")){ lbl.textContent = "Linking chats…"; linked = await linkChats(); } } catch(_){}
|
|
719
|
+
try {
|
|
720
|
+
lbl.textContent = "Starting…";
|
|
721
|
+
await mcp.callTool(CFG.remoteServer || "Claude Code Remote", "fire_trigger", {trigger_id: w.updateTask}, {cache: false});
|
|
722
|
+
if(w === WS) statusDoc = {state: "running", startedAt: Date.now()};
|
|
723
|
+
toast((linked ? "Linked " + linked + " chat" + (linked === 1 ? "" : "s") + ". " : "") + (w.updateStartedMsg || "Updating now. New items show up in a few minutes."));
|
|
724
|
+
} catch(e){
|
|
725
|
+
const c = e && e.code;
|
|
726
|
+
toast(c === "server_not_connected" || c === "needs_reauth" ? "Reconnect Claude Code Remote in Settings → Connectors." :
|
|
727
|
+
c === "not_in_manifest" || c === "approval_required" || c === "cancelled" ? "Starting the update needs your OK." : "The update couldn't start. Try again in a minute.");
|
|
728
|
+
} finally { delete btn.dataset.local; renderStatus(); }
|
|
729
|
+
}
|
|
730
|
+
$("updateBtn").onclick = runUpdate;
|
|
731
|
+
|
|
732
|
+
function greeting(){ const h = new Date().getHours(); return (h < 12 ? "Good morning" : h < 17 ? "Good afternoon" : "Good evening") + (OWNER_NAME ? ", " + OWNER_NAME : ""); }
|
|
733
|
+
$("refreshed").textContent = greeting();
|
|
734
|
+
$("date").textContent = new Date().toLocaleDateString("en-US", {weekday: "long", month: "long", day: "numeric"});
|
|
735
|
+
$("ver").textContent = "v" + VERSION;
|
|
736
|
+
|
|
737
|
+
/* ---------- start ---------- */
|
|
738
|
+
WS = pickInitial();
|
|
739
|
+
setView(view); setActiveOnly(activeOnly);
|
|
740
|
+
(async () => {
|
|
741
|
+
const use = n => (window.claude && window.claude.use) ? window.claude.use(n).catch(() => null) : Promise.resolve(null);
|
|
742
|
+
[db, mcp] = await Promise.all([use("db"), use("mcp")]);
|
|
743
|
+
if(!mcp){ canWrite = false; applyWorkspace(WS); $("refreshed").textContent = "Open this page in Claude to see your dashboard."; return; }
|
|
744
|
+
setStatus("Loading your to-dos…");
|
|
745
|
+
applyWorkspace(WS);
|
|
746
|
+
setInterval(loadTasks, 120000);
|
|
747
|
+
let calDay = new Date().toDateString();
|
|
748
|
+
setInterval(() => { if(new Date().toDateString() !== calDay){ calDay = new Date().toDateString(); loadCalendar(); $("date").textContent = new Date().toLocaleDateString("en-US", {weekday: "long", month: "long", day: "numeric"}); } $("refreshed").textContent = greeting(); renderStatus(); }, 60000);
|
|
749
|
+
document.addEventListener("visibilitychange", () => { if(!document.hidden) loadTasks(); });
|
|
750
|
+
})();
|
|
751
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jt-workspace-dashboard",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.2-stable",
|
|
4
|
+
"description": "Shared code for Jeremy's Claude dashboards: a Todoist + Google Calendar consolidator with workspaces.",
|
|
5
|
+
"main": "dist/dashboard.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/dashboard.js",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "node build.mjs",
|
|
12
|
+
"test": "node build.mjs && node test/smoke.test.mjs"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"jsdom": "24.1.3"
|
|
17
|
+
}
|
|
18
|
+
}
|