@vitrinka/web 0.7.1 → 0.8.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/CHANGELOG.md +128 -0
- package/README.md +117 -19
- package/build/hud.iife.js +11 -11
- package/build/recorder/config.d.ts +6 -2
- package/build/recorder/hud/Hud.d.ts +3 -1
- package/build/recorder/hud/Hud.js +2 -2
- package/build/recorder/hud/Menu.d.ts +7 -1
- package/build/recorder/hud/Menu.js +2 -2
- package/build/recorder/hud/host.d.ts +13 -0
- package/build/recorder/hud/host.js +96 -1
- package/build/recorder/hud/icons.d.ts +2 -0
- package/build/recorder/hud/icons.js +4 -0
- package/build/recorder/hud/mount.d.ts +2 -0
- package/build/recorder/hud/mount.js +1 -0
- package/build/recorder/index.d.ts +6 -0
- package/build/recorder/index.js +3 -0
- package/build/recorder/lead.js +12 -2
- package/build/recorder/link.js +1 -1
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/build/report/attachments.d.ts +56 -0
- package/build/report/attachments.js +91 -0
- package/build/report/drag.d.ts +18 -0
- package/build/report/drag.js +34 -0
- package/build/report/element.d.ts +11 -2
- package/build/report/element.js +106 -15
- package/build/report/engine.d.ts +5 -1
- package/build/report/engine.js +7 -1
- package/build/report/face.d.ts +23 -0
- package/build/report/face.js +92 -0
- package/build/report/i18n.d.ts +75 -3
- package/build/report/i18n.js +125 -6
- package/build/report/place.d.ts +26 -0
- package/build/report/place.js +33 -0
- package/build/report/reader.d.ts +42 -0
- package/build/report/reader.js +39 -0
- package/build/report/recorder-face.js +6 -2
- package/build/report/sent.d.ts +16 -0
- package/build/report/sent.js +39 -0
- package/build/report/settings.d.ts +32 -0
- package/build/report/settings.js +47 -0
- package/build/report/styles.d.ts +1 -1
- package/build/report/styles.js +216 -52
- package/build/report/widget.d.ts +109 -3
- package/build/report/widget.js +1063 -99
- package/build/report/wire.d.ts +20 -9
- package/build/report/wire.js +44 -9
- package/build/report-widget.mjs +223 -59
- package/package.json +1 -1
package/build/report/widget.js
CHANGED
|
@@ -4,25 +4,48 @@
|
|
|
4
4
|
* - A large floating "Report a problem" button (hidden with `button: false`;
|
|
5
5
|
* the host then opens it from its own control, `open-selector`, or
|
|
6
6
|
* `open()`), and the reporter's own shortcut (keybind.ts).
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* - ONE card (vt-8020 D10 A), one fixed size from drafting through sending
|
|
8
|
+
* to thanks: the reporter's word for it (vt-8020 D11 chips), "What went wrong?",
|
|
9
|
+
* one numbered note line per mark, and Send — the capture frozen when the
|
|
10
|
+
* card opens (the buffer rolls on).
|
|
11
|
+
* - "Show us where" marks the frozen page under a top bar (vt-8020 D6 A): a segmented
|
|
12
|
+
* circle · box · arrow · hide, and Cancel, which leaves marking and drops
|
|
13
|
+
* this pass's marks (vt-8020 D12). The card stays on screen while marking, parked
|
|
14
|
+
* in the corner that covers none of the marks (place.ts). No element
|
|
15
|
+
* selector. Until the first mark exists a coach card rides beside the
|
|
16
|
+
* pointer with a tiny loop of the gesture and the words "click, hold and
|
|
17
|
+
* move".
|
|
18
|
+
* - The reporter's files (vt-8020 D9, attachments.ts): 📎 in the card's foot,
|
|
19
|
+
* paste or drop onto the card; chips above the foot, refused at once past
|
|
20
|
+
* the project's caps, sent on the wire's attachment leg.
|
|
21
|
+
* - The button drags to any corner, or moves with Alt+arrows (drag.ts); the
|
|
22
|
+
* card rests beside it. Settings adds the size (S · M · L, settings.ts)
|
|
23
|
+
* and the technical details a support conversation asks for.
|
|
13
24
|
* - Rendered once into the shared HUD host's shadow root (top layer,
|
|
14
25
|
* shielded, blocked from rrweb); `paint()` rewrites text and state in place,
|
|
15
26
|
* so a locale switch keeps the typed draft, the marks and their notes.
|
|
16
27
|
* Drafts live in memory only.
|
|
17
28
|
*/
|
|
29
|
+
import { LinkExpired, linkWorkspace, pollLink, startLink } from '@vitrinka/link';
|
|
30
|
+
import { api, VitrinkaApiError } from '../recorder/api';
|
|
18
31
|
import { redactUrl } from '../recorder/capture/redact';
|
|
32
|
+
import { clearLink, defaultLinkLabel, readLink, storeLink } from '../recorder/config';
|
|
33
|
+
import { readRecents } from '../recorder/recents';
|
|
19
34
|
import { createHudHost, createSheetHost, insideHud, sheetTarget } from '../recorder/hud/host';
|
|
20
35
|
import { listen } from '../recorder/hud/listen';
|
|
36
|
+
import { RECORDER_VERSION } from '../recorder/version';
|
|
37
|
+
import { admit, DEFAULT_ATTACHMENT_CAPS, formatBytes, pastedName, typesLabel } from './attachments';
|
|
38
|
+
import { cornerToward, DRAG_THRESHOLD, nearestCorner, readDock, saveDock } from './drag';
|
|
39
|
+
import { memberLinked, rememberDisplayMode } from './face';
|
|
21
40
|
import { acquireEngine, releaseEngine } from './engine';
|
|
22
|
-
import { browserLocale, parseLocale, strings } from './i18n';
|
|
41
|
+
import { browserLocale, parseLocale, REPORT_KINDS, strings } from './i18n';
|
|
23
42
|
import { normalizeIdentity, onSharedIdentity, sharedIdentity } from './identity';
|
|
24
43
|
import { keybindLabel, loadKeybind, matchesKeybind, readKeybindPress, saveKeybind, watchKeybind } from './keybind';
|
|
25
44
|
import { arrowEnds, arrowHead, isMark, rectBetween, renumber, toWire, } from './markers';
|
|
45
|
+
import { cornerRect, pickCorner } from './place';
|
|
46
|
+
import { listMine, openSession, sessionLive } from './reader';
|
|
47
|
+
import { noteSent, readSent } from './sent';
|
|
48
|
+
import { readSize, SIZE_KEY, SIZE_SCALE, SIZES, techDetails, writePref } from './settings';
|
|
26
49
|
import { REPORT_CSS } from './styles';
|
|
27
50
|
import { ReportJob } from './wire';
|
|
28
51
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
@@ -32,6 +55,11 @@ const TOOLS = ['circle', 'box', 'arrow', 'hide'];
|
|
|
32
55
|
/** A keyboard mark starts as this, centred; arrows move it 10 px, Shift+arrows resize it. */
|
|
33
56
|
const KB_DRAFT = { w: 160, h: 80 };
|
|
34
57
|
const MIN_KB_SIZE = 16;
|
|
58
|
+
/** The one card's size (vt-8020 D10: it never changes between states) and the clear band the marking bar keeps at the top. */
|
|
59
|
+
const CARD = { w: 380, h: 460 };
|
|
60
|
+
const BAR_CLEAR = 72;
|
|
61
|
+
/** The gap a parked card keeps on a side it did not rest against. */
|
|
62
|
+
const PARK_EDGE = 16;
|
|
35
63
|
const KB_STEPS = {
|
|
36
64
|
ArrowLeft: [-10, 0],
|
|
37
65
|
ArrowRight: [10, 0],
|
|
@@ -40,7 +68,19 @@ const KB_STEPS = {
|
|
|
40
68
|
};
|
|
41
69
|
const ICON = {
|
|
42
70
|
close: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',
|
|
43
|
-
|
|
71
|
+
// A toothed cog: the sun-like ring of rays read as brightness, not settings.
|
|
72
|
+
gear: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6.9 1.5h2.2l.35 1.75a5 5 0 011.3.75l1.7-.57 1.1 1.9-1.35 1.18a5 5 0 010 1.5l1.35 1.18-1.1 1.9-1.7-.57a5 5 0 01-1.3.75L9.1 14.5H6.9l-.35-1.75a5 5 0 01-1.3-.75l-1.7.57-1.1-1.9 1.35-1.18a5 5 0 010-1.5L2.45 6.81l1.1-1.9 1.7.57a5 5 0 011.3-.75z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/><circle cx="8" cy="8" r="2" fill="none" stroke="currentColor" stroke-width="1.3"/></svg>',
|
|
73
|
+
circle: '<svg viewBox="0 0 16 16" aria-hidden="true"><ellipse cx="8" cy="8" rx="6" ry="4.6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',
|
|
74
|
+
box: '<svg viewBox="0 0 16 16" aria-hidden="true"><rect x="2.2" y="3.4" width="11.6" height="9.2" rx="1.8" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',
|
|
75
|
+
arrow: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 13L12.5 3.5M7 3.5h5.5V9" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
76
|
+
hide: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 8s2.3-4 6-4 6 4 6 4-2.3 4-6 4-6-4-6-4z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/><path d="M3 13L13 3" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',
|
|
77
|
+
dots: '<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="3.5" cy="8" r="1.3" fill="currentColor"/><circle cx="8" cy="8" r="1.3" fill="currentColor"/><circle cx="12.5" cy="8" r="1.3" fill="currentColor"/></svg>',
|
|
78
|
+
left: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3.5L5.5 8l4.5 4.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
79
|
+
ext: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9 3h4v4M13 3L7.5 8.5M11 9.5V13H3V5h3.5" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
80
|
+
list: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5.5 4h8M5.5 8h8M5.5 12h8M2.5 4h.01M2.5 8h.01M2.5 12h.01" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',
|
|
81
|
+
clock: '<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M8 4.8V8l2.2 1.6" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',
|
|
82
|
+
rec: '<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.4"/><circle cx="8" cy="8" r="2.8" fill="currentColor"/></svg>',
|
|
83
|
+
link: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M7 9a3 3 0 004.2 0l2-2a3 3 0 00-4.2-4.2l-.8.8M9 7a3 3 0 00-4.2 0l-2 2a3 3 0 004.2 4.2l.8-.8" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>',
|
|
44
84
|
clip: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.5 4.5l-5 5a1.6 1.6 0 002.3 2.3l5.4-5.4a3 3 0 00-4.2-4.2L3.6 7.6a4.4 4.4 0 006.2 6.2l4-4" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>',
|
|
45
85
|
chevron: '<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
46
86
|
pen: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.8 2.7l2.5 2.5-7.6 7.6-3.1 0.6 0.6-3.1z" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/></svg>',
|
|
@@ -98,47 +138,137 @@ function deepActiveElement() {
|
|
|
98
138
|
return null;
|
|
99
139
|
return active instanceof HTMLElement || active instanceof SVGElement ? active : null;
|
|
100
140
|
}
|
|
141
|
+
/** Up to two initials of a name, or an email's first letter. */
|
|
142
|
+
function initials(label) {
|
|
143
|
+
const words = label.split('@')[0]?.split(/[\s._-]+/).filter(Boolean) ?? [];
|
|
144
|
+
return words.slice(0, 2).map((w) => w[0]?.toUpperCase() ?? '').join('') || '?';
|
|
145
|
+
}
|
|
146
|
+
/** A menu row's text: the span after its icon. */
|
|
147
|
+
function setLabel(el, text) {
|
|
148
|
+
const span = el.querySelector('span');
|
|
149
|
+
if (span)
|
|
150
|
+
span.textContent = text;
|
|
151
|
+
}
|
|
152
|
+
/** A segmented control's sliding indicator under its picked segment (the marking bar's shapes, the settings' sizes); unmeasurable while hidden. */
|
|
153
|
+
function placeIndicator(seg, ind, btn) {
|
|
154
|
+
if (!btn || !btn.offsetWidth)
|
|
155
|
+
return;
|
|
156
|
+
ind.style.width = `${btn.offsetWidth}px`;
|
|
157
|
+
ind.style.transform = `translateX(${btn.offsetLeft}px)`;
|
|
158
|
+
seg.classList.add('measured');
|
|
159
|
+
}
|
|
160
|
+
/** A text field has the focus — its own editing keys (⌘Z included) are its. */
|
|
161
|
+
function typing() {
|
|
162
|
+
const el = deepActiveElement();
|
|
163
|
+
return el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || (el instanceof HTMLElement && el.isContentEditable);
|
|
164
|
+
}
|
|
101
165
|
/** The widget's DOM, built once into the HUD host's shadow mount. */
|
|
102
166
|
function buildDom(mount) {
|
|
103
167
|
const fabLabel = h('span');
|
|
104
168
|
const fabKbd = h('kbd');
|
|
105
169
|
const fab = h('button', { class: 'fab', type: 'button', part: 'button', 'aria-haspopup': 'dialog' }, fabLabel, fabKbd);
|
|
106
170
|
const title = h('h2', { id: 'vr-title' });
|
|
107
|
-
|
|
171
|
+
// Who you are, at a glance (vt-8020 D5 A): the chip opens the account popover, ⋯ the menu.
|
|
172
|
+
const whoAv = h('span', { class: 'av', 'aria-hidden': 'true' });
|
|
173
|
+
const whoName = h('span', { class: 'who-name' });
|
|
174
|
+
const whoBtn = h('button', { class: 'who', type: 'button', 'aria-haspopup': 'dialog', 'aria-expanded': 'false' }, whoAv, whoName);
|
|
175
|
+
const more = h('button', { class: 'icon', type: 'button', 'aria-haspopup': 'menu', 'aria-expanded': 'false' }, icon(ICON.dots));
|
|
108
176
|
const closeBtn = h('button', { class: 'icon', type: 'button' }, icon(ICON.close));
|
|
109
|
-
const head = h('header', { class: 'head' }, title,
|
|
177
|
+
const head = h('header', { class: 'head' }, title, whoBtn, more, closeBtn);
|
|
178
|
+
const accName = h('strong');
|
|
179
|
+
const accMail = h('span', { class: 'acc-mail' });
|
|
180
|
+
const accVia = h('p', { class: 'acc-via' });
|
|
181
|
+
const accLinked = h('p', { class: 'acc-linked' });
|
|
182
|
+
const accUnlink = h('button', { class: 'link', type: 'button' });
|
|
183
|
+
const accLink = h('button', { class: 'pop-item', type: 'button' }, icon(ICON.link), h('span'));
|
|
184
|
+
const accPortal = h('a', { class: 'pop-item', target: '_blank', rel: 'noopener noreferrer' }, icon(ICON.ext), h('span'));
|
|
185
|
+
const accountPop = h('div', { class: 'pop acc', role: 'dialog' }, h('div', { class: 'acc-who' }, accName, accMail, accVia), h('div', { class: 'acc-member' }, accLinked, accUnlink), accLink, accPortal);
|
|
186
|
+
const menuItem = (glyph) => h('button', { class: 'pop-item', type: 'button', role: 'menuitem' }, icon(glyph), h('span'));
|
|
187
|
+
const mReports = menuItem(ICON.list);
|
|
188
|
+
const mRecents = menuItem(ICON.clock);
|
|
189
|
+
const mRecord = menuItem(ICON.rec);
|
|
190
|
+
const mSettings = menuItem(ICON.gear);
|
|
191
|
+
const mOpen = h('a', { class: 'pop-item', role: 'menuitem', target: '_blank', rel: 'noopener noreferrer' }, icon(ICON.ext), h('span'));
|
|
192
|
+
const morePop = h('div', { class: 'pop more', role: 'menu' }, mReports, mRecents, mRecord, mSettings, mOpen);
|
|
193
|
+
const kindsLabel = h('span', { class: 'sr', id: 'vr-kinds' });
|
|
194
|
+
const kindButtons = new Map();
|
|
195
|
+
for (const k of REPORT_KINDS)
|
|
196
|
+
kindButtons.set(k, h('button', { type: 'button', role: 'radio', 'aria-checked': 'false', 'data-kind': k }));
|
|
197
|
+
const kinds = h('div', { class: 'kinds', role: 'radiogroup', 'aria-labelledby': 'vr-kinds' }, kindsLabel, ...kindButtons.values());
|
|
110
198
|
const prompt = h('label', { class: 'prompt', for: 'vr-desc' });
|
|
111
199
|
const desc = h('textarea', { class: 'desc', id: 'vr-desc', rows: '3' });
|
|
200
|
+
const lines = h('ol', { class: 'lines' });
|
|
201
|
+
const linesEmpty = h('p', { class: 'ln-empty' });
|
|
112
202
|
const attachedText = h('span');
|
|
113
203
|
const discloseText = h('span');
|
|
114
204
|
const disclose = h('button', { class: 'link', type: 'button', 'aria-expanded': 'false', 'aria-controls': 'vr-included' }, discloseText, icon(ICON.chevron));
|
|
115
205
|
const attached = h('div', { class: 'attached' }, icon(ICON.clip), attachedText, h('span', { 'aria-hidden': 'true' }, '·'), disclose);
|
|
116
206
|
const included = h('ul', { class: 'included', id: 'vr-included' });
|
|
117
|
-
const markedChips = h('span', { class: 'chips' });
|
|
118
|
-
const markedText = h('span');
|
|
119
|
-
const marked = h('div', { class: 'marked' }, markedChips, markedText);
|
|
120
207
|
const notifyBox = h('input', { type: 'checkbox' });
|
|
121
208
|
const notifyText = h('span');
|
|
122
209
|
const notify = h('label', { class: 'notify' }, notifyBox, notifyText);
|
|
123
210
|
const error = h('p', { class: 'error', role: 'alert' });
|
|
124
211
|
const whereText = h('span');
|
|
125
|
-
const where = h('button', { class: 'where', type: 'button' }, icon(ICON.pen), whereText);
|
|
212
|
+
const where = h('button', { class: 'where', type: 'button', 'aria-pressed': 'false' }, icon(ICON.pen), whereText);
|
|
126
213
|
const send = h('button', { class: 'send', type: 'button' });
|
|
127
|
-
const describe = h('div', { class: 'pane describe' }, prompt, desc,
|
|
214
|
+
const describe = h('div', { class: 'pane describe' }, kinds, prompt, desc, h('div', { class: 'lines-wrap' }, lines, linesEmpty), attached, included, notify, error);
|
|
215
|
+
// The reporter's files (vt-8020 D9): 📎 opens the picker (paste and drop land on the card too);
|
|
216
|
+
// the chips sit in a tray above the foot that scrolls — the card never grows.
|
|
217
|
+
const attach = h('button', { class: 'icon', type: 'button' }, icon(ICON.clip));
|
|
218
|
+
const fileInput = h('input', { type: 'file', multiple: '', tabindex: '-1', 'aria-hidden': 'true', hidden: '' });
|
|
219
|
+
const fileNote = h('p', { class: 'file-note', role: 'status' });
|
|
220
|
+
const files = h('ul', { class: 'files' });
|
|
221
|
+
const tray = h('div', { class: 'tray' }, fileNote, files);
|
|
222
|
+
// The bottom actions, the chat-input foot of the board's composer: attachments, `where`, Send.
|
|
223
|
+
const foot = h('div', { class: 'foot' }, attach, fileInput, where, send);
|
|
128
224
|
const bindLabel = h('span', { class: 'label', id: 'vr-bind-label' });
|
|
129
225
|
const bindBtn = h('button', { class: 'bind', type: 'button', 'aria-pressed': 'false', 'aria-describedby': 'vr-bind-label' });
|
|
130
226
|
const unbind = h('button', { class: 'link', type: 'button' });
|
|
131
227
|
const bindHint = h('p', { class: 'hint' });
|
|
132
228
|
const bindReason = h('p', { class: 'reason', role: 'status' });
|
|
133
229
|
const back = h('button', { class: 'link', type: 'button' });
|
|
134
|
-
|
|
230
|
+
// Size (vt-8020 D9): the marking bar's segmented control, its indicator sliding under the pick.
|
|
231
|
+
const sizeLabel = h('span', { class: 'label', id: 'vr-size-label' });
|
|
232
|
+
const sizeButtons = new Map();
|
|
233
|
+
for (const z of SIZES)
|
|
234
|
+
sizeButtons.set(z, h('button', { type: 'button', role: 'radio', 'aria-checked': 'false', 'data-size': z }));
|
|
235
|
+
const sizeInd = h('span', { class: 'seg-ind', 'aria-hidden': 'true' });
|
|
236
|
+
const sizeSeg = h('div', { class: 'seg', role: 'radiogroup', 'aria-labelledby': 'vr-size-label' }, sizeInd, ...sizeButtons.values());
|
|
237
|
+
// Technical details: read-only, for support conversations.
|
|
238
|
+
const techText = h('span');
|
|
239
|
+
const techBtn = h('button', { class: 'link', type: 'button', 'aria-expanded': 'false', 'aria-controls': 'vr-tech' }, techText, icon(ICON.chevron));
|
|
240
|
+
const tech = h('dl', { class: 'tech', id: 'vr-tech' });
|
|
241
|
+
const settings = h('div', { class: 'pane settings' }, h('div', { class: 'row' }, bindLabel, bindBtn), bindReason, bindHint, h('div', { class: 'row size-row' }, sizeLabel, sizeSeg), h('div', { class: 'tech-wrap' }, techBtn, tech), h('div', { class: 'settings-foot' }, back, unbind));
|
|
135
242
|
const sentTitle = h('h3');
|
|
136
243
|
const sentBody = h('p', { class: 'sent-body' });
|
|
137
244
|
const seeText = h('span');
|
|
138
245
|
const see = h('a', { class: 'see', target: '_blank', rel: 'noopener noreferrer' }, seeText);
|
|
139
246
|
const sentClose = h('button', { class: 'link', type: 'button' });
|
|
140
247
|
const sent = h('div', { class: 'pane sent', role: 'status' }, h('div', { class: 'sent-head' }, icon(ICON.check), sentTitle), sentBody, h('div', { class: 'sent-actions' }, see, sentClose));
|
|
141
|
-
|
|
248
|
+
// A list opens in the card body with ← back (vt-8020 D5); the card keeps its size.
|
|
249
|
+
const backRow = () => h('button', { class: 'back', type: 'button' }, icon(ICON.left), h('span'));
|
|
250
|
+
const repBack = backRow();
|
|
251
|
+
const repStatus = h('p', { class: 'list-status' });
|
|
252
|
+
const repRows = h('ul', { class: 'rows' });
|
|
253
|
+
const repLocal = h('p', { class: 'list-note' });
|
|
254
|
+
const repPortal = h('a', { class: 'link', target: '_blank', rel: 'noopener noreferrer' });
|
|
255
|
+
const reports = h('div', { class: 'pane list' }, repBack, repStatus, repRows, repLocal, repPortal);
|
|
256
|
+
const recBack = backRow();
|
|
257
|
+
const recStatus = h('p', { class: 'list-status' });
|
|
258
|
+
const recRows = h('ul', { class: 'rows' });
|
|
259
|
+
const recents = h('div', { class: 'pane list' }, recBack, recStatus, recRows);
|
|
260
|
+
const linkBack = backRow();
|
|
261
|
+
const linkLabel = h('p', { class: 'list-note' });
|
|
262
|
+
const linkCode = h('div', { class: 'code' });
|
|
263
|
+
const linkOpenText = h('span');
|
|
264
|
+
const linkOpen = h('a', { class: 'see', target: '_blank', rel: 'noopener noreferrer' }, linkOpenText);
|
|
265
|
+
const linkQr = h('img', { class: 'qr', alt: '' });
|
|
266
|
+
const linkHint = h('p', { class: 'hint' });
|
|
267
|
+
const linkWait = h('p', { class: 'list-status', role: 'status' });
|
|
268
|
+
const linkRetry = h('button', { class: 'link', type: 'button' });
|
|
269
|
+
const linking = h('div', { class: 'pane linking' }, linkBack, linkLabel, linkCode, h('div', { class: 'link-go' }, linkOpen, linkQr), linkHint, linkWait, linkRetry);
|
|
270
|
+
const body = h('div', { class: 'body' }, describe, settings, sent, reports, recents, linking);
|
|
271
|
+
const card = h('section', { class: 'card', role: 'dialog', 'aria-modal': 'false', 'aria-labelledby': 'vr-title' }, head, accountPop, morePop, body, tray, foot);
|
|
142
272
|
const ink = svgEl('svg', { class: 'ink', 'aria-hidden': 'true' });
|
|
143
273
|
const defs = svgEl('defs', {});
|
|
144
274
|
const headMarker = svgEl('marker', { id: 'vr-head', viewBox: '0 0 10 10', refX: 7, refY: 5, markerWidth: 5, markerHeight: 5, orient: 'auto-start-reverse' });
|
|
@@ -153,28 +283,47 @@ function buildDom(mount) {
|
|
|
153
283
|
const coachKeys = h('p', { class: 'keys', id: 'vr-keys' });
|
|
154
284
|
const coach = h('div', { class: 'coach', role: 'status' });
|
|
155
285
|
coach.append(icon(coachArt(reducedMotion())), coachText, coachMore, coachKeys);
|
|
286
|
+
// The top bar (vt-8020 D6): one plain line, the shape as a segmented control whose indicator slides, Cancel.
|
|
156
287
|
const toolButtons = new Map();
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
288
|
+
const toolLabels = new Map();
|
|
289
|
+
for (const t of TOOLS) {
|
|
290
|
+
const label = h('span');
|
|
291
|
+
toolLabels.set(t, label);
|
|
292
|
+
toolButtons.set(t, h('button', { type: 'button', role: 'radio', 'aria-checked': 'false', 'data-tool': t }, icon(ICON[t]), label));
|
|
293
|
+
}
|
|
294
|
+
const segInd = h('span', { class: 'seg-ind', 'aria-hidden': 'true' });
|
|
295
|
+
const seg = h('div', { class: 'seg', role: 'radiogroup' }, segInd, ...toolButtons.values());
|
|
296
|
+
const barLead = h('span', { class: 'tb-lead' });
|
|
297
|
+
const cancel = h('button', { type: 'button', class: 'tb-quiet' });
|
|
298
|
+
const askText = h('span', { class: 'tb-ask' });
|
|
299
|
+
const discard = h('button', { type: 'button', class: 'tb-discard' });
|
|
300
|
+
const keep = h('button', { type: 'button', class: 'tb-quiet' });
|
|
301
|
+
const ask = h('span', { class: 'tb-confirm', role: 'group' }, askText, discard, keep);
|
|
302
|
+
const toolbar = h('div', { class: 'tb', role: 'toolbar' }, barLead, seg, h('span', { class: 'tb-sep', 'aria-hidden': 'true' }), cancel, ask);
|
|
162
303
|
// Focusable: from the keyboard, Enter places a mark the arrows then move (markKey).
|
|
163
304
|
const mark = h('div', { class: 'mark', tabindex: '0', role: 'application', 'aria-describedby': 'vr-keys' }, pins, coach, toolbar);
|
|
164
305
|
mark.prepend(ink);
|
|
165
|
-
|
|
306
|
+
// The card after the marking layer: it stays on top of it, usable, while the reporter marks.
|
|
307
|
+
const root = h('div', { class: 'vr' }, fab, mark, card);
|
|
166
308
|
const style = h('style');
|
|
167
309
|
style.textContent = REPORT_CSS;
|
|
168
310
|
// The sheet rides inside the root: the whole tree moves into an open dialog and back (followDialog).
|
|
169
311
|
root.prepend(style);
|
|
170
312
|
mount.append(root);
|
|
171
313
|
return {
|
|
172
|
-
root, fab, fabLabel, fabKbd, card, title,
|
|
173
|
-
|
|
314
|
+
root, fab, fabLabel, fabKbd, card, head, title, whoBtn, whoAv, whoName, more, closeBtn, body, foot,
|
|
315
|
+
accountPop, accName, accMail, accVia, accLinked, accUnlink, accLink, accPortal,
|
|
316
|
+
morePop, mReports, mRecents, mRecord, mSettings, mOpen,
|
|
317
|
+
reports, repBack, repStatus, repRows, repLocal, repPortal, recents, recBack, recStatus, recRows,
|
|
318
|
+
linking, linkBack, linkLabel, linkCode, linkOpen, linkOpenText, linkQr, linkHint, linkWait, linkRetry,
|
|
319
|
+
describe, kinds, kindsLabel, kindButtons, prompt, desc, lines, linesEmpty, attached, attachedText, disclose, discloseText, included,
|
|
174
320
|
notify, notifyBox, notifyText, error, where, whereText, send,
|
|
321
|
+
attach, fileInput, fileNote, files, tray,
|
|
175
322
|
settings, bindLabel, bindBtn, unbind, bindHint, bindReason, back,
|
|
323
|
+
sizeLabel, sizeButtons, sizeInd, sizeSeg, techText, techBtn, tech,
|
|
176
324
|
sent, sentTitle, sentBody, see, seeText, sentClose,
|
|
177
|
-
mark, ink, shapes, draft, pins, coach, coachText, coachMore, coachKeys,
|
|
325
|
+
mark, ink, shapes, draft, pins, coach, coachText, coachMore, coachKeys,
|
|
326
|
+
toolbar, barLead, seg, segInd, toolButtons, toolLabels, cancel, ask, askText, discard, keep,
|
|
178
327
|
};
|
|
179
328
|
}
|
|
180
329
|
export class ReportWidget {
|
|
@@ -200,6 +349,7 @@ export class ReportWidget {
|
|
|
200
349
|
frozen = null;
|
|
201
350
|
job = null;
|
|
202
351
|
sending = false;
|
|
352
|
+
/** Which leg a failed send stopped at: nothing reached the server, a file, or the replay. */
|
|
203
353
|
error = '';
|
|
204
354
|
result = null;
|
|
205
355
|
notify = false;
|
|
@@ -207,11 +357,45 @@ export class ReportWidget {
|
|
|
207
357
|
includedOpen = false;
|
|
208
358
|
recordingBind = false;
|
|
209
359
|
bindRefused = false;
|
|
210
|
-
/** The
|
|
211
|
-
|
|
360
|
+
/** The reporter's own word for it (vt-8020 D11); null until they pick one. */
|
|
361
|
+
kind = null;
|
|
362
|
+
/** The marks that existed when this marking pass began: Cancel keeps exactly these (vt-8020 D12). */
|
|
363
|
+
passKeys = new Set();
|
|
364
|
+
/** Cancel asked "Discard N marks?" and waits for the answer. */
|
|
365
|
+
confirming = false;
|
|
366
|
+
/** The corner the card is parked in once marking has moved it; null = its anchored place. */
|
|
367
|
+
parked = null;
|
|
368
|
+
/** The insets marking parks the card with, read where it rested when marking started (insetsAt). */
|
|
369
|
+
parkInsets = null;
|
|
370
|
+
/** The corner the button docks in (drag.ts); the card rests beside it and marking parks it from there. */
|
|
371
|
+
dock = readDock();
|
|
372
|
+
size = readSize();
|
|
373
|
+
techOpen = false;
|
|
374
|
+
/** A press on the button: it becomes a drag once it travels DRAG_THRESHOLD; `grab` is where the pointer holds it. */
|
|
375
|
+
fabDrag = null;
|
|
376
|
+
/** The click that ends a drag is the drop, not a press of the button. */
|
|
377
|
+
swallowClick = false;
|
|
378
|
+
/** The button's glide to its new corner, while it runs. */
|
|
379
|
+
glide = null;
|
|
380
|
+
/** The reporter's attachments (vt-8020 D9), in the order added, and the reason the last refused one got. */
|
|
381
|
+
files = [];
|
|
382
|
+
fileRefusal = null;
|
|
383
|
+
pastes = 0;
|
|
384
|
+
chips = new Map();
|
|
385
|
+
/** Swaps this widget for the recorder pill; set only for a linked member (setRecordSwitch). */
|
|
386
|
+
recordSwitch = null;
|
|
387
|
+
menu = null;
|
|
388
|
+
/** The reporter session the host's signed token was traded for (vt-8020 D4), and that token. */
|
|
389
|
+
session = null;
|
|
390
|
+
sessionToken = '';
|
|
391
|
+
/** The vitrinka member this browser is linked to (vt-8020 D3), read with the link's own token. */
|
|
392
|
+
member = null;
|
|
393
|
+
mine = { rows: [], state: 'ok' };
|
|
394
|
+
linkFlow = null;
|
|
212
395
|
drawing = null;
|
|
213
396
|
offs = [];
|
|
214
397
|
pins = new Map();
|
|
398
|
+
lines = new Map();
|
|
215
399
|
/** Per hide mark: the page nodes it covered when drawn (they are blanked in the capture). */
|
|
216
400
|
hideIds = new Map();
|
|
217
401
|
/** Native dialogs in the order they opened (seeded with those already open, in DOM order). */
|
|
@@ -302,6 +486,9 @@ export class ReportWidget {
|
|
|
302
486
|
this.frozen = this.engine?.freeze() ?? null;
|
|
303
487
|
this.paint();
|
|
304
488
|
requestAnimationFrame(() => this.e.desc.focus());
|
|
489
|
+
// Who you are fills the chip as soon as the server says it.
|
|
490
|
+
void this.refreshWho();
|
|
491
|
+
void this.refreshMember();
|
|
305
492
|
}
|
|
306
493
|
close() {
|
|
307
494
|
if (!this.isOpen)
|
|
@@ -311,6 +498,7 @@ export class ReportWidget {
|
|
|
311
498
|
this.stopRecordingBind();
|
|
312
499
|
this.isOpen = false;
|
|
313
500
|
this.view = 'describe';
|
|
501
|
+
this.unpark();
|
|
314
502
|
this.paint();
|
|
315
503
|
// Focus goes back where it came from — the host's control, the field the
|
|
316
504
|
// shortcut fired in — else to the button; never lost to <body> when the
|
|
@@ -338,13 +526,23 @@ export class ReportWidget {
|
|
|
338
526
|
setOpenSelector(sel) {
|
|
339
527
|
this.openSelector = sel || null;
|
|
340
528
|
}
|
|
529
|
+
/**
|
|
530
|
+
* The way to the recorder pill (vt-8020 D8): element.ts sets it only for a
|
|
531
|
+
* linked vitrinka member — the menu then offers "Record" — and clears it
|
|
532
|
+
* with null; reporters never get one.
|
|
533
|
+
*/
|
|
534
|
+
setRecordSwitch(fn) {
|
|
535
|
+
this.recordSwitch = fn;
|
|
536
|
+
this.paint();
|
|
537
|
+
}
|
|
341
538
|
identify(input) {
|
|
342
539
|
// null (or a malformed identity) is this widget going anonymous; undefined hands it back to the page-wide one.
|
|
343
540
|
this.identity = input === undefined ? undefined : normalizeIdentity(input);
|
|
344
|
-
this.
|
|
541
|
+
this.whoChanged();
|
|
345
542
|
}
|
|
346
543
|
unmount() {
|
|
347
544
|
this.stopRecordingBind();
|
|
545
|
+
this.linkFlow?.abort.abort();
|
|
348
546
|
for (const off of this.offs.splice(0).reverse())
|
|
349
547
|
off();
|
|
350
548
|
releaseEngine(this.engine);
|
|
@@ -358,9 +556,133 @@ export class ReportWidget {
|
|
|
358
556
|
const on = (el, type, fn) => {
|
|
359
557
|
el.addEventListener(type, fn);
|
|
360
558
|
};
|
|
361
|
-
on(e.fab, 'click', () =>
|
|
559
|
+
on(e.fab, 'click', () => {
|
|
560
|
+
if (this.swallowClick) {
|
|
561
|
+
this.swallowClick = false;
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
if (this.isOpen)
|
|
565
|
+
this.close();
|
|
566
|
+
else
|
|
567
|
+
this.open();
|
|
568
|
+
});
|
|
569
|
+
// The button moves to any corner (vt-8020 D9): dragged, or Alt+arrows while it has the focus.
|
|
570
|
+
on(e.fab, 'pointerdown', (ev) => this.fabDown(ev));
|
|
571
|
+
on(e.fab, 'pointermove', (ev) => this.fabMove(ev));
|
|
572
|
+
on(e.fab, 'pointerup', (ev) => this.fabUp(ev, true));
|
|
573
|
+
on(e.fab, 'pointercancel', (ev) => this.fabUp(ev, false));
|
|
574
|
+
on(e.fab, 'keydown', (ev) => {
|
|
575
|
+
if (!ev.altKey || ev.ctrlKey || ev.metaKey || ev.shiftKey)
|
|
576
|
+
return;
|
|
577
|
+
const next = cornerToward(this.dock, ev.key);
|
|
578
|
+
if (!next)
|
|
579
|
+
return;
|
|
580
|
+
ev.preventDefault(); // Alt+← is the browser's Back
|
|
581
|
+
if (next !== this.dock)
|
|
582
|
+
this.moveDock(next);
|
|
583
|
+
});
|
|
584
|
+
on(e.attach, 'click', () => e.fileInput.click());
|
|
585
|
+
on(e.fileInput, 'change', () => {
|
|
586
|
+
this.addFiles([...(e.fileInput.files ?? [])]);
|
|
587
|
+
e.fileInput.value = ''; // the same file picked again is a new pick
|
|
588
|
+
});
|
|
589
|
+
// A pasted or dropped file joins the attachments; pasted or dropped text stays the field's.
|
|
590
|
+
on(e.card, 'paste', (ev) => {
|
|
591
|
+
const pasted = [...(ev.clipboardData?.files ?? [])];
|
|
592
|
+
if (!pasted.length || !this.canAttach())
|
|
593
|
+
return;
|
|
594
|
+
// Office puts copied text beside an image of it: the text wins, unless it is only the copied file's name (the pill's rule, Sheet.tsx).
|
|
595
|
+
const text = ev.clipboardData?.getData('text/plain').trim() ?? '';
|
|
596
|
+
if (text && !pasted.some((f) => f.name && text.includes(f.name)))
|
|
597
|
+
return;
|
|
598
|
+
ev.preventDefault();
|
|
599
|
+
this.addFiles(pasted.map((f) => {
|
|
600
|
+
const name = pastedName(f.name, ++this.pastes);
|
|
601
|
+
return name === f.name ? f : new File([f], name, { type: f.type, lastModified: f.lastModified });
|
|
602
|
+
}));
|
|
603
|
+
});
|
|
604
|
+
on(e.card, 'dragover', (ev) => {
|
|
605
|
+
if (!ev.dataTransfer?.types.includes('Files') || !this.canAttach())
|
|
606
|
+
return;
|
|
607
|
+
ev.preventDefault();
|
|
608
|
+
ev.dataTransfer.dropEffect = 'copy';
|
|
609
|
+
e.card.classList.add('dropping');
|
|
610
|
+
});
|
|
611
|
+
on(e.card, 'dragleave', (ev) => {
|
|
612
|
+
if (ev.relatedTarget instanceof Node && e.card.contains(ev.relatedTarget))
|
|
613
|
+
return;
|
|
614
|
+
e.card.classList.remove('dropping');
|
|
615
|
+
});
|
|
616
|
+
on(e.card, 'drop', (ev) => {
|
|
617
|
+
e.card.classList.remove('dropping');
|
|
618
|
+
const dropped = [...(ev.dataTransfer?.files ?? [])];
|
|
619
|
+
if (!dropped.length || !this.canAttach())
|
|
620
|
+
return;
|
|
621
|
+
ev.preventDefault();
|
|
622
|
+
this.addFiles(dropped);
|
|
623
|
+
});
|
|
624
|
+
for (const [z, btn] of e.sizeButtons) {
|
|
625
|
+
on(btn, 'click', () => {
|
|
626
|
+
this.size = z;
|
|
627
|
+
writePref(SIZE_KEY, z);
|
|
628
|
+
this.paint();
|
|
629
|
+
// A parked card is placed by its painted size: re-place it at the new one.
|
|
630
|
+
if (this.parked)
|
|
631
|
+
this.placeCard();
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
on(e.techBtn, 'click', () => {
|
|
635
|
+
this.techOpen = !this.techOpen;
|
|
636
|
+
this.paint();
|
|
637
|
+
});
|
|
362
638
|
on(e.closeBtn, 'click', () => this.close());
|
|
363
|
-
on(e.
|
|
639
|
+
on(e.whoBtn, 'click', () => this.toggleMenu('account'));
|
|
640
|
+
on(e.more, 'click', () => this.toggleMenu('more'));
|
|
641
|
+
const fromMenu = (fn) => () => {
|
|
642
|
+
this.menu = null;
|
|
643
|
+
fn();
|
|
644
|
+
this.paint();
|
|
645
|
+
};
|
|
646
|
+
// A role=menu moves its focus with the arrows, Home and End over the items on show (the pill's Menu.tsx onKey).
|
|
647
|
+
on(e.morePop, 'keydown', (ev) => {
|
|
648
|
+
if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(ev.key))
|
|
649
|
+
return;
|
|
650
|
+
const items = [...e.morePop.querySelectorAll('[role="menuitem"]')].filter((el) => !el.hidden && !(el instanceof HTMLButtonElement && el.disabled));
|
|
651
|
+
if (!items.length)
|
|
652
|
+
return;
|
|
653
|
+
ev.preventDefault();
|
|
654
|
+
const root = e.morePop.getRootNode();
|
|
655
|
+
const at = items.indexOf(root.activeElement);
|
|
656
|
+
const last = items.length - 1;
|
|
657
|
+
const down = ev.key === 'ArrowDown';
|
|
658
|
+
const next = ev.key === 'Home' ? 0 : ev.key === 'End' ? last : at < 0 ? (down ? 0 : last) : (at + (down ? 1 : -1) + items.length) % items.length;
|
|
659
|
+
items[next]?.focus();
|
|
660
|
+
});
|
|
661
|
+
on(e.mReports, 'click', fromMenu(() => void this.openReports()));
|
|
662
|
+
on(e.mRecents, 'click', fromMenu(() => this.show('recents')));
|
|
663
|
+
on(e.mRecord, 'click', fromMenu(() => this.recordSwitch?.()));
|
|
664
|
+
on(e.mSettings, 'click', fromMenu(() => this.show('settings')));
|
|
665
|
+
on(e.mOpen, 'click', fromMenu(() => undefined));
|
|
666
|
+
on(e.accPortal, 'click', fromMenu(() => undefined));
|
|
667
|
+
on(e.accLink, 'click', fromMenu(() => this.startLinkFlow()));
|
|
668
|
+
on(e.accUnlink, 'click', () => {
|
|
669
|
+
clearLink();
|
|
670
|
+
this.member = null;
|
|
671
|
+
this.paint();
|
|
672
|
+
});
|
|
673
|
+
for (const b of [e.repBack, e.recBack, e.linkBack])
|
|
674
|
+
on(b, 'click', () => this.show('describe'));
|
|
675
|
+
on(e.linkRetry, 'click', () => this.startLinkFlow());
|
|
676
|
+
// A press anywhere in the card but the open popover (or its button) closes it.
|
|
677
|
+
on(e.card, 'pointerdown', (ev) => {
|
|
678
|
+
const t = ev.target;
|
|
679
|
+
if (!this.menu || !(t instanceof Node))
|
|
680
|
+
return;
|
|
681
|
+
if ([e.accountPop, e.morePop, e.whoBtn, e.more].some((el) => el.contains(t)))
|
|
682
|
+
return;
|
|
683
|
+
this.menu = null;
|
|
684
|
+
this.paint();
|
|
685
|
+
});
|
|
364
686
|
on(e.back, 'click', () => this.show('describe'));
|
|
365
687
|
on(e.sentClose, 'click', () => this.close());
|
|
366
688
|
on(e.desc, 'input', () => this.paint());
|
|
@@ -371,7 +693,7 @@ export class ReportWidget {
|
|
|
371
693
|
on(e.notifyBox, 'change', () => {
|
|
372
694
|
this.notify = e.notifyBox.checked;
|
|
373
695
|
});
|
|
374
|
-
on(e.where, 'click', () => this.startMarking());
|
|
696
|
+
on(e.where, 'click', () => (this.marking ? this.endMarking(true) : this.startMarking()));
|
|
375
697
|
on(e.send, 'click', () => void this.send());
|
|
376
698
|
on(e.bindBtn, 'click', () => (this.recordingBind ? this.stopRecordingBind() : this.startRecordingBind()));
|
|
377
699
|
on(e.unbind, 'click', () => {
|
|
@@ -379,11 +701,26 @@ export class ReportWidget {
|
|
|
379
701
|
saveKeybind(null);
|
|
380
702
|
this.paint();
|
|
381
703
|
});
|
|
704
|
+
for (const [kind, btn] of e.kindButtons) {
|
|
705
|
+
// A second press on the picked word unpicks it: the word is optional.
|
|
706
|
+
on(btn, 'click', () => {
|
|
707
|
+
this.kind = this.kind === kind ? null : kind;
|
|
708
|
+
this.paint();
|
|
709
|
+
});
|
|
710
|
+
}
|
|
382
711
|
on(e.card, 'keydown', (ev) => {
|
|
383
|
-
|
|
712
|
+
// Marking's own Escape (the window listener) already acted on it.
|
|
713
|
+
if (ev.key !== 'Escape' || this.recordingBind || ev.defaultPrevented)
|
|
384
714
|
return;
|
|
385
715
|
ev.preventDefault();
|
|
386
|
-
|
|
716
|
+
// Esc steps back one layer: an open popover, then a list or settings, then the card itself.
|
|
717
|
+
if (this.menu) {
|
|
718
|
+
const opener = this.menu === 'account' ? e.whoBtn : e.more;
|
|
719
|
+
this.menu = null;
|
|
720
|
+
this.paint();
|
|
721
|
+
opener.focus();
|
|
722
|
+
}
|
|
723
|
+
else if (this.view !== 'describe' && this.view !== 'sent')
|
|
387
724
|
this.show('describe');
|
|
388
725
|
else
|
|
389
726
|
this.close();
|
|
@@ -393,18 +730,24 @@ export class ReportWidget {
|
|
|
393
730
|
this.tool = tool;
|
|
394
731
|
this.renderKbDraft();
|
|
395
732
|
this.paint();
|
|
733
|
+
this.placeSeg();
|
|
396
734
|
// From the keyboard (no pointer: detail 0), go straight back to drawing with it.
|
|
397
735
|
if (ev.detail === 0)
|
|
398
736
|
e.mark.focus();
|
|
399
737
|
});
|
|
400
738
|
}
|
|
401
739
|
on(e.mark, 'keydown', (ev) => this.markKey(ev));
|
|
402
|
-
on(e.
|
|
403
|
-
|
|
740
|
+
on(e.cancel, 'click', () => this.cancelMarking());
|
|
741
|
+
on(e.discard, 'click', () => {
|
|
742
|
+
this.markers = renumberDrawn(this.markers.filter((m) => this.passKeys.has(m.key)));
|
|
404
743
|
this.renderMarks();
|
|
744
|
+
this.endMarking(true);
|
|
745
|
+
});
|
|
746
|
+
on(e.keep, 'click', () => {
|
|
747
|
+
this.confirming = false;
|
|
405
748
|
this.paint();
|
|
749
|
+
e.cancel.focus();
|
|
406
750
|
});
|
|
407
|
-
on(e.done, 'click', () => this.endMarking(true));
|
|
408
751
|
on(e.mark, 'pointerdown', (ev) => this.pointerDown(ev));
|
|
409
752
|
on(e.mark, 'pointermove', (ev) => this.pointerMove(ev));
|
|
410
753
|
on(e.mark, 'pointerup', (ev) => this.pointerUp(ev));
|
|
@@ -417,13 +760,23 @@ export class ReportWidget {
|
|
|
417
760
|
return;
|
|
418
761
|
if (this.marking && ev.key === 'Escape') {
|
|
419
762
|
ev.preventDefault();
|
|
420
|
-
// Esc drops a keyboard mark being placed
|
|
421
|
-
if (this.
|
|
763
|
+
// Esc answers an open "Discard?" with Keep, drops a keyboard mark being placed, and only then leaves marking — keeping the marks.
|
|
764
|
+
if (this.confirming)
|
|
765
|
+
e.keep.click();
|
|
766
|
+
else if (this.kbDraft)
|
|
422
767
|
this.cancelDraft();
|
|
423
768
|
else
|
|
424
769
|
this.endMarking(true);
|
|
425
770
|
return;
|
|
426
771
|
}
|
|
772
|
+
// ⌘Z / Ctrl+Z takes the newest mark back — unless a field is being typed in, whose own undo wins.
|
|
773
|
+
if (this.marking && (ev.metaKey || ev.ctrlKey) && !ev.shiftKey && !ev.altKey && ev.key.toLowerCase() === 'z' && !typing()) {
|
|
774
|
+
ev.preventDefault();
|
|
775
|
+
this.markers = renumberDrawn(this.markers.slice(0, -1));
|
|
776
|
+
this.renderMarks();
|
|
777
|
+
this.paint();
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
427
780
|
if (this.keybind && matchesKeybind(ev, this.keybind)) {
|
|
428
781
|
ev.preventDefault();
|
|
429
782
|
if (this.isOpen)
|
|
@@ -449,11 +802,17 @@ export class ReportWidget {
|
|
|
449
802
|
ev.preventDefault();
|
|
450
803
|
this.open();
|
|
451
804
|
}));
|
|
805
|
+
this.offs.push(listen(window, 'resize', () => {
|
|
806
|
+
if (this.parked)
|
|
807
|
+
this.placeCard();
|
|
808
|
+
if (this.marking)
|
|
809
|
+
this.placeSeg();
|
|
810
|
+
}));
|
|
452
811
|
this.offs.push(watchKeybind((b) => {
|
|
453
812
|
this.keybind = b;
|
|
454
813
|
this.paint();
|
|
455
814
|
}));
|
|
456
|
-
this.offs.push(onSharedIdentity(() => this.
|
|
815
|
+
this.offs.push(onSharedIdentity(() => this.whoChanged()));
|
|
457
816
|
// The recorder took the page's capture over: stop saying minutes are attached.
|
|
458
817
|
if (this.engine)
|
|
459
818
|
this.offs.push(this.engine.onChange(() => this.paint()));
|
|
@@ -493,16 +852,202 @@ export class ReportWidget {
|
|
|
493
852
|
}
|
|
494
853
|
show(view) {
|
|
495
854
|
this.stopRecordingBind();
|
|
855
|
+
if (view !== 'link' && this.linkFlow) {
|
|
856
|
+
this.linkFlow.abort.abort();
|
|
857
|
+
this.linkFlow = null;
|
|
858
|
+
}
|
|
496
859
|
this.view = view;
|
|
497
860
|
this.paint();
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
861
|
+
const focus = { describe: this.e.desc, settings: this.e.bindBtn, sent: null, reports: this.e.repBack, recents: this.e.recBack, link: this.e.linkBack }[view];
|
|
862
|
+
if (focus)
|
|
863
|
+
requestAnimationFrame(() => focus.focus());
|
|
864
|
+
}
|
|
865
|
+
// -- the account and the lists (vt-8020 D2–D5) ------------------------------
|
|
866
|
+
target() {
|
|
867
|
+
return { url: this.opts.base, key: this.opts.key };
|
|
868
|
+
}
|
|
869
|
+
toggleMenu(which) {
|
|
870
|
+
this.menu = this.menu === which ? null : which;
|
|
871
|
+
if (this.menu === 'account') {
|
|
872
|
+
void this.refreshWho();
|
|
873
|
+
void this.refreshMember();
|
|
874
|
+
}
|
|
875
|
+
this.paint();
|
|
876
|
+
const pop = this.menu === 'account' ? this.e.accountPop : this.menu === 'more' ? this.e.morePop : null;
|
|
877
|
+
const first = pop?.querySelector('button:not([hidden]), a:not([hidden])');
|
|
878
|
+
first?.focus();
|
|
879
|
+
}
|
|
880
|
+
/** The host's signed token traded once for a reporter session; renewed only when it is about to lapse. Answers the session in force. */
|
|
881
|
+
async refreshWho() {
|
|
882
|
+
const who = this.who();
|
|
883
|
+
if (!who || !('token' in who)) {
|
|
884
|
+
this.session = null;
|
|
885
|
+
this.sessionToken = '';
|
|
886
|
+
return null;
|
|
887
|
+
}
|
|
888
|
+
if (this.sessionToken === who.token && sessionLive(this.session))
|
|
889
|
+
return this.session;
|
|
890
|
+
this.sessionToken = who.token;
|
|
891
|
+
let opened = null;
|
|
892
|
+
try {
|
|
893
|
+
opened = await openSession(this.target(), who.token);
|
|
894
|
+
}
|
|
895
|
+
catch (e) {
|
|
896
|
+
console.warn('vitrinka: the reporter session could not be opened — My reports shows this browser’s reports only', e);
|
|
897
|
+
}
|
|
898
|
+
// The person changed while the trade was in flight (whoChanged): this session is someone else's now.
|
|
899
|
+
if (this.sessionToken !== who.token)
|
|
900
|
+
return null;
|
|
901
|
+
this.session = opened;
|
|
902
|
+
this.paint();
|
|
903
|
+
return this.session;
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* identify() or the page-wide identity moved: a session and a list read for
|
|
907
|
+
* the previous person never stay on screen for the next one, and an open My
|
|
908
|
+
* reports reloads for whoever is here now.
|
|
909
|
+
*/
|
|
910
|
+
whoChanged() {
|
|
911
|
+
if (this.whoToken() !== this.sessionToken) {
|
|
912
|
+
this.session = null;
|
|
913
|
+
this.sessionToken = '';
|
|
914
|
+
this.mine = { rows: [], state: 'ok' };
|
|
915
|
+
if (this.isOpen)
|
|
916
|
+
void (this.view === 'reports' ? this.loadReports() : this.refreshWho());
|
|
917
|
+
}
|
|
918
|
+
this.paint();
|
|
919
|
+
}
|
|
920
|
+
async refreshMember() {
|
|
921
|
+
// The browser-wide link goes only to the vitrinka it was minted on: its token never reaches another widget's base.
|
|
922
|
+
const link = memberLinked(this.opts.base) ? readLink() : null;
|
|
923
|
+
if (!link) {
|
|
924
|
+
if (this.member) {
|
|
925
|
+
this.member = null;
|
|
926
|
+
this.paint();
|
|
927
|
+
}
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
try {
|
|
931
|
+
const me = await api('GET', '/api/v1/recorder/me', undefined, { target: { url: this.opts.base, key: link.token } });
|
|
932
|
+
this.member = { email: me.user?.email ?? '', name: me.user?.name ?? '', workspace: me.workspace?.slug ?? link.workspace };
|
|
933
|
+
// A dev-mode member starts on the pill next mount (face.ts startFace).
|
|
934
|
+
rememberDisplayMode(me.displayMode);
|
|
935
|
+
}
|
|
936
|
+
catch (e) {
|
|
937
|
+
console.warn('vitrinka: the linked vitrinka account could not be read', e);
|
|
938
|
+
this.member = { email: '', name: '', workspace: link.workspace };
|
|
939
|
+
}
|
|
940
|
+
this.paint();
|
|
941
|
+
}
|
|
942
|
+
async openReports() {
|
|
943
|
+
this.show('reports');
|
|
944
|
+
await this.loadReports();
|
|
945
|
+
}
|
|
946
|
+
async loadReports() {
|
|
947
|
+
const asked = this.whoToken();
|
|
948
|
+
const session = await this.refreshWho();
|
|
949
|
+
// The person changed meanwhile: whoChanged already reloads for the next one.
|
|
950
|
+
if (this.whoToken() !== asked)
|
|
951
|
+
return;
|
|
952
|
+
if (!session) {
|
|
953
|
+
this.mine = { rows: [], state: 'ok' };
|
|
954
|
+
this.paint();
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
this.mine = { rows: [], state: 'loading' };
|
|
958
|
+
this.paint();
|
|
959
|
+
let mine;
|
|
960
|
+
try {
|
|
961
|
+
mine = { rows: await this.listMineRenewing(session), state: 'ok' };
|
|
962
|
+
}
|
|
963
|
+
catch (e) {
|
|
964
|
+
console.warn('vitrinka: My reports could not be loaded', e);
|
|
965
|
+
mine = { rows: [], state: 'failed' };
|
|
966
|
+
}
|
|
967
|
+
// A list read for the previous person is dropped; whoChanged already reloads for the next one.
|
|
968
|
+
if (this.whoToken() !== asked)
|
|
969
|
+
return;
|
|
970
|
+
this.mine = mine;
|
|
971
|
+
this.paint();
|
|
972
|
+
}
|
|
973
|
+
/** My reports; a 401 means the reporter session lapsed or the host's key rotated: trade the token again, then ask once more. */
|
|
974
|
+
async listMineRenewing(session) {
|
|
975
|
+
try {
|
|
976
|
+
return (await listMine(this.target(), session.session)).reports;
|
|
977
|
+
}
|
|
978
|
+
catch (e) {
|
|
979
|
+
if (!(e instanceof VitrinkaApiError) || e.status !== 401)
|
|
980
|
+
throw e;
|
|
981
|
+
this.session = null;
|
|
982
|
+
this.sessionToken = '';
|
|
983
|
+
const renewed = await this.refreshWho();
|
|
984
|
+
if (!renewed)
|
|
985
|
+
throw e;
|
|
986
|
+
return (await listMine(this.target(), renewed.session)).reports;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
/** The pill's member link (vt-8020 D3): a code approved in vitrinka mints this browser's own recorder key. */
|
|
990
|
+
startLinkFlow() {
|
|
991
|
+
this.linkFlow?.abort.abort();
|
|
992
|
+
const flow = { start: null, state: 'starting', abort: new AbortController() };
|
|
993
|
+
this.linkFlow = flow;
|
|
994
|
+
this.show('link');
|
|
995
|
+
const base = this.opts.base;
|
|
996
|
+
const workspace = linkWorkspace(base);
|
|
997
|
+
void (async () => {
|
|
998
|
+
try {
|
|
999
|
+
flow.start = await startLink(base, { label: defaultLinkLabel(), workspace });
|
|
1000
|
+
flow.state = 'waiting';
|
|
1001
|
+
this.paint();
|
|
1002
|
+
const linked = await pollLink(base, flow.start.device_code, {
|
|
1003
|
+
interval: flow.start.interval,
|
|
1004
|
+
expiresIn: flow.start.expires_in,
|
|
1005
|
+
workspace,
|
|
1006
|
+
signal: flow.abort.signal,
|
|
1007
|
+
});
|
|
1008
|
+
// The link names the vitrinka it belongs to: face.ts offers the pill only on that base.
|
|
1009
|
+
storeLink({ ...linked, base });
|
|
1010
|
+
this.linkFlow = null;
|
|
1011
|
+
this.show('describe');
|
|
1012
|
+
await this.refreshMember();
|
|
1013
|
+
}
|
|
1014
|
+
catch (e) {
|
|
1015
|
+
if (flow.abort.signal.aborted)
|
|
1016
|
+
return;
|
|
1017
|
+
flow.state = e instanceof LinkExpired ? 'expired' : 'failed';
|
|
1018
|
+
if (flow.state === 'failed')
|
|
1019
|
+
console.warn('vitrinka: linking the vitrinka account failed', e);
|
|
1020
|
+
this.paint();
|
|
1021
|
+
}
|
|
1022
|
+
})();
|
|
1023
|
+
}
|
|
1024
|
+
/** "2 h ago" in the widget's language. */
|
|
1025
|
+
ago(at) {
|
|
1026
|
+
const rtf = new Intl.RelativeTimeFormat(this.locale, { numeric: 'auto' });
|
|
1027
|
+
const s = Math.round((at - Date.now()) / 1000);
|
|
1028
|
+
const steps = [[60, 'second'], [60, 'minute'], [24, 'hour'], [30, 'day'], [12, 'month'], [Infinity, 'year']];
|
|
1029
|
+
let v = s;
|
|
1030
|
+
for (const [size, unit] of steps) {
|
|
1031
|
+
if (Math.abs(v) < size)
|
|
1032
|
+
return rtf.format(v, unit);
|
|
1033
|
+
v = Math.round(v / size);
|
|
1034
|
+
}
|
|
1035
|
+
return rtf.format(v, 'year');
|
|
1036
|
+
}
|
|
1037
|
+
/** One list row: a title, a quiet state chip and its age; a link when the server minted an address. */
|
|
1038
|
+
row(title, state, at, url) {
|
|
1039
|
+
const kids = [h('span', { class: 'row-t' }, title), h('span', { class: 'step' }, state), h('span', { class: 'age' }, this.ago(at))];
|
|
1040
|
+
const inner = url ? h('a', { class: 'row', href: url, target: '_blank', rel: 'noopener noreferrer' }, ...kids) : h('div', { class: 'row' }, ...kids);
|
|
1041
|
+
return h('li', {}, inner);
|
|
502
1042
|
}
|
|
503
1043
|
who() {
|
|
504
1044
|
return this.identity !== undefined ? this.identity : sharedIdentity();
|
|
505
1045
|
}
|
|
1046
|
+
/** The signed token of the person here now; '' for an asserted or anonymous reporter. */
|
|
1047
|
+
whoToken() {
|
|
1048
|
+
const who = this.who();
|
|
1049
|
+
return who && 'token' in who ? who.token : '';
|
|
1050
|
+
}
|
|
506
1051
|
// -- the shortcut recorder ----------------------------------------------
|
|
507
1052
|
stopBindListener = null;
|
|
508
1053
|
startRecordingBind() {
|
|
@@ -536,27 +1081,238 @@ export class ReportWidget {
|
|
|
536
1081
|
this.stopBindListener = null;
|
|
537
1082
|
this.paint();
|
|
538
1083
|
}
|
|
1084
|
+
// -- the reporter's files (vt-8020 D9) ---------------------------------------
|
|
1085
|
+
/** Files join while the report is being written — not while it is on its way (Retry sends it as it was). */
|
|
1086
|
+
canAttach() {
|
|
1087
|
+
return this.isOpen && this.view === 'describe' && !this.sending && !this.job?.id;
|
|
1088
|
+
}
|
|
1089
|
+
caps() {
|
|
1090
|
+
return this.config?.attachments ?? DEFAULT_ATTACHMENT_CAPS;
|
|
1091
|
+
}
|
|
1092
|
+
addFiles(incoming) {
|
|
1093
|
+
if (!incoming.length)
|
|
1094
|
+
return;
|
|
1095
|
+
const { files, refusal } = admit(this.files, incoming, this.caps());
|
|
1096
|
+
this.files = [...this.files, ...files];
|
|
1097
|
+
this.fileRefusal = refusal;
|
|
1098
|
+
this.renderFiles();
|
|
1099
|
+
this.paint();
|
|
1100
|
+
}
|
|
1101
|
+
removeFile(f) {
|
|
1102
|
+
this.files = this.files.filter((x) => x !== f);
|
|
1103
|
+
this.fileRefusal = null;
|
|
1104
|
+
this.renderFiles();
|
|
1105
|
+
this.paint();
|
|
1106
|
+
// Its ✕ is gone: the focus goes to 📎, never lost to <body>.
|
|
1107
|
+
this.e.attach.focus();
|
|
1108
|
+
}
|
|
1109
|
+
/** One chip per file, built once; paint() writes their sizes and labels. */
|
|
1110
|
+
renderFiles() {
|
|
1111
|
+
const live = new Set(this.files);
|
|
1112
|
+
for (const [f, chip] of this.chips) {
|
|
1113
|
+
if (live.has(f))
|
|
1114
|
+
continue;
|
|
1115
|
+
chip.el.remove();
|
|
1116
|
+
this.chips.delete(f);
|
|
1117
|
+
}
|
|
1118
|
+
for (const f of this.files) {
|
|
1119
|
+
if (this.chips.has(f))
|
|
1120
|
+
continue;
|
|
1121
|
+
const size = h('span', { class: 'file-size' });
|
|
1122
|
+
const rm = h('button', { class: 'ln-x', type: 'button' }, icon(ICON.close));
|
|
1123
|
+
const el = h('li', { class: 'file' }, h('span', { class: 'file-name' }, f.name), size, rm);
|
|
1124
|
+
rm.addEventListener('click', () => this.removeFile(f));
|
|
1125
|
+
this.e.files.append(el);
|
|
1126
|
+
this.chips.set(f, { el, size, rm });
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
/** The one line a refused file gets: the cap it broke, by name. */
|
|
1130
|
+
refusalText(r) {
|
|
1131
|
+
const s = this.s;
|
|
1132
|
+
if (!r)
|
|
1133
|
+
return '';
|
|
1134
|
+
if (r.kind === 'size')
|
|
1135
|
+
return s.fileTooBig(r.name, formatBytes(r.cap, this.locale));
|
|
1136
|
+
if (r.kind === 'count')
|
|
1137
|
+
return s.tooManyFiles(r.cap);
|
|
1138
|
+
return s.fileType(r.name, typesLabel(this.caps().types, s.typeNames, this.locale));
|
|
1139
|
+
}
|
|
1140
|
+
// -- the button's corner (vt-8020 D9) ---------------------------------------
|
|
1141
|
+
fabDown(ev) {
|
|
1142
|
+
this.swallowClick = false;
|
|
1143
|
+
if (ev.button !== 0 || !ev.isPrimary)
|
|
1144
|
+
return;
|
|
1145
|
+
const r = this.e.fab.getBoundingClientRect();
|
|
1146
|
+
this.fabDrag = { pointer: ev.pointerId, start: { x: ev.clientX, y: ev.clientY }, grab: { x: ev.clientX - r.left, y: ev.clientY - r.top }, moved: false };
|
|
1147
|
+
try {
|
|
1148
|
+
this.e.fab.setPointerCapture(ev.pointerId);
|
|
1149
|
+
}
|
|
1150
|
+
catch {
|
|
1151
|
+
// a synthetic pointer: no capture needed
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
/** Past the threshold the press is a drag: the button rides the pointer, inside the viewport. */
|
|
1155
|
+
fabMove(ev) {
|
|
1156
|
+
const d = this.fabDrag;
|
|
1157
|
+
if (!d || ev.pointerId !== d.pointer)
|
|
1158
|
+
return;
|
|
1159
|
+
if (!d.moved && Math.hypot(ev.clientX - d.start.x, ev.clientY - d.start.y) < DRAG_THRESHOLD)
|
|
1160
|
+
return;
|
|
1161
|
+
d.moved = true;
|
|
1162
|
+
const fab = this.e.fab;
|
|
1163
|
+
fab.classList.add('dragging');
|
|
1164
|
+
const r = fab.getBoundingClientRect();
|
|
1165
|
+
const vw = globalThis.innerWidth || 800;
|
|
1166
|
+
const vh = globalThis.innerHeight || 600;
|
|
1167
|
+
const s = fab.style;
|
|
1168
|
+
s.left = `${Math.min(Math.max(0, ev.clientX - d.grab.x), vw - r.width)}px`;
|
|
1169
|
+
s.top = `${Math.min(Math.max(0, ev.clientY - d.grab.y), vh - r.height)}px`;
|
|
1170
|
+
s.right = 'auto';
|
|
1171
|
+
s.bottom = 'auto';
|
|
1172
|
+
}
|
|
1173
|
+
/** A drop docks the button in the nearest corner (a cancelled drag goes home); a press that never travelled stays a click. */
|
|
1174
|
+
fabUp(ev, drop) {
|
|
1175
|
+
const d = this.fabDrag;
|
|
1176
|
+
if (!d || ev.pointerId !== d.pointer)
|
|
1177
|
+
return;
|
|
1178
|
+
this.fabDrag = null;
|
|
1179
|
+
if (!d.moved)
|
|
1180
|
+
return;
|
|
1181
|
+
const fab = this.e.fab;
|
|
1182
|
+
const at = fab.getBoundingClientRect();
|
|
1183
|
+
fab.classList.remove('dragging');
|
|
1184
|
+
for (const p of ['left', 'top', 'right', 'bottom'])
|
|
1185
|
+
fab.style.removeProperty(p);
|
|
1186
|
+
// The click this pointerup is about to fire is the drop; a click that never comes must not eat the next one.
|
|
1187
|
+
this.swallowClick = true;
|
|
1188
|
+
setTimeout(() => {
|
|
1189
|
+
this.swallowClick = false;
|
|
1190
|
+
}, 0);
|
|
1191
|
+
const vw = globalThis.innerWidth || 800;
|
|
1192
|
+
const vh = globalThis.innerHeight || 600;
|
|
1193
|
+
this.moveDock(drop ? nearestCorner({ x: at.left + at.width / 2, y: at.top + at.height / 2 }, vw, vh) : this.dock, at);
|
|
1194
|
+
}
|
|
1195
|
+
/** Docks the button in `c` and remembers it; it glides there from `from` (the drop point, else where it was). */
|
|
1196
|
+
moveDock(c, from) {
|
|
1197
|
+
const fab = this.e.fab;
|
|
1198
|
+
const before = from ?? fab.getBoundingClientRect();
|
|
1199
|
+
this.dock = c;
|
|
1200
|
+
saveDock(c);
|
|
1201
|
+
this.paint();
|
|
1202
|
+
if (fab.hidden || reducedMotion())
|
|
1203
|
+
return;
|
|
1204
|
+
const after = fab.getBoundingClientRect();
|
|
1205
|
+
const dx = before.left - after.left;
|
|
1206
|
+
const dy = before.top - after.top;
|
|
1207
|
+
if (!dx && !dy)
|
|
1208
|
+
return;
|
|
1209
|
+
// FLIP: start where it was, then let the placement transition carry it home.
|
|
1210
|
+
this.glide?.abort();
|
|
1211
|
+
const glide = new AbortController();
|
|
1212
|
+
this.glide = glide;
|
|
1213
|
+
fab.classList.remove('gliding');
|
|
1214
|
+
fab.style.setProperty('translate', `${dx}px ${dy}px`);
|
|
1215
|
+
void fab.offsetWidth;
|
|
1216
|
+
fab.classList.add('gliding');
|
|
1217
|
+
fab.style.setProperty('translate', '0px 0px');
|
|
1218
|
+
// Only this glide's own end: the hover lift transitions too, and a newer glide replaces this one.
|
|
1219
|
+
const done = (ev) => {
|
|
1220
|
+
if (ev.propertyName !== 'translate')
|
|
1221
|
+
return;
|
|
1222
|
+
glide.abort();
|
|
1223
|
+
fab.classList.remove('gliding');
|
|
1224
|
+
fab.style.removeProperty('translate');
|
|
1225
|
+
};
|
|
1226
|
+
fab.addEventListener('transitionend', done, { signal: glide.signal });
|
|
1227
|
+
fab.addEventListener('transitioncancel', done, { signal: glide.signal });
|
|
1228
|
+
}
|
|
539
1229
|
// -- marking --------------------------------------------------------------
|
|
540
1230
|
startMarking() {
|
|
541
1231
|
if (this.job?.id)
|
|
542
1232
|
return; // the report is on its way: Retry finishes it as it was marked
|
|
543
1233
|
this.marking = true;
|
|
544
|
-
this.
|
|
1234
|
+
this.confirming = false;
|
|
1235
|
+
this.passKeys = new Set(this.markers.map((m) => m.key));
|
|
1236
|
+
// Marking parks the card from where it is (beside the button's dock, or a corner an earlier pass
|
|
1237
|
+
// chose), with the insets it has there: starting never moves it — only a mark landing under it does.
|
|
1238
|
+
const corner = this.parked ?? this.dock;
|
|
1239
|
+
this.parkInsets = this.insetsAt(corner, this.e.card.getBoundingClientRect());
|
|
1240
|
+
this.parked = corner;
|
|
545
1241
|
this.renderMarks();
|
|
546
1242
|
this.paint();
|
|
1243
|
+
this.placeCard();
|
|
1244
|
+
this.placeSeg();
|
|
547
1245
|
const vw = globalThis.innerWidth || 800;
|
|
548
|
-
|
|
549
|
-
this.placeCoach({ x: vw / 2 - 150, y: vh - 260 }, false);
|
|
1246
|
+
this.placeCoach({ x: vw / 2 - 150, y: BAR_CLEAR + 12 }, false);
|
|
550
1247
|
this.e.mark.focus();
|
|
551
1248
|
}
|
|
1249
|
+
/** Leaves marking; the card stays where marking parked it until it closes (it never jumps back). */
|
|
552
1250
|
endMarking(backToCard) {
|
|
553
1251
|
this.cancelDraft();
|
|
554
1252
|
this.marking = false;
|
|
555
|
-
this.
|
|
1253
|
+
this.confirming = false;
|
|
556
1254
|
this.paint();
|
|
557
1255
|
if (backToCard && this.isOpen)
|
|
558
1256
|
requestAnimationFrame(() => this.e.desc.focus());
|
|
559
1257
|
}
|
|
1258
|
+
/** Cancel (vt-8020 D12): leave marking and drop this pass's marks — asking first when there are any. */
|
|
1259
|
+
cancelMarking() {
|
|
1260
|
+
const added = this.markers.filter((m) => !this.passKeys.has(m.key)).length;
|
|
1261
|
+
if (added === 0) {
|
|
1262
|
+
this.endMarking(true);
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
this.confirming = true;
|
|
1266
|
+
this.paint();
|
|
1267
|
+
this.e.discard.focus();
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* The card's live insets in `corner` (the nearer side, and the bottom or the top — never above the
|
|
1271
|
+
* marking bar's band), the far side at the default: `cornerRect(corner)` is then exactly where it is.
|
|
1272
|
+
*/
|
|
1273
|
+
insetsAt(corner, r) {
|
|
1274
|
+
const vw = globalThis.innerWidth || 800;
|
|
1275
|
+
const vh = globalThis.innerHeight || 600;
|
|
1276
|
+
const bar = BAR_CLEAR * SIZE_SCALE[this.size];
|
|
1277
|
+
const atBottom = corner === 'br' || corner === 'bl';
|
|
1278
|
+
return {
|
|
1279
|
+
edge: Math.max(0, Math.min(r.left, vw - r.right)),
|
|
1280
|
+
top: atBottom ? bar : Math.max(bar, r.top),
|
|
1281
|
+
bottom: atBottom ? Math.max(0, vh - r.bottom) : PARK_EDGE,
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
/** The card's box as painted (the size setting scales it, styles: `--vr-scale`) and the insets marking parks it with. */
|
|
1285
|
+
frame() {
|
|
1286
|
+
const vw = globalThis.innerWidth || 800;
|
|
1287
|
+
const vh = globalThis.innerHeight || 600;
|
|
1288
|
+
const k = SIZE_SCALE[this.size];
|
|
1289
|
+
const insets = this.parkInsets ?? { top: BAR_CLEAR * k, bottom: PARK_EDGE, edge: PARK_EDGE };
|
|
1290
|
+
const r = this.e.card.getBoundingClientRect();
|
|
1291
|
+
return { vw, vh, w: r.width || Math.min(CARD.w * k, vw - 32), h: r.height || Math.min(CARD.h * k, vh - insets.top - insets.bottom), ...insets };
|
|
1292
|
+
}
|
|
1293
|
+
/** Parks the card in the corner that covers none of the marks; it glides there (styles: `.card.parked`). */
|
|
1294
|
+
placeCard() {
|
|
1295
|
+
if (!this.parked)
|
|
1296
|
+
return;
|
|
1297
|
+
const f = this.frame();
|
|
1298
|
+
this.parked = pickCorner(this.parked, this.markers.map((m) => m.rect), f);
|
|
1299
|
+
const r = cornerRect(this.parked, f);
|
|
1300
|
+
const s = this.e.card.style;
|
|
1301
|
+
this.e.card.classList.add('parked');
|
|
1302
|
+
s.left = `${r.x}px`;
|
|
1303
|
+
s.top = `${r.y}px`;
|
|
1304
|
+
}
|
|
1305
|
+
unpark() {
|
|
1306
|
+
this.parked = null;
|
|
1307
|
+
this.parkInsets = null;
|
|
1308
|
+
this.e.card.classList.remove('parked');
|
|
1309
|
+
this.e.card.style.removeProperty('left');
|
|
1310
|
+
this.e.card.style.removeProperty('top');
|
|
1311
|
+
}
|
|
1312
|
+
/** The segmented control's indicator under the picked shape. */
|
|
1313
|
+
placeSeg() {
|
|
1314
|
+
placeIndicator(this.e.seg, this.e.segInd, this.e.toolButtons.get(this.tool));
|
|
1315
|
+
}
|
|
560
1316
|
onChrome(t) {
|
|
561
1317
|
return t instanceof Node && (this.e.toolbar.contains(t) || this.e.pins.contains(t));
|
|
562
1318
|
}
|
|
@@ -567,7 +1323,6 @@ export class ReportWidget {
|
|
|
567
1323
|
const root = this.e.root.getRootNode();
|
|
568
1324
|
if (root instanceof ShadowRoot && root.activeElement instanceof HTMLElement)
|
|
569
1325
|
root.activeElement.blur();
|
|
570
|
-
this.noteOpen = null;
|
|
571
1326
|
this.drawing = { start: { x: ev.clientX, y: ev.clientY }, shape: this.tool, pointer: ev.pointerId };
|
|
572
1327
|
try {
|
|
573
1328
|
this.e.mark.setPointerCapture(ev.pointerId);
|
|
@@ -576,7 +1331,6 @@ export class ReportWidget {
|
|
|
576
1331
|
// a synthetic pointer: no capture needed
|
|
577
1332
|
}
|
|
578
1333
|
this.e.coach.classList.add('pressing');
|
|
579
|
-
this.renderPins();
|
|
580
1334
|
}
|
|
581
1335
|
pointerMove(ev) {
|
|
582
1336
|
if (!this.markers.length)
|
|
@@ -605,10 +1359,10 @@ export class ReportWidget {
|
|
|
605
1359
|
this.hideIds.set(key, ids);
|
|
606
1360
|
}
|
|
607
1361
|
this.markers = renumberDrawn([...this.markers, { key, n: this.markers.length + 1, shape, rect, note: '', ...(head ? { head } : {}) }]);
|
|
608
|
-
this.noteOpen = key;
|
|
609
1362
|
this.renderMarks();
|
|
610
1363
|
this.paint();
|
|
611
|
-
|
|
1364
|
+
// Drawing a shape opens its note: the new line in the card takes the typing.
|
|
1365
|
+
this.lines.get(key)?.note.focus();
|
|
612
1366
|
}
|
|
613
1367
|
cancelDraft() {
|
|
614
1368
|
this.drawing = null;
|
|
@@ -692,61 +1446,76 @@ export class ReportWidget {
|
|
|
692
1446
|
pin.el.remove();
|
|
693
1447
|
this.pins.delete(key);
|
|
694
1448
|
}
|
|
1449
|
+
for (const [key, line] of this.lines) {
|
|
1450
|
+
if (live.has(key))
|
|
1451
|
+
continue;
|
|
1452
|
+
line.el.remove();
|
|
1453
|
+
this.lines.delete(key);
|
|
1454
|
+
}
|
|
1455
|
+
const remove = (key) => {
|
|
1456
|
+
this.markers = renumberDrawn(this.markers.filter((x) => x.key !== key));
|
|
1457
|
+
this.renderMarks();
|
|
1458
|
+
this.paint();
|
|
1459
|
+
};
|
|
695
1460
|
for (const m of this.markers) {
|
|
696
1461
|
if (this.pins.has(m.key))
|
|
697
1462
|
continue;
|
|
698
1463
|
const num = h('button', { class: 'num', type: 'button' });
|
|
699
|
-
const note = h('input', { class: 'note', type: 'text', maxlength: '500' });
|
|
700
1464
|
const rm = h('button', { class: 'rm', type: 'button' }, icon(ICON.close));
|
|
701
|
-
const el = h('div', { class: 'pin' }, num,
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
});
|
|
1465
|
+
const el = h('div', { class: 'pin' }, num, rm);
|
|
1466
|
+
// The pin points at its note: a press on the number puts the caret in its line.
|
|
1467
|
+
num.addEventListener('click', () => this.lines.get(m.key)?.note.focus());
|
|
1468
|
+
rm.addEventListener('click', () => remove(m.key));
|
|
1469
|
+
this.e.pins.append(el);
|
|
1470
|
+
this.pins.set(m.key, { el, num, rm });
|
|
1471
|
+
const lineNum = h('span', { class: 'ln-n', 'aria-hidden': 'true' });
|
|
1472
|
+
const note = h('input', { class: 'ln-t', type: 'text', maxlength: '500' });
|
|
1473
|
+
const lineRm = h('button', { class: 'ln-x', type: 'button' }, icon(ICON.close));
|
|
1474
|
+
const line = h('li', { class: 'ln' }, lineNum, note, lineRm);
|
|
707
1475
|
note.addEventListener('input', () => {
|
|
708
1476
|
this.markers = this.markers.map((x) => (x.key === m.key ? { ...x, note: note.value } : x));
|
|
709
|
-
|
|
710
|
-
note.addEventListener('focus', () => {
|
|
711
|
-
this.noteOpen = m.key;
|
|
712
|
-
this.renderPins();
|
|
1477
|
+
this.paint();
|
|
713
1478
|
});
|
|
714
1479
|
note.addEventListener('keydown', (ev) => {
|
|
715
|
-
if (ev.key !== 'Enter')
|
|
1480
|
+
if (ev.key !== 'Enter' || !this.marking)
|
|
716
1481
|
return;
|
|
717
1482
|
ev.preventDefault();
|
|
718
1483
|
// Back to the page, ready for the next mark from the keyboard.
|
|
719
1484
|
this.e.mark.focus();
|
|
720
1485
|
});
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
this.
|
|
1486
|
+
lineRm.addEventListener('click', () => remove(m.key));
|
|
1487
|
+
this.e.lines.append(line);
|
|
1488
|
+
this.lines.set(m.key, { el: line, num: lineNum, note, rm: lineRm });
|
|
1489
|
+
}
|
|
1490
|
+
// Renumbering after a removal keeps the lines in mark order.
|
|
1491
|
+
for (const m of this.markers) {
|
|
1492
|
+
const line = this.lines.get(m.key);
|
|
1493
|
+
if (line)
|
|
1494
|
+
this.e.lines.append(line.el);
|
|
728
1495
|
}
|
|
729
1496
|
this.renderPins();
|
|
1497
|
+
if (this.parked)
|
|
1498
|
+
this.placeCard();
|
|
730
1499
|
}
|
|
731
|
-
/** Pin numbers
|
|
1500
|
+
/** Pin numbers and positions, line numbers and labels; text in place (the locale may have changed). */
|
|
732
1501
|
renderPins() {
|
|
733
1502
|
const vw = globalThis.innerWidth || 800;
|
|
734
1503
|
for (const m of this.markers) {
|
|
735
1504
|
const pin = this.pins.get(m.key);
|
|
736
|
-
|
|
1505
|
+
const line = this.lines.get(m.key);
|
|
1506
|
+
if (!pin || !line)
|
|
737
1507
|
continue;
|
|
738
1508
|
const anchor = m.shape === 'arrow' ? arrowEnds(m.rect, m.head ?? 'se').tail : { x: m.rect.x, y: m.rect.y };
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
pin.el.style.left = `${Math.min(Math.max(4, anchor.x - 12), vw - width)}px`;
|
|
742
|
-
pin.el.style.top = `${Math.max(4, anchor.y - 12)}px`;
|
|
1509
|
+
pin.el.style.left = `${Math.min(Math.max(4, anchor.x - 12), vw - 60)}px`;
|
|
1510
|
+
pin.el.style.top = `${Math.max(BAR_CLEAR - 12, anchor.y - 12)}px`;
|
|
743
1511
|
pin.num.textContent = String(m.n);
|
|
744
1512
|
pin.num.setAttribute('aria-label', this.s.mark(m.n));
|
|
745
|
-
pin.note.hidden = !showNote;
|
|
746
|
-
pin.rm.hidden = !showNote;
|
|
747
|
-
pin.note.placeholder = this.s.notePlaceholder;
|
|
748
|
-
pin.note.setAttribute('aria-label', `${this.s.mark(m.n)} — ${this.s.notePlaceholder}`);
|
|
749
1513
|
pin.rm.setAttribute('aria-label', this.s.removeMark(m.n));
|
|
1514
|
+
line.num.textContent = String(m.n);
|
|
1515
|
+
line.el.classList.toggle('hide', m.shape === 'hide');
|
|
1516
|
+
line.note.placeholder = this.s.notePlaceholder;
|
|
1517
|
+
line.note.setAttribute('aria-label', `${this.s.mark(m.n)} — ${this.s.notePlaceholder}`);
|
|
1518
|
+
line.rm.setAttribute('aria-label', this.s.removeMark(m.n));
|
|
750
1519
|
}
|
|
751
1520
|
}
|
|
752
1521
|
// -- sending --------------------------------------------------------------
|
|
@@ -768,12 +1537,19 @@ export class ReportWidget {
|
|
|
768
1537
|
...(who ? { identity: who, notify: this.notify } : {}),
|
|
769
1538
|
markers: toWire(this.markers),
|
|
770
1539
|
locale: this.locale,
|
|
1540
|
+
...(this.kind ? { type: this.kind } : {}),
|
|
771
1541
|
};
|
|
772
1542
|
}
|
|
1543
|
+
/** The words the report goes with: the description, else the first mark's note — either one is enough to send. */
|
|
1544
|
+
words() {
|
|
1545
|
+
return this.e.desc.value.trim() || (this.markers.find((m) => m.note.trim())?.note.trim() ?? '');
|
|
1546
|
+
}
|
|
773
1547
|
async send() {
|
|
774
|
-
const description = this.
|
|
1548
|
+
const description = this.words();
|
|
775
1549
|
if (this.sending || !description)
|
|
776
1550
|
return;
|
|
1551
|
+
if (this.marking)
|
|
1552
|
+
this.endMarking(false);
|
|
777
1553
|
this.sending = true;
|
|
778
1554
|
this.error = '';
|
|
779
1555
|
this.paint();
|
|
@@ -792,9 +1568,15 @@ export class ReportWidget {
|
|
|
792
1568
|
return EMPTY_CAPTURE;
|
|
793
1569
|
})
|
|
794
1570
|
: EMPTY_CAPTURE;
|
|
795
|
-
this.job = new ReportJob(capture, globalThis.location?.host ?? '', { url: this.opts.base, key: this.opts.key });
|
|
1571
|
+
this.job = new ReportJob(capture, globalThis.location?.host ?? '', { url: this.opts.base, key: this.opts.key }, this.files);
|
|
796
1572
|
}
|
|
797
1573
|
this.result = await this.job.run(this.envelope(description, this.job.capture));
|
|
1574
|
+
noteSent(this.opts.base, globalThis.location?.host ?? '', {
|
|
1575
|
+
title: titleOf(description),
|
|
1576
|
+
at: Date.now(),
|
|
1577
|
+
status: this.result.status,
|
|
1578
|
+
...(this.result.reportUrl ? { url: this.result.reportUrl } : {}),
|
|
1579
|
+
});
|
|
798
1580
|
this.sentNotify = this.notify && this.who() !== null;
|
|
799
1581
|
this.view = 'sent';
|
|
800
1582
|
this.job = null;
|
|
@@ -802,15 +1584,19 @@ export class ReportWidget {
|
|
|
802
1584
|
this.e.desc.value = '';
|
|
803
1585
|
this.markers = [];
|
|
804
1586
|
this.hideIds.clear();
|
|
1587
|
+
this.kind = null;
|
|
805
1588
|
this.notify = false;
|
|
806
1589
|
this.e.notifyBox.checked = false;
|
|
807
1590
|
this.includedOpen = false;
|
|
1591
|
+
this.files = [];
|
|
1592
|
+
this.fileRefusal = null;
|
|
808
1593
|
this.renderMarks();
|
|
1594
|
+
this.renderFiles();
|
|
809
1595
|
this.engine?.clear();
|
|
810
1596
|
}
|
|
811
1597
|
catch (e) {
|
|
812
1598
|
console.warn('vitrinka: the report did not go through — Retry resumes it', e);
|
|
813
|
-
this.error = this.job?.id ? '
|
|
1599
|
+
this.error = !this.job?.id ? 'create' : this.job.filesPending ? 'files' : 'capture';
|
|
814
1600
|
}
|
|
815
1601
|
finally {
|
|
816
1602
|
this.sending = false;
|
|
@@ -839,26 +1625,188 @@ export class ReportWidget {
|
|
|
839
1625
|
items.push(s.incIdentity);
|
|
840
1626
|
if (this.markers.length)
|
|
841
1627
|
items.push(s.incMarks);
|
|
1628
|
+
if (this.files.length)
|
|
1629
|
+
items.push(s.incFiles);
|
|
842
1630
|
return items;
|
|
843
1631
|
}
|
|
1632
|
+
/** Who the face says you are (vt-8020 D2): the host's person, then the linked member; never a guess. */
|
|
1633
|
+
paintAccount() {
|
|
1634
|
+
const { e, s } = this;
|
|
1635
|
+
const who = this.who();
|
|
1636
|
+
const person = !who ? null : 'email' in who ? { name: who.name ?? '', email: who.email } : this.session ? { name: this.session.reporter.name ?? '', email: this.session.reporter.email } : null;
|
|
1637
|
+
const label = person?.name || person?.email || '';
|
|
1638
|
+
e.whoAv.textContent = who ? initials(label) : '?';
|
|
1639
|
+
e.whoName.textContent = label.split(/[\s@]/)[0] ?? '';
|
|
1640
|
+
e.whoName.hidden = !label;
|
|
1641
|
+
e.whoBtn.setAttribute('aria-label', `${s.account}: ${label || (who ? '' : s.anonymous)}`.replace(/: $/, ''));
|
|
1642
|
+
e.whoBtn.setAttribute('aria-expanded', String(this.menu === 'account'));
|
|
1643
|
+
e.more.setAttribute('aria-label', s.menu);
|
|
1644
|
+
e.more.setAttribute('aria-expanded', String(this.menu === 'more'));
|
|
1645
|
+
e.accountPop.hidden = this.menu !== 'account';
|
|
1646
|
+
e.morePop.hidden = this.menu !== 'more';
|
|
1647
|
+
e.accountPop.setAttribute('aria-label', s.account);
|
|
1648
|
+
e.morePop.setAttribute('aria-label', s.menu);
|
|
1649
|
+
e.accName.textContent = who ? person?.name || person?.email || '' : s.anonymous;
|
|
1650
|
+
e.accMail.textContent = person?.name ? person.email : '';
|
|
1651
|
+
e.accMail.hidden = !e.accMail.textContent;
|
|
1652
|
+
// Only a token the host signed is a sign-in; an asserted email waits for the team like an anonymous report.
|
|
1653
|
+
e.accVia.textContent = who && 'token' in who ? s.signedInByApp : s.anonymousHint;
|
|
1654
|
+
const member = this.member;
|
|
1655
|
+
e.accLinked.hidden = !member;
|
|
1656
|
+
e.accUnlink.hidden = !member;
|
|
1657
|
+
e.accLinked.textContent = member ? s.linkedAs(member.email || member.name || member.workspace) : '';
|
|
1658
|
+
e.accUnlink.textContent = s.unlink;
|
|
1659
|
+
e.accLink.hidden = Boolean(member);
|
|
1660
|
+
setLabel(e.accLink, s.linkVitrinka);
|
|
1661
|
+
const portal = this.session?.portalUrl;
|
|
1662
|
+
e.accPortal.hidden = !portal;
|
|
1663
|
+
if (portal)
|
|
1664
|
+
e.accPortal.setAttribute('href', portal);
|
|
1665
|
+
setLabel(e.accPortal, s.openPortal);
|
|
1666
|
+
setLabel(e.mReports, s.myReports);
|
|
1667
|
+
setLabel(e.mRecents, s.recentRecordings);
|
|
1668
|
+
setLabel(e.mRecord, s.record);
|
|
1669
|
+
setLabel(e.mSettings, s.settings);
|
|
1670
|
+
// Recording lives where the pill does: only a linked member gets it, its recents and the way to vitrinka.
|
|
1671
|
+
e.mRecents.hidden = !this.recordSwitch;
|
|
1672
|
+
e.mRecord.hidden = !this.recordSwitch;
|
|
1673
|
+
// The switch unmounts this card: never while a report is sending or waiting on Try again, which would be lost with it.
|
|
1674
|
+
e.mRecord.disabled = this.sending || this.job !== null;
|
|
1675
|
+
const open = member ? this.opts.base : portal;
|
|
1676
|
+
e.mOpen.hidden = !open;
|
|
1677
|
+
if (open)
|
|
1678
|
+
e.mOpen.setAttribute('href', open);
|
|
1679
|
+
setLabel(e.mOpen, member ? s.openVitrinka : s.openPortal);
|
|
1680
|
+
}
|
|
1681
|
+
paintReports() {
|
|
1682
|
+
const { e, s } = this;
|
|
1683
|
+
setLabel(e.repBack, s.myReports);
|
|
1684
|
+
const local = !this.session;
|
|
1685
|
+
const rows = local
|
|
1686
|
+
? readSent(this.opts.base, globalThis.location?.host ?? '').map((r) => this.row(r.title, r.status === 'quarantined' ? s.waiting : s.steps.received ?? '', r.at, r.url))
|
|
1687
|
+
: this.mine.rows.map((r) => this.row(r.title, s.steps[r.step] ?? r.step, Date.parse(r.updatedAt), r.url));
|
|
1688
|
+
e.repRows.replaceChildren(...rows);
|
|
1689
|
+
const state = local ? 'ok' : this.mine.state;
|
|
1690
|
+
e.repStatus.hidden = state === 'ok' && rows.length > 0;
|
|
1691
|
+
e.repStatus.textContent = state === 'loading' ? s.loading : state === 'failed' ? s.listFailed : s.noReports;
|
|
1692
|
+
e.repLocal.hidden = !local || rows.length === 0;
|
|
1693
|
+
e.repLocal.textContent = s.fromThisBrowser;
|
|
1694
|
+
const portal = this.session?.portalUrl;
|
|
1695
|
+
e.repPortal.hidden = !portal;
|
|
1696
|
+
if (portal)
|
|
1697
|
+
e.repPortal.setAttribute('href', portal);
|
|
1698
|
+
e.repPortal.textContent = s.openPortal;
|
|
1699
|
+
}
|
|
1700
|
+
paintRecents() {
|
|
1701
|
+
const { e, s } = this;
|
|
1702
|
+
setLabel(e.recBack, s.recentRecordings);
|
|
1703
|
+
const rows = readRecents().map((r) => this.row(r.title, '', r.startedAt, r.boardUrl));
|
|
1704
|
+
e.recRows.replaceChildren(...rows);
|
|
1705
|
+
e.recStatus.hidden = rows.length > 0;
|
|
1706
|
+
e.recStatus.textContent = s.noRecordings;
|
|
1707
|
+
}
|
|
1708
|
+
paintLink() {
|
|
1709
|
+
const { e, s } = this;
|
|
1710
|
+
const flow = this.linkFlow;
|
|
1711
|
+
setLabel(e.linkBack, s.linkVitrinka);
|
|
1712
|
+
e.linkLabel.textContent = s.linkCode;
|
|
1713
|
+
e.linkCode.textContent = flow?.start?.user_code ?? '…';
|
|
1714
|
+
e.linkOpenText.textContent = s.openVitrinka;
|
|
1715
|
+
const start = flow?.start;
|
|
1716
|
+
e.linkOpen.hidden = !start;
|
|
1717
|
+
if (start)
|
|
1718
|
+
e.linkOpen.setAttribute('href', start.verifyUrl);
|
|
1719
|
+
// The QR is for another device: a fine pointer (a desk) shows it, a phone is already the other device.
|
|
1720
|
+
const fine = globalThis.matchMedia?.('(pointer: fine)').matches ?? true;
|
|
1721
|
+
e.linkQr.hidden = !start || !fine;
|
|
1722
|
+
if (start && fine && e.linkQr.getAttribute('src') !== start.qrUrl)
|
|
1723
|
+
e.linkQr.setAttribute('src', start.qrUrl);
|
|
1724
|
+
e.linkHint.textContent = s.linkHint;
|
|
1725
|
+
const state = flow?.state ?? 'failed';
|
|
1726
|
+
e.linkWait.textContent = state === 'expired' ? s.linkExpired : state === 'failed' ? s.linkFailed : state === 'waiting' ? s.linkWaiting : s.loading;
|
|
1727
|
+
e.linkRetry.hidden = state !== 'expired' && state !== 'failed';
|
|
1728
|
+
e.linkRetry.textContent = s.retry;
|
|
1729
|
+
}
|
|
1730
|
+
/** 📎, the picker's types, the tray of chips and the refusal line — the tray shows only while there is something in it. */
|
|
1731
|
+
paintFiles() {
|
|
1732
|
+
const { e, s } = this;
|
|
1733
|
+
const locked = this.sending || Boolean(this.job?.id);
|
|
1734
|
+
e.attach.setAttribute('aria-label', s.attach);
|
|
1735
|
+
e.attach.disabled = locked;
|
|
1736
|
+
// maxCount 0: the project switched attaching off — no 📎 to press.
|
|
1737
|
+
e.attach.hidden = this.caps().maxCount === 0;
|
|
1738
|
+
e.fileInput.setAttribute('accept', this.caps().types.join(','));
|
|
1739
|
+
e.tray.hidden = this.view !== 'describe' || (this.files.length === 0 && !this.fileRefusal);
|
|
1740
|
+
e.files.hidden = this.files.length === 0;
|
|
1741
|
+
e.files.setAttribute('aria-label', s.incFiles);
|
|
1742
|
+
e.fileNote.hidden = !this.fileRefusal;
|
|
1743
|
+
e.fileNote.textContent = this.refusalText(this.fileRefusal);
|
|
1744
|
+
for (const [f, chip] of this.chips) {
|
|
1745
|
+
chip.size.textContent = formatBytes(f.size, this.locale);
|
|
1746
|
+
chip.rm.setAttribute('aria-label', s.removeFile(f.name));
|
|
1747
|
+
chip.rm.disabled = locked;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
/** Size and technical details (vt-8020 D9); the size indicator is measured once the pane shows. */
|
|
1751
|
+
paintSettings() {
|
|
1752
|
+
const { e, s } = this;
|
|
1753
|
+
e.sizeLabel.textContent = s.size;
|
|
1754
|
+
for (const [z, btn] of e.sizeButtons) {
|
|
1755
|
+
btn.textContent = s.sizes[z];
|
|
1756
|
+
btn.setAttribute('aria-checked', String(this.size === z));
|
|
1757
|
+
}
|
|
1758
|
+
e.techText.textContent = s.techDetails;
|
|
1759
|
+
e.techBtn.setAttribute('aria-expanded', String(this.techOpen));
|
|
1760
|
+
e.tech.hidden = !this.techOpen;
|
|
1761
|
+
if (this.techOpen && this.view === 'settings') {
|
|
1762
|
+
const rows = techDetails({ version: RECORDER_VERSION, base: this.opts.base, config: this.config, engine: this.engine !== null, locale: this.locale }, s);
|
|
1763
|
+
e.tech.replaceChildren(...rows.flatMap(([k, v]) => [h('dt', {}, k), h('dd', {}, v)]));
|
|
1764
|
+
}
|
|
1765
|
+
if (this.view === 'settings')
|
|
1766
|
+
placeIndicator(e.sizeSeg, e.sizeInd, e.sizeButtons.get(this.size));
|
|
1767
|
+
}
|
|
844
1768
|
paint() {
|
|
845
1769
|
const { e, s } = this;
|
|
846
1770
|
const who = this.who();
|
|
847
1771
|
e.root.setAttribute('lang', this.locale);
|
|
848
1772
|
e.root.classList.toggle('nobutton', !this.button);
|
|
1773
|
+
// The dock and the size (vt-8020 D9): the stylesheet places and scales everything from these two.
|
|
1774
|
+
e.root.dataset.dock = this.dock;
|
|
1775
|
+
e.root.style.setProperty('--vr-scale', String(SIZE_SCALE[this.size]));
|
|
849
1776
|
e.fab.hidden = !this.button || this.marking;
|
|
850
1777
|
e.fabLabel.textContent = s.button;
|
|
851
1778
|
e.fab.setAttribute('aria-expanded', String(this.isOpen));
|
|
1779
|
+
e.fab.setAttribute('aria-description', s.moveHint);
|
|
1780
|
+
e.fab.setAttribute('aria-keyshortcuts', 'Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight');
|
|
852
1781
|
e.fabKbd.hidden = !this.keybind;
|
|
853
1782
|
e.fabKbd.textContent = this.keybind ? keybindLabel(this.keybind) : '';
|
|
854
|
-
|
|
1783
|
+
// The one card stays up while marking (vt-8020 D10): its note lines and Send are where the reporter finishes.
|
|
1784
|
+
e.card.hidden = !this.isOpen;
|
|
1785
|
+
e.card.classList.toggle('busy', this.sending);
|
|
855
1786
|
e.title.textContent = s.title;
|
|
856
|
-
e.gear.setAttribute('aria-label', s.settings);
|
|
857
|
-
e.gear.setAttribute('aria-pressed', String(this.view === 'settings'));
|
|
858
1787
|
e.closeBtn.setAttribute('aria-label', s.close);
|
|
1788
|
+
this.paintAccount();
|
|
859
1789
|
e.describe.hidden = this.view !== 'describe';
|
|
860
1790
|
e.settings.hidden = this.view !== 'settings';
|
|
861
1791
|
e.sent.hidden = this.view !== 'sent';
|
|
1792
|
+
e.reports.hidden = this.view !== 'reports';
|
|
1793
|
+
e.recents.hidden = this.view !== 'recents';
|
|
1794
|
+
e.linking.hidden = this.view !== 'link';
|
|
1795
|
+
if (this.view === 'reports')
|
|
1796
|
+
this.paintReports();
|
|
1797
|
+
if (this.view === 'recents')
|
|
1798
|
+
this.paintRecents();
|
|
1799
|
+
if (this.view === 'link')
|
|
1800
|
+
this.paintLink();
|
|
1801
|
+
e.foot.hidden = this.view !== 'describe';
|
|
1802
|
+
this.paintFiles();
|
|
1803
|
+
e.kindsLabel.textContent = s.kindsLabel;
|
|
1804
|
+
for (const [kind, btn] of e.kindButtons) {
|
|
1805
|
+
btn.textContent = s.kinds[kind];
|
|
1806
|
+
btn.setAttribute('aria-checked', String(this.kind === kind));
|
|
1807
|
+
// The type rides only the create: once the report is on its way a retry cannot change it.
|
|
1808
|
+
btn.disabled = this.sending || Boolean(this.job?.id);
|
|
1809
|
+
}
|
|
862
1810
|
e.prompt.textContent = s.prompt;
|
|
863
1811
|
e.desc.placeholder = s.placeholder;
|
|
864
1812
|
e.attachedText.textContent = s.attached(this.config?.profile.windowSec ?? 60);
|
|
@@ -868,17 +1816,23 @@ export class ReportWidget {
|
|
|
868
1816
|
e.disclose.setAttribute('aria-expanded', String(this.includedOpen));
|
|
869
1817
|
e.included.hidden = !this.includedOpen;
|
|
870
1818
|
e.included.replaceChildren(...this.includedItems().map((t) => h('li', {}, t)));
|
|
871
|
-
e.
|
|
872
|
-
e.
|
|
873
|
-
e.
|
|
1819
|
+
e.desc.disabled = this.sending;
|
|
1820
|
+
e.lines.hidden = this.markers.length === 0;
|
|
1821
|
+
e.linesEmpty.hidden = !this.marking || this.markers.length > 0;
|
|
1822
|
+
e.linesEmpty.textContent = s.linesEmpty;
|
|
1823
|
+
for (const line of this.lines.values()) {
|
|
1824
|
+
line.note.disabled = this.sending;
|
|
1825
|
+
line.rm.disabled = this.sending;
|
|
1826
|
+
}
|
|
874
1827
|
e.notify.hidden = who === null;
|
|
875
1828
|
e.notifyText.textContent = s.notify;
|
|
876
1829
|
e.error.hidden = this.error === '';
|
|
877
|
-
e.error.textContent =
|
|
1830
|
+
e.error.textContent = { '': '', create: s.errorCreate, files: s.errorFiles, capture: s.errorCapture }[this.error];
|
|
878
1831
|
e.whereText.textContent = s.showWhere;
|
|
1832
|
+
e.where.setAttribute('aria-pressed', String(this.marking));
|
|
879
1833
|
e.where.disabled = this.sending || Boolean(this.job?.id);
|
|
880
1834
|
e.send.textContent = this.sending ? s.sending : this.error ? s.retry : s.send;
|
|
881
|
-
e.send.disabled = this.sending ||
|
|
1835
|
+
e.send.disabled = this.sending || this.words() === '';
|
|
882
1836
|
e.bindLabel.textContent = s.shortcut;
|
|
883
1837
|
e.bindBtn.setAttribute('aria-pressed', String(this.recordingBind));
|
|
884
1838
|
e.bindBtn.setAttribute('aria-label', `${s.shortcut}: ${this.keybind ? keybindLabel(this.keybind) : s.notSet} — ${s.recordShortcut}`);
|
|
@@ -889,8 +1843,10 @@ export class ReportWidget {
|
|
|
889
1843
|
e.bindReason.hidden = !this.bindRefused;
|
|
890
1844
|
e.bindReason.textContent = this.bindRefused ? s.needModifier : '';
|
|
891
1845
|
e.back.textContent = s.back;
|
|
1846
|
+
this.paintSettings();
|
|
892
1847
|
e.sentTitle.textContent = s.sentTitle;
|
|
893
|
-
|
|
1848
|
+
// Filed or waiting: an unsigned report is checked by the team before it is filed, and says so.
|
|
1849
|
+
e.sentBody.textContent = this.result?.status === 'quarantined' ? s.sentQueued : this.sentNotify ? s.sentNotify : s.sentBody;
|
|
894
1850
|
e.seeText.textContent = s.seeReport;
|
|
895
1851
|
const url = this.result?.reportUrl;
|
|
896
1852
|
e.see.hidden = !url;
|
|
@@ -901,13 +1857,20 @@ export class ReportWidget {
|
|
|
901
1857
|
e.sentClose.textContent = s.close;
|
|
902
1858
|
e.mark.hidden = !this.marking;
|
|
903
1859
|
e.toolbar.setAttribute('aria-label', s.toolbar);
|
|
1860
|
+
e.seg.setAttribute('aria-label', s.toolbar);
|
|
1861
|
+
e.barLead.textContent = s.barLead;
|
|
904
1862
|
for (const [tool, btn] of e.toolButtons) {
|
|
905
|
-
|
|
906
|
-
|
|
1863
|
+
const label = e.toolLabels.get(tool);
|
|
1864
|
+
if (label)
|
|
1865
|
+
label.textContent = s.tools[tool];
|
|
1866
|
+
btn.setAttribute('aria-checked', String(this.tool === tool));
|
|
907
1867
|
}
|
|
908
|
-
e.
|
|
909
|
-
e.
|
|
910
|
-
e.
|
|
1868
|
+
e.cancel.textContent = s.cancelMarking;
|
|
1869
|
+
e.cancel.hidden = this.confirming;
|
|
1870
|
+
e.ask.hidden = !this.confirming;
|
|
1871
|
+
e.askText.textContent = s.discardMarks(this.markers.filter((m) => !this.passKeys.has(m.key)).length);
|
|
1872
|
+
e.discard.textContent = s.discard;
|
|
1873
|
+
e.keep.textContent = s.keep;
|
|
911
1874
|
e.coach.hidden = !this.marking || this.markers.length > 0;
|
|
912
1875
|
e.coachText.textContent = s.coach;
|
|
913
1876
|
e.coachMore.textContent = s.coachMore;
|
|
@@ -918,8 +1881,9 @@ export class ReportWidget {
|
|
|
918
1881
|
if (label.textContent)
|
|
919
1882
|
label.textContent = s.hidden;
|
|
920
1883
|
}
|
|
921
|
-
this.renderPins();
|
|
922
1884
|
}
|
|
1885
|
+
// Always: the note lines live in the card, so their labels follow the locale outside marking too.
|
|
1886
|
+
this.renderPins();
|
|
923
1887
|
}
|
|
924
1888
|
}
|
|
925
1889
|
function renumberDrawn(markers) {
|