docs(guide): race day, series fixes and driver page in guide and READMEs; two new video guides, all clips re-recorded in sync (1.89.41)

This commit is contained in:
larssand committed 2026-11-15 22:32:03 +01:00
1 parent 7af4a81aaa
commit 8d7d4d33e6
29 files changed
+404 -36

No files matched your search

+291 -24
View File
@@ -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 = `<!doctype html><html><body style="margin:0;height:100vh;display:flex;align-items:center;justify-content:center;gap:48px;background:#10151c;font:600 22px system-ui;color:#cfd8e3">
<div style="max-width:420px;line-height:1.5">${"Alex's own page"}<br><small style="font-weight:400;color:#8a97a8">Scanned once from the QR code</small></div>
<iframe id="phone" src="${phone("standard")}" style="width:400px;height:820px;border:12px solid #2a323d;border-radius:36px;background:#fff"></iframe></body></html>`;
// A plain page from the same server (its 404), filled with the phone frame - Chrome
// won't load the local server inside a data: page.
await send("Page.navigate", { url: `${origin}/phone-frame` });
await pause(800);
await evaluate(`document.open(); document.write(${JSON.stringify(page)}); document.close();`);
await pause(3500);
},
},
{
text: "Standard shows everything: goals, challenges, guided exercises and a timer for a practice session.",
},
{
text: "Pro is a clean practice view: today's laps, stints, drive time, best and average lap, and the stint cards. The phone remembers the choice.",
async action({ evaluate }) {
await evaluate(`(() => { const frame = document.getElementById("phone"); frame.src = frame.src.replace("mode=standard", "mode=pro"); })()`);
await pause(2500);
},
},
{ text: "Only the driver's own numbers are sent to the phone. Contact details and other drivers' data never are." },
],
},