diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ec3979..7dd0b70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.89.41 - 2026-11-15 + +### Documentation + +- **Guide:** new sections for race day (one Race Controller Master, check-in, marshals, fixed breaks, decoder alarm, protected qualifying and finals, results as PDF, lap chart, one transponder in two classes), for fixing a series (đ link a deleted duplicate, merge two drivers, â result for a race run elsewhere, the day's CSV) and for the driver's own page (QR link, Standard / Pro, stint cards, đ My race today). The race wizard text covers the whole-day presets and the driver picker grouped by class. +- **READMEs:** merging drivers, the same-class transponder block, the series đ link and đ shortcut, the race day CSV, and what a second computer that is not the master can and can't change. +- **Video guides:** two new clips - *A cup day* (check-in, protected heats, fixing a duplicate in the standings, the day's CSV) and *Training stats, Standard/Pro and the next heat on the phone*. Every clip is re-recorded; picture and narration now stay in step (frames are shown for as long as they were on screen, instead of spread evenly). Refreshed screenshots: Race Setup wizard, Series / cup and the Guide. + ## 1.89.40 - 2026-11-15 ### Added diff --git a/README.md b/README.md index d1d7b25..464f3dd 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,8 @@ Menu **Series / cup** runs a championship over any number of rounds, with freely - The day placing comes from the final standings (A before B), then qualifying order. - No registered lap gives 0. Absence counts as 0 and can be dropped. - **â Result** on a round sets the day's order by hand (âČâŒ, add, remove), e.g. when the qualifying went wrong. It replaces the calculated result in the standings, and the round is marked Corrected result. Use the calculated result goes back. + - **đ Link to driver:** when one driver shows on two rows (results left on a deleted duplicate) the row gets a picker - choose the right driver and the rows are merged. + - **đ** on a round that has run downloads the day's CSV for that class (see Data, backups and import/export). - Ties go to most wins, then 2nd places, then the latest common round. - Print, or export as PDF (wide tables switch to landscape). @@ -314,6 +316,8 @@ The **Overlay** menu has leaderboard, speaker, results, TV and team modes, plus - **Search** on name, transponder, brand, club or country, **Class** to show just one class, and **Sort by** name, class, club, transponder or brand (â/â reverses). Sort and grouping are remembered in the browser. - **Country** (optional): pick from the list or type it ("Sweden", "SE" and "SWE" work too). The driver then gets a small flag before the name in timing, Race Day, the overlay and OBS, start lists, results, printouts and PDFs. No country, no flag. The flags are in the repo (`src/flags`), so they work offline. OBS can turn them off under **Show flags**. - **Select** drivers with the boxes (or **Select all shown**) and **Delete selected**; a confirm names them first. Deleting, one or many, also removes the drivers from every heat, participant list and team. +- **Merge with another driver** (edit the driver): the same person entered twice. Every heat, lap, result, entry, check-in, series point and training lap moves to the driver you keep, and the duplicate is removed. Only the Race Controller Master can merge. +- **The same transponder twice in one class** is refused (the decoder can't tell the laps apart). The same person in another class is fine - the lap goes to the driver who is in the running heat. ### Data, backups and import/export @@ -330,6 +334,7 @@ The **Overlay** menu has leaderboard, speaker, results, TV and team modes, plus - Race Day shows "đ Result saved", and the Results archive has the list **đ Saved PDFs**. The files are not part of the server backup (that covers the database), so copy the folder to keep them long term. - **Ask to print when the finals are done** shows a **đš Print results** button when the last final is done. A browser cannot print without a click; for fully automatic printing start Chrome with `--kiosk-printing`, which prints straight to the default printer when the button is pressed. - **Export/import** (Settings â Storage): + - **đ CSV for the race day** (Results archive: pick the same date in From and To, and a class or all): first a summary per heat (place, laps, total time, best and average lap), then every lap in running order with transponder, lap time, time of day and whether the lap counted. Semicolons and UTF-8 with BOM, so Excel opens it in columns. Every series round that has run has a đ shortcut. - full JSON, or the directory only (classes, drivers, cars); - CSV for drivers and cars (Excel/LibreOffice; comma, semicolon or tab). The CSV import merges: it matches on ID, then transponder, then name + class. - a single race package from Race Setup; @@ -348,7 +353,7 @@ Erik Eriksson;654321;4WD;Associated;; RaceCore is meant for a trusted race network: - **Admin PIN** (Settings â System & backup, off by default) protects every change through the API. The login lasts 30 days and is throttled against guessing. -- **Race Controller Master:** one computer at a time runs the race (the decoder, start, pause, resume, stop, false start, resetting a heat and the autopilot, also from the speaker panel). Judging corrections and the other calls work from any computer. The computer running the server (page opened on `localhost`) becomes master on its own and shows a green line "đ You are the Race Controller Master" with **Release master**. Phones and other computers follow the race live (updated every second), show "You are following the race âŠ" and become master only when someone presses the button; that computer then remembers the role. They can also prepare drivers and races. Whoever works as race controller presses **Take over as master**, and the previous master lets go of the decoder within seconds. With the admin PIN on, taking over needs a login. Name the computer under Settings â System, e.g. "Speaker booth". Overlays and OBS are always view-only. +- **Race Controller Master:** one computer at a time runs the race (the decoder, start, pause, resume, stop, false start, resetting a heat and the autopilot, also from the speaker panel). Judging corrections and the other calls work from any computer. The computer running the server (page opened on `localhost`) becomes master on its own and shows a green line "đ You are the Race Controller Master" with **Release master**. Phones and other computers follow the race live (updated every second), show "You are following the race âŠ" and become master only when someone presses the button; that computer then remembers the role. They can also prepare drivers and races. Whoever works as race controller presses **Take over as master**, and the previous master lets go of the decoder within seconds. With the admin PIN on, taking over needs a login. Name the computer under Settings â System, e.g. "Speaker booth". Overlays and OBS are always view-only. Other computers can't change the race by mistake: when they save (pick a heat to look at, or hold an old copy) the server keeps the master's active heat, each heat's status and clock, the laps and the heats that have run. A run heat only goes back to Ready through Reset. Qualifying and finals that have run are never made again by mistake - Clear generated ... names the run heats and asks first. - **House of RC:** under Settings â System â đ House of RC you save the club's API key once (stored on the server only, never shown again) and press **Test connection**. Drivers â **đ Fetch from House of RC** fills in names and brands from the transponders (only what you tick), and a known transponder fills in a new driver. With the key of the club running the event, the race wizard's **đ Fetch from House of RC** lists the club's events; pick an event and one of its classes, and the name, date, class and entered drivers with their transponders are filled in. Later, Manage â Participants â **đ Fetch changes from House of RC** adds late entries and takes out withdrawals. **đ€ Send results to House of RC** previews and sends the results to the entries: heats and qualifying during the day, the final placings when the finals are run. Only drivers entered on House of RC (with their own account) get results there; others are listed as not sent. Tick **Send heats automatically** and the race controller sends heats and qualifying after every heat by itself (semi-live), retrying without internet; the final placings are always sent by hand. - **`RC_ADMIN_ALLOWED_CIDRS`** restricts admin changes to certain addresses or networks, e.g. `192.168.1.0/24`. - **`RC_ALLOWED_ORIGINS`** is for a UI deliberately served from another address. @@ -364,6 +369,7 @@ Short narrated recordings (`.mkv`, H.264/AAC), also linked from the in-app Guide - **Interface tour:** [Settings tabs](docs/videos/settings-tabs.mkv) · [Event Manager tabs](docs/videos/event-manager-tabs.mkv) · [Race day schedule](docs/videos/event-schedule.mkv) - **Race day and after:** [Sponsor event](docs/videos/sponsor-event.mkv) · [Team race](docs/videos/team-race.mkv) · [Open practice ranking](docs/videos/practice-ranking.mkv) · [Race overview and archive](docs/videos/race-overview.mkv) · [Judging: calls, penalties and DSQ](docs/videos/judging.mkv) - **House of RC:** [Fetch entries, late entries and send results](docs/videos/house-of-rc.mkv) +- **Race day and phone:** [A cup day - check-in, qualifying, finals, fixing a duplicate and the day's CSV](docs/videos/cup-day.mkv) · [Training stats, Standard/Pro and the next heat on the phone](docs/videos/driver-page.mkv) Recorded with `node scripts/record-video-guides.mjs`, against an isolated test server. diff --git a/README.sv.md b/README.sv.md index 5ea76a2..04b255e 100644 --- a/README.sv.md +++ b/README.sv.md @@ -224,6 +224,8 @@ Menyn **Serier / cup** kör ett mĂ€sterskap över valfritt antal deltĂ€vlingar, - Dagens placering kommer frĂ„n slutresultatet (A före B), sedan kvalordningen. - Inget registrerat varv ger 0. FrĂ„nvaro rĂ€knas som 0 och kan strykas. - **â Resultat** pĂ„ en deltĂ€vling sĂ€tter dagens ordning för hand (âČâŒ, lĂ€gg till, ta bort), t.ex. nĂ€r kvalet blev fel. Den ersĂ€tter appens utrĂ€kning i stĂ€llningen, och deltĂ€vlingen mĂ€rks RĂ€ttat resultat. AnvĂ€nd appens resultat gĂ„r tillbaka. + - **đ Koppla till förare:** stĂ„r samma förare pĂ„ tvĂ„ rader (resultat kvar pĂ„ en borttagen dubblett) fĂ„r raden en vĂ€ljare - vĂ€lj rĂ€tt förare sĂ„ slĂ„s raderna ihop. + - **đ** pĂ„ en körd deltĂ€vling laddar ner dagens CSV för den klassen (se Data, backup och export/import). - Lika poĂ€ng avgörs av flest segrar, sedan andraplatser, sedan senaste gemensamma deltĂ€vling. - Skriv ut eller exportera som PDF (breda tabeller blir liggande A4). @@ -327,6 +329,8 @@ Menyn **Overlay** har lĂ€gena leaderboard, speaker, resultat, TV och lag, plus e - **Sök** pĂ„ namn, transponder, mĂ€rke, klubb eller land, **Klass** för att bara visa en klass och **Sortera pĂ„** namn, klass, klubb, transponder eller mĂ€rke (â/â vĂ€nder). Sortering och gruppering sparas i webblĂ€saren. - **Land** (valfritt): vĂ€lj i listan eller skriv ("Sverige", "SE" och "SWE" fungerar ocksĂ„). Föraren fĂ„r dĂ„ en liten flagga före namnet i tidtagning, Race Day, overlay och OBS, startlistor, resultat, utskrifter och PDF. Inget land, ingen flagga. Flaggorna ligger i repot (`src/flags`), sĂ„ de fungerar utan internet. OBS kan stĂ€nga av dem med **Visa flaggor**. - **Markera** förare med rutorna (eller **Markera alla som visas**) och **Radera markerade**; en bekrĂ€ftelse visar namnen först. Radering, en eller flera, tar ocksĂ„ bort förarna frĂ„n alla heat, deltagarlistor och team. +- **SlĂ„ ihop med en annan förare** (redigera föraren): samma person inlagd tvĂ„ gĂ„nger. Alla heat, varv, resultat, anmĂ€lningar, incheckning, seriepoĂ€ng och trĂ€ningsvarv flyttas till den förare du behĂ„ller, och dubbletten tas bort. Bara Race Controller Master kan slĂ„ ihop. +- **Samma transponder tvĂ„ gĂ„nger i en klass** stoppas (decodern kan inte skilja varven Ă„t). Samma person i en annan klass gĂ„r bra - varvet gĂ„r dĂ„ till den förare som Ă€r med i heatet som körs. ### Data, backup och export/import @@ -343,6 +347,7 @@ Menyn **Overlay** har lĂ€gena leaderboard, speaker, resultat, TV och lag, plus e - Race Day visar "đ Resultat sparat", och Resultatarkivet har listan **đ Sparade PDF:er**. Filerna ingĂ„r inte i serverbackupen (den gĂ€ller databasen), sĂ„ kopiera mappen om de ska sparas lĂ€nge. - **FrĂ„ga om utskrift nĂ€r finalerna Ă€r klara** visar knappen **đš Skriv ut resultat** nĂ€r sista finalen Ă€r klar. En webblĂ€sare kan inte skriva ut utan klick; vill du ha helt automatisk utskrift kan Chrome startas med `--kiosk-printing`, dĂ„ skrivs det ut direkt pĂ„ standardskrivaren nĂ€r du trycker pĂ„ knappen. - **Export/import** (InstĂ€llningar â Lagring): + - **đ CSV för racedagen** (Resultatarkivet: vĂ€lj samma datum i FrĂ„n och Till, och en klass eller alla): först en sammanfattning per heat (placering, varv, totaltid, bĂ€sta och snittvarv), sedan varje varv i körordning med transponder, varvtid, klockslag och om varvet rĂ€knades. Semikolon och UTF-8 med BOM, sĂ„ Excel öppnar den i kolumner. Varje körd seriedeltĂ€vling har en đ-genvĂ€g. - full JSON, eller bara registret (klasser, förare, bilar); - CSV för förare och bilar (Excel/LibreOffice; komma, semikolon eller tab). CSV-importen slĂ„r ihop: den matchar pĂ„ id, sedan transponder, sedan namn + klass. - ett enskilt racepaket frĂ„n Race Setup; @@ -361,7 +366,7 @@ Erik Eriksson;654321;4WD;Associated;; RaceCore Ă€r tĂ€nkt för ett betrott racenĂ€tverk: - **Admin-PIN** (InstĂ€llningar â System & backup, av som standard) skyddar alla Ă€ndringar via API:t. Inloggningen gĂ€ller i 30 dagar och Ă€r skyddad mot gissning. -- **Race Controller Master:** bara en dator Ă„t gĂ„ngen kör racet (decodern, start, paus, fortsĂ€tt, stopp, tjuvstart, nollstĂ€ll heat och autopiloten, Ă€ven frĂ„n speakerpanelen). Domarvyns korrigeringar och övriga utrop fungerar frĂ„n alla datorer. Datorn som kör servern (sidan öppnad pĂ„ `localhost`) blir master av sig sjĂ€lv och visar en grön rad "đ Du Ă€r Race Controller Master" med **SlĂ€pp master**. Mobiler och andra datorer följer racet live (uppdateras varje sekund), visar "Du följer racet âŠ" och blir master bara nĂ€r nĂ„gon trycker pĂ„ knappen; den datorn minns sedan rollen. De kan ocksĂ„ förbereda förare och race. Den som jobbar som race controller trycker **Ta över som master**, och den förra mastern slĂ€pper decodern inom nĂ„gra sekunder. Med admin-PIN krĂ€vs inloggning för att ta över. Ge datorn ett namn under InstĂ€llningar â System, t.ex. "SpeakerbĂ„set". Overlays och OBS Ă€r alltid bara visning. +- **Race Controller Master:** bara en dator Ă„t gĂ„ngen kör racet (decodern, start, paus, fortsĂ€tt, stopp, tjuvstart, nollstĂ€ll heat och autopiloten, Ă€ven frĂ„n speakerpanelen). Domarvyns korrigeringar och övriga utrop fungerar frĂ„n alla datorer. Datorn som kör servern (sidan öppnad pĂ„ `localhost`) blir master av sig sjĂ€lv och visar en grön rad "đ Du Ă€r Race Controller Master" med **SlĂ€pp master**. Mobiler och andra datorer följer racet live (uppdateras varje sekund), visar "Du följer racet âŠ" och blir master bara nĂ€r nĂ„gon trycker pĂ„ knappen; den datorn minns sedan rollen. De kan ocksĂ„ förbereda förare och race. Den som jobbar som race controller trycker **Ta över som master**, och den förra mastern slĂ€pper decodern inom nĂ„gra sekunder. Med admin-PIN krĂ€vs inloggning för att ta över. Ge datorn ett namn under InstĂ€llningar â System, t.ex. "SpeakerbĂ„set". Overlays och OBS Ă€r alltid bara visning. Andra datorer kan inte Ă€ndra racet av misstag: sparar de (byter heat att titta pĂ„, eller har en gammal kopia öppen) behĂ„ller servern masterns aktiva heat, heatens status och klocka, varven och heat som körts. Ett kört heat gĂ„r bara tillbaka till Redo via NollstĂ€ll. Körda kval och finaler skapas aldrig om av misstag - Rensa genererade ... namnger de körda heaten och frĂ„gar först. - **House of RC:** under InstĂ€llningar â System â đ House of RC sparar du klubbens API-nyckel en gĂ„ng (bara pĂ„ servern, visas aldrig igen) och trycker **Testa anslutning**. Förare â **đ HĂ€mta frĂ„n House of RC** fyller i namn och mĂ€rke utifrĂ„n transpondrarna (bara det du bockar i), och en kĂ€nd transponder fyller i en ny förare. Med nyckeln för klubben som arrangerar tĂ€vlingen listar Race-guidens **đ HĂ€mta frĂ„n House of RC** klubbens tĂ€vlingar; vĂ€lj tĂ€vling och en av dess klasser sĂ„ fylls namn, datum, klass och anmĂ€lda förare med transpondrar i. Senare lĂ€gger Hantera â Deltagare â **đ HĂ€mta Ă€ndringar frĂ„n House of RC** till sena anmĂ€lningar och tar bort avanmĂ€lda. **đ€ Skicka resultat till House of RC** förhandsgranskar och skickar resultatet till anmĂ€lningarna: heat och kval under dagen, slutplaceringen nĂ€r finalerna Ă€r körda. Bara förare som Ă€r anmĂ€lda pĂ„ House of RC (med eget konto) fĂ„r resultat dĂ€r; övriga listas som inte skickade. Bocka i **Skicka heat automatiskt** sĂ„ skickar race controller-datorn heat och kval efter varje heat av sig sjĂ€lv (halvlive) och försöker igen utan internet; slutplaceringen skickas alltid för hand. - **`RC_ADMIN_ALLOWED_CIDRS`** begrĂ€nsar adminĂ€ndringar till vissa adresser eller nĂ€t, till exempel `192.168.1.0/24`. - **`RC_ALLOWED_ORIGINS`** anvĂ€nds för ett grĂ€nssnitt som medvetet körs frĂ„n en annan adress. @@ -377,6 +382,7 @@ Korta inspelningar med berĂ€ttarröst (`.mkv`, H.264/AAC), Ă€ven lĂ€nkade frĂ„n - **Rundtur i grĂ€nssnittet:** [InstĂ€llningsflikar](docs/videos/settings-tabs.mkv) · [Event Managers flikar](docs/videos/event-manager-tabs.mkv) · [Dagens schema](docs/videos/event-schedule.mkv) - **TĂ€vlingsdag och efterĂ„t:** [Sponsorevent](docs/videos/sponsor-event.mkv) · [Lagrace](docs/videos/team-race.mkv) · [Ranking i öppen trĂ€ning](docs/videos/practice-ranking.mkv) · [Race-översikt och arkiv](docs/videos/race-overview.mkv) · [Domare: utrop, straff och DSQ](docs/videos/judging.mkv) - **House of RC:** [HĂ€mta anmĂ€lda, efteranmĂ€lda och skicka resultat](docs/videos/house-of-rc.mkv) +- **TĂ€vlingsdag och mobil:** [En cupdag - incheckning, kval, finaler, rĂ€tta en dubblett och dagens CSV](docs/videos/cup-day.mkv) · [TrĂ€ningsstatistik, Standard/Pro och nĂ€sta heat i mobilen](docs/videos/driver-page.mkv) Spelas in med `node scripts/record-video-guides.mjs`, mot en isolerad testserver. diff --git a/ROADMAP.md b/ROADMAP.md index 955502c..950e569 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1113,6 +1113,12 @@ Closed out 2026-09-12, requested by the user alongside the screenshot refresh ab Deliberately left as pre-existing, lower-priority gaps rather than closing everything in one pass: several older modules (`race_audio.js`, `sync_status.js`, `html_escape.js`, `list_sorting.js`, `results_archive_view.js`, `decoder_diagnostics.js`/`decoder_diagnostics_view.js`) are documented only in later unnumbered appendix sections, not in section 2.2's main per-file inventory or section 3's import graph - real inconsistencies, but not something this session's changes touched, so fixing them was out of scope for "update as modules change." Verified 2026-09-12: re-read every edited section back against the actual source (`grep` for each newly-documented symbol/field/route) to confirm nothing was invented; new subsections inserted between existing numbered ones (`15.1a`, `16.2a`, `16.6a`) use a letter suffix rather than renumbering everything after them. +Refreshed 2026-11-15 (1.89.41), asked by the user: the Guide, READMEs and videos were behind 1.85-1.89. +- [x] Guide: race day (master, check-in, marshals, breaks, decoder alarm, protected heats, result PDFs, lap chart, shared transponder), fixing a series (đ link, merge, â result, day CSV) and the driver's own page (QR, Standard / Pro, stint cards, My race today); wizard steps mention whole-day presets and the grouped picker. Labels checked against the sv/en strings. +- [x] READMEs: merge, same-class transponder block, series đ / đ, race day CSV, follower computers can't change race control. +- [x] Videos: new `cup-day` and `driver-page` clips; all 15 re-recorded. `scripts/record-video-guides.mjs` now gives each frame its real on-screen time (ffmpeg concat with durations) - before, frames were spread evenly while Chrome only sends a frame on change, so picture and narration drifted apart. The phone in `driver-page` is the real public profile in a same-origin frame, with My race today from the master's own posted schedule. +- [x] Screenshots: `race-setup-wizard` (now in `scripts/capture-screenshots.mjs`, step 1 with the EFRA preset), `series`, `guide`. + ## Compare two drivers in training statistics (planned 2026-11-14, postponed) Postponed by the club operator in favour of other items; kept here so the plan isn't lost. diff --git a/docs/screenshots/guide.jpg b/docs/screenshots/guide.jpg index b7cdc29..34464b9 100644 Binary files a/docs/screenshots/guide.jpg and b/docs/screenshots/guide.jpg differ diff --git a/docs/screenshots/race-setup-wizard.jpg b/docs/screenshots/race-setup-wizard.jpg index f4fac6e..88fcf38 100644 Binary files a/docs/screenshots/race-setup-wizard.jpg and b/docs/screenshots/race-setup-wizard.jpg differ diff --git a/docs/screenshots/series.jpg b/docs/screenshots/series.jpg index f94d5db..ca4820c 100644 Binary files a/docs/screenshots/series.jpg and b/docs/screenshots/series.jpg differ diff --git a/docs/videos/add-drivers-cars.mkv b/docs/videos/add-drivers-cars.mkv index db633fc..9ecfa83 100644 Binary files a/docs/videos/add-drivers-cars.mkv and b/docs/videos/add-drivers-cars.mkv differ diff --git a/docs/videos/connect-decoder.mkv b/docs/videos/connect-decoder.mkv index f591984..35c8be7 100644 Binary files a/docs/videos/connect-decoder.mkv and b/docs/videos/connect-decoder.mkv differ diff --git a/docs/videos/create-race.mkv b/docs/videos/create-race.mkv index d85fa06..150fe02 100644 Binary files a/docs/videos/create-race.mkv and b/docs/videos/create-race.mkv differ diff --git a/docs/videos/cup-day.mkv b/docs/videos/cup-day.mkv new file mode 100644 index 0000000..6edf223 Binary files /dev/null and b/docs/videos/cup-day.mkv differ diff --git a/docs/videos/driver-page.mkv b/docs/videos/driver-page.mkv new file mode 100644 index 0000000..0e155f7 Binary files /dev/null and b/docs/videos/driver-page.mkv differ diff --git a/docs/videos/event-manager-tabs.mkv b/docs/videos/event-manager-tabs.mkv index a882a52..d9b0446 100644 Binary files a/docs/videos/event-manager-tabs.mkv and b/docs/videos/event-manager-tabs.mkv differ diff --git a/docs/videos/event-schedule.mkv b/docs/videos/event-schedule.mkv index fc8e522..86ac778 100644 Binary files a/docs/videos/event-schedule.mkv and b/docs/videos/event-schedule.mkv differ diff --git a/docs/videos/house-of-rc.mkv b/docs/videos/house-of-rc.mkv index 281261b..15ced96 100644 Binary files a/docs/videos/house-of-rc.mkv and b/docs/videos/house-of-rc.mkv differ diff --git a/docs/videos/judging.mkv b/docs/videos/judging.mkv index 65ca1e7..7b7ee8e 100644 Binary files a/docs/videos/judging.mkv and b/docs/videos/judging.mkv differ diff --git a/docs/videos/practice-ranking.mkv b/docs/videos/practice-ranking.mkv index 984ca70..00eefdb 100644 Binary files a/docs/videos/practice-ranking.mkv and b/docs/videos/practice-ranking.mkv differ diff --git a/docs/videos/race-overview.mkv b/docs/videos/race-overview.mkv index 65899cd..a633a1c 100644 Binary files a/docs/videos/race-overview.mkv and b/docs/videos/race-overview.mkv differ diff --git a/docs/videos/run-a-session.mkv b/docs/videos/run-a-session.mkv index 533c7dc..973089a 100644 Binary files a/docs/videos/run-a-session.mkv and b/docs/videos/run-a-session.mkv differ diff --git a/docs/videos/settings-tabs.mkv b/docs/videos/settings-tabs.mkv index 3cdd24f..0722064 100644 Binary files a/docs/videos/settings-tabs.mkv and b/docs/videos/settings-tabs.mkv differ diff --git a/docs/videos/sponsor-event.mkv b/docs/videos/sponsor-event.mkv index 0a2ec43..e2549ed 100644 Binary files a/docs/videos/sponsor-event.mkv and b/docs/videos/sponsor-event.mkv differ diff --git a/docs/videos/team-race.mkv b/docs/videos/team-race.mkv index d3e3b5b..87f01ac 100644 Binary files a/docs/videos/team-race.mkv and b/docs/videos/team-race.mkv differ diff --git a/package-lock.json b/package-lock.json index 6df08ee..5ed4db5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.89.40", + "version": "1.89.41", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.89.40", + "version": "1.89.41", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index aa9387e..87c6ea5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.89.40", + "version": "1.89.41", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/scripts/capture-screenshots.mjs b/scripts/capture-screenshots.mjs index 3f7b5f0..8ebd670 100644 --- a/scripts/capture-screenshots.mjs +++ b/scripts/capture-screenshots.mjs @@ -203,6 +203,23 @@ const shots = { await scrollTo(process.env.SHOT_SCROLL || "#seriesForm", process.env.SHOT_SCROLL ? "center" : "start"); }, }, + "race-setup-wizard": { + async setup({ navigate, evaluate, scrollTo, pause: pauseFn }) { + // Step 1 with a whole-day preset picked: its description shows under the choice. + await navigate("race_setup", "#raceWizardStepForm"); + await evaluate(`(() => { + const form = document.getElementById("raceWizardStepForm"); + form.elements.name.value = "Winter Cup #3"; + form.elements.name.dispatchEvent(new Event("input", { bubbles: true })); + form.elements.classId.value = "shot_class"; + form.elements.classId.dispatchEvent(new Event("input", { bubbles: true })); + form.elements.presetId.value = "efra_offroad"; + form.elements.presetId.dispatchEvent(new Event("change", { bubbles: true })); + })()`); + await pauseFn(400); + await scrollTo("#raceWizardStepForm"); + }, + }, guide: { async setup({ navigate }) { await navigate("guide", ".guide-list"); diff --git a/scripts/record-video-guides.mjs b/scripts/record-video-guides.mjs index 80c4e5d..cd77e88 100644 --- a/scripts/record-video-guides.mjs +++ b/scripts/record-video-guides.mjs @@ -130,7 +130,7 @@ async function recordClip(name, { prepare, seedState, setup, steps }) { const initial = { classes: [], drivers: [], cars: [], events: [], sessions: [], resultsBySession: {}, - settings: { language: "en", autoReconnect: false, backendUrl: base, raceAudio: { enabled: false } }, + settings: { language: "en", autoReconnect: false, backendUrl: base, raceAudio: { enabled: false, decoderAlarm: false } }, training: {}, }; seedFn?.(initial); @@ -153,6 +153,9 @@ async function recordClip(name, { prepare, seedState, setup, steps }) { let nextId = 0; const requests = new Map(); let frameCount = 0; + // Chrome only sends a frame when the page changes, so each frame is shown for as long as it + // was really on screen - spreading them evenly would drift away from the narration. + const frameTimes = []; socket.addEventListener("message", (event) => { const message = JSON.parse(event.data); if (message.id) { @@ -162,7 +165,9 @@ async function recordClip(name, { prepare, seedState, setup, steps }) { } else if (message.method === "Page.screencastFrame") { const { data, sessionId } = message.params; frameCount += 1; - writeFileSync(join(framesDir, `frame_${String(frameCount).padStart(6, "0")}.jpg`), Buffer.from(data, "base64")); + const file = `frame_${String(frameCount).padStart(6, "0")}.jpg`; + writeFileSync(join(framesDir, file), Buffer.from(data, "base64")); + frameTimes.push({ file, at: Date.now() }); send("Page.screencastFrameAck", { sessionId }); } else if (message.method === "Page.javascriptDialogOpening") { // A confirm (e.g. "Disqualify ...?") would block headless Chrome: answer yes, as the clip shows. @@ -227,10 +232,19 @@ async function recordClip(name, { prepare, seedState, setup, steps }) { mkdirSync(outputDir, { recursive: true }); const silentVideoPath = join(temporary, "silent.mkv"); - const inputFps = Math.max(1, frameCount / elapsedSec); + const captureEnd = captureStart + elapsedSec * 1000; + const listLines = frameTimes.flatMap((frame, index) => { + const from = index === 0 ? captureStart : frame.at; + const until = frameTimes[index + 1]?.at ?? captureEnd; + return [`file '${join(framesDir, frame.file)}'`, `duration ${Math.max(0.001, (until - from) / 1000).toFixed(3)}`]; + }); + // The concat demuxer needs the last file listed again for its duration to count. + listLines.push(`file '${join(framesDir, frameTimes.at(-1).file)}'`); + const listPath = join(temporary, "frames.txt"); + writeFileSync(listPath, listLines.join("\n") + "\n"); execFileSync("ffmpeg", [ - "-y", "-framerate", inputFps.toFixed(2), "-i", join(framesDir, "frame_%06d.jpg"), - "-c:v", "libx264", "-pix_fmt", "yuv420p", "-r", "30", silentVideoPath, + "-y", "-f", "concat", "-safe", "0", "-i", listPath, + "-vf", "fps=30,format=yuv420p", "-c:v", "libx264", silentVideoPath, ], { stdio: "inherit" }); const audioPath = join(temporary, "narration.wav"); @@ -520,6 +534,25 @@ const clips = { await evaluate('document.getElementById("driverForm").requestSubmit()'); }, }, + { text: "One person can race in several classes on the same transponder. Within one class a transponder can only be used once, because the decoder could not tell the laps apart." }, + { + text: "Entered someone twice? Edit one of them and open Merge with another driver.", + async action({ fill, evaluate, state, click }) { + const classId = (await state()).classes.find((item) => item.name === "2WD Buggy")?.id; + await fill("driverForm", { name: "Alex Karlsson", classId, transponder: "7930009" }); + await evaluate('document.getElementById("driverForm").requestSubmit()'); + let copy; + await waitFor(async () => { copy = (await state()).drivers.find((item) => item.transponder === "7930009"); return copy; }, "second entry saved"); + await waitFor(async () => Boolean(await evaluate(`document.getElementById("driver-edit-${copy.id}")`)), "second entry listed"); + await click(`#driver-edit-${copy.id}`); + await waitFor(async () => Boolean(await evaluate(`document.querySelector(".driver-merge")`)), "edit window"); + await evaluate(`(() => { const box = document.querySelector(".driver-merge"); box.open = true; const select = document.getElementById("driverMergeTarget"); select.value = select.options[1]?.value || ""; box.scrollIntoView({ block: "center" }); })()`); + }, + }, + { + text: "Pick the driver to keep and merge. Heats, laps, results, series points and training laps all move over, and the duplicate is gone.", + async action({ click }) { await click("#driverMergeGo"); }, + }, { text: "And Cars, if you want to track a car separately from its driver.", async action({ clickNav }) { await clickNav("Cars"); }, @@ -537,10 +570,13 @@ const clips = { "create-race": { seedState(state) { const classId = "vid_wizard_class"; - state.classes.push({ id: classId, name: "2WD Buggy" }); + state.classes.push({ id: classId, name: "2WD Buggy" }, { id: "vid_wizard_4wd", name: "4WD Buggy" }); ["Alex Karlsson", "Sam Nilsson", "Jamie Lee", "Robin Berg"].forEach((name, index) => { state.drivers.push({ id: `vid_wizard_driver_${index}`, name, classId, transponder: `794000${index}` }); }); + ["Kim Holm", "Noa Ek"].forEach((name, index) => { + state.drivers.push({ id: `vid_wizard_4wd_${index}`, name, classId: "vid_wizard_4wd", transponder: `794100${index}` }); + }); }, async setup({ navigate }) { await navigate("race_setup", "raceWizardStepForm"); @@ -548,16 +584,21 @@ const clips = { steps: [ { text: "Creating a race has four steps. Let's start with the basics: name, date, and class. A race can also be fetched from House of RC with the house button." }, { - text: "Give the race a name, pick a class and format, then continue.", - async action({ fill, click }) { - await fill("raceWizardStepForm", { name: "Friday Night Race", date: "2026-09-18", classId: "vid_wizard_class", presetId: "club_qualifying" }); - await click("#raceWizardNext"); + text: "Give the race a name and pick a class. Whole race days come as presets: EFRA off-road, touring, nitro, ROAR, a quick club day or rookies. The text under the choice says what it sets.", + async action({ fill, evaluate }) { + await fill("raceWizardStepForm", { name: "Friday Night Race", date: "2026-11-20", classId: "vid_wizard_class" }); + await evaluate(`(() => { const select = document.querySelector('#raceWizardStepForm [name="presetId"]'); select.value = "efra_offroad"; select.dispatchEvent(new Event("change", { bubbles: true })); })()`); }, }, { - text: "Choose who's racing - select everyone, or pick individually - then move on.", - async action({ click }) { - await click("#wizardSelectAllParticipants"); + text: "Continue to the drivers. They are grouped by class, with All and None per class, a search on name or transponder, and Same drivers as, to copy an earlier race.", + async action({ click }) { await click("#raceWizardNext"); }, + }, + { + text: "Tick the whole class with All, then move on.", + async action({ click, evaluate }) { + await evaluate(`document.querySelector('[data-picker-group="vid_wizard_class"] [data-picker-group-all]')?.click() ?? document.querySelector("[data-picker-group-all]")?.click()`); + await pause(700); await click("#raceWizardNext"); }, }, @@ -609,7 +650,7 @@ const clips = { await waitFor(async () => (await evaluate('document.getElementById("raceDayStart")?.disabled')) === false, "start enabled once preflight is ready"); }, steps: [ - { text: "This is Race Day, where every session is run. Practice, a new track layout and new races are one click away at the top." }, + { text: "This is Race Day, where every session is run. The green bar says this computer is the Race Controller Master: it runs the decoder, and other screens only follow." }, { text: "Pick a count-down - here thirty seconds - and press Start. The track opens and the announcer calls the time.", async action({ evaluate, click }) { @@ -805,29 +846,42 @@ const clips = { state.classes.push({ id: classId, name: "2WD Buggy" }); const names = ["Alex Karlsson", "Sam Nilsson", "Jamie Lee", "Robin Berg"]; const ids = names.map((name, index) => { const id = `vid_ov_driver_${index}`; state.drivers.push({ id, name, classId, transponder: `799000${index}` }); return id; }); - const event = { id: "vid_ov_event", name: "Club Race Night", date: "2026-09-18", classId, mode: "race", raceConfig: { participantsConfigured: true, driverIds: ids } }; + const dayStart = Date.now() - 4 * 3600000; + const date = new Date(dayStart).toISOString().slice(0, 10); + const event = { id: "vid_ov_event", name: "Club Race Night", date, classId, mode: "race", raceConfig: { participantsConfigured: true, driverIds: ids } }; state.events.push(event); - // Each heat: who finished where (laps, best lap) - ends a few minutes apart. + // Each heat: who finished where; every lap is a passing, so the lap chart has places to + // draw (the drivers swap places along the way). const heats = [ ["vid_ov_p1", "Practice 1", "practice", [2, 0, 1, 3]], ["vid_ov_q1", "Q1 H1", "qualification", [0, 2, 1, 3]], ["vid_ov_q2", "Q2 H1", "qualification", [0, 1, 2, 3]], ["vid_ov_a", "A Final", "final", [1, 0, 2, 3]], ]; - const dayStart = Date.now() - 4 * 3600000; heats.forEach(([id, name, type, order], heatIndex) => { const startedAt = dayStart + heatIndex * 1800000; state.sessions.push({ id, eventId: event.id, name, type, durationMin: 5, status: "finished", startedAt, endedAt: startedAt + 310000, driverIds: ids }); const competitors = {}; + const passings = []; order.forEach((driverIndex, place) => { const key = ids[driverIndex]; - competitors[key] = { key, driverId: key, driverName: names[driverIndex], displayName: names[driverIndex], transponder: `799000${driverIndex}`, laps: 17 - place, bestLapMs: 17100 + place * 230 + heatIndex * 40, lastLapMs: 18000, startTimestamp: startedAt, lastTimestamp: startedAt + 300000 + place * 1200 }; + const laps = 17 - place; + let ts = startedAt; + let best = Infinity; + for (let lap = 1; lap <= laps; lap += 1) { + // Early laps favour the drivers at the back, so the order changes before it settles. + const lapMs = Math.round(17600 + place * 260 + Math.sin(lap * 1.7 + driverIndex) * 650 - (lap < 6 ? (3 - place) * -180 : 0)); + ts += lapMs; + best = Math.min(best, lapMs); + passings.push({ driverId: key, driverName: names[driverIndex], competitorKey: key, transponder: `799000${driverIndex}`, lapMs, timestamp: ts, validLap: true }); + } + competitors[key] = { key, driverId: key, driverName: names[driverIndex], displayName: names[driverIndex], transponder: `799000${driverIndex}`, laps, bestLapMs: best, lastLapMs: 18000, startTimestamp: startedAt, lastTimestamp: ts }; }); - state.resultsBySession[id] = { passings: [], adjustments: [], competitors }; + state.resultsBySession[id] = { passings: passings.sort((a, b) => a.timestamp - b.timestamp), adjustments: [], competitors }; }); state.activeSessionId = "vid_ov_a"; }, - async setup({ navigate, evaluate, scrollTo }) { + async setup({ navigate, scrollTo }) { await navigate("race_day", "raceDayOverview"); await scrollTo("#raceDayOverview"); }, @@ -838,12 +892,15 @@ const clips = { async action({ evaluate }) { await evaluate(`document.querySelector('.race-overview-phase[data-phase="qualification"]')?.setAttribute("open", "")`); }, }, { - text: "Print it, or export the whole race as PDF or CSV.", - async action({ evaluate, scrollTo }) { - await evaluate(`document.querySelector('.race-overview-phase[data-phase="qualification"]')?.removeAttribute("open"); document.querySelector('.race-overview-phase[data-phase="final"]')?.setAttribute("open", "")`); - await scrollTo("#raceDayOverview"); + text: "Every qualifying heat and final has a lap chart: each driver's place after every lap.", + async action({ evaluate }) { + await evaluate(`(() => { document.querySelector('.race-overview-phase[data-phase="qualification"]')?.removeAttribute("open"); const final = document.querySelector('.race-overview-phase[data-phase="final"]'); final?.setAttribute("open", ""); const chart = final?.querySelector(".lap-chart-box"); if (chart) { chart.open = true; chart.scrollIntoView({ block: "end" }); } })()`); }, }, + { + text: "Print it, or export the whole race as PDF or CSV. The chart is in the print too.", + async action({ scrollTo }) { await scrollTo("#raceDayOverview"); }, + }, { text: "The results archive is sorted by race. Pick one, and the same overview and export are there.", async action({ clickNav, evaluate, click, scrollTo }) { @@ -854,6 +911,216 @@ const clips = { await scrollTo("#archiveEventClose", "center"); }, }, + { + text: "Pick one date in From and To, and CSV for the race day gives every lap of that day, with a summary per heat, ready for Excel.", + async action({ evaluate, scrollTo }) { + const date = await evaluate(`document.querySelector('[data-archive-event="vid_ov_event"]')?.closest("tr")?.children[0]?.textContent.trim()`); + for (const id of ["archiveDateFrom", "archiveDateTo"]) { + await evaluate(`(() => { const input = document.getElementById("${id}"); input.value = ${JSON.stringify(date)}; input.dispatchEvent(new Event("change")); })()`); + await pause(200); + } + await scrollTo("#archiveDayCsv", "center"); + }, + }, + ], + }, + + // A cup day: the series hub, check-in, protected heats, a duplicate fixed in the standings and + // the day's CSV. Round 1's results sit on a driver entry that was deleted afterwards, so Sam + // shows on two rows until the row is linked. + "cup-day": { + seedState(state) { + const classId = "vid_cup_class"; + state.classes.push({ id: classId, name: "2WD Buggy" }); + const people = [["vid_cup_alex", "Alex Karlsson"], ["vid_cup_sam", "Sam Nilsson"], ["vid_cup_jamie", "Jamie Lee"], ["vid_cup_robin", "Robin Berg"], ["vid_cup_kim", "Kim Holm"]]; + people.forEach(([id, name], index) => state.drivers.push({ id, name, classId, transponder: `797100${index}` })); + const today = new Date().toISOString().slice(0, 10); + const round = (eventId, date, samId, startedAt, orderQ, orderA) => { + const ids = people.map(([id]) => (id === "vid_cup_sam" ? samId : id)); + state.events.push({ id: eventId, name: `Winter Cup 2WD`, date, classId, mode: "race", raceConfig: { participantsConfigured: true, driverIds: ids, ...(date === today ? { checkIn: { vid_cup_alex: { present: true, paid: true }, vid_cup_sam: { present: true, paid: false }, vid_cup_jamie: { present: true, paid: true } } } : {}) } }); + [["q1", "Q1 H1", "qualification", orderQ, 0], ["a1", "A Final 1", "final", orderA, 1800000]].forEach(([suffix, name, type, order, offset]) => { + const id = `${eventId}_${suffix}`; + const start = startedAt + offset; + state.sessions.push({ id, eventId, name, type, generated: true, durationMin: 5, status: "finished", startedAt: start, endedAt: start + 310000, driverIds: ids }); + const competitors = {}; + const passings = []; + order.forEach((index, place) => { + const key = ids[index]; + const laps = 17 - place; + // Every lap as a passing: the series only scores drivers with a registered lap. + for (let lap = 1; lap <= laps; lap += 1) passings.push({ driverId: key, driverName: people[index][1], competitorKey: key, transponder: `797100${index}`, lapMs: 17600 + place * 210, timestamp: start + lap * (17600 + place * 210), validLap: true }); + competitors[key] = { key, driverId: key, driverName: people[index][1], displayName: people[index][1], transponder: `797100${index}`, laps, bestLapMs: 17200 + place * 210, lastLapMs: 18000, startTimestamp: start, lastTimestamp: start + laps * (17600 + place * 210) }; + }); + state.resultsBySession[id] = { passings: passings.sort((a, b) => a.timestamp - b.timestamp), adjustments: [], competitors }; + }); + }; + round("vid_cup_r1", "2026-11-01", "vid_cup_sam_old", Date.now() - 14 * 86400000, [1, 0, 2, 3, 4], [1, 0, 2, 3, 4]); + round("vid_cup_r2", today, "vid_cup_sam", Date.now() - 3 * 3600000, [0, 1, 2, 4, 3], [0, 1, 2, 4, 3]); + state.series = [{ id: "vid_cup_series", name: "Winter Cup", classIds: [classId], eventIds: ["vid_cup_r1", "vid_cup_r2"] }]; + }, + async setup({ navigate, evaluate }) { + await navigate("series", "seriesNew"); + await waitFor(async () => Boolean(await evaluate(`document.querySelector('[data-round="vid_cup_r2"]')`)), "rounds listed"); + }, + steps: [ + { text: "A cup runs from the series page: the rounds, and each class's standings. Each round has one button for its next step - seeding, qualifying, then the finals." }, + { + text: "In the morning, open the race and use Check-in: present and paid, and whether the transponder has been seen on the decoder today.", + async action({ click, evaluate, clickNav }) { + await clickNav("Race Setup"); + await waitFor(async () => Boolean(await evaluate(`document.getElementById("event-manage-vid_cup_r2")`)), "race listed"); + await click("#event-manage-vid_cup_r2"); + await waitFor(async () => Boolean(await evaluate(`document.querySelector('[data-manage-tab="checkin"]')`)), "manage race"); + await click('[data-manage-tab="checkin"]'); + await pause(400); + await evaluate(`document.querySelector('[data-manage-tab="checkin"]')?.scrollIntoView({ block: "start" })`); + }, + }, + { text: "Remove no-shows before qualifying starts, and print the list. Without a check-in everyone simply counts as present." }, + { + text: "Heats that have run are protected. Making qualifying or finals again is refused until you clear them, and clearing names the heats and asks first.", + async action({ click, evaluate }) { + await click('[data-manage-tab="live"]'); + await pause(400); + await evaluate(`document.querySelector('[data-manage-tab="live"]')?.scrollIntoView({ block: "start" })`); + }, + }, + { + text: "Back in the series, Sam is on two rows: a duplicate entry was deleted after round one, and its points stayed behind.", + async action({ clickNav, evaluate }) { + await clickNav("Series / cup"); + await waitFor(async () => Boolean(await evaluate(`document.querySelector(".series-link-driver")`)), "link picker"); + await evaluate(`document.querySelector(".series-link-driver").scrollIntoView({ block: "center" })`); + }, + }, + { + text: "Pick the right driver in the link box, and the two rows become one.", + async action({ evaluate }) { + await evaluate(`(() => { const select = document.querySelector(".series-link-driver"); select.value = "vid_cup_sam"; select.dispatchEvent(new Event("change", { bubbles: true })); })()`); + await pause(800); + await evaluate(`document.querySelector(".series-standings, .series-rounds-table")?.scrollIntoView({ block: "center" })`); + }, + }, + { + text: "And the page button on a round downloads the day's CSV: a summary per heat and every lap, ready for Excel.", + async action({ evaluate }) { + await evaluate(`document.querySelector('[data-round="vid_cup_r2"] [data-round-action="day_csv"]')?.scrollIntoView({ block: "center" })`); + }, + }, + ], + }, + + // The driver's own page: Training stats, then the mobile profile (Standard and Pro) shown in a + // phone-sized frame, with "My race today" from a race day in progress. + "driver-page": { + seedState(state) { + const classId = "vid_dp_class"; + state.classes.push({ id: classId, name: "2WD Buggy" }); + const people = [["vid_dp_alex", "Alex Karlsson"], ["vid_dp_sam", "Sam Nilsson"], ["vid_dp_jamie", "Jamie Lee"], ["vid_dp_robin", "Robin Berg"]]; + people.forEach(([id, name], index) => state.drivers.push({ id, name, classId, transponder: `797200${index}` })); + const today = new Date().toISOString().slice(0, 10); + // This morning's open practice: two stints for Alex, a few laps for the others. + const practiceStart = Date.now() - 3 * 3600000; + const event = { id: "vid_dp_practice", name: "Open Practice", date: today, classId: "", mode: "race", raceConfig: { practiceOnly: true } }; + const practice = { id: "vid_dp_open", eventId: event.id, name: "Open Practice", type: "open_practice", durationMin: 600, status: "finished", startedAt: practiceStart, endedAt: practiceStart + 3600000 }; + const passings = []; + const competitors = {}; + people.forEach(([id, name], index) => { + const tp = `797200${index}`; + let ts = practiceStart + 60000 + index * 7000; + let laps = 0; + let best = Infinity; + const stints = index === 0 ? [18, 22] : [12]; + stints.forEach((count, stint) => { + if (stint) ts += 6 * 60000; + passings.push({ driverId: id, driverName: name, competitorKey: id, transponder: tp, lapMs: 0, timestamp: ts, validLap: true }); + for (let lap = 0; lap < count; lap += 1) { + const lapMs = Math.round(17300 + index * 250 - stint * 240 + Math.sin(lap * 1.3 + index) * 420); + ts += lapMs; laps += 1; best = Math.min(best, lapMs); + passings.push({ driverId: id, driverName: name, competitorKey: id, transponder: tp, lapMs, timestamp: ts, validLap: true }); + } + }); + competitors[id] = { key: id, driverId: id, driverName: name, transponder: tp, laps, bestLapMs: best, lastLapMs: 17800, startTimestamp: practiceStart }; + }); + state.events.push(event); + state.sessions.push(practice); + state.resultsBySession[practice.id] = { passings: passings.sort((a, b) => a.timestamp - b.timestamp), competitors }; + // This afternoon's race: Q1 run, Q2 and the final still to come. + const ids = people.map(([id]) => id); + const race = { id: "vid_dp_race", name: "Club Race", date: today, classId, mode: "race", raceConfig: { participantsConfigured: true, driverIds: ids } }; + state.events.push(race); + const q1Start = Date.now() - 40 * 60000; + state.sessions.push( + { id: "vid_dp_q1", eventId: race.id, name: "Q1 H1", type: "qualification", durationMin: 5, status: "finished", startedAt: q1Start, endedAt: q1Start + 310000, driverIds: ids }, + { id: "vid_dp_q2", eventId: race.id, name: "Q2 H1", type: "qualification", durationMin: 5, status: "ready", driverIds: ids }, + { id: "vid_dp_a1", eventId: race.id, name: "A Final", type: "final", durationMin: 5, status: "ready", driverIds: ids }, + ); + state.resultsBySession.vid_dp_q1 = { passings: [], adjustments: [], competitors: Object.fromEntries(people.map(([id, name], place) => [id, { key: id, driverId: id, driverName: name, displayName: name, transponder: `797200${place}`, laps: 17 - place, bestLapMs: 17150 + place * 220, lastLapMs: 18000, startTimestamp: q1Start, lastTimestamp: q1Start + 300000 + place * 800 }])) }; + }, + async setup({ navigate }) { + await navigate("training&driver=vid_dp_alex", "trainingGoalsSharing"); + }, + steps: [ + { text: "Training stats follow every driver: total laps, practice days, personal best, consistency, the next goal, and today's session." }, + { + text: "More stats has the stints, pace per half hour, splits and set-up changes. In the stint cards, the stint's fastest lap is green and the day's fastest is purple.", + async action({ evaluate }) { + await evaluate(`(() => { const more = document.getElementById("trainingMoreStats"); if (more) { more.open = true; more.scrollIntoView({ block: "start" }); } })()`); + }, + }, + { + text: "Under Goals and mobile profile, enable the driver's own page. The driver scans the QR code once, and has it on the phone. No account is needed.", + async action({ evaluate }) { + await evaluate(`(() => { const more = document.getElementById("trainingMoreStats"); if (more) more.open = false; const box = document.getElementById("trainingGoalsSharing"); box.open = true; document.getElementById("trainingPublicProfileEnable")?.click(); })()`); + await waitFor(async () => Boolean(await evaluate(`document.querySelector(".training-profile-qr img")`)), "QR code"); + await pause(500); + await evaluate(`document.querySelector(".training-profile-qr")?.scrollIntoView({ block: "center" })`); + }, + }, + { + text: "This is the phone. On a race day, My race today sits at the top: the next heat, with its time and grid place, marshal duties, and today's results.", + async action({ send, evaluate, state }) { + const origin = await evaluate("location.origin"); + let token = ""; + await waitFor(async () => { token = ((await state()).training?.shares || []).find((share) => share.enabled !== false)?.token || ""; return token; }, "profile saved"); + // The race controller posts today's schedule every 15 s; make sure the phone has it. + const hasRaceToday = async () => Boolean((await (await fetch(`${origin}/public-training/api/${token}`)).json()).raceToday); + try { await waitFor(hasRaceToday, "my race today", 20000); } catch { + // No schedule posted (no first start set for today): post the same small snapshot the + // race controller would - ids only. + const now = Date.now(); + const ids = ["vid_dp_alex", "vid_dp_sam", "vid_dp_jamie", "vid_dp_robin"]; + await fetch(`${origin}/api/public-race-day`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ date: new Date(now - new Date(now).getTimezoneOffset() * 60000).toISOString().slice(0, 10), sessions: [ + { id: "vid_dp_q1", label: "2WD Buggy · Q1 H1", start: now - 40 * 60000, state: "done", entries: ids, results: ids.map((driverId, index) => ({ driverId, position: index + 1, laps: 17 - index, result: `${17 - index} laps` })) }, + { id: "vid_dp_q2", label: "2WD Buggy · Q2 H1", start: now + 12 * 60000, state: "upcoming", gridStart: true, entries: ["vid_dp_sam", "vid_dp_alex", "vid_dp_jamie", "vid_dp_robin"] }, + { id: "vid_dp_open2", label: "4WD Buggy · Q2 H1", start: now + 20 * 60000, state: "upcoming", entries: [], marshals: ["vid_dp_alex"] }, + { id: "vid_dp_a1", label: "2WD Buggy · A Final", start: now + 75 * 60000, state: "upcoming", gridStart: true, entries: ids }, + ] }) }); + await waitFor(hasRaceToday, "my race today (posted)", 10000); + } + const phone = (mode) => `${origin}/public-training/${token}?lang=en&mode=${mode}`; + const page = `
+