# User-manual source

The Chinese user manual lives at [`../user-manual.html`](../user-manual.html) — a
single self-contained HTML file with every screenshot inlined as base64. That file
is **generated**; edit the sources here, don't hand-edit the output.

## Files

- `template.html` — the manual's content + styles. Screenshots are referenced with
  `__IMG:<name>__` tokens (e.g. `__IMG:a-deposits__`).
- `shots/` — the source screenshots (`<name>.jpg`). `a-*` render in a browser frame,
  `p-*` in a phone frame.
- `build.mjs` — inlines the shots and writes `../user-manual.html`.

## Rebuild

```
node docs/manual-src/build.mjs
```

The build fails loudly if a `__IMG:__` token has no matching `shots/<name>.jpg`, or
if any `__TOKEN__` is left unreplaced.

## Adding a screenshot

1. Force the app to `zh-HK` first — `localStorage['rms-admin-lang'|'rms-portal-lang']
   = 'zh-HK'`, then reload. The admin defaults to English, so skipping this gives you
   an English shot for a Chinese manual.
2. Capture at the house viewport:

   | | CSS viewport | device scale | resulting JPEG |
   |---|---|---|---|
   | admin (`a-*`) | 1700 × 1117 | 1× | 1700 × 1117 |
   | portal (`p-*`) | 360 × 744 | 2× | 720 × 1488 |

   The admin is shot at 1× on a wide viewport so the whole page fits — sidebar,
   toolbar and every table column. The manual lays these out at roughly 880px, so
   1700 is already about 2× effective; a true 2× desktop shot is 2800px wide and 50
   of those would nearly triple a document that already ships as one 7.6 MB file
   through `/api/manual`. The portal is the opposite case: its layout has to stay at
   phone width, so 360 CSS px is the only way to get the mobile rendering, and that
   needs 2× to be readable. Every referenced shot now matches the table; the one
   off-spec file left, 920-wide `_portal-error.jpg`, is an orphan the `__IMG:`
   regex could never match anyway — it does not take a leading underscore.
3. Save as JPEG into `shots/<name>.jpg` (`a-` prefix = admin, `p-` = portal).
4. Reference it in `template.html` with `__IMG:<name>__` — a shot nothing references is
   dead weight the build never notices.
5. Rebuild.

## Re-shooting in bulk

`capture.mjs` drives a real browser against a running dev stack, so re-shooting is one
command rather than an afternoon of hand-cropping — which is how the shots went two
months stale in the first place. Start the API and both front ends, then:

```
node docs/manual-src/capture.mjs              # every wired-up shot
node docs/manual-src/capture.mjs a-metering   # just these
node docs/manual-src/build.mjs                # inline them
```

It forces `zh-HK` before the bundle boots (the admin defaults to English) and uses the
viewports above, so every file lands at the same size.

`build.mjs` reads each JPEG's own dimensions into `width`/`height` on the `<img>`, so
the document does not reflow while 50 images decode. It also writes `alt=""`: every
shot sits in a `<figure>` whose Chinese `<figcaption>` already describes it.
