create-pmos 0.397.0 → 0.399.0
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/package.json +25 -25
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +105 -52
- package/workspace/briefing-premium-board-test.js +284 -128
- package/workspace/briefing-premium-calendar-2-test.js +135 -198
- package/workspace/briefing-premium-calendar-3-test.js +143 -418
- package/workspace/briefing-premium-calendar-test.js +85 -196
- package/workspace/briefing-premium-doc-edit-test.js +99 -83
- package/workspace/briefing-premium-initiative-test.js +175 -290
- package/workspace/briefing-premium-insights-test.js +414 -219
- package/workspace/briefing-premium-metrics-test.js +55 -97
- package/workspace/briefing-premium-products-test.js +44 -28
- package/workspace/briefing-premium-sources-test.js +70 -49
- package/workspace/briefing-premium-test.js +155 -648
- package/workspace/briefing-premium-work-test.js +88 -283
- package/workspace/changelog.json +24 -0
- package/workspace/ev-everywhere-test.js +210 -0
- package/workspace/fixtures/board-premium-trail.js +32 -0
- package/workspace/fixtures/premium-viewer-fixtures.js +187 -0
- package/workspace/guide/briefing-premium.md +3 -1
- package/workspace/guide/home.md +68 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/lib/agent-roles.js +71 -0
- package/workspace/lib/board-grill.js +63 -0
- package/workspace/lib/board-premium.js +121 -24
- package/workspace/lib/board-trail.js +223 -0
- package/workspace/lib/home-work-item.js +58 -0
- package/workspace/lib/initiative-layout.js +77 -0
- package/workspace/lib/insights-goals.js +196 -0
- package/workspace/lib/insights-premium.js +64 -15
- package/workspace/lib/insights-records.js +115 -0
- package/workspace/lib/jira-tickets.js +1 -1
- package/workspace/lib/meeting-points.js +52 -0
- package/workspace/lib/news-for-you.js +88 -0
- package/workspace/lib/notes-series.js +29 -6
- package/workspace/lib/report-confirm.js +48 -0
- package/workspace/lib/route-modules.js +12 -0
- package/workspace/lib/routes-board-docs.js +46 -0
- package/workspace/lib/routes-board-grill.js +90 -0
- package/workspace/lib/routes-board-trail.js +33 -0
- package/workspace/lib/routes-home-desk.js +176 -0
- package/workspace/lib/routes-home-review.js +108 -0
- package/workspace/lib/routes-initiative-layout.js +57 -0
- package/workspace/lib/routes-insights-premium.js +16 -4
- package/workspace/lib/routes-insights-records.js +133 -0
- package/workspace/lib/routes-meeting-points.js +37 -0
- package/workspace/lib/routes-news.js +57 -0
- package/workspace/lib/routes-notes.js +3 -1
- package/workspace/lib/routes-report-confirm.js +31 -0
- package/workspace/lib/routes-search.js +38 -0
- package/workspace/lib/routes-viewer.js +108 -0
- package/workspace/lib/search-index.js +176 -0
- package/workspace/lib/transcript-steps.js +123 -0
- package/workspace/lib/viewer-meeting.js +205 -0
- package/workspace/lib/viewer-report.js +89 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +128 -82
- package/workspace/premium-briefing-depth-test.js +104 -90
- package/workspace/premium-chat-attach-test.js +54 -63
- package/workspace/premium-chat-chart-tab-test.js +37 -37
- package/workspace/premium-chat-context-test.js +19 -18
- package/workspace/premium-chat-goal-view-test.js +23 -23
- package/workspace/premium-chat-notes-test.js +26 -31
- package/workspace/premium-chat-report-tab-test.js +46 -28
- package/workspace/premium-chat-term-test.js +16 -16
- package/workspace/premium-chat-viewer-test.js +60 -59
- package/workspace/premium-core-doc-issue-test.js +52 -43
- package/workspace/premium-html-viewer-test.js +14 -17
- package/workspace/premium-phone-card-test.js +10 -3
- package/workspace/premium-phone-room-test.js +41 -35
- package/workspace/premium-report-read-test.js +152 -197
- package/workspace/premium-viewer-download-test.js +19 -22
- package/workspace/premium-viewer-flicker-test.js +11 -16
- package/workspace/premium-viewer-share-test.js +6 -9
- package/workspace/premium-viewer-test.js +41 -60
- package/workspace/premium-vw-backlog-test.js +53 -33
- package/workspace/premium-vw-cal-test.js +97 -128
- package/workspace/premium-vw-copy-test.js +17 -33
- package/workspace/premium-vw-doc-test.js +17 -10
- package/workspace/premium-vw-item-test.js +50 -49
- package/workspace/premium-vw-jira-test.js +53 -27
- package/workspace/premium-vw-meet-test.js +115 -187
- package/workspace/premium-vw-notes-test.js +88 -109
- package/workspace/premium-vw-rec-test.js +71 -194
- package/workspace/premium-vw-slides-test.js +46 -50
- package/workspace/premium-welcome-test.js +3 -2
- package/workspace/premium-work-depth-test.js +61 -53
- package/workspace/public/pm/bd-acts.js +383 -0
- package/workspace/public/pm/bd-asks.js +261 -0
- package/workspace/public/pm/bd-pop.js +59 -0
- package/workspace/public/pm/bd-span.js +222 -82
- package/workspace/public/pm/bd-stages.js +25 -11
- package/workspace/public/pm/bd-views.js +169 -0
- package/workspace/public/pm/c3-doc-sheet.js +1 -1
- package/workspace/public/pm/c3-md.js +3 -395
- package/workspace/public/pm/c3-phone-detail.js +1 -1
- package/workspace/public/pm/c3-phone-model.js +3 -68
- package/workspace/public/pm/chat-term.js +3 -3
- package/workspace/public/pm/cozy-board.css +798 -230
- package/workspace/public/pm/cozy-ev.css +228 -0
- package/workspace/public/pm/cozy-evmodel.js +106 -0
- package/workspace/public/pm/cozy-evui.js +47 -0
- package/workspace/public/pm/cozy-home.css +570 -142
- package/workspace/public/pm/cozy-home.js +5 -3
- package/workspace/public/pm/cozy-insights.css +437 -170
- package/workspace/public/pm/cozy-md.js +396 -0
- package/workspace/public/pm/cozy-nav.js +104 -29
- package/workspace/public/pm/cozy-news.js +140 -0
- package/workspace/public/pm/cozy-placeholder.js +26 -0
- package/workspace/public/pm/cozy-search.js +203 -0
- package/workspace/public/pm/cozy-settings.js +198 -0
- package/workspace/public/pm/cozy-sources.js +89 -0
- package/workspace/public/pm/cozy-today.css +217 -0
- package/workspace/public/pm/cozy-viewer.css +3 -3
- package/workspace/public/pm/cozy-viewer.js +145 -0
- package/workspace/public/pm/cozy-vw-mtg.css +350 -0
- package/workspace/public/pm/cozy-vw-rp.css +152 -0
- package/workspace/public/pm/cozy-vw.css +485 -0
- package/workspace/public/pm/cozy.css +83 -1
- package/workspace/public/pm/home-adddoc.js +48 -0
- package/workspace/public/pm/home-app.js +1179 -0
- package/workspace/public/pm/home-around.js +413 -0
- package/workspace/public/pm/home-chat.js +512 -0
- package/workspace/public/pm/home-data.js +312 -0
- package/workspace/public/pm/home-dictate.js +54 -0
- package/workspace/public/pm/home-draft.js +68 -0
- package/workspace/public/pm/home-ini-model.js +190 -0
- package/workspace/public/pm/home-ini.css +171 -0
- package/workspace/public/pm/home-ini.js +456 -0
- package/workspace/public/pm/home-list.js +276 -0
- package/workspace/public/pm/home-more.js +132 -0
- package/workspace/public/pm/home-phone-card.js +109 -0
- package/workspace/public/pm/home-review.js +104 -0
- package/workspace/public/pm/home-task.js +67 -0
- package/workspace/public/pm/home-today.js +144 -0
- package/workspace/public/pm/home-work.js +547 -0
- package/workspace/public/pm/phone-moment.js +69 -0
- package/workspace/public/pm/pm-work-view.js +1 -1
- package/workspace/public/pm/premium-attach.js +4 -0
- package/workspace/public/pm/premium-board.js +548 -395
- package/workspace/public/pm/premium-chart-tab.js +109 -62
- package/workspace/public/pm/premium-deck.js +3 -3
- package/workspace/public/pm/premium-first.js +23 -21
- package/workspace/public/pm/premium-insights.js +1102 -581
- package/workspace/public/pm/premium-meeting.js +61 -549
- package/workspace/public/pm/premium-mtg-present.js +138 -0
- package/workspace/public/pm/premium-mtg-replay.js +142 -0
- package/workspace/public/pm/premium-notes.js +1 -1
- package/workspace/public/pm/premium-report-frame.css +20 -0
- package/workspace/public/pm/premium-report-read.js +669 -476
- package/workspace/public/pm/premium-report-tab.js +116 -67
- package/workspace/public/pm/premium-shell.js +76 -123
- package/workspace/public/pm/premium-viewer.js +22 -1
- package/workspace/public/pm/premium-vw-cal.js +277 -48
- package/workspace/public/pm/premium-vw-doc.css +6 -0
- package/workspace/public/pm/premium-vw-doc.js +40 -2
- package/workspace/public/pm/premium-vw-file.js +2 -2
- package/workspace/public/pm/premium-vw-meet.js +6 -83
- package/workspace/public/pm/premium-vw-mtg.js +958 -0
- package/workspace/public/pm/premium-vw-notes.js +116 -68
- package/workspace/public/pm/premium-vw-open.js +35 -0
- package/workspace/public/pm/premium-vw-page.js +16 -0
- package/workspace/public/pm/premium-vw-rec.js +11 -218
- package/workspace/public/pm/premium-vw-slides.css +5 -0
- package/workspace/public/pm/premium-vw-slides.js +44 -8
- package/workspace/public/pm/rp-parts.js +269 -0
- package/workspace/public/pm/term-view.js +22 -0
- package/workspace/public/premium-board.html +29 -70
- package/workspace/public/premium-initiative.html +8 -48
- package/workspace/public/premium-insights.html +26 -64
- package/workspace/public/premium-viewer.html +20 -0
- package/workspace/public/premium.html +18 -107
- package/workspace/r/m1.png +0 -0
- package/workspace/r/m2.png +0 -0
- package/workspace/r/m3.png +0 -0
- package/workspace/r/nl.png +0 -0
- package/workspace/server.js +18 -3
- package/workspace/test-files.json +1 -0
- package/workspace/test-lists/home-libs.json +9 -0
- package/workspace/test-lists/initiative-layout.json +9 -0
- package/workspace/test-lists/premium-report-read.json +1 -1
- package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
- package/workspace/test-lists/premium-uncovered-reports.json +9 -0
- package/workspace/test-lists/premium-vw-agreed.json +9 -0
- package/workspace/test-lists/premium-vw-notes.json +1 -1
- package/workspace/test-lists/uf-everywhere.json +15 -0
- package/workspace/test-lists/uf-home.json +9 -0
- package/workspace/test-lists/uncovered-board.json +9 -0
- package/workspace/public/pm/premium-work.js +0 -729
- package/workspace/public/pm/premium.js +0 -1146
|
@@ -0,0 +1,958 @@
|
|
|
1
|
+
/* pm/premium-vw-mtg.js — a meeting in the Viewer (initiative premium-agreed-design, area viewer; redesigned by premium-uncovered-features, area
|
|
2
|
+
* meetings: MtReplay, MtFocus, MtMaterial, MtAfter, MtNotes and MtPhone.dc.html).
|
|
3
|
+
* Head the title, then one line: the day, the time, the length and who is in it. Beside it: the state (Starts in 30 min, Recording),
|
|
4
|
+
* the series "‹ 4 of 4 ›" (or "Not in a series"), what it is about (a dashed "What it is about" when it is not linked), Record
|
|
5
|
+
* before the meeting, and ⋯ (Copy as Markdown, New meeting, What Record and Focus do).
|
|
6
|
+
* Recording while it records, one line in the head: Recording · 12:04 with Highlight, Pause and Stop; "Recording paused at 12:04 · nothing
|
|
7
|
+
* is kept while paused" with Resume and Stop; and a warning when the sound stopped or the recording was off for a while.
|
|
8
|
+
* Tabs before the meeting none: the prep (Prepared for you, What it is for, What matters today, Agenda, Material, Previous meetings).
|
|
9
|
+
* While it records: Live notes | Focus | Transcript. After it: Notes | Replay | Transcript (Replay when it was recorded).
|
|
10
|
+
* Focus: Now · topic N of M with Change topic, what was said so far, the agenda with the minutes used, the material with
|
|
11
|
+
* Present (a deck: the presenter view, premium-mtg-present.js) and Add material.
|
|
12
|
+
* Replay: premium-mtg-replay.js. Notes: the summary, Since the last one, decisions, next steps (Make task, with "Task made ·
|
|
13
|
+
* added to <initiative>, under <stage>" and Undo; a work-item through the ticket button), facts, open questions, and the prep.
|
|
14
|
+
* Popovers Add material (suggested for this meeting, Find in PMOS, Paste a link, the topic and the series), What it is about (find an
|
|
15
|
+
* initiative, suggested from the notes, or the product, the whole portfolio, or leave it out), the series (take it out, put it back).
|
|
16
|
+
*
|
|
17
|
+
* WHERE EACH PART COMES FROM (nothing is invented; a part the answers do not hold is left out or says so):
|
|
18
|
+
* GET /api/notes, /api/notes/one the note, its transcript, highlights, body, speakers, screen shots, its place in a series
|
|
19
|
+
* GET /api/meeting-focus the event, its brief (In short, What matters today, Last time), material, topics, runs, captured
|
|
20
|
+
* GET /api/meeting-replay the recording's length, stretches by topic, key points and shots (Replay)
|
|
21
|
+
* GET /api/meeting-points what the PM confirmed or marked not right in Replay
|
|
22
|
+
* GET /api/calendar-views?view=week the calendar row: what it is about, people, the boards and initiatives to link to
|
|
23
|
+
* GET /api/notes/series the meetings before this one
|
|
24
|
+
* GET /api/viewer-meeting agenda minutes per topic, the audio source and Pause shots, the steps that became a ticket or a task
|
|
25
|
+
* GET /api/meeting-material/suggest Add material's suggestions and Find in PMOS
|
|
26
|
+
* WRITES (each a press): Record, Pause, Resume, Stop and Highlight through the page's recorder (premium-meeting.js recCore); POST
|
|
27
|
+
* /api/notes/save (Your notes), /api/notes/private, /api/notes/speaker (naming a speaker), /api/notes/series-member, /api/notes/link or
|
|
28
|
+
* /api/calendar-links (About), /api/viewer-meeting/agenda|capture|work-item, /api/plan-items (Make task), /api/meeting-material (Add material,
|
|
29
|
+
* Remove), /api/meeting-focus/topic (Change topic), /api/meeting-points (Confirm, Not right).
|
|
30
|
+
*
|
|
31
|
+
* meetModel(D, now) → the view model (pure; for the unit suite)
|
|
32
|
+
* meetHtml(model, ui) → the card's body (pure)
|
|
33
|
+
* mdOf(model) → the note as Markdown, for Copy as Markdown (pure)
|
|
34
|
+
* aboutOptions(row | null, W | null, choices | null, notesText) → the What it is about choices (pure)
|
|
35
|
+
* openMeeting(ref, { ws }) → opens the card. ref: a note id, { note }, { event, date }, a calendar week row or a brief-page today row. */
|
|
36
|
+
import { open as vOpen, current as vCur } from './cozy-viewer.js';
|
|
37
|
+
import { pmGet, pmPost } from './http.js';
|
|
38
|
+
import { noteSheet, aboutChoices, aboutBody, aboutNow } from './premium-vw-meet.js';
|
|
39
|
+
import { weekView, noteOfRow, sameMeeting, recordable, prevOf, taskEvent, linkBody, mmss, focusView, replayModel, RECORD_LINE, FOCUS_LINE, STOP_LINE, CONSENT_LINE, recCore } from './premium-meeting.js';
|
|
40
|
+
import { APPS, recall, remember } from './listen-sources.js';
|
|
41
|
+
import { replayView, replayHtml } from './premium-mtg-replay.js';
|
|
42
|
+
|
|
43
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
44
|
+
const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
|
|
45
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
46
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
47
|
+
const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
48
|
+
const hasTime = (s) => typeof s === 'string' && /T\d{2}:\d{2}/.test(s);
|
|
49
|
+
const ok = (t) => Number.isFinite(Date.parse(t));
|
|
50
|
+
const hm = (iso) => { const t = new Date(iso); return ok(iso) ? pad(t.getHours()) + ':' + pad(t.getMinutes()) : ''; };
|
|
51
|
+
const dayKey = (ms) => { const t = new Date(ms); return t.getFullYear() + '-' + pad(t.getMonth() + 1) + '-' + pad(t.getDate()); };
|
|
52
|
+
/** "Oct 15". */
|
|
53
|
+
export const shortDay = (iso) => (ok(iso) ? MON[new Date(iso).getMonth()] + ' ' + new Date(iso).getDate() : '');
|
|
54
|
+
/** "Today", "Yesterday", "Tomorrow" or "Wed 21 Oct". */
|
|
55
|
+
export function dayWord(iso, now = Date.now()) {
|
|
56
|
+
if (!ok(iso)) return '';
|
|
57
|
+
const k = dayKey(Date.parse(iso));
|
|
58
|
+
if (k === dayKey(now)) return 'Today';
|
|
59
|
+
if (k === dayKey(now - 864e5)) return 'Yesterday';
|
|
60
|
+
if (k === dayKey(now + 864e5)) return 'Tomorrow';
|
|
61
|
+
const t = new Date(iso); return WD[t.getDay()] + ' ' + t.getDate() + ' ' + MON[t.getMonth()];
|
|
62
|
+
}
|
|
63
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many || one + 's');
|
|
64
|
+
const CLOCK_ICON = 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18M12 7v5l3 2';
|
|
65
|
+
const MENU = {
|
|
66
|
+
copy: ['Copy as Markdown', 'The notes, decisions and next steps'],
|
|
67
|
+
fresh: ['New meeting', 'Start an untitled note now'],
|
|
68
|
+
why: ['What Record and Focus do', 'Audio and notes stay on this machine'],
|
|
69
|
+
};
|
|
70
|
+
export const EMPTY_LIVE = 'Press Record when the meeting starts. PMOS listens to your microphone and the meeting sound, and keeps both on this machine.';
|
|
71
|
+
export const EMPTY_NOTES = 'The summary, decisions and next steps are written when you stop recording.';
|
|
72
|
+
export const LIVE_FOOT = 'Transcribed on this machine. Audio and notes stay here.';
|
|
73
|
+
export const MINE_HINT = 'Type here. Your lines are kept with the transcript.';
|
|
74
|
+
export const PRIVATE_TEXT = 'Private: keep only what I type. Audio and transcript are deleted.';
|
|
75
|
+
const KIND = { 'pmos-deck': 'Deck', 'pmos-doc': 'Doc', report: 'Report', gdoc: 'Google doc', conf: 'Confluence', link: 'Link' };
|
|
76
|
+
/** The key of a next step: the first 8 hex of a hash of its words, as lib/viewer-meeting.js stepKey (sha256) — the server sends the keys it
|
|
77
|
+
* knows, so the page matches on the text it sent. The page keeps the text → key map from the answer of /api/viewer-meeting. */
|
|
78
|
+
const norm = (t) => String(t || '').toLowerCase().replace(/\s+/g, ' ').trim();
|
|
79
|
+
/** The words lib/viewer-meeting.js stepKey hashes: folded to lower-case letters, digits and single spaces. */
|
|
80
|
+
export const stepNorm = (s) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, 400).toLowerCase().replace(/[^a-z0-9 ]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
81
|
+
|
|
82
|
+
/** The transcript as lines with who said each, and the key that names a speaker: `source` for live lines, `key` for the final segments. */
|
|
83
|
+
export function linesOf(n) {
|
|
84
|
+
if (!n || n.private) return [];
|
|
85
|
+
const sp = n.speakers || {}, DEF = { mic: 'You', meeting: 'Meeting', speech: 'You' };
|
|
86
|
+
if (n.final && Array.isArray(n.final.segments) && n.final.segments.length) {
|
|
87
|
+
const names = (n.final && n.final.speakers) || {};
|
|
88
|
+
return n.final.segments.filter((g) => g && String(g.text || '').trim()).map((g) => ({ t: g.t, text: String(g.text), who: names[g.spk] || sp[g.spk] || DEF[g.spk] || String(g.spk || 'Speaker'), key: g.spk == null ? '' : String(g.spk), source: '' }));
|
|
89
|
+
}
|
|
90
|
+
return (n.transcript || []).filter((x) => x && x.text && !x.dropped).map((x) => ({ t: x.t, text: String(x.text), who: sp[x.source] || DEF[x.source] || 'You', key: '', source: x.source || 'mic' }));
|
|
91
|
+
}
|
|
92
|
+
/** The facts said in the meeting, as view-notes.js caught() reads them: a statement with a number, or one checked against a repository file. */
|
|
93
|
+
export function factsOf(n) {
|
|
94
|
+
if (!n || n.private) return [];
|
|
95
|
+
return (n.transcript || []).filter((x) => x && x.text && !x.dropped && x.cat === 'statement' && (/\d|\b(?:percent|half|double|twice)\b/i.test(x.text) || (x.check && x.check.doc)))
|
|
96
|
+
.map((x) => { const v = x.check && x.check.verdict; return { text: clip(x.text, 240), src: (x.check && x.check.doc) || '', tag: v === 'agrees' ? 'Matches' : v === 'differs' ? 'Differs' : 'Not checked', k: v === 'agrees' ? 'ok' : v === 'differs' ? 'warn' : '' }; });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const NO_NOTES = 'No notes for this meeting. It was not recorded, and nobody wrote any.';
|
|
100
|
+
export const PAUSED_LINE = 'nothing is kept while paused';
|
|
101
|
+
const peopleText = (ps) => (ps.length ? ps.slice(0, 3).join(', ') + (ps.length > 3 ? ' and ' + (ps.length - 3) + ' more' : '') : '');
|
|
102
|
+
const GAP_MS = 120000; // two minutes with no sound from the meeting while you speak: the warning line
|
|
103
|
+
|
|
104
|
+
/** Where the recording heard nothing: the stretches it was off between two starts (n.sessions), and, while it records, two minutes or more with
|
|
105
|
+
* no line from the meeting's sound while the microphone still has lines. → [{ kind: 'off' | 'quiet', from, to, text }] (from/to: wall clock HH:MM) */
|
|
106
|
+
export function gapsOf(n, now = Date.now()) {
|
|
107
|
+
if (!n || n.private) return [];
|
|
108
|
+
const out = [];
|
|
109
|
+
const ses = (Array.isArray(n.sessions) ? n.sessions : []).filter((x) => x && ok(x.from)).sort((a, b) => Date.parse(a.from) - Date.parse(b.from));
|
|
110
|
+
for (let i = 1; i < ses.length; i++) {
|
|
111
|
+
const off = Date.parse(ses[i - 1].to), on = Date.parse(ses[i].from);
|
|
112
|
+
if (Number.isFinite(off) && on > off + 30000) out.push({ kind: 'off', from: hm(ses[i - 1].to), to: hm(ses[i].from), min: Math.max(1, Math.round((on - off) / 60000)) });
|
|
113
|
+
}
|
|
114
|
+
if (n.state === 'recording' && ok(n.recorded_from)) {
|
|
115
|
+
const t0 = Date.parse(n.recorded_from), tr = (n.transcript || []).filter((x) => x && Number.isFinite(x.t) && !x.dropped);
|
|
116
|
+
const meet = tr.filter((x) => x.source === 'meeting'), mic = tr.filter((x) => x.source !== 'meeting');
|
|
117
|
+
const lastMeet = meet.length ? Math.max(...meet.map((x) => x.t)) : 0, lastMic = mic.length ? Math.max(...mic.map((x) => x.t)) : 0;
|
|
118
|
+
if (meet.length && lastMic - lastMeet >= GAP_MS) out.push({ kind: 'quiet', from: hm(new Date(t0 + lastMeet).toISOString()), to: hm(new Date(t0 + lastMic).toISOString()), min: Math.round((lastMic - lastMeet) / 60000) });
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** The view model. D = { row, n (the raw note), S (noteSheet), F (the meeting-focus answer), rep (replayModel), vm (the viewer-meeting answer),
|
|
124
|
+
* prev (prevOf), about, people, rec: { held, started }, elapsed (ms heard so far), frames (screen shots kept), canRecord, app, steps, points } */
|
|
125
|
+
export function meetModel(D, now = Date.now()) {
|
|
126
|
+
const row = D.row || null, n = D.n || null, S = D.S || null, F = D.F && D.F.ok !== false ? D.F : null, rep = D.rep || null;
|
|
127
|
+
const ev = (F && F.event) || {}, nm = n && n.meeting && n.meeting.kind === 'event' ? n.meeting : null;
|
|
128
|
+
const at = (row && row.at) || (nm && nm.start) || ev.at || (n && (n.recorded_from || n.created_at)) || null;
|
|
129
|
+
const end = (row && row.end) || (nm && nm.end) || ev.end || null;
|
|
130
|
+
const title = clip((row && row.title) || (nm && nm.title) || (S && S.title) || ev.title || 'Untitled note', 120);
|
|
131
|
+
const st = n ? n.state : null;
|
|
132
|
+
const done = !!n && (st === 'ended' || !!(S && (S.from === 'final' || S.overview || S.decisions.length)));
|
|
133
|
+
const mk = st === 'recording' || st === 'paused' ? 'live' : done ? 'notes' : 'prep';
|
|
134
|
+
const liveK = st === 'paused' ? 'paused' : st === 'recording' ? (D.rec && D.rec.held ? 'rec' : 'stale') : '';
|
|
135
|
+
const el = Math.max(0, Number(D.elapsed) || 0);
|
|
136
|
+
const over = hasTime(at) && ok(end) && now > Date.parse(end);
|
|
137
|
+
/* the state chip */
|
|
138
|
+
let chip;
|
|
139
|
+
if (mk === 'live') chip = liveK === 'rec' ? { text: 'Recording', tone: 'rec' } : liveK === 'paused' ? { text: 'Paused', tone: 'warn' } : { text: 'Not capturing', tone: 'warn' };
|
|
140
|
+
else if (mk === 'notes') chip = { text: 'Done', tone: 'ok' };
|
|
141
|
+
else if (hasTime(at) && now < Date.parse(at)) { const m = Math.max(1, Math.round((Date.parse(at) - now) / 60000)); chip = { text: 'Starts in ' + (m < 60 ? m + ' min' : Math.floor(m / 60) + ' h' + (m % 60 ? ' ' + (m % 60) + ' min' : '')), tone: m <= 60 ? 'warn' : '' }; }
|
|
142
|
+
else if (hasTime(at) && (!ok(end) || now < Date.parse(end))) chip = { text: 'On now', tone: 'rec' };
|
|
143
|
+
else chip = { text: hasTime(at) ? 'Not recorded' : 'Not started', tone: '' };
|
|
144
|
+
const people = (D.people || []).map((p) => String(p)).filter(Boolean);
|
|
145
|
+
const primary = mk === 'prep' && D.canRecord ? { k: 'record', label: 'Record' } : null;
|
|
146
|
+
const series = S && S.series ? { title: S.series.title || title, pos: S.series.pos, count: S.series.count, prev: S.series.prev, next: S.series.next } : null;
|
|
147
|
+
const seriesOff = !!(S && S.seriesOff);
|
|
148
|
+
const menu = (mk === 'notes' ? ['copy', 'fresh'] : ['fresh']).concat(['why']).map((k) => ({ k, label: MENU[k][0], sub: MENU[k][1] }));
|
|
149
|
+
/* the head's line: day · time · length · people */
|
|
150
|
+
const len = ok(at) && ok(end) ? Math.round((Date.parse(end) - Date.parse(at)) / 60000) : 0;
|
|
151
|
+
const heardMin = mk === 'notes' ? Math.round(((rep && rep.len) || (S && S.minutes * 60000) || 0) / 60000) : 0;
|
|
152
|
+
const started = D.rec && D.rec.started ? new Date(D.rec.started).toISOString() : n && n.recorded_from ? n.recorded_from : at;
|
|
153
|
+
const when = mk === 'live' ? 'Started ' + hm(started) + ' · ' + mmss(el) + ' so far'
|
|
154
|
+
: [dayWord(at, now), hasTime(at) ? hm(at) + (hasTime(end) ? ' to ' + hm(end) : '') : ''].filter(Boolean).join(' ');
|
|
155
|
+
const sub = [mk === 'live' ? 'Live' : dayWord(at, now), hasTime(at) ? (mk === 'live' && hasTime(end) ? hm(at) + ' to ' + hm(end) : hm(at)) : '',
|
|
156
|
+
heardMin ? heardMin + ' min' : len > 0 && len < 1440 ? len + ' min' : '', peopleText(people)].filter(Boolean).join(' · ');
|
|
157
|
+
/* prep */
|
|
158
|
+
const mats = (F && Array.isArray(F.material) ? F.material : []).map((m) => ({ kind: KIND[m.kind] || (m.kind ? String(m.kind) : 'Link'), title: clip(m.title || m.ref || m.url, 120), sub: [m.topic ? 'For ' + clip(m.topic, 60) : '', m.scope === 'series' ? 'every meeting of the series' : m.from === 'you' ? 'added by you' : m.from ? 'from ' + m.from : ''].filter(Boolean).join(' · ') || 'For the meeting', url: m.url || '', ref: m.ref || '', mkind: m.kind || '', ws: m.ws || '', scope: m.scope || 'meeting', topic: m.topic || '', deck: m.kind === 'pmos-deck', slides: Number(m.slides) || 0 }));
|
|
159
|
+
const brief = (F && F.brief) || null;
|
|
160
|
+
const prev = D.prev || [];
|
|
161
|
+
const carried = (S && S.carriedIn && S.carriedIn.items) || [];
|
|
162
|
+
const last = prev[0] ? prev[0].date + ' · ' + prev[0].decided + ' decided · ' + plural(prev[0].steps, 'next step') : brief && brief.last && brief.last.at ? shortDay(brief.last.at) + ' · ' + plural((brief.last.decisions || []).length, 'decided', 'decided') + ' · ' + plural((brief.last.actions || []).length, 'next step') : '';
|
|
163
|
+
const ready = [
|
|
164
|
+
{ label: 'About', text: D.about || 'Not linked yet', ok: !!D.about },
|
|
165
|
+
{ label: 'People', text: people.length ? peopleText(people) : 'None listed', ok: people.length > 0 },
|
|
166
|
+
{ label: 'Material', text: mats.length ? mats.length + ' linked' : 'None linked', ok: mats.length > 0 },
|
|
167
|
+
{ label: 'Last time', text: last || 'No earlier notes', ok: !!last && !carried.length },
|
|
168
|
+
];
|
|
169
|
+
const matters = (brief && Array.isArray(brief.matters) ? brief.matters : []).slice(0, 5).map((x) => ({ tag: clip(x.tag, 20) || 'Changed', text: clip(x.text, 200), meta: clip(x.meta, 80), k: x.tone === 'ok' ? 'ok' : x.tone ? 'warn' : '' }))
|
|
170
|
+
.concat(carried.slice(0, 4).map((x) => ({ tag: 'Carried in', text: x.text, meta: [x.owner, 'still open'].filter(Boolean).join(' · '), k: 'warn' })));
|
|
171
|
+
const ag = D.vm && D.vm.agenda ? D.vm.agenda : { topics: [], total: 0, key: '' };
|
|
172
|
+
const purpose = (S && S.context && S.context.purpose) || (brief && brief.purpose) || ev.purpose || '';
|
|
173
|
+
const prepText = (S && S.context && S.context.prep) || (brief && brief.prep) || '';
|
|
174
|
+
/* live */
|
|
175
|
+
const fv = F ? focusView(F) : D.F && D.F.ok === false ? focusView(D.F) : null; // a refused read says why
|
|
176
|
+
const topics = fv && fv.state === 'ok' ? fv.topics : [];
|
|
177
|
+
const cur = topics.findIndex((t) => t.state === 'now');
|
|
178
|
+
const cap = fv && fv.state === 'ok' ? fv.captured : { decisions: 0, actions: 0, questions: 0 };
|
|
179
|
+
const caughtText = [cap.decisions && plural(cap.decisions, 'decision'), cap.actions && plural(cap.actions, 'next step'), cap.questions && plural(cap.questions, 'question')].filter(Boolean).join(', ') || 'nothing yet';
|
|
180
|
+
const lines = linesOf(n);
|
|
181
|
+
const hl = (n && !n.private && Array.isArray(n.highlights) ? n.highlights : []).map((h) => ({ t: mmss(h.t || h.from || 0), text: clip(h.text, 300), label: h.label || '' }));
|
|
182
|
+
const capture = (D.vm && D.vm.capture) || { app: null, shots: 'on' };
|
|
183
|
+
const app = APPS.find((a) => a.id === (capture.app || D.app)) || APPS[0];
|
|
184
|
+
const recLine = mk !== 'live' ? null : liveK === 'rec' ? { k: 'rec', text: 'Recording · ' + mmss(el) }
|
|
185
|
+
: liveK === 'paused' ? { k: 'paused', text: 'Recording paused at ' + mmss(el) + ' · ' + PAUSED_LINE }
|
|
186
|
+
: { k: 'stale', text: 'Recording, but not on this page · nothing is kept until you resume here' };
|
|
187
|
+
const gaps = gapsOf(n, now).map((g) => ({ ...g, text: g.kind === 'quiet' ? 'No sound from ' + app.label.replace(/ app$/, '') + ' for ' + plural(g.min, 'min', 'min') + ' (' + g.from + ' to ' + g.to + '). Is the meeting in another app?' : 'Earlier: the recording was off for ' + plural(g.min, 'min', 'min') + ' (' + g.from + ' to ' + g.to + '). That gap is marked in the notes.' }));
|
|
188
|
+
/* Focus: the topic now, the agenda with the minutes used of the minutes planned */
|
|
189
|
+
const plannedOf = (t, i) => { const a = ag.topics.find((x) => norm(x.text) === norm(t.text)) || ag.topics[i]; return a ? a.min : 0; };
|
|
190
|
+
const fAgenda = (topics.length ? topics : ag.topics.map((a) => ({ n: a.n, text: a.text, state: 'plan', minutes: 0 }))).map((t, i) => {
|
|
191
|
+
const plan = plannedOf(t, i), used = Math.round(t.minutes || 0);
|
|
192
|
+
const k = t.state === 'now' ? (plan && used >= plan * 0.9 ? 'late' : 'now') : t.state === 'done' ? 'done' : 'plan';
|
|
193
|
+
return { n: t.n || i + 1, text: t.text, k, used, plan, fill: plan ? Math.min(1, used / plan) : t.state === 'done' ? 1 : 0,
|
|
194
|
+
say: t.state === 'plan' ? (plan ? plan + ' min' : 'planned') : plan ? used + ' of ' + plan : used + ' min' };
|
|
195
|
+
});
|
|
196
|
+
const focus = { now: cur >= 0 ? topics[cur].text : '', nowLine: topics.length ? (cur >= 0 ? 'Now · topic ' + (cur + 1) + ' of ' + topics.length : plural(topics.length, 'topic') + ' planned') : 'No topics yet',
|
|
197
|
+
gist: fv && fv.state === 'ok' ? fv.gist : '', topics: topics.map((t) => ({ text: t.text, now: t.state === 'now' })), agenda: fAgenda,
|
|
198
|
+
agendaSub: ag.total ? ag.total + ' min' : '', material: mats, error: fv && fv.state !== 'ok' ? fv.reason : '' };
|
|
199
|
+
/* after */
|
|
200
|
+
const links = (D.vm && D.vm.steps && D.vm.steps.links) || {}, tasks = new Set((D.vm && D.vm.steps && D.vm.steps.tasks) || []), keys = D.steps || {};
|
|
201
|
+
const steps = (S ? S.actions : []).map((a, i) => { const key = keys[norm(a.text)] || ''; const tk = links[key] || ''; const task = !!key && tasks.has(key);
|
|
202
|
+
return { i, text: a.text, meta: [a.owner || 'No owner', a.due ? (/^\d{4}-\d{2}-\d{2}$/.test(a.due) ? shortDay(a.due + 'T12:00:00') : a.due) : 'No date'].join(' · '), owner: a.owner, due: a.due, key, ticket: tk, task, made: tk ? 'Becomes ' + tk : task ? 'Task made' : '' }; });
|
|
203
|
+
const since = S && S.since ? { sub: S.since.day.replace(/^\w+ /, '') + ' · ' + plural(S.since.items.length, 'step') + ' then, ' + S.since.fresh.length + ' new',
|
|
204
|
+
rows: S.since.items.map((x) => ({ tag: x.state === 'done' ? 'Done' : x.state === 'again' || x.state === 'raised' ? 'Raised again' : 'Not mentioned', k: x.state === 'done' ? 'ok' : x.state === 'again' || x.state === 'raised' ? 'warn' : '', text: x.text, owner: x.owner }))
|
|
205
|
+
.concat(S.since.fresh.map((x) => ({ tag: 'New', k: 'new', text: x.text, owner: x.owner }))) } : null;
|
|
206
|
+
const replay = rep ? replayView(rep, { n, points: D.points || {}, now }) : null;
|
|
207
|
+
const trk = rep ? { len: rep.len } : null;
|
|
208
|
+
const decided = S ? S.decisions.length : 0, nsteps = steps.length, nq = S ? S.questions.length : 0;
|
|
209
|
+
const tabs = mk === 'live' ? [['notes', 'Live notes'], ['focus', 'Focus'], ['tr', 'Transcript']]
|
|
210
|
+
: mk === 'notes' ? [['notes', 'Notes']].concat(replay ? [['replay', 'Replay']] : [], [['tr', 'Transcript']]) : [];
|
|
211
|
+
const parts = [
|
|
212
|
+
{ k: 'prep', title: 'Prep and material', sub: mk === 'prep' ? 'Agenda, material and last time' : 'Prepared ' + (shortDay(at) || 'for this meeting') + ' · ' + mats.length + ' linked', empty: '' },
|
|
213
|
+
{ k: 'live', title: 'Transcript and live notes', sub: mk === 'live' ? mmss(el) + ' · ' + (liveK === 'rec' ? 'recording' : liveK === 'paused' ? 'paused' : 'not capturing') : mk === 'notes' ? Math.max(1, heardMin || Math.round(el / 60000)) + ' min · ' + plural(lines.length, 'line') : 'Starts when you record', empty: mk === 'prep' ? EMPTY_LIVE : '' },
|
|
214
|
+
{ k: 'notes', title: 'Notes and next steps', sub: mk === 'notes' ? [plural(decided, 'decision'), plural(nsteps, 'next step'), plural(nq, 'question')].join(' · ') : mk === 'live' ? 'Written when you stop' : 'Written after the meeting', empty: mk !== 'notes' ? EMPTY_NOTES : '' },
|
|
215
|
+
];
|
|
216
|
+
const kind = mk === 'live' ? 'Meeting · recording' : mk === 'notes' ? 'Meeting notes' : 'Meeting prep';
|
|
217
|
+
const head = title + ' · ' + (mk === 'live' ? 'now' : hasTime(at) ? (dayWord(at, now) === 'Today' ? (mk === 'notes' ? 'today ' : '') + hm(at) : shortDay(at) + ' ' + hm(at)) : shortDay(at) || 'note');
|
|
218
|
+
return {
|
|
219
|
+
mk, liveK, title, kind, head, noteId: n ? n.id : '', private: !!(n && n.private), at, end, sub, tabs, noNotes: mk === 'prep' && over && !n,
|
|
220
|
+
chip, people, primary, menu, when, about: D.about || '', series, seriesOff, parts, recLine, gaps,
|
|
221
|
+
prep: { ready, readyText: ready.filter((r) => r.ok).length + ' of ' + ready.length + ' ready', purpose: clip(purpose, 300), gist: clip(brief && Array.isArray(brief.gist) ? brief.gist.join(' ') : '', 600), matters,
|
|
222
|
+
agenda: ag.topics.map((t) => ({ n: t.n, text: t.text, min: t.min, set: !!t.set, key: ag.key })), agendaSub: ag.topics.length ? plural(ag.topics.length, 'topic') + (ag.total ? ' · ' + ag.total + ' min' : '') : '', agendaKey: ag.key,
|
|
223
|
+
toBeReady: clip(prepText, 300), material: mats, prev },
|
|
224
|
+
live: { state: recLine ? recLine.text : '', app: app.label, appId: app.id, shots: Number(D.frames) || 0, shotsPaused: capture.shots === 'paused',
|
|
225
|
+
topics: topics.map((t) => ({ n: t.n, text: t.text, k: t.state === 'now' ? 'now' : t.state === 'done' ? 'done' : 'plan', state: t.state === 'now' ? 'Now' : t.state === 'done' ? 'Discussed' : t.state === 'parked' ? 'Parked' : 'Planned', flex: Math.max(4, t.minutes || 0) })),
|
|
226
|
+
nowSub: topics.length ? (cur >= 0 ? 'topic ' + (cur + 1) + ' of ' + topics.length : plural(topics.length, 'topic') + ' planned') : '',
|
|
227
|
+
caught: caughtText, mine: n ? String(n.body || '') : '', hl, lines: mk === 'live' ? lines.slice(-6) : lines, total: lines.length },
|
|
228
|
+
focus,
|
|
229
|
+
notes: { summary: S ? S.overview : '', track: trk, replay, since, decisions: S ? S.decisions : [], steps, stepsSub: Object.keys(links).length ? plural(steps.filter((s) => s.ticket).length, 'step') + ' proposed as work-items' : nsteps ? plural(nsteps, 'next step') : '',
|
|
230
|
+
facts: factsOf(n), questions: S ? S.questions : [], lines, trTitle: 'Transcript · ' + plural(lines.length, 'line') + ' · press a speaker to name them' },
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** The note as Markdown: title, when, about, summary, decisions, next steps and questions. */
|
|
235
|
+
export function mdOf(m) {
|
|
236
|
+
const out = ['# ' + m.title, '', '_' + [m.when, m.about ? 'about ' + m.about : ''].filter(Boolean).join(' · ') + '_', ''];
|
|
237
|
+
if (m.people.length) out.push('**People:** ' + m.people.join(', '), '');
|
|
238
|
+
if (m.notes.summary) out.push('## Summary', '', m.notes.summary, '');
|
|
239
|
+
if (m.notes.decisions.length) out.push('## Decisions', '', ...m.notes.decisions.map((d) => '- ' + d.text + (d.why ? ' (why: ' + d.why + ')' : '')), '');
|
|
240
|
+
if (m.notes.steps.length) out.push('## Next steps', '', ...m.notes.steps.map((s) => '- [ ] ' + s.text + ' (' + s.meta + ')' + (s.ticket ? ' → ' + s.ticket : '')), '');
|
|
241
|
+
if (m.notes.questions.length) out.push('## Open questions', '', ...m.notes.questions.map((q) => '- ' + q.text), '');
|
|
242
|
+
return out.join('\n').replace(/\n{3,}/g, '\n\n');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** What it is about (MtAfter): the choices for a calendar meeting (row + its week W) or a note (aboutChoices of the boards), with the
|
|
246
|
+
* initiatives whose name the notes mention suggested first. → { suggested, initiatives, boards, portfolio, none, cur } each { v, label, sub } */
|
|
247
|
+
export function aboutOptions(row, W, choices, text = '', cur = '') {
|
|
248
|
+
const said = ' ' + norm(text).replace(/[^a-z0-9 ]+/g, ' ') + ' ';
|
|
249
|
+
const hit = (name) => { const ws = norm(name).replace(/[^a-z0-9 ]+/g, ' ').split(' ').filter((w) => w.length > 3); const got = ws.filter((w) => said.includes(' ' + w)); return ws.length && got.length ? '“' + got.slice(0, 2).join(' ') + '” matches' : ''; };
|
|
250
|
+
let inis = [], boards = [], portfolio = 'p', none = 'none';
|
|
251
|
+
if (row) {
|
|
252
|
+
inis = ((W && W.initiatives) || []).map((i) => ({ v: 'initiative|' + i.id, label: clip(i.name || i.id, 70), sub: clip(i.stage || i.board || '', 40) }));
|
|
253
|
+
boards = ((W && W.boards) || []).map((b) => ({ v: 'board|' + b.ws + '|' + b.id, label: clip(b.name || b.id, 60) + ' · product' }));
|
|
254
|
+
portfolio = 'portfolio';
|
|
255
|
+
} else {
|
|
256
|
+
for (const c of choices || []) {
|
|
257
|
+
if (c.v[0] === 'i') inis.push({ v: c.v, label: c.label.replace(/^Initiative: /, ''), sub: c.body && c.body.board ? clip(c.body.board.title, 40) : '' });
|
|
258
|
+
else if (c.v[0] === 'b') boards.push({ v: c.v, label: c.label.replace(/^Board: /, '') + ' · product' });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const suggested = text ? inis.map((i) => ({ ...i, sub: [i.sub, hit(i.label)].filter(Boolean).join(' · '), m: hit(i.label) })).filter((i) => i.m).slice(0, 3) : [];
|
|
262
|
+
return { suggested, initiatives: inis, boards, portfolio: { v: portfolio, label: 'The whole portfolio' }, none: { v: none, label: 'Leave it out of an initiative' }, cur };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/* ── html (pure) ── */
|
|
266
|
+
const SV = { link: '<path d="M10 14a4 4 0 0 0 6 0l3-3a4 4 0 0 0-6-6l-1 1M14 10a4 4 0 0 0-6 0l-3 3a4 4 0 0 0 6 6l1-1"/>',
|
|
267
|
+
prev: '<path d="M15 6l-6 6 6 6"/>', next: '<path d="M9 6l6 6-6 6"/>', chev: '<path d="M7 10l5 5 5-5"/>', flag: '<path d="M5 21V4h11l-2 4 2 4H5"/>',
|
|
268
|
+
ser: '<path d="M4 6h16M4 12h16M4 18h10"/>', plus: '<path d="M12 5v14M5 12h14"/>', x: '<path d="M6 6l12 12M18 6L6 18"/>', find: '<path d="M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14M20 20l-4-4"/>',
|
|
269
|
+
pause: '<path d="M8 5v14M16 5v14"/>', stop: '<path d="M7 7h10v10H7z"/>', play: '<path d="M8 5v14l11-7z"/>', check: '<path d="M5 12.5l4.5 4.5L19 7.5"/>',
|
|
270
|
+
doc: '<path d="M7 3h7l5 5v13H7zM14 3v5h5"/>', deck: '<path d="M4 5h16v11H4zM12 16v4M8 20h8"/>', board: '<path d="M4 4h4v16H4zM10 4h4v10h-4zM16 4h4v13h-4z"/>',
|
|
271
|
+
prod: '<path d="M5 20V11M12 20V5M19 20v-6"/>', ticket: '<path d="M4 7h16v4a2 2 0 0 0 0 4v4H4v-4a2 2 0 0 0 0-4z"/>', warn: '<path d="M12 4l9 16H3zM12 10v4M12 17v.01"/>', rec: '<circle cx="12" cy="12" r="6"/>' };
|
|
272
|
+
const svg = (k, w, extra) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"${extra || ''}>${SV[k]}</svg>`;
|
|
273
|
+
const dots = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" class="vz-dots"><circle cx="5" cy="12" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="19" cy="12" r="2"/></svg>';
|
|
274
|
+
/* bars split by weight (live topics): an SVG, so each length is an attribute and not an inline style */
|
|
275
|
+
function weightBar(cls, parts) {
|
|
276
|
+
const tot = parts.reduce((a, x) => a + x.w, 0) || 1, gap = 1.2, room = 100 - gap * Math.max(0, parts.length - 1);
|
|
277
|
+
let x = 0;
|
|
278
|
+
const rects = parts.map((q) => { const w = Math.max(0.6, room * q.w / tot), r = `<rect x="${x.toFixed(2)}%" width="${w.toFixed(2)}%" height="100%" rx="4"${q.attrs || ''}/>`; x += w + gap; return r; }).join('');
|
|
279
|
+
return `<svg class="${cls}" aria-hidden="true" width="100%" height="100%">${rects}</svg>`;
|
|
280
|
+
}
|
|
281
|
+
const fillBar = (f, k) => `<svg class="vzm-fb" aria-hidden="true" width="100%" height="8"><rect width="100%" height="8" rx="4" class="bg"/>${f > 0 ? `<rect width="${(Math.min(1, f) * 100).toFixed(1)}%" height="8" rx="4" class="fg" data-k="${k}"/>` : ''}</svg>`;
|
|
282
|
+
const lineHtml = (l, i, ui, seek) => {
|
|
283
|
+
const naming = ui.naming === i;
|
|
284
|
+
const who = naming ? `<span class="vz-name"><input data-a="namein" data-i="${i}" aria-label="Name this speaker" value="${esc(l.who)}" maxlength="60"><button type="button" class="vz-link vz-hv" data-a="nameok" data-i="${i}">Save</button></span>`
|
|
285
|
+
: `<button type="button" class="vz-who vz-hv" data-a="name" data-i="${i}" title="Name this speaker">${esc(l.who)}</button>`;
|
|
286
|
+
const t = seek && Number.isFinite(l.t) ? `<button type="button" class="vzm-t vz-hv" data-a="trseek" data-t="${l.t}" aria-label="Play from ${esc(mmss(l.t))}">${esc(mmss(l.t))}</button>` : `<time>${esc(mmss(l.t))}</time>`;
|
|
287
|
+
return `<div class="vz-line">${t}<span>${who} ${esc(l.text)}</span></div>`;
|
|
288
|
+
};
|
|
289
|
+
const matIcon = (m) => svg(m.deck ? 'deck' : 'doc', 16);
|
|
290
|
+
|
|
291
|
+
function prepHtml(P, m) {
|
|
292
|
+
const h = [];
|
|
293
|
+
if (m.noNotes) h.push(`<div class="vzm-box vzm-mut">${esc(NO_NOTES)} <button type="button" class="vzm-btn vzm-card" data-a="m-fresh">New note</button></div>`);
|
|
294
|
+
h.push(`<div class="vz-col"><p class="vzm-lbl">Prepared for you <small>${esc(P.readyText)}</small></p>${P.ready.map((r) => `<div class="vz-ready"><span class="vz-mk" data-k="${r.ok ? 'ok' : 'no'}" aria-hidden="true">${r.ok ? svg('check', 12) : '!'}</span><span><b>${esc(r.label)}</b> <em>${esc(r.text)}</em></span></div>`).join('')}</div>`);
|
|
295
|
+
if (P.purpose) h.push(`<div><p class="vzm-lbl">What it is for</p><p class="vz-p">${esc(P.purpose)}</p></div>`);
|
|
296
|
+
if (P.gist) h.push(`<div><p class="vzm-lbl">In short</p><p class="vz-p">${esc(P.gist)}</p></div>`);
|
|
297
|
+
if (P.matters.length) h.push(`<div class="vz-col"><p class="vzm-lbl">What matters today</p>${P.matters.map((x) => `<div class="vz-tagrow"><span class="vz-tag" data-k="${x.k}">${esc(x.tag)}</span><span>${esc(x.text)} <small>${esc(x.meta)}</small></span></div>`).join('')}</div>`);
|
|
298
|
+
h.push(`<div class="vz-col"><p class="vzm-lbl">Agenda <small>${esc(P.agendaSub)}</small></p>${P.agenda.length ? P.agenda.map((a, i) => `<div class="vz-ag"><i class="vz-num" aria-hidden="true">${a.n}</i><span>${esc(a.text)}</span><button type="button" class="vz-min vz-hv" data-a="min" data-i="${i}" title="Change the minutes for this topic" aria-label="${esc(a.text)}: ${a.min} minutes. Change">${a.min} min</button></div>`).join('') : '<p class="vz-empty">The invite lists no topics yet.</p>'}</div>`);
|
|
299
|
+
if (P.toBeReady) h.push(`<div><p class="vzm-lbl">To be ready</p><p class="vz-p">${esc(P.toBeReady)}</p></div>`);
|
|
300
|
+
h.push(materialHtml(P.material, m, false));
|
|
301
|
+
h.push(`<div class="vz-col"><p class="vzm-lbl">Previous meetings <small>${P.prev.length ? P.prev.length + ' before this' : 'none kept'}</small></p>${P.prev.map((p) => `<button type="button" class="vz-prev vz-hv" data-a="note" data-id="${esc(p.id)}"><time>${esc(p.date)}</time><span>${esc(p.decided + ' decided · ' + plural(p.steps, 'next step') + (p.overview ? ' · ' + p.overview : ''))}</span></button>`).join('')}</div>`);
|
|
302
|
+
return `<div class="vz-col14">${h.join('')}</div>`;
|
|
303
|
+
}
|
|
304
|
+
/** Material (MtFocus, MtMaterial): each row with Present (a deck) or Open, and Remove; then Add material and its popover. */
|
|
305
|
+
function materialHtml(mats, m, focus) {
|
|
306
|
+
const rows = mats.map((x, i) => `<div class="vzm-trow"><span class="vzm-mi" aria-hidden="true">${matIcon(x)}</span><span class="vzm-mt"><b>${esc(x.title)}</b> <span class="vzm-mut">· ${esc(x.deck && x.slides ? plural(x.slides, 'slide') : x.sub)}</span></span>`
|
|
307
|
+
+ (x.deck ? `<button type="button" class="vzm-btn vzm-soft" data-a="present" data-i="${i}">Present</button>${focus ? '<span class="vzm-mut vzm-sm">opens the presenter view</span>' : ''}` : `<button type="button" class="vzm-btn vzm-soft" data-a="mat" data-i="${i}">Open</button>`)
|
|
308
|
+
+ `<button type="button" class="vzm-ib vz-hv" data-a="matrm" data-i="${i}" aria-label="${esc('Remove ' + x.title)}">${svg('x', 14)}</button></div>`).join('');
|
|
309
|
+
return `<div class="vz-col"><p class="vzm-lbl">Material${mats.length ? '' : ' <small>none linked</small>'}</p>${rows}<button type="button" class="vzm-btn vzm-ghost" data-a="addmat" aria-expanded="${m.ui && m.ui.pop === 'mat'}">${svg('plus', 14)}Add material</button><div class="vzm-anc" data-pop="mat"></div></div>`;
|
|
310
|
+
}
|
|
311
|
+
function liveNotesHtml(m, ui) {
|
|
312
|
+
const L = m.live, h = [];
|
|
313
|
+
h.push(`<div class="vz-src"><span>Listening to <b>${esc(L.app)}</b> · microphone and meeting</span><button type="button" class="vz-link vz-hv" data-a="src" aria-expanded="${!!ui.src}">Change</button><span class="vz-sp"></span><span>${plural(L.shots, 'screen shot')}${L.shotsPaused ? ' · paused' : ''}</span><button type="button" class="vz-link vz-hv" data-a="shots">${L.shotsPaused ? 'Resume shots' : 'Pause shots'}</button></div>`);
|
|
314
|
+
if (ui.src) h.push(appsHtml(L));
|
|
315
|
+
h.push(`<label class="vz-priv"><input type="checkbox" data-a="priv"${m.private ? ' checked disabled' : ''}>${esc(PRIVATE_TEXT)}</label>`);
|
|
316
|
+
if (ui.ask === 'priv') h.push(`<div class="vz-ask" role="alert"><span>Make this note private? Its audio, transcript and screen shots are deleted now, and none are kept while it stays private.</span><div><button type="button" class="vz-b vz-solid" data-a="privgo">Make it private</button><button type="button" class="vz-b" data-a="askno">Cancel</button></div></div>`);
|
|
317
|
+
if (L.topics.length) h.push(`<div class="vz-col"><p class="vzm-lbl">Now on <small>${esc(L.nowSub)}</small></p>${weightBar('vz-stretch', L.topics.map((t) => ({ w: +t.flex || 1, attrs: ` data-k="${t.k}"` })))}${L.topics.map((t) => `<div class="vz-ag" data-k="${t.k}"><i class="vz-num" data-k="${t.k}" aria-hidden="true">${t.n}</i><span>${esc(t.text)}</span><small>${esc(t.state)}</small></div>`).join('')}</div>`);
|
|
318
|
+
h.push(`<p class="vz-caught"><b>Caught so far:</b> ${esc(L.caught)}</p>`);
|
|
319
|
+
h.push(mineHtml(m, L));
|
|
320
|
+
const off = L.total - L.lines.length;
|
|
321
|
+
h.push(`<div class="vz-col"><p class="vzm-lbl">Said last <small>${plural(L.total, 'line')} · all of them in Transcript</small></p>${L.lines.length ? L.lines.map((l, i) => lineHtml(l, i + off, ui)).join('') : `<p class="vz-empty">${m.private ? 'This note is private: only what you type is kept.' : 'Nothing has been said yet.'}</p>`}<p class="vz-note vz-fine">${esc(LIVE_FOOT)}</p></div>`);
|
|
322
|
+
return `<div class="vz-col14">${h.join('')}</div>`;
|
|
323
|
+
}
|
|
324
|
+
const appsHtml = (L) => `<div class="vz-apps" role="radiogroup" aria-label="Where the meeting is">${APPS.map((a) => `<button type="button" role="radio" class="vz-b${a.id === L.appId ? ' vz-solid' : ''}" aria-checked="${a.id === L.appId}" data-a="app" data-id="${a.id}">${esc(a.label)}</button>`).join('')}<span class="vz-note">Used the next time you record or resume.</span></div>`;
|
|
325
|
+
function mineHtml(m, L) {
|
|
326
|
+
return `<div class="vz-col"><p class="vzm-lbl">Your notes</p><textarea class="vz-mine" data-a="mine" aria-label="Your notes" placeholder="${esc(MINE_HINT)}">${esc(L.mine)}</textarea></div>`
|
|
327
|
+
+ `<div class="vz-col"><p class="vzm-lbl">Highlights <small>${L.hl.length} kept</small></p>${L.hl.length ? L.hl.map((x) => `<div class="vz-hl"><time>${esc(x.t)}</time><span>${esc(x.text)}</span></div>`).join('') : `<p class="vz-empty">${m.mk === 'live' ? 'Press Highlight to keep the last 30 seconds and the next ones.' : 'No highlights were kept.'}</p>`}</div>`;
|
|
328
|
+
}
|
|
329
|
+
function focusHtml(m, ui) {
|
|
330
|
+
const Fo = m.focus, h = [];
|
|
331
|
+
h.push(`<div class="vzm-now"><div class="vzm-r"><p class="vzm-lbl vzm-grow">${esc(Fo.nowLine)}</p>${Fo.topics.length ? `<button type="button" class="vzm-btn" data-a="topic" aria-expanded="${ui.pop === 'topic'}">Change topic</button>` : ''}</div>`
|
|
332
|
+
+ (ui.pop === 'topic' ? `<div class="vzm-topics" role="group" aria-label="Make it the topic">${Fo.topics.map((t, i) => `<button type="button" class="vzm-chip${t.now ? ' on' : ''}" data-a="topicgo" data-i="${i}"${t.now ? ' aria-current="true"' : ''}>${esc(t.text)}</button>`).join('')}</div>` : '')
|
|
333
|
+
+ `<p class="vzm-h1">${esc(Fo.now || (Fo.error ? 'Focus could not read this meeting' : 'No topic is current yet'))}</p><p class="vzm-sm">${esc(Fo.error ? Fo.error : Fo.gist ? 'So far: ' + Fo.gist : 'What was said on the topic shows here while the note records.')}</p></div>`);
|
|
334
|
+
h.push(`<div><p class="vzm-lbl">Agenda${Fo.agendaSub ? ' · ' + esc(Fo.agendaSub) : ''}</p>${Fo.agenda.length ? Fo.agenda.map((a) => `<div class="vzm-ag" data-k="${a.k}"><span>${a.k === 'now' || a.k === 'late' ? `<b>${a.n} ${esc(a.text)}</b>` : esc(a.n + ' ' + a.text)}</span>${fillBar(a.fill, a.k)}<small>${esc(a.say)}</small></div>`).join('') : '<p class="vz-empty">The invite lists no topics yet.</p>'}</div>`);
|
|
335
|
+
h.push(materialHtml(Fo.material, m, true));
|
|
336
|
+
return `<div class="vz-col14">${h.join('')}</div>`;
|
|
337
|
+
}
|
|
338
|
+
function stepHtml(a, ui) {
|
|
339
|
+
const made = ui.made && ui.made[a.i];
|
|
340
|
+
const act = a.made ? `<span class="vzm-pill" data-k="${a.ticket ? 'you' : ''}">${esc(a.ticket ? a.made : 'Task')}</span>`
|
|
341
|
+
: `<button type="button" class="vzm-btn vzm-soft" data-a="maketask" data-i="${a.i}">Make task</button><button type="button" class="vzm-ib vz-hv" data-a="makewi" data-i="${a.i}" aria-label="Make it a work-item" title="A ticket Drafted in PMOS, shown on the Board. It goes to Jira only through the Commit gate.">${svg('ticket', 15)}</button>`;
|
|
342
|
+
return `<div class="vzm-step"><span class="vzm-grow">${esc(a.text)}</span><span class="vzm-mut vzm-sm">${esc(a.meta.replace('No owner · No date', 'No owner, no date'))}</span>${act}</div>`
|
|
343
|
+
+ (made ? `<div class="vzm-made" role="status">${svg('check', 14)}<span>${made.html}</span>${made.undo ? `<button type="button" class="vzm-btn vzm-ghost" data-a="madeundo" data-i="${a.i}">Undo</button>` : ''}</div>` : '');
|
|
344
|
+
}
|
|
345
|
+
function notesHtml(m, ui) {
|
|
346
|
+
const N = m.notes, h = [];
|
|
347
|
+
h.push(`<p class="vz-sum">${N.summary ? esc(N.summary) : '<span class="vz-empty">No summary was written for this meeting.</span>'}</p>`);
|
|
348
|
+
if (N.since) h.push(`<div class="vz-col"><p class="vzm-lbl">Since the last one <small>${esc(N.since.sub)}</small></p>${N.since.rows.map((s) => `<div class="vz-tagrow"><span class="vz-tag" data-k="${s.k}">${esc(s.tag)}</span><span>${esc(s.text)} <small>${esc(s.owner)}</small></span></div>`).join('')}</div>`);
|
|
349
|
+
h.push(`<div class="vz-col"><p class="vzm-lbl">Decisions</p>${N.decisions.length ? N.decisions.map((d) => `<div class="vzm-trow vzm-top"><span class="vzm-grow">${esc(d.text)}</span>${d.why ? `<span class="vzm-mut vzm-sm vzm-why">${esc(d.why)}</span>` : ''}</div>`).join('') : '<p class="vz-empty">No decisions were caught.</p>'}</div>`);
|
|
350
|
+
h.push(`<div class="vz-col"><p class="vzm-lbl">Next steps <small>${esc(N.stepsSub)}</small></p>${N.steps.length ? N.steps.map((a) => stepHtml(a, ui)).join('') : '<p class="vz-empty">No next steps were caught.</p>'}</div>`);
|
|
351
|
+
if (N.facts.length) h.push(`<div class="vz-col"><p class="vzm-lbl">Facts mentioned <small>checked against the repository</small></p>${N.facts.map((f) => `<div class="vz-tagrow"><span class="vz-tag" data-k="${f.k}">${esc(f.tag)}</span><span>${esc(f.text)} <small>${esc(f.src)}</small></span></div>`).join('')}</div>`);
|
|
352
|
+
h.push(`<div class="vz-col"><p class="vzm-lbl">Open questions</p>${N.questions.length ? N.questions.map((q) => `<div class="vzm-trow"><span class="vzm-grow">${esc(q.text)}</span></div>`).join('') : '<p class="vz-empty">No question was left open.</p>'}</div>`);
|
|
353
|
+
h.push(`<button type="button" class="vzm-fold vz-hv" data-a="prepfold" aria-expanded="${!!ui.prepOpen}">${svg('next', 14)}<b>Prep and material</b><span class="vzm-mut">${esc(m.parts[0].sub)}</span></button>`);
|
|
354
|
+
if (ui.prepOpen) h.push(prepHtml(m.prep, m));
|
|
355
|
+
return `<div class="vz-col vz-g16">${h.join('')}</div>`;
|
|
356
|
+
}
|
|
357
|
+
function transcriptHtml(m, ui) {
|
|
358
|
+
const L = m.mk === 'live' ? m.live : null, lines = m.notes.lines, h = [];
|
|
359
|
+
if (m.mk === 'notes') h.push(mineHtml(m, m.live));
|
|
360
|
+
h.push(`<div class="vz-col"><p class="vzm-lbl">${esc(m.notes.trTitle)}</p>${lines.length ? lines.map((l, i) => lineHtml(l, i, ui, m.mk === 'notes' && !!m.notes.replay)).join('') : `<p class="vz-empty">${m.private ? 'This note is private: only what you type is kept.' : L ? 'Nothing has been said yet.' : 'Nothing was transcribed.'}</p>`}<p class="vz-note vz-fine">${esc(LIVE_FOOT)}</p></div>`);
|
|
361
|
+
return `<div class="vz-col14">${h.join('')}</div>`;
|
|
362
|
+
}
|
|
363
|
+
function recHtml(m, ui) {
|
|
364
|
+
const R = m.recLine; if (!R) return '';
|
|
365
|
+
const h = [];
|
|
366
|
+
const lead = R.k === 'rec' ? '<span class="vzm-dot" aria-hidden="true"></span>' : svg(R.k === 'paused' ? 'pause' : 'warn', 16, ' class="vzm-ink3"');
|
|
367
|
+
const acts = R.k === 'rec' ? `<button type="button" class="vzm-btn vzm-card" data-a="hl" title="Keep the last 30 seconds and the next ones">Highlight</button><button type="button" class="vzm-btn vzm-card" data-a="pause" title="Pause listening; resume within an hour">Pause</button>`
|
|
368
|
+
: `<button type="button" class="vzm-btn vzm-dark" data-a="resume">Resume</button>`;
|
|
369
|
+
h.push(`<div class="vzm-box vzm-rec" role="group" aria-label="Recording" data-k="${R.k}">${lead}<b class="vzm-grow vzm-sm" data-clk="state">${esc(R.text)}</b>${acts}<button type="button" class="vzm-ib vz-hv" data-a="stop" aria-label="Stop the recording" title="Stop and write the notes">${svg('stop', 12, ' class="vzm-fill"')}</button></div>`);
|
|
370
|
+
if (ui.ask === 'stop') h.push(`<div class="vz-ask" role="alert"><span><b>Stop for good?</b> ${esc(STOP_LINE)}</span><div><button type="button" class="vz-b vz-solid" data-a="stopgo">Stop and write the notes</button>${m.liveK === 'rec' ? '<button type="button" class="vz-b" data-a="pause">Pause instead</button>' : ''}<button type="button" class="vz-b" data-a="askno">Cancel</button></div></div>`);
|
|
371
|
+
for (const g of m.gaps) h.push(`<div class="vzm-warn vzm-sm"><span class="vzm-grow">${g.kind === 'off' ? '<b>Earlier:</b> ' + esc(g.text.replace(/^Earlier: /, '')) : esc(g.text)}</span>${g.kind === 'quiet' ? '<button type="button" class="vzm-btn vzm-card" data-a="src">Listen to another app</button>' : ''}</div>`);
|
|
372
|
+
if (ui.src && m.gaps.some((g) => g.kind === 'quiet')) h.push(appsHtml(m.live));
|
|
373
|
+
return h.join('');
|
|
374
|
+
}
|
|
375
|
+
/** The card's body. ui = { tab, pop, more, why, ask, src, naming, pos, playing, speed, filter, sel, leftOpen, made, prepOpen, msg, popHtml } */
|
|
376
|
+
export function meetHtml(m, ui = {}) {
|
|
377
|
+
const c = m.chip, h = [];
|
|
378
|
+
m.ui = ui;
|
|
379
|
+
const ser = m.series ? `<span class="vzm-ser"><button type="button" class="vzm-sb vz-hv" data-a="note" data-id="${esc(m.series.prev ? m.series.prev.id : '')}" aria-label="${esc(m.series.prev ? 'The meeting before, ' + m.series.prev.day : 'No meeting before this one')}"${m.series.prev ? '' : ' disabled'}>${svg('prev', 14)}</button><button type="button" class="vzm-sb vzm-sn vz-hv" data-a="sermenu" aria-expanded="${ui.pop === 'ser'}" title="${esc(m.series.title)}">${esc(m.series.pos + ' of ' + m.series.count)}</button><button type="button" class="vzm-sb vz-hv" data-a="note" data-id="${esc(m.series.next ? m.series.next.id : '')}" aria-label="${esc(m.series.next ? 'The meeting after, ' + m.series.next.day : 'No meeting after this one yet')}"${m.series.next ? '' : ' disabled'}>${svg('next', 14)}</button></span>`
|
|
380
|
+
: m.seriesOff ? `<button type="button" class="vzm-chip" data-a="sermenu" aria-expanded="${ui.pop === 'ser'}">${svg('ser', 14)}Not in a series</button>` : '';
|
|
381
|
+
const about = m.about ? `<button type="button" class="vzm-chip on" data-a="m-about" aria-expanded="${ui.pop === 'about'}" title="What it is about. Change">${svg('flag', 14)}${esc(m.about)}</button>`
|
|
382
|
+
: `<button type="button" class="vzm-chip vzm-dash" data-a="m-about" aria-expanded="${ui.pop === 'about'}">${svg('link', 14)}What it is about</button>`;
|
|
383
|
+
const state = m.mk === 'notes' ? '' : `<span class="vzm-chip vzm-state" data-tone="${c.tone}">${c.tone === 'rec' ? '<span class="vzm-dot" aria-hidden="true"></span>' : ''}${esc(c.text)}</span>`;
|
|
384
|
+
const pri = m.primary ? `<button type="button" class="vzm-btn vzm-dark" data-a="record" title="${esc(RECORD_LINE)}"><span class="vzm-dot" aria-hidden="true"></span>Record</button>` : '';
|
|
385
|
+
h.push(`<div class="vzm-hd"><div class="vzm-ht"><h2 class="vzm-h2">${esc(m.title)}</h2><p class="vzm-sub" data-clk="when">${esc(m.sub)}</p></div><div class="vzm-hc">${state}${ser}${about}${pri}<button type="button" class="vzm-ib vz-hv" data-a="more" aria-label="More for this meeting" aria-expanded="${!!ui.more}">${dots}</button></div></div>`);
|
|
386
|
+
h.push('<div class="vzm-anc" data-pop="head"></div>');
|
|
387
|
+
if (ui.more) h.push(`<div class="vz-menu vzm-menu" role="menu">${m.menu.map((x) => `<button type="button" role="menuitem" class="vz-hv" data-a="m-${x.k}"><b>${esc(x.label)}</b><small>${esc(x.sub)}</small></button>`).join('')}</div>`);
|
|
388
|
+
if (m.seriesOff) h.push(`<div class="vzm-box vzm-sm"><span class="vzm-grow">Taken out of the series “${esc(m.title)}”. Its notes no longer compare with the others.</span><button type="button" class="vzm-btn vzm-card" data-a="m-serback">Put it back</button></div>`);
|
|
389
|
+
h.push(recHtml(m, ui));
|
|
390
|
+
if (ui.ask === 'consent') h.push(`<div class="vz-ask" role="alert"><span><b>Tell everyone first.</b> ${esc(CONSENT_LINE.replace('Tell everyone first. ', ''))}</span><div><button type="button" class="vz-b vz-solid" data-a="recgo">I told them, start</button><button type="button" class="vz-b" data-a="askno">Not yet</button></div></div>`);
|
|
391
|
+
if (ui.why) h.push(`<div class="vz-why" role="note"><p>${esc(RECORD_LINE)}</p><p>${esc(FOCUS_LINE)}</p></div>`);
|
|
392
|
+
if (ui.msg) h.push(`<p class="vz-msg" role="status" data-tone="${ui.msg.tone || ''}"><span>${esc(ui.msg.text)}</span>${ui.msg.undo ? '<button type="button" class="vz-link vz-hv" data-a="msgundo">Undo</button>' : ''}</p>`);
|
|
393
|
+
const tab = m.tabs.some(([k]) => k === ui.tab) ? ui.tab : m.tabs.length ? m.tabs[0][0] : '';
|
|
394
|
+
if (m.tabs.length) h.push(`<div class="vzm-tabs" role="tablist" aria-label="${esc(m.title)}">${m.tabs.map(([k, l]) => `<button type="button" role="tab" class="vzm-tab" data-a="tab" data-k="${k}" aria-selected="${k === tab}">${l}</button>`).join('')}</div>`);
|
|
395
|
+
const PANE = { focus: () => focusHtml(m, ui), replay: () => replayHtml(m.notes.replay, ui), tr: () => transcriptHtml(m, ui) };
|
|
396
|
+
const body = !tab ? prepHtml(m.prep, m) : PANE[tab] ? PANE[tab]() : m.mk === 'live' ? liveNotesHtml(m, ui) : notesHtml(m, ui);
|
|
397
|
+
h.push(`<div class="vzm-pane" role="${tab ? 'tabpanel' : 'region'}" data-tab="${tab || 'prep'}">${body}</div>`);
|
|
398
|
+
return `<div class="vz vz-mtg" data-mk="${m.mk}" data-tab="${tab || 'prep'}">${h.join('')}</div>`;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/** Add material's popover (MtMaterial). P = { row, sug, found, q, topics, series, err, busy } */
|
|
402
|
+
export function matPopHtml(P) {
|
|
403
|
+
if (!P.row) return `<div class="vzm-pop" role="dialog" aria-label="Add material"><p class="vzm-h3">Add material</p><p class="vzm-sm vzm-mut">Material is kept per calendar meeting. This note has no calendar event.</p></div>`;
|
|
404
|
+
return `<div class="vzm-pop" role="dialog" aria-label="Add material"><div class="vzm-r"><p class="vzm-h3 vzm-grow">Add material</p><button type="button" class="vzm-ib vz-hv" data-a="popx" aria-label="Close">${svg('x', 14)}</button></div>`
|
|
405
|
+
+ `<div data-pl="list">${matListHtml(P)}</div>`
|
|
406
|
+
+ `<div class="vzm-in">${svg('find', 16)}<input data-a="matq" type="search" placeholder="Find in PMOS" aria-label="Find in PMOS" value="${esc(P.q || '')}"></div>`
|
|
407
|
+
+ `<div class="vzm-in">${svg('link', 16)}<input data-a="matlink" type="url" placeholder="Paste a link" aria-label="Paste a link"></div>`
|
|
408
|
+
+ `<div class="vzm-r vzm-sm">${P.topics && P.topics.length ? `<select class="vz-in" data-a="mattopic" aria-label="Topic"><option value="">For the whole meeting</option>${P.topics.map((t) => `<option value="${esc(t)}">For ${esc(clip(t, 60))}</option>`).join('')}</select>` : ''}<label class="vz-priv"><input type="checkbox" data-a="matser">For every meeting in the series</label></div>`
|
|
409
|
+
+ '<p class="vzm-sm vzm-mut">The invite in your calendar is not changed.</p>'
|
|
410
|
+
+ `<p class="vz-msg" data-tone="bad" role="alert" data-pl="err"${P.err ? '' : ' hidden'}>${esc(P.err || '')}</p></div>`;
|
|
411
|
+
}
|
|
412
|
+
export function matListHtml(P) {
|
|
413
|
+
const items = P.q ? P.found : P.sug;
|
|
414
|
+
if (!items) return `<p class="vzm-mlbl">${P.q ? 'Looking in PMOS' : 'Suggested for this meeting'}</p><p class="vz-empty">Looking in PMOS.</p>`;
|
|
415
|
+
return `<p class="vzm-mlbl">${P.q ? 'Found in PMOS' : 'Suggested for this meeting'}</p>` + (items.length ? items.map((it, i) => `<button type="button" class="vzm-mi2 vz-hv" data-a="matadd" data-i="${i}">${svg(it.kind === 'pmos-deck' ? 'deck' : it.kind === 'board' ? 'board' : 'doc', 16)}<span class="vzm-grow">${esc(clip(it.title, 80))}${it.meta ? `<br><span class="vzm-sm vzm-mut">${esc(clip(it.meta, 80))}</span>` : ''}</span><span class="vzm-k">${svg('plus', 16)}</span></button>`).join('')
|
|
416
|
+
: `<p class="vz-empty">${P.q ? 'Nothing in PMOS matches. Paste a link instead.' : 'Nothing to suggest yet. Find it in PMOS or paste a link.'}</p>`);
|
|
417
|
+
}
|
|
418
|
+
/** What it is about's popover (MtAfter). O = aboutOptions(), q = the find text */
|
|
419
|
+
export function aboutPopHtml(O, q = '', note = '') {
|
|
420
|
+
return `<div class="vzm-pop" role="dialog" aria-label="What it is about"><div class="vzm-in">${svg('find', 16)}<input data-a="aboutq" type="search" placeholder="Find an initiative" aria-label="Find an initiative" value="${esc(q)}"></div><div data-pl="list">${aboutListHtml(O, q)}</div><p class="vzm-sm vzm-mut">${esc(note)}</p></div>`;
|
|
421
|
+
}
|
|
422
|
+
export function aboutListHtml(O, q = '') {
|
|
423
|
+
const words = norm(q).split(' ').filter(Boolean), hit = (x) => words.every((w) => norm(x.label).includes(w));
|
|
424
|
+
const item = (x, ic, hl) => `<button type="button" class="vzm-mi2 vz-hv${hl ? ' hl' : ''}" data-a="aboutpick" data-v="${esc(x.v)}"${x.v === O.cur ? ' aria-current="true"' : ''}>${svg(ic, 16)}<span class="vzm-grow">${esc(x.label)}${x.sub ? `<br><span class="vzm-sm vzm-mut">${esc(x.sub)}</span>` : ''}</span>${x.v === O.cur ? svg('check', 14) : ''}</button>`;
|
|
425
|
+
const h = [];
|
|
426
|
+
if (words.length) { const f = O.initiatives.filter(hit).slice(0, 8); h.push(`<p class="vzm-mlbl">Initiatives</p>${f.length ? f.map((x) => item(x, 'flag')).join('') : '<p class="vz-empty">No initiative has that name.</p>'}`); }
|
|
427
|
+
else if (O.suggested.length) h.push(`<p class="vzm-mlbl">Suggested from the notes</p>${O.suggested.map((x) => item(x, 'flag', true)).join('')}`);
|
|
428
|
+
else if (O.initiatives.length) h.push(`<p class="vzm-mlbl">Initiatives</p>${O.initiatives.slice(0, 5).map((x) => item(x, 'flag')).join('')}`);
|
|
429
|
+
h.push(`<p class="vzm-mlbl">Or</p>${O.boards.filter((x) => !words.length || hit(x)).map((x) => item(x, 'prod')).join('')}${item(O.portfolio, 'board')}${item(O.none, 'x')}`);
|
|
430
|
+
return h.join('');
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/* ── the page half ── */
|
|
434
|
+
let MT = null; // the meeting shown
|
|
435
|
+
let WEEKS = new Map(); // date → weekView, read once per open
|
|
436
|
+
const q = (o) => Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
|
|
437
|
+
const toast = (t) => { try { if (typeof window !== 'undefined' && window.pmToast) window.pmToast(t); } catch { /* none */ } };
|
|
438
|
+
/** This module's sheet (the redesign's parts), added to the page once. */
|
|
439
|
+
const CSS = '/pm/cozy-vw-mtg.css';
|
|
440
|
+
export function mtgStyle() { if (typeof document === 'undefined' || document.querySelector(`link[href="${CSS}"]`)) return; const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.append(l); }
|
|
441
|
+
/** The Viewer is wider for a meeting (MtReplay: 780px) while it shows one; the page's own rule sizes it otherwise. */
|
|
442
|
+
export function widen(k) { const v = typeof document !== 'undefined' && document.getElementById('czViewer'); if (v) { if (k) v.dataset.vzw = k; else delete v.dataset.vzw; } }
|
|
443
|
+
/** The recorder of the page: the one Home mounted (premium-meeting.js mountMeeting), else one made here. */
|
|
444
|
+
const rec = () => recCore({ pmGet, pmPost, ws: () => (MT && MT.ws) || new URLSearchParams(location.search).get('ws') });
|
|
445
|
+
async function weekOf(date, ws) {
|
|
446
|
+
const k = date + '|' + (ws || '');
|
|
447
|
+
if (!WEEKS.has(k)) WEEKS.set(k, weekView(await pmGet('/api/calendar-views?' + q({ view: 'week', date, ws })), date));
|
|
448
|
+
return WEEKS.get(k);
|
|
449
|
+
}
|
|
450
|
+
const rowsOf = (W) => (W && W.state === 'ok' ? W.days.flatMap((d) => d.rows) : []);
|
|
451
|
+
/** The item's own address: Open in a new tab opens the standalone viewer page on it. */
|
|
452
|
+
export function meetingUrl(r) {
|
|
453
|
+
if (r.note) return '/premium-viewer.html?' + q({ open: 'meeting', note: r.note, ws: r.ws });
|
|
454
|
+
if (r.event) return '/premium-viewer.html?' + q({ open: 'meeting', event: r.event, date: r.date, ws: r.ws });
|
|
455
|
+
return '';
|
|
456
|
+
}
|
|
457
|
+
/** What a ref names: { note?, event?, date?, at?, title? }. */
|
|
458
|
+
export function refOf(ref) {
|
|
459
|
+
if (!ref) return {};
|
|
460
|
+
if (typeof ref === 'string') return /^\d{4}-\d{2}-\d{2}$/.test(ref) ? { date: ref } : { note: ref };
|
|
461
|
+
if (ref.note) return { note: typeof ref.note === 'string' ? ref.note : ref.note.id, event: ref.event, date: ref.date };
|
|
462
|
+
const at = ref.at || ref.start || null;
|
|
463
|
+
const date = ref.date || ref.day || (ok(at) ? dayKey(Date.parse(at)) : '');
|
|
464
|
+
return { event: ref.event || ref.id || '', date, at, title: ref.title || '', row: ref.at && ref.day && 'who' in ref ? ref : null };
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export async function openMeeting(ref, o = {}) {
|
|
468
|
+
mtgStyle();
|
|
469
|
+
const R = refOf(ref);
|
|
470
|
+
const me = { R, ws: o.ws || new URLSearchParams(location.search).get('ws') || '', ui: { tab: o.tab || '', sel: new Set(), made: {} }, D: null, n: null, row: null, alive: true, timers: [], play: null };
|
|
471
|
+
if (MT) { MT.alive = false; MT.timers.forEach(clearInterval); stopPlay(MT); }
|
|
472
|
+
MT = me;
|
|
473
|
+
const id = 'meeting:' + (R.note || R.event || R.title || 'new');
|
|
474
|
+
const draw0 = (body) => { body.innerHTML = '<div class="vz"><p class="vz-empty" role="status">Reading the meeting.</p></div>'; };
|
|
475
|
+
me.vid = id;
|
|
476
|
+
vOpen({ id, kind: 'Meeting', title: R.title || 'Meeting', icon: CLOCK_ICON, url: meetingUrl({ ...R, ws: me.ws }), render: draw0, onClose: () => closed(me) });
|
|
477
|
+
widen('mtg');
|
|
478
|
+
await load(me);
|
|
479
|
+
if (MT !== me) return;
|
|
480
|
+
if (o.about) await openAbout(me);
|
|
481
|
+
me.timers.push(setInterval(() => tick(me), 1000));
|
|
482
|
+
me.timers.push(setInterval(() => { if (me.model && me.model.mk === 'live') load(me, true); }, 4000));
|
|
483
|
+
me.timers.push(setInterval(() => { if (me.model && me.model.mk !== 'live') load(me, true); }, 30000));
|
|
484
|
+
}
|
|
485
|
+
function closed(me) { if (MT === me && !me.reopen) { me.alive = false; me.timers.forEach(clearInterval); stopPlay(me); MT = null; widen(''); } }
|
|
486
|
+
|
|
487
|
+
/** Read everything the card shows, then draw it. */
|
|
488
|
+
async function load(me, quiet) {
|
|
489
|
+
const C = rec();
|
|
490
|
+
const NR = await C.refresh().catch(() => C.notes());
|
|
491
|
+
if (MT !== me) return;
|
|
492
|
+
let noteId = me.R.note || (me.n && me.n.id) || '';
|
|
493
|
+
let row = me.row;
|
|
494
|
+
if (!noteId && !row && me.R.row) row = me.R.row;
|
|
495
|
+
/* the calendar row, from the week of the meeting's day */
|
|
496
|
+
if (!row && (me.R.event || me.R.at) && me.R.date) {
|
|
497
|
+
const W = await weekOf(me.R.date, me.ws); me.W = W;
|
|
498
|
+
row = rowsOf(W).find((r) => (me.R.event && r.id === me.R.event) || (me.R.at && Date.parse(r.at) === Date.parse(me.R.at) && (!me.R.title || r.title === clip(me.R.title, 120)))) || null;
|
|
499
|
+
}
|
|
500
|
+
if (!noteId && row) { const nt = noteOfRow(NR, row); if (nt) noteId = nt.id; }
|
|
501
|
+
const one = noteId ? await pmGet('/api/notes/one?id=' + encodeURIComponent(noteId)) : null;
|
|
502
|
+
if (MT !== me) return;
|
|
503
|
+
const n = one && one.ok ? one.note : null, S = noteSheet(one);
|
|
504
|
+
if (n && !row && n.meeting && n.meeting.kind === 'event' && ok(n.meeting.start)) {
|
|
505
|
+
const W = await weekOf(dayKey(Date.parse(n.meeting.start)), me.ws); me.W = W;
|
|
506
|
+
row = rowsOf(W).find((r) => sameMeeting(n.meeting, r)) || null;
|
|
507
|
+
}
|
|
508
|
+
me.row = row; me.n = n;
|
|
509
|
+
const date = row ? row.day : n && n.meeting && ok(n.meeting.start) ? dayKey(Date.parse(n.meeting.start)) : me.R.date || '';
|
|
510
|
+
const evId = row ? row.id : n && n.meeting && n.meeting.event_id ? n.meeting.event_id : me.R.event || '';
|
|
511
|
+
const fq = evId ? { event: evId, date } : n ? { note: n.id } : null;
|
|
512
|
+
me.fq = fq;
|
|
513
|
+
const done = n && (n.state === 'ended' || (S && S.from === 'final'));
|
|
514
|
+
const [F, rp, ser, pts] = await Promise.all([
|
|
515
|
+
fq ? pmGet('/api/meeting-focus?' + q(fq)) : null,
|
|
516
|
+
n && done && !n.private ? pmGet('/api/meeting-replay?' + q({ note: n.id })) : null,
|
|
517
|
+
!quiet && S && S.series && S.series.key ? pmGet('/api/notes/series?key=' + encodeURIComponent(S.series.key)) : null,
|
|
518
|
+
n && done && !n.private ? pmGet('/api/meeting-points?' + q({ note: n.id })) : null,
|
|
519
|
+
]);
|
|
520
|
+
if (MT !== me) return;
|
|
521
|
+
const topicTexts = (F && F.ok && Array.isArray(F.topics) && F.topics.length ? F.topics.map((t) => t.text) : S && S.context ? S.context.agenda.map((a) => a.text) : []).slice(0, 12);
|
|
522
|
+
const len = row && ok(row.at) && ok(row.end) ? Math.round((Date.parse(row.end) - Date.parse(row.at)) / 60000) : 0;
|
|
523
|
+
const vmq = new URLSearchParams(q({ note: n ? n.id : '', event: evId, series: row && row.series, title: (row && row.title) || (n && n.title) || '', length: len || '' }));
|
|
524
|
+
topicTexts.forEach((t) => vmq.append('topic', t));
|
|
525
|
+
const vm = await pmGet('/api/viewer-meeting?' + vmq.toString());
|
|
526
|
+
if (MT !== me) return;
|
|
527
|
+
/* the steps' keys: the server keys a step by its words; the page asks once per open for the keys of the note's steps */
|
|
528
|
+
const steps = me.D && me.D.steps ? me.D.steps : {};
|
|
529
|
+
if (S && S.actions.length && !Object.keys(steps).length) for (const a of S.actions) steps[norm(a.text)] = await keyOf(a.text);
|
|
530
|
+
if (ser) me.prev = prevOf(ser, row || { at: (n && n.meeting && n.meeting.start) || (n && n.created_at) });
|
|
531
|
+
const level = row && row.level ? row.level : F && F.ok && F.brief && F.brief.initiative ? { kind: 'initiative', id: F.brief.initiative.id, name: F.brief.initiative.title } : null;
|
|
532
|
+
const about = level ? (level.kind === 'portfolio' ? 'Portfolio' : clip(level.name || level.id, 60)) : S && S.about ? S.about : '';
|
|
533
|
+
const held = !!(window.__premiumHolding && n && window.__premiumHolding.id === n.id);
|
|
534
|
+
const nr = n ? NR.find((x) => x.id === n.id) : null;
|
|
535
|
+
const rep = rp && rp.ok ? replayModel(rp) : null;
|
|
536
|
+
if (rep) rep.raw = rp.keys || [];
|
|
537
|
+
me.D = { row, n, S, F: F && F.ok ? F : F && F.ok === false ? { ok: false, error: F.error } : null, rep, vm: vm && vm.ok ? vm : null, prev: me.prev || [], about, level,
|
|
538
|
+
people: (row && row.who && row.who.length ? row.who : F && F.ok && F.event && F.event.attendees && F.event.attendees.length ? F.event.attendees : S && S.context ? S.context.people : []),
|
|
539
|
+
rec: { held, started: held ? C.started() : null }, elapsedBase: nr ? nr.meeting_ms || 0 : 0, frames: one && one.screen ? (one.screen.frames || []).length : 0,
|
|
540
|
+
canRecord: row ? recordable(row) : !!(n && (n.state === 'idle' || !n.state)), app: recall(safeStorage()).app, steps, points: pts && pts.ok ? pts.points || {} : (me.D && me.D.points) || {} };
|
|
541
|
+
draw(me);
|
|
542
|
+
}
|
|
543
|
+
async function keyOf(text) {
|
|
544
|
+
try {
|
|
545
|
+
const b = new TextEncoder().encode(stepNorm(text));
|
|
546
|
+
const h = await crypto.subtle.digest('SHA-256', b);
|
|
547
|
+
return [...new Uint8Array(h)].slice(0, 4).map((x) => x.toString(16).padStart(2, '0')).join('');
|
|
548
|
+
} catch { return ''; }
|
|
549
|
+
}
|
|
550
|
+
const safeStorage = () => { try { return localStorage; } catch { return null; } };
|
|
551
|
+
const elapsedOf = (me) => { const D = me.D; if (!D) return 0; if (D.rec.held && D.rec.started) return Date.now() - D.rec.started; return D.elapsedBase; };
|
|
552
|
+
|
|
553
|
+
function draw(me) {
|
|
554
|
+
if (MT !== me || !me.D) return;
|
|
555
|
+
const body = vCur() && vCur().id === me.vid ? document.querySelector('#czViewer .cz-vw-body') : null;
|
|
556
|
+
const m = me.model = meetModel({ ...me.D, elapsed: elapsedOf(me) });
|
|
557
|
+
const busy = body && body.contains(document.activeElement) && /^(TEXTAREA|INPUT|SELECT)$/.test(document.activeElement.tagName);
|
|
558
|
+
if (!body || me.kind !== m.kind || me.head !== m.head) { // the header names the state: open again when it changed
|
|
559
|
+
me.kind = m.kind; me.head = m.head; me.reopen = true;
|
|
560
|
+
const R = me.n ? { note: me.n.id } : me.row ? { event: me.row.id, date: me.row.day } : me.R;
|
|
561
|
+
vOpen({ id: me.vid, kind: m.kind, title: m.head, icon: CLOCK_ICON, url: meetingUrl({ ...R, ws: me.ws }), render: (b) => paint(me, b), onClose: () => closed(me) });
|
|
562
|
+
widen('mtg');
|
|
563
|
+
me.reopen = false;
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
if (busy) return; // the PM is typing: the next read draws it
|
|
567
|
+
paint(me, body);
|
|
568
|
+
}
|
|
569
|
+
function paint(me, body) {
|
|
570
|
+
const top = body.scrollTop;
|
|
571
|
+
body.innerHTML = meetHtml(me.model, me.ui);
|
|
572
|
+
body.scrollTop = top;
|
|
573
|
+
placePop(me, body);
|
|
574
|
+
body.querySelectorAll('.vzp-top[data-w]').forEach((b) => b.style.setProperty('flex-grow', b.dataset.w)); // the topic names under the strip, as wide as their stretch
|
|
575
|
+
body.onclick = (e) => press(me, e);
|
|
576
|
+
body.onchange = (e) => change(me, e);
|
|
577
|
+
body.oninput = (e) => input(me, e);
|
|
578
|
+
body.onkeydown = (e) => keydown(me, e, body);
|
|
579
|
+
}
|
|
580
|
+
/** The open popover goes in its anchor, drawn once per paint (its list is redrawn on its own while the PM types). */
|
|
581
|
+
function placePop(me, body) {
|
|
582
|
+
const P = me.ui.pop; if (P !== 'mat' && P !== 'about' && P !== 'ser') return;
|
|
583
|
+
const anc = P === 'mat' ? body.querySelector('[data-pop="mat"]') : body.querySelector('[data-pop="head"]'); if (!anc) return;
|
|
584
|
+
if (P === 'mat') { anc.innerHTML = matPopHtml(me.mat || { row: me.row }); if (!me.matShown && anc.scrollIntoView) { me.matShown = true; anc.scrollIntoView({ block: 'nearest' }); } }
|
|
585
|
+
else if (P === 'about') anc.innerHTML = me.about ? aboutPopHtml(me.about, me.aboutQ || '', me.row ? 'Applies to every meeting of “' + me.row.title + '”. The calendar itself is never written.' : 'Applies to this note.') : '<div class="vzm-pop"><p class="vz-empty">Reading what it can be about.</p></div>';
|
|
586
|
+
else anc.innerHTML = `<div class="vzm-pop vzm-pop-s" role="menu"><button type="button" role="menuitem" class="vzm-mi2 vz-hv" data-a="${me.model.seriesOff ? 'm-serback' : 'm-serout'}">${me.model.seriesOff ? 'Put it back in its series' : 'Not part of this series'}<br><span class="vzm-sm vzm-mut">${me.model.seriesOff ? 'Join the meetings with the same title again' : 'Keep this note on its own'}</span></button></div>`;
|
|
587
|
+
}
|
|
588
|
+
function keydown(me, e, body) {
|
|
589
|
+
const a = e.target.dataset && e.target.dataset.a;
|
|
590
|
+
if (e.key === 'Enter' && a === 'namein') { e.preventDefault(); nameIt(me, +e.target.dataset.i, e.target.value); }
|
|
591
|
+
if (e.key === 'Enter' && a === 'minin') { e.preventDefault(); setMin(me, +e.target.dataset.i, e.target.value); }
|
|
592
|
+
if (e.key === 'Enter' && a === 'matlink') { e.preventDefault(); addLink(me, e.target.value); }
|
|
593
|
+
if (e.key === 'Escape' && me.ui.naming != null) { me.ui.naming = null; paint(me, body); }
|
|
594
|
+
if (e.key === 'Escape' && me.ui.pop) { e.stopPropagation(); me.ui.pop = ''; paint(me, body); }
|
|
595
|
+
if (a === 'seek' && (e.key === 'ArrowRight' || e.key === 'ArrowLeft')) { e.preventDefault(); const P = ensurePlay(me); if (P) seek(me, P.pos + (e.key === 'ArrowRight' ? 10000 : -10000), false); }
|
|
596
|
+
}
|
|
597
|
+
const bodyEl = () => document.querySelector('#czViewer .cz-vw-body');
|
|
598
|
+
const repaint = (me) => { const b = bodyEl(); if (b && MT === me) paint(me, b); };
|
|
599
|
+
function say(me, text, tone, undo) { me.ui.msg = { text, tone, undo }; repaint(me); clearTimeout(me.msgT); me.msgT = setTimeout(() => { if (me.ui.msg && me.ui.msg.text === text) { me.ui.msg = null; repaint(me); } }, 9000); }
|
|
600
|
+
function tick(me) {
|
|
601
|
+
if (MT !== me || !me.model) return;
|
|
602
|
+
const b = bodyEl(); if (!b) return;
|
|
603
|
+
if (me.model.mk === 'live' && me.D.rec.held) {
|
|
604
|
+
const el = elapsedOf(me), s = b.querySelector('[data-clk="state"]');
|
|
605
|
+
if (s && me.model.liveK === 'rec') s.textContent = 'Recording · ' + mmss(el);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/* the presses */
|
|
610
|
+
async function press(me, e) {
|
|
611
|
+
const t = e.target.closest('[data-a]');
|
|
612
|
+
if (!t) { if (me.ui.pop && !e.target.closest('.vzm-pop')) { me.ui.pop = ''; repaint(me); } return; }
|
|
613
|
+
if (t.disabled) return;
|
|
614
|
+
const a = t.dataset.a, ui = me.ui, m = me.model, C = rec();
|
|
615
|
+
if (a !== 'more' && !a.startsWith('m-')) ui.more = false;
|
|
616
|
+
if (ui.pop && !t.closest('.vzm-pop') && !['addmat', 'm-about', 'sermenu', 'topic'].includes(a)) ui.pop = '';
|
|
617
|
+
switch (a) {
|
|
618
|
+
case 'tab': ui.tab = t.dataset.k; ui.pop = ''; return repaint(me);
|
|
619
|
+
case 'more': ui.more = !ui.more; return repaint(me);
|
|
620
|
+
case 'popx': ui.pop = ''; return repaint(me);
|
|
621
|
+
case 'askno': ui.ask = null; return repaint(me);
|
|
622
|
+
case 'record': ui.ask = 'consent'; return repaint(me);
|
|
623
|
+
case 'recgo': {
|
|
624
|
+
ui.ask = null; t.disabled = true;
|
|
625
|
+
const res = me.n && !me.row ? await C.resume(me.n.id) : await C.record(me.row);
|
|
626
|
+
say(me, res.ok ? 'Recording. Notes are being taken on this machine. Let people know.' : res.error, res.ok ? '' : 'bad');
|
|
627
|
+
ui.tab = ''; return load(me);
|
|
628
|
+
}
|
|
629
|
+
case 'resume': { t.disabled = true; const res = await C.resume(me.n.id); say(me, res.ok ? 'Listening again.' : res.error, res.ok ? '' : 'bad'); return load(me); }
|
|
630
|
+
case 'pause': { ui.ask = null; t.disabled = true; const res = await C.pause(); say(me, res.ok ? 'Paused. You can resume within 1 hour.' : res.error, res.ok ? '' : 'bad'); return load(me); }
|
|
631
|
+
case 'stop': ui.ask = 'stop'; return repaint(me);
|
|
632
|
+
case 'stopgo': { ui.ask = null; t.disabled = true; const res = await C.stop(me.n.id); say(me, res.ok ? (res.discarded ? 'Nothing was recorded, so the note was deleted.' : 'Stopped. The final notes are written now.') : res.error, res.ok ? '' : 'bad'); ui.tab = ''; return load(me); }
|
|
633
|
+
case 'hl': { const res = await C.highlight(); say(me, res.ok ? 'Keeping the last 30 seconds and the next ones as a highlight.' : res.error, res.ok ? '' : 'bad'); return; }
|
|
634
|
+
case 'src': ui.src = !ui.src; return repaint(me);
|
|
635
|
+
case 'app': {
|
|
636
|
+
const s = safeStorage(); remember(s, { ...recall(s), app: t.dataset.id }); me.D.app = t.dataset.id;
|
|
637
|
+
if (me.n) { const r = await pmPost('/api/viewer-meeting/capture', { id: me.n.id, app: t.dataset.id }); if (r && r.ok) me.D.vm = { ...(me.D.vm || {}), capture: r.capture }; }
|
|
638
|
+
ui.src = false; return draw(me);
|
|
639
|
+
}
|
|
640
|
+
case 'shots': {
|
|
641
|
+
if (!me.n) return;
|
|
642
|
+
const r = await pmPost('/api/viewer-meeting/capture', { id: me.n.id, shots: m.live.shotsPaused ? 'on' : 'paused' });
|
|
643
|
+
if (!r || !r.ok) return say(me, 'Not changed: ' + ((r && r.error) || 'no answer'), 'bad');
|
|
644
|
+
me.D.vm = { ...(me.D.vm || {}), capture: r.capture }; say(me, r.capture.shots === 'paused' ? 'Screen shots are paused. Sound and the transcript go on.' : 'Screen shots go on.'); return draw(me);
|
|
645
|
+
}
|
|
646
|
+
case 'privgo': {
|
|
647
|
+
ui.ask = null; const r = await pmPost('/api/notes/private', { id: me.n.id, private: true });
|
|
648
|
+
say(me, r && r.ok ? 'Private. Only what you type is kept.' : 'Not changed: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad'); return load(me);
|
|
649
|
+
}
|
|
650
|
+
case 'name': ui.naming = +t.dataset.i; repaint(me); { const i = bodyEl().querySelector('[data-a="namein"]'); if (i) { i.focus(); i.select(); } } return;
|
|
651
|
+
case 'nameok': { const i = bodyEl().querySelector('[data-a="namein"]'); return nameIt(me, +t.dataset.i, i ? i.value : ''); }
|
|
652
|
+
case 'min': {
|
|
653
|
+
const row = t.closest('.vz-ag'), a0 = m.prep.agenda[+t.dataset.i]; if (!a0) return;
|
|
654
|
+
t.outerHTML = `<span class="vz-min"><input type="number" min="0" max="240" step="5" data-a="minin" data-i="${t.dataset.i}" value="${a0.min}" aria-label="Minutes for ${esc(a0.text)}"></span>`;
|
|
655
|
+
const i = row.querySelector('input'); if (i) { i.focus(); i.select(); i.onblur = () => setMin(me, +i.dataset.i, i.value); } return;
|
|
656
|
+
}
|
|
657
|
+
case 'note': if (t.dataset.id) return openMeeting({ note: t.dataset.id }, { ws: me.ws }); return;
|
|
658
|
+
case 'mat': {
|
|
659
|
+
const x = matAt(me, +t.dataset.i); if (!x) return;
|
|
660
|
+
if (x.url && /^https:\/\//.test(x.url)) { window.open(x.url, '_blank', 'noopener'); return; }
|
|
661
|
+
return say(me, '“' + x.title + '” is a PMOS ' + x.kind.toLowerCase() + '. Open it from its initiative.');
|
|
662
|
+
}
|
|
663
|
+
case 'present': return presentIt(me, matAt(me, +t.dataset.i));
|
|
664
|
+
case 'matrm': return removeMat(me, matAt(me, +t.dataset.i));
|
|
665
|
+
case 'addmat': if (ui.pop === 'mat') { ui.pop = ''; return repaint(me); } return openMat(me);
|
|
666
|
+
case 'matadd': { const P = me.mat; const it = P && (P.q ? P.found : P.sug)[+t.dataset.i]; if (it) return addMat(me, it.url && !it.ref ? { url: it.url, title: it.title } : { kind: it.kind, ref: it.ref, title: it.title, ...(it.ws ? { ws: it.ws } : {}) }); return; }
|
|
667
|
+
case 'topic': ui.pop = ui.pop === 'topic' ? '' : 'topic'; return repaint(me);
|
|
668
|
+
case 'topicgo': return changeTopic(me, m.focus.topics[+t.dataset.i]);
|
|
669
|
+
case 'maketask': return makeTask(me, +t.dataset.i);
|
|
670
|
+
case 'makewi': return makeWorkItem(me, +t.dataset.i);
|
|
671
|
+
case 'madeundo': { const md = ui.made[+t.dataset.i]; delete ui.made[+t.dataset.i]; repaint(me); if (md && md.undo) await md.undo(); return; }
|
|
672
|
+
case 'msgundo': { const u = ui.msg && ui.msg.undo; ui.msg = null; if (u) await u(); return; }
|
|
673
|
+
case 'prepfold': ui.prepOpen = !ui.prepOpen; return repaint(me);
|
|
674
|
+
/* Replay */
|
|
675
|
+
case 'play': return togglePlay(me);
|
|
676
|
+
case 'speed': { const P = ensurePlay(me); const sp = [1, 1.5, 2]; ui.speed = sp[(sp.indexOf(ui.speed || 1) + 1) % sp.length]; if (P && P.aud) P.aud.playbackRate = ui.speed; return repaint(me); }
|
|
677
|
+
case 'seekto': if (t.dataset.t !== '') return seek(me, +t.dataset.t, true); return;
|
|
678
|
+
case 'trseek': ui.tab = 'replay'; repaint(me); return seek(me, +t.dataset.t, true);
|
|
679
|
+
case 'seek': { const r = t.getBoundingClientRect(); return seek(me, Math.max(0, Math.min(1, (e.clientX - r.left) / r.width)) * m.notes.replay.len, false); }
|
|
680
|
+
case 'shotbig': if (m.notes.replay && m.notes.replay.noteId) window.open('/api/notes/screen?id=' + encodeURIComponent(m.notes.replay.noteId) + '&t=' + t.dataset.t, '_blank', 'noopener'); return;
|
|
681
|
+
case 'pf': ui.filter = t.dataset.k; return repaint(me);
|
|
682
|
+
case 'tick': { const id = t.dataset.id; if (ui.sel.has(id)) ui.sel.delete(id); else ui.sel.add(id); return repaint(me); }
|
|
683
|
+
case 'leftout': ui.leftOpen = !ui.leftOpen; return repaint(me);
|
|
684
|
+
case 'bulk': return bulk(me, t.dataset.k, [...ui.sel]);
|
|
685
|
+
case 'confirmall': return bulk(me, 'confirmed', m.notes.replay.points.filter((p) => !p.verdict).map((p) => p.id));
|
|
686
|
+
case 'unwrong': return verdict(me, [t.dataset.id], null, 'It is back in the kept points.');
|
|
687
|
+
case 'ptask': return bulk(me, 'task', [t.dataset.id]);
|
|
688
|
+
/* the head */
|
|
689
|
+
case 'sermenu': ui.pop = ui.pop === 'ser' ? '' : 'ser'; return repaint(me);
|
|
690
|
+
case 'm-about': if (ui.pop === 'about') { ui.pop = ''; return repaint(me); } return openAbout(me);
|
|
691
|
+
case 'aboutpick': return saveAbout(me, t.dataset.v);
|
|
692
|
+
case 'm-copy': { ui.more = false; repaint(me); const md = mdOf(m); try { await navigator.clipboard.writeText(md); say(me, 'Copied the notes as Markdown.'); } catch { say(me, 'The browser did not allow copying. Select the text in the notes instead.', 'bad'); } return; }
|
|
693
|
+
case 'm-fresh': { ui.more = false; return newNote(me.ws); }
|
|
694
|
+
case 'm-serout': case 'm-serback': {
|
|
695
|
+
ui.more = false; ui.pop = ''; const r = await pmPost('/api/notes/series-member', { id: me.n.id, key: a === 'm-serout' ? 'off' : null });
|
|
696
|
+
say(me, r && r.ok ? (a === 'm-serout' ? 'Taken out of the series. It stays a note on its own.' : 'Back in its series.') : 'Not saved: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad'); return load(me);
|
|
697
|
+
}
|
|
698
|
+
case 'm-why': ui.more = false; ui.why = !ui.why; return repaint(me);
|
|
699
|
+
default:
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
function change(me, e) {
|
|
703
|
+
const t = e.target;
|
|
704
|
+
if (t.dataset.a === 'priv' && t.checked) { t.checked = false; me.ui.ask = 'priv'; repaint(me); }
|
|
705
|
+
}
|
|
706
|
+
function input(me, e) {
|
|
707
|
+
const a = e.target.dataset.a, v = e.target.value;
|
|
708
|
+
if (a === 'mine') return saveMine(me, v);
|
|
709
|
+
if (a === 'matq') { clearTimeout(me.matT); me.matT = setTimeout(() => findMat(me, v.trim()), 220); return; }
|
|
710
|
+
if (a === 'aboutq') { me.aboutQ = v; const l = bodyEl() && bodyEl().querySelector('.vzm-pop [data-pl="list"]'); if (l && me.about) l.innerHTML = aboutListHtml(me.about, v); }
|
|
711
|
+
}
|
|
712
|
+
let mineT = null;
|
|
713
|
+
function saveMine(me, v) {
|
|
714
|
+
if (!me.n) return;
|
|
715
|
+
clearTimeout(mineT);
|
|
716
|
+
mineT = setTimeout(async () => { const r = await pmPost('/api/notes/save', { id: me.n.id, body: v }); if (r && r.ok && me.n) me.n.body = v; else if (MT === me) say(me, 'Your notes were not saved: ' + ((r && r.error) || 'no answer'), 'bad'); }, 900);
|
|
717
|
+
}
|
|
718
|
+
async function nameIt(me, i, name) {
|
|
719
|
+
const all = linesOf(me.n), l = all[i];
|
|
720
|
+
me.ui.naming = null;
|
|
721
|
+
if (!l || !String(name).trim()) return repaint(me);
|
|
722
|
+
const body = l.key ? { id: me.n.id, key: l.key, name: String(name).trim() } : { id: me.n.id, source: l.source, name: String(name).trim() };
|
|
723
|
+
const r = await pmPost('/api/notes/speaker', body);
|
|
724
|
+
say(me, r && r.ok ? 'Named. Every line of this speaker shows the name.' : 'Not saved: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad');
|
|
725
|
+
return load(me, true);
|
|
726
|
+
}
|
|
727
|
+
async function setMin(me, i, v) {
|
|
728
|
+
const a = me.model && me.model.prep.agenda[i]; if (!a || me.savingMin) return;
|
|
729
|
+
const min = Math.max(0, Math.min(240, Math.round(Number(v) || 0)));
|
|
730
|
+
if (min === a.min && a.set) return repaint(me);
|
|
731
|
+
me.savingMin = true;
|
|
732
|
+
const r = await pmPost('/api/viewer-meeting/agenda', { key: a.key, topic: a.text, min });
|
|
733
|
+
me.savingMin = false;
|
|
734
|
+
if (!r || !r.ok) say(me, 'The minutes were not saved: ' + ((r && r.error) || 'no answer'), 'bad');
|
|
735
|
+
return load(me, true);
|
|
736
|
+
}
|
|
737
|
+
/** Change topic (Focus): the topic now, for this meeting (POST /api/meeting-focus/topic). */
|
|
738
|
+
async function changeTopic(me, tp) {
|
|
739
|
+
me.ui.pop = '';
|
|
740
|
+
const ev = me.row ? me.row.id : me.n && me.n.meeting && me.n.meeting.event_id;
|
|
741
|
+
if (!tp || !ev) { say(me, 'The topic can be changed on a calendar meeting only.', 'bad'); return; }
|
|
742
|
+
const r = await pmPost('/api/meeting-focus/topic', { event: ev, date: me.fq ? me.fq.date : '', action: 'set', topic: tp.text });
|
|
743
|
+
say(me, r && r.ok ? 'The topic now is “' + clip(tp.text, 60) + '”.' : 'Not changed: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad');
|
|
744
|
+
return load(me, true);
|
|
745
|
+
}
|
|
746
|
+
/** Make task: the step goes into the first stage of the note's initiative (POST /api/plan-items); the made line has Undo, which withdraws it. */
|
|
747
|
+
async function makeTask(me, i, quiet) {
|
|
748
|
+
const S = me.D.S, step = S && S.actions[i]; if (!step) return { ok: false };
|
|
749
|
+
const r = await taskOf(me, step);
|
|
750
|
+
if (!r.ok) { if (!quiet) say(me, 'The task was not made: ' + r.error, 'bad'); return r; }
|
|
751
|
+
me.ui.made[i] = { html: 'Task made · added to <b>' + esc(r.ini) + '</b>, under ' + esc(r.stage), undo: r.undo };
|
|
752
|
+
await load(me, true);
|
|
753
|
+
return r;
|
|
754
|
+
}
|
|
755
|
+
async function taskOf(me, step) {
|
|
756
|
+
const S = me.D.S;
|
|
757
|
+
if (!S || !S.initiative) return { ok: false, error: 'link the meeting to an initiative first' };
|
|
758
|
+
const lay = await pmGet('/api/plan-items?' + q({ ladder: 0, ws: S.initiative.ws, id: S.initiative.id }));
|
|
759
|
+
const stage = lay && lay.ok && (lay.stages || [])[0];
|
|
760
|
+
const plan = taskEvent(S, step, stage);
|
|
761
|
+
if (!plan.ok) return { ok: false, error: plan.reason };
|
|
762
|
+
const r = await pmPost('/api/plan-items', { ws: plan.ws, events: [plan.event] });
|
|
763
|
+
if (!r || r.ok !== true) return { ok: false, error: (r && r.error) || 'no answer' };
|
|
764
|
+
const item = r.written && r.written[0] && r.written[0].item;
|
|
765
|
+
return { ok: true, ini: S.initiative.name, stage: stage.label || stage.id, undo: item ? async () => {
|
|
766
|
+
const u = await pmPost('/api/plan-items', { ws: plan.ws, events: [{ ev: 'withdrawn', item, initiative: S.initiative.id }] });
|
|
767
|
+
say(me, u && u.ok ? 'The task is withdrawn.' : 'The task was not withdrawn: ' + ((u && u.error) || 'no answer'), u && u.ok ? '' : 'bad'); load(me, true);
|
|
768
|
+
} : null };
|
|
769
|
+
}
|
|
770
|
+
/** A work-item: the step becomes a ticket Drafted in PMOS on the note's initiative (POST /api/viewer-meeting/work-item). */
|
|
771
|
+
async function makeWorkItem(me, i) {
|
|
772
|
+
const S = me.D.S, step = S && S.actions[i]; if (!step) return;
|
|
773
|
+
const r = await workItem(me.n.id, step);
|
|
774
|
+
if (!r.ok) return say(me, 'The work-item was not made: ' + r.error, 'bad');
|
|
775
|
+
await load(me, true);
|
|
776
|
+
say(me, r.created ? r.ticket + ' is drafted in PMOS. It shows on the Board under Drafted in PMOS and goes to Jira only through the Commit gate.' : 'This step is already ' + r.ticket + '.');
|
|
777
|
+
}
|
|
778
|
+
export async function workItem(noteId, step) {
|
|
779
|
+
const r = await pmPost('/api/viewer-meeting/work-item', { note: noteId, step: { text: step.text, owner: step.owner || '', due: step.due || '' } });
|
|
780
|
+
return r && r.ok ? { ok: true, ticket: r.ticket && r.ticket.id ? r.ticket.id : r.ticket, created: !!r.created } : { ok: false, error: (r && r.error) || 'no answer' };
|
|
781
|
+
}
|
|
782
|
+
/** New meeting: an untitled note, listened to at once, shown live. */
|
|
783
|
+
export async function newNote(ws) {
|
|
784
|
+
const C = rec();
|
|
785
|
+
const r = await C.fresh();
|
|
786
|
+
if (!r.ok) { if (MT) say(MT, r.error, 'bad'); else toast(r.error); return r; }
|
|
787
|
+
await openMeeting({ note: r.id }, { ws });
|
|
788
|
+
return r;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/* Replay's bulk bar: Make tasks (the To do points), Confirm and Not right (POST /api/meeting-points) */
|
|
792
|
+
async function bulk(me, k, ids) {
|
|
793
|
+
const V = me.model.notes.replay; if (!V || !ids.length) return;
|
|
794
|
+
if (k === 'task') {
|
|
795
|
+
const S = me.D.S, pts = V.points.filter((p) => ids.includes(p.id) && p.kind === 'action');
|
|
796
|
+
if (!pts.length) return say(me, 'Only a To do point can become a task.', 'bad');
|
|
797
|
+
let made = 0, err = '';
|
|
798
|
+
for (const p of pts) {
|
|
799
|
+
const i = S ? S.actions.findIndex((x) => norm(x.text) === norm(p.text)) : -1;
|
|
800
|
+
const r = i >= 0 ? await makeTask(me, i, true) : await taskOf(me, { text: p.text, owner: p.owner, due: p.due });
|
|
801
|
+
if (r.ok) { made++; (me.ui.pmade = me.ui.pmade || {})[p.id] = true; } else err = r.error;
|
|
802
|
+
}
|
|
803
|
+
me.ui.sel = new Set(); me.ui.made = { ...me.ui.made };
|
|
804
|
+
return say(me, made ? plural(made, 'task') + ' made in ' + (S && S.initiative ? S.initiative.name : 'the initiative') + '.' + (err ? ' One was not: ' + err : '') : 'No task was made: ' + err, made ? '' : 'bad');
|
|
805
|
+
}
|
|
806
|
+
return verdict(me, ids, k, k === 'confirmed' ? plural(ids.length, 'point') + ' confirmed.' : plural(ids.length, 'point') + ' moved to Left out.', k === 'wrong');
|
|
807
|
+
}
|
|
808
|
+
async function verdict(me, ids, v, text, undo) {
|
|
809
|
+
const r = await pmPost('/api/meeting-points', { note: me.n.id, ids, verdict: v });
|
|
810
|
+
if (!r || !r.ok) return say(me, 'Not saved: ' + ((r && r.error) || 'no answer'), 'bad');
|
|
811
|
+
me.D.points = r.points || {}; me.ui.sel = new Set(); draw(me);
|
|
812
|
+
say(me, text, '', undo ? async () => verdict(me, ids, null, 'Put back.') : null);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/* the replay player */
|
|
816
|
+
function stopPlay(me) { if (me && me.play) { clearInterval(me.play.tm); if (me.play.aud) { try { me.play.aud.pause(); } catch { /* gone */ } } me.play.on = false; } }
|
|
817
|
+
function ensurePlay(me) {
|
|
818
|
+
const T = me.model && me.model.notes.replay; if (!T) return null;
|
|
819
|
+
if (!me.play) { me.play = { pos: 0, on: false, aud: null, tm: null, last: 0 }; if (T.audio && T.audio.url) { me.play.aud = new Audio(T.audio.url); me.play.aud.preload = 'metadata'; me.play.aud.addEventListener('error', () => { if (me.play) me.play.aud = null; }); } }
|
|
820
|
+
return me.play;
|
|
821
|
+
}
|
|
822
|
+
function playUi(me) {
|
|
823
|
+
const P = me.play, T = me.model.notes.replay; me.ui.pos = P.pos; me.ui.playing = P.on;
|
|
824
|
+
const b = bodyEl(); if (!b) return;
|
|
825
|
+
const sh = T.shotAt(P.pos);
|
|
826
|
+
if (sh !== me.shotNow || P.on !== me.wasOn) { me.shotNow = sh; me.wasOn = P.on; return repaint(me); } // a new capture or Play/Pause: draw the tab again
|
|
827
|
+
b.querySelectorAll('[data-clk="head"]').forEach((h) => h.setAttribute('x', Math.min(100, P.pos / T.len * 100).toFixed(2) + '%')); // an SVG attribute: where the replay is
|
|
828
|
+
b.querySelectorAll('[data-clk="pos"]').forEach((p) => { p.textContent = mmss(P.pos); });
|
|
829
|
+
b.querySelectorAll('.vzp-top').forEach((x) => { const on = T.stretchAt(P.pos) && +x.dataset.t === T.stretchAt(P.pos).from; if (on) x.setAttribute('aria-current', 'true'); else x.removeAttribute('aria-current'); });
|
|
830
|
+
}
|
|
831
|
+
function togglePlay(me) {
|
|
832
|
+
const P = ensurePlay(me); if (!P) return;
|
|
833
|
+
const T = me.model.notes.replay;
|
|
834
|
+
if (P.on) { stopPlay(me); playUi(me); return; }
|
|
835
|
+
if (P.pos >= T.len - 200) P.pos = 0;
|
|
836
|
+
P.on = true; P.last = performance.now();
|
|
837
|
+
if (P.aud) { try { P.aud.currentTime = P.pos / 1000; P.aud.playbackRate = me.ui.speed || 1; } catch { /* not loaded */ } const pr = P.aud.play(); if (pr && pr.catch) pr.catch(() => { P.aud = null; P.last = performance.now(); }); }
|
|
838
|
+
P.tm = setInterval(() => {
|
|
839
|
+
if (MT !== me) { stopPlay(me); return; }
|
|
840
|
+
const now = performance.now();
|
|
841
|
+
if (P.aud && !P.aud.paused) P.pos = P.aud.currentTime * 1000; else P.pos += (now - P.last) * (me.ui.speed || 1); P.last = now;
|
|
842
|
+
if (P.pos >= T.len) { P.pos = T.len; stopPlay(me); }
|
|
843
|
+
playUi(me);
|
|
844
|
+
}, 250);
|
|
845
|
+
playUi(me);
|
|
846
|
+
}
|
|
847
|
+
function seek(me, ms, play) {
|
|
848
|
+
const P = ensurePlay(me); if (!P) return;
|
|
849
|
+
P.pos = Math.max(0, Math.min(me.model.notes.replay.len, ms));
|
|
850
|
+
if (P.aud) { try { P.aud.currentTime = P.pos / 1000; } catch { /* not loaded */ } }
|
|
851
|
+
if (play && !P.on) togglePlay(me); else playUi(me);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/* Present (MtFocus → MtPresent): a PMOS deck in the presenter view */
|
|
855
|
+
async function presentIt(me, x) {
|
|
856
|
+
if (!x || !x.deck || !x.ref) return;
|
|
857
|
+
const M = await import('./premium-mtg-present.js');
|
|
858
|
+
const meetingNow = () => {
|
|
859
|
+
const m = me.model, Fo = m ? m.focus : null, cur = Fo ? Fo.agenda.findIndex((a) => a.k === 'now' || a.k === 'late') : -1, a = cur >= 0 ? Fo.agenda[cur] : null;
|
|
860
|
+
const F = me.D && me.D.F, qs = F && F.captured && Array.isArray(F.captured.questions) ? F.captured.questions.filter((z) => z && z.text && !z.answered) : [];
|
|
861
|
+
const last = qs[qs.length - 1];
|
|
862
|
+
return { title: m ? m.title : '', rec: !!(m && m.liveK === 'rec'), at: m && m.at, end: m && m.end, topic: a ? { n: a.n, of: Fo.agenda.length, text: a.text, left: a.plan ? (a.plan - a.used) * 60000 : null } : null, question: last ? last.text : '', asker: last ? last.who || last.by || '' : '' };
|
|
863
|
+
};
|
|
864
|
+
const r = await M.presentDeck({ ws: x.ws || me.ws, path: x.ref, title: x.title, meeting: meetingNow(), getMeeting: meetingNow,
|
|
865
|
+
onKeep: async (text) => { if (!me.n || !text) return { ok: false, error: 'the meeting has no note yet' }; const body = String(me.n.body || '').replace(/\s+$/, '') + (me.n.body ? '\n' : '') + 'Question: ' + text; const s = await pmPost('/api/notes/save', { id: me.n.id, body }); if (s && s.ok) me.n.body = body; return s; } });
|
|
866
|
+
if (r && r.ok === false) say(me, r.error, 'bad');
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/* Add material (MtMaterial): a popover under the Material list */
|
|
870
|
+
const matAt = (me, i) => { const tab = me.model && (me.ui.tab && me.model.focus && me.ui.tab in { focus: 1 } ? me.model.focus.material : me.model.prep.material); return tab ? tab[i] : null; };
|
|
871
|
+
async function openMat(me) {
|
|
872
|
+
const row = me.row;
|
|
873
|
+
me.ui.pop = 'mat'; me.matShown = false; me.mat = { row, sug: null, found: null, q: '', topics: [], err: '' };
|
|
874
|
+
repaint(me);
|
|
875
|
+
if (!row) return;
|
|
876
|
+
const [s, t] = await Promise.all([
|
|
877
|
+
pmGet('/api/meeting-material/suggest?' + q({ ws: me.ws, initiative: row.level && row.level.kind === 'initiative' ? row.level.id : '' })),
|
|
878
|
+
pmGet('/api/meeting-material?' + q({ event: row.id, title: row.title, series: row.series, date: row.day, topics: 1, ws: me.ws })),
|
|
879
|
+
]);
|
|
880
|
+
if (MT !== me || me.ui.pop !== 'mat') return;
|
|
881
|
+
me.mat.sug = s && s.ok ? s.suggested || [] : []; me.matShown = false;
|
|
882
|
+
me.mat.topics = t && t.ok && Array.isArray(t.topics) ? t.topics.map((x) => x.text).filter(Boolean) : [];
|
|
883
|
+
const b = bodyEl(), l = b && b.querySelector('.vzm-pop [data-pl="list"]');
|
|
884
|
+
if (b && b.contains(document.activeElement) && l) { l.innerHTML = matListHtml(me.mat); } else repaint(me);
|
|
885
|
+
}
|
|
886
|
+
async function findMat(me, v) {
|
|
887
|
+
const P = me.mat; if (!P || !P.row) return;
|
|
888
|
+
P.q = v.length >= 2 ? v : ''; P.found = null;
|
|
889
|
+
const l = () => bodyEl() && bodyEl().querySelector('.vzm-pop [data-pl="list"]');
|
|
890
|
+
if (l()) l().innerHTML = matListHtml(P);
|
|
891
|
+
if (!P.q) return;
|
|
892
|
+
const r = await pmGet('/api/meeting-material/suggest?' + q({ ws: me.ws, q: P.q }));
|
|
893
|
+
if (MT !== me || P !== me.mat || P.q !== v) return;
|
|
894
|
+
P.found = r && r.ok ? r.found || [] : [];
|
|
895
|
+
if (l()) l().innerHTML = matListHtml(P);
|
|
896
|
+
}
|
|
897
|
+
const matErr = (me, text) => { if (me.mat) me.mat.err = text; const e = bodyEl() && bodyEl().querySelector('.vzm-pop [data-pl="err"]'); if (e) { e.textContent = text; e.hidden = !text; } };
|
|
898
|
+
const matEv = (row) => ({ id: row.id || undefined, title: row.title, ...(row.series ? { series: row.series } : {}) });
|
|
899
|
+
async function addMat(me, item) {
|
|
900
|
+
const row = me.row; if (!row) return;
|
|
901
|
+
const b = bodyEl(), ser = b && b.querySelector('[data-a="matser"]'), tsel = b && b.querySelector('[data-a="mattopic"]');
|
|
902
|
+
const scope = ser && ser.checked ? 'series' : 'meeting', topic = tsel ? tsel.value : '';
|
|
903
|
+
matErr(me, '');
|
|
904
|
+
const r = await pmPost('/api/meeting-material', { op: 'add', event: matEv(row), scope, item, ...(topic ? { topic } : {}) });
|
|
905
|
+
if (!r || !r.ok) return matErr(me, 'Not added: ' + ((r && r.error) || 'no answer'));
|
|
906
|
+
me.ui.pop = ''; say(me, 'Added “' + clip(item.title, 60) + '”' + (scope === 'series' ? ' for every meeting of the series.' : ' for this meeting.')); load(me, true);
|
|
907
|
+
}
|
|
908
|
+
function addLink(me, v) {
|
|
909
|
+
let u = null;
|
|
910
|
+
try { u = new URL(String(v).trim()); } catch { /* not an address */ }
|
|
911
|
+
if (!u || u.protocol !== 'https:') return matErr(me, 'Only an https link can be added.');
|
|
912
|
+
return addMat(me, { url: u.href, title: u.hostname });
|
|
913
|
+
}
|
|
914
|
+
async function removeMat(me, x) {
|
|
915
|
+
const row = me.row; if (!x) return;
|
|
916
|
+
if (!row) return say(me, 'Material is kept per calendar meeting. This note has no calendar event.', 'bad');
|
|
917
|
+
const scope = x.scope || 'meeting', item = x.url && !x.ref ? { url: x.url, title: x.title } : { kind: x.mkind || x.kind, ref: x.ref, title: x.title, ...(x.ws ? { ws: x.ws } : {}) };
|
|
918
|
+
const r = await pmPost('/api/meeting-material', { op: 'remove', event: matEv(row), scope, item });
|
|
919
|
+
if (!r || !r.ok) return say(me, 'Not removed: ' + ((r && r.error) || 'no answer'), 'bad');
|
|
920
|
+
await load(me, true);
|
|
921
|
+
say(me, 'Removed “' + clip(x.title, 60) + '”.', '', async () => { const u = await pmPost('/api/meeting-material', { op: 'add', event: matEv(row), scope, item, ...(x.topic ? { topic: x.topic } : {}) }); say(me, u && u.ok ? 'It is back.' : 'Not added back: ' + ((u && u.error) || 'no answer'), u && u.ok ? '' : 'bad'); load(me, true); });
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/* What it is about (MtAfter): the initiative, the product, the whole portfolio, or none. A calendar meeting is linked for its whole series
|
|
925
|
+
* (POST /api/calendar-links); a note with no calendar event is linked itself (POST /api/notes/link). */
|
|
926
|
+
async function openAbout(me) {
|
|
927
|
+
me.ui.pop = 'about'; me.about = null; me.aboutQ = ''; repaint(me);
|
|
928
|
+
const S = me.D && me.D.S, text = S ? [S.overview, ...S.actions.map((a) => a.text), ...S.decisions.map((d) => d.text), ...S.questions.map((x) => x.text)].join(' ') : '';
|
|
929
|
+
if (me.row) {
|
|
930
|
+
const W = me.W || (me.row.day ? await weekOf(me.row.day, me.ws) : null); me.W = W;
|
|
931
|
+
const lv = me.row.level, cur = lv ? (lv.kind === 'portfolio' ? 'portfolio' : lv.kind === 'board' ? 'board|' + lv.ws + '|' + lv.id : 'initiative|' + lv.id) : '';
|
|
932
|
+
me.about = aboutOptions(me.row, W, null, text, cur);
|
|
933
|
+
} else if (me.n) {
|
|
934
|
+
const r = await pmGet('/api/boards'), list = r && r.ok && Array.isArray(r.boards) ? r.boards.filter((b) => b && b.id && !b.error) : [];
|
|
935
|
+
await Promise.all(list.map(async (b) => { const x = await pmGet('/api/boards/backlog?' + q({ ws: b.ws, board: b.id, limit: 100 })); b.inis = x && x.ok && Array.isArray(x.rows) ? x.rows : []; }));
|
|
936
|
+
me.choices = aboutChoices(list);
|
|
937
|
+
me.about = aboutOptions(null, null, me.choices, text, aboutNow(me.n));
|
|
938
|
+
} else { me.ui.pop = ''; return say(me, 'There is nothing to link yet.', 'bad'); }
|
|
939
|
+
if (MT === me && me.ui.pop === 'about') { repaint(me); const i = bodyEl() && bodyEl().querySelector('[data-a="aboutq"]'); if (i) i.focus(); }
|
|
940
|
+
}
|
|
941
|
+
async function saveAbout(me, v) {
|
|
942
|
+
if (!v) return;
|
|
943
|
+
let r;
|
|
944
|
+
if (me.row) { const W = me.W || {}; const body = linkBody(me.row, v, W.boards || []); if (!body) return; r = await pmPost('/api/calendar-links', body); WEEKS = new Map(); me.row = null; me.R.row = null; }
|
|
945
|
+
else { const body = aboutBody(me.n.id, v, me.choices); if (!body) return; r = await pmPost('/api/notes/link', body); }
|
|
946
|
+
me.ui.pop = '';
|
|
947
|
+
say(me, r && r.ok ? (v === 'none' ? 'Left out of an initiative.' : 'Linked.') : 'Not saved: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad');
|
|
948
|
+
return load(me);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
if (typeof window !== 'undefined') {
|
|
952
|
+
document.addEventListener('click', (e) => {
|
|
953
|
+
if (!MT || !e.target.isConnected) return; // the press repainted the card: its own handler already decided
|
|
954
|
+
if (MT.ui.more && !e.target.closest('.vz-menu,[data-a="more"]')) { MT.ui.more = false; repaint(MT); }
|
|
955
|
+
if (MT.ui.pop && !e.target.closest('#czViewer')) { MT.ui.pop = ''; repaint(MT); }
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
export const _test = { refOf, linesOf, factsOf, gapsOf };
|