# HTML Actions Authoring Guide — DSLR Remote Pro (Windows) Embed interactive HTML inside a DSLR Remote Pro photo booth screen (a game, a form, a quiz, a custom overlay) and exchange data with the rest of the app — read tokens, write tokens, trigger touchscreen actions. This is the guide for the *page author*. The native side (the Web View Panel, a Microsoft Edge WebView2 control) builds the bridge automatically; you do not need to register anything. > The companion guide for Breeze Booth (iPad) is `HTML_ACTIONS.md`. The API is deliberately the same; the differences are listed in `API_DIFFERENCES.md`. --- ## 1. The runtime API When Remote Pro mounts your HTML in its web view panel, it injects a `window.bb` object **before any of your scripts run**. It exposes: | API | Direction | Purpose | |---|---|---| | `window.bb.tokens` | app → page | Read-only snapshot of the substitution map (the `{curly}` tokens). | | `window.bb.setToken(key, value)` | page → app | Write a value back to the app. Surfaces as `{_}`. | | `window.bb.runAction(name)` | page → app | Trigger a touchscreen action by its editor caption (e.g. `Start photobooth`). | | `window.bb.actionId` | app → page | The panel's **Token id** (the Web View Panel setting). | | `window.bb.close()` | page → app | Remote Pro extra: hide the web view panel. | `window.bb` is **not present** when the file is opened in a regular browser (for design / preview work). Always feature-check before calling — see the helpers below. ### Recommended helpers Paste these at the top of your script and use them everywhere (identical to the iPad guide): ```js function bbGet(key, fallback) { if (window.bb && window.bb.tokens && Object.prototype.hasOwnProperty.call(window.bb.tokens, key)) { const v = window.bb.tokens[key]; return (v === '' || v == null) ? fallback : v; } return fallback; } function bbSet(key, value) { if (window.bb && typeof window.bb.setToken === 'function') { window.bb.setToken(key, String(value)); } } function bbRun(actionName) { if (window.bb && typeof window.bb.runAction === 'function') { window.bb.runAction(actionName); } } ``` The fallbacks make the page usable in a desktop browser for layout/styling work — `bbGet` returns the fallback you pass in, `bbSet` and `bbRun` no-op. --- ## 2. Reading tokens (`window.bb.tokens`) `window.bb.tokens` is a plain object whose **keys include the curly braces**, exactly as they appear in Remote Pro's substitution system. ```js const event = bbGet('{eventName}', ''); const input = bbGet('{user_data}', ''); // touchscreen keyboard input const qr = bbGet('{qr1}', ''); // first scanned QR string ``` The snapshot contains everything Remote Pro's own substitutions can see, including: `{eventName}`, `{eventDate}`, `{eventId}`, `{eventString1}`–`{eventString5}`, `{eventKite*}`, `{computerName}`, `{printTemplateName}`, `{eventPrintCounter}`, `{eventPrintTotal}`, `{user_data}` / `{user_data}` keyboard input, survey tags, `{qr1}`–`{qr10}` QR strings, `{PhotoboothText1}`–`{PhotoboothText5}`, values previously written with `setToken` (`{_}`), and the `%`-style date/time tokens (`%Y`, `%m`, `%D`, `%t`, …). ### Important: it's a snapshot The token map is captured when the panel is shown / navigates. **It does not refresh while the page stays loaded.** If you need a value that changes during the session, capture it once at start; a full page reload picks up the snapshot registered the last time the panel was shown. --- ## 3. Writing tokens (`window.bb.setToken`) Values written from your page land in the app as `{_}`, where `` is the **Token id** field in the Web View Panel settings (default `webview`). ```js // With Token id = "soccer" bbSet('score', 7); // → {soccer_score} = "7" bbSet('streak', 3); // → {soccer_streak} = "3" bbSet('player', 'Alice'); // → {soccer_player} = "Alice" ``` The values are merged into **every** substitution Remote Pro performs, so they are usable wherever any `{token}` works — filename templates, email/SMS bodies, print layout text, captions, overlay text, sharing URLs, the Status URL, etc. ### Overwrite semantics Calling `setToken` with the same key replaces the previous value. There's no append — the page is the authoritative source for its own keys. ### Value coercion Everything becomes a string on the way through. Pass numbers, booleans, anything — the helper wraps with `String(...)`. `null` and `undefined` become the string `""`. ### Key rules Keys become part of a substitution tag, so they are sanitised on the native side: characters outside `A–Z a–z 0–9 _ -` are replaced with `_`, keys are capped at 64 characters, and an empty/unusable key is ignored (logged as `DIAG-WebViewBB: setToken ignored`). ### Lifetime Values are cleared at the start of each photo booth session (the same reset that clears QR strings and session ids). For "use the value in the email being sent right now" this is exactly right; for "remember the high score across sessions" you'd need to persist it elsewhere (out of scope for this doc). --- ## 4. Triggering touchscreen actions (`window.bb.runAction`) Invoke any touchscreen action by the **caption shown in the touchscreen editor** — the same names the Status URL `ts` command uses. Common ones: | Action caption | Effect | |---|---| | `Start photobooth` | Begin a capture (countdown + photos). | | `Photo start` / `Video/GIF start` | Start in a specific mode. | | `Switch from ready to standby` | Drop to standby. | | `Switch from standby to ready` | Wake from standby. | | `Photo info open` / `Photo info close` | Open/close the info screens. | | `Select B&W mode` / `Select color mode` | Change capture style. | | `Web view: close` | Close this panel (same as `bb.close()`). | The full list is the action list in the touchscreen editor (Photobooth Settings > Start options: Touchscreen > Settings…). ```js document.getElementById('takePhoto').addEventListener('click', () => bbRun('Start photobooth')); ``` Caption matching is forgiving: case, spaces and the characters `: + ( ) &` are ignored, so `startphotobooth` also works. ### Breeze Booth (iPad) action names are accepted as aliases To let pages written for Breeze Booth run unchanged, these `PhotoboothAction` enum names are translated automatically: | iPad name | Runs the Remote Pro action | |---|---| | `stillsStart` | Photo start | | `gifStart` | Video/GIF start | | `videoStart` | Start video capture | | `videoEnd` | Stop video capture | | `stillsPhotoAccept` | Preview: accept | | `stillsPhotoRetake` | Preview: retake | | `standBy` | Switch from ready to standby | | `switchToStillsAndStart` | Select photobooth+start | | `switchToVideoAndStart` / `switchToGifAndStart` | Select video booth+start | | `exit` | Exit fullscreen photobooth | Each translation is logged (`DIAG-WebViewBB: Breeze Booth action alias mapped to '…'`). **Not** mapped (no safe Remote Pro equivalent, dropped like any unknown caption): `cancelCountdown`, `exitFromReady`, `exitFromStandby`. ### State gating Actions are processed by the same path as the Status URL `ts` command. If the action name is unknown or does not apply to the current screen, the call is **silently dropped** and a `DIAG-WebView` line is written to the log (`DSLRRemotePro.log`). There is no error callback to the page — design your UI to not rely on a response. ### Common pitfall: the panel does not live on every screen `runAction('Start photobooth')` moves the booth off the ready screen. If the countdown/capture screens are not among the panel's configured screens, the panel is hidden (the page and its JS state survive — see §5 — but the guest can no longer see it). Plan which screens the panel should be visible on before wiring actions. --- ## 5. Configuration The panel is configured per profile in **Photobooth Settings > Start options: Touchscreen > Settings… > Web view panel…** (and its rectangle is positioned in the visual touchscreen editor): | Setting | Purpose | |---|---| | Enable web view panel | Master switch. | | URL | `https://`, `http://` or `file:///` page to load. Sibling CSS/JS/images next to a local file load fine. | | Display on these screens | Check boxes for ready / info / preview / standby / video ready / video info / before/after session. Leave all unchecked for manual-only (touchscreen actions `Web view: open` / `Web view: close`). | | Hide after (secs) | Inactivity auto-hide, 0 = never. | | Allowed hosts | `';'`-separated navigation allow list; blank = the host of the URL only. The booth is a kiosk — navigation outside the list is blocked. | | **Token id** | Namespaces `setToken` writes as `{_}` and is exposed as `window.bb.actionId`. Blank falls back to `webview`. | ### Show/hide behaviour (vs the iPad "diff" remount) Remote Pro keeps **one** panel instance. When the booth changes screen: - Screen is in the panel's list → the panel stays (or is shown); the page, its JS heap and in-page state are **preserved**. - Screen is not in the list → the panel is **hidden, not destroyed** — the page survives and reappears intact when a listed screen returns. (The browser process may be suspended while hidden.) - The page is only torn down/navigated when the profile's URL changes, the profile is switched, or the booth exits. **Implication.** The iPad rule "list both states in `screens` so the page survives the transition" translates to: check every screen the guest should *see* the panel on. State the page holds in JS survives being hidden either way. A manually opened panel (action `Web view: open`) is deliberately not carried across a screen change. --- ## 6. Worked example — a scored mini-game on the ready screen A game that reads the guest's keyboard input, starts the booth when they tap PLAY, pushes the running score on every goal, and pushes the final stats. Settings: URL = `file:///C:/booth/game/soccer.html`, Token id = `soccer`, screens = Ready (and any others the guest should see it on). ```html ``` Using the values elsewhere, e.g. the email body: ``` Hi {user_data}, You scored {soccer_score} out of {soccer_attempts} ({soccer_accuracy}%) - see attached! ``` The values are available everywhere the substitution system runs. --- ## 7. Debugging - **Page does nothing when opened in a browser.** Expected — `window.bb` only exists inside the booth's panel. The helpers in §1 return fallbacks so layout/styling can be worked on outside the app. - **`setToken` value doesn't show up.** Check the **Token id** setting matches the token you're reading (`Token id = soccer` → `{soccer_…}`, not `{score_…}`). Every accepted write is logged: `DIAG-WebViewBB: setToken {soccer_score} = '7'`. - **`runAction` doesn't fire.** Check `DSLRRemotePro.log` — the request is logged (`DIAG-WebView: page requested touchscreen action '…'`); if nothing happens after it, the caption is wrong or the action doesn't apply to the current screen. - **`window.bb` is missing on the page.** Look for `DIAG-WebViewBB: bootstrap script registration FAILED` in the log; also confirm the panel navigated after the profile loaded (the script is registered when the panel is shown). - **Tokens look stale.** They are — `window.bb.tokens` is a snapshot from when the panel was shown/navigated. Reload the page (or close/open the panel) for a fresh snapshot. - **Navigation is blocked.** `DIAG-WebView: navigation blocked by the allow list` — add the host to Allowed hosts. ## 8. Touch input The WebView2 control handles taps on your HTML content directly — `