wip
This commit is contained in:
@@ -14,22 +14,24 @@ export interface IFixtureServer {
|
||||
* Steps 2-17 map to the corresponding HTML fixture files.
|
||||
*/
|
||||
const STEP_TO_FIXTURE: Record<number, string> = {
|
||||
2: 'step-02-hosted-racing.html',
|
||||
3: 'step-03-create-race.html',
|
||||
4: 'step-04-race-information.html',
|
||||
5: 'step-05-server-details.html',
|
||||
6: 'step-06-set-admins.html',
|
||||
7: 'step-07-time-limits.html', // Time Limits wizard step
|
||||
8: 'step-08-set-cars.html', // Set Cars wizard step
|
||||
9: 'step-09-add-car-modal.html', // Add Car modal
|
||||
10: 'step-10-set-car-classes.html', // Set Car Classes
|
||||
11: 'step-11-set-track.html', // Set Track wizard step (CORRECTED)
|
||||
12: 'step-12-add-track-modal.html', // Add Track modal
|
||||
13: 'step-13-track-options.html',
|
||||
14: 'step-14-time-of-day.html',
|
||||
15: 'step-15-weather.html',
|
||||
16: 'step-16-race-options.html',
|
||||
17: 'step-17-track-conditions.html',
|
||||
1: '01-hosted-racing.html',
|
||||
2: '02-create-a-race.html',
|
||||
3: '03-race-information.html',
|
||||
4: '04-server-details.html',
|
||||
5: '05-set-admins.html',
|
||||
6: '06-add-an-admin.html',
|
||||
7: '07-time-limits.html',
|
||||
8: '08-set-cars.html',
|
||||
9: '09-add-a-car.html',
|
||||
10: '10-set-car-classes.html',
|
||||
11: '11-set-track.html',
|
||||
12: '12-add-a-track.html',
|
||||
13: '13-track-options.html',
|
||||
14: '14-time-of-day.html',
|
||||
15: '15-weather.html',
|
||||
16: '16-race-options.html',
|
||||
17: '17-team-driving.html',
|
||||
18: '18-track-conditions.html',
|
||||
};
|
||||
|
||||
export class FixtureServer implements IFixtureServer {
|
||||
@@ -38,7 +40,7 @@ export class FixtureServer implements IFixtureServer {
|
||||
private fixturesPath: string;
|
||||
|
||||
constructor(fixturesPath?: string) {
|
||||
this.fixturesPath = fixturesPath ?? path.resolve(process.cwd(), 'html-dumps');
|
||||
this.fixturesPath = fixturesPath ?? path.resolve(process.cwd(), 'html-dumps/iracing-hosted-sessions');
|
||||
}
|
||||
|
||||
async start(port: number = 3456): Promise<{ url: string; port: number }> {
|
||||
@@ -122,8 +124,8 @@ export class FixtureServer implements IFixtureServer {
|
||||
return;
|
||||
}
|
||||
|
||||
const stepMatch = fileName.match(/step-(\d+)-/);
|
||||
const stepNum = stepMatch ? Number(stepMatch[1]) : 2;
|
||||
const stepMatch = fileName.match(/(\d+)-/);
|
||||
const stepNum = stepMatch ? Number(stepMatch[1]) : 1;
|
||||
|
||||
const fallbackHtml = `
|
||||
<!doctype html>
|
||||
@@ -144,30 +146,60 @@ export class FixtureServer implements IFixtureServer {
|
||||
try {
|
||||
const step = Number(${stepNum});
|
||||
let id = null;
|
||||
if (step === 2) {
|
||||
let indicator = null;
|
||||
if (step === 1) {
|
||||
id = null; // hosted sessions - not part of modal
|
||||
} else if (step === 2) {
|
||||
id = 'set-session-information';
|
||||
indicator = 'race-information';
|
||||
} else if (step === 3) {
|
||||
id = 'set-session-information';
|
||||
indicator = 'race-information';
|
||||
} else if (step === 4) {
|
||||
id = 'set-server-details';
|
||||
} else if (step === 5 || step === 6) {
|
||||
indicator = 'server-details';
|
||||
} else if (step === 5) {
|
||||
id = 'set-admins';
|
||||
indicator = 'set-admins';
|
||||
} else if (step === 6) {
|
||||
id = 'set-admins';
|
||||
indicator = 'add-admin';
|
||||
} else if (step === 7) {
|
||||
id = 'set-time-limit';
|
||||
} else if (step === 8 || step === 9) {
|
||||
indicator = 'time-limits';
|
||||
} else if (step === 8) {
|
||||
id = 'set-cars';
|
||||
} else if (step === 11 || step === 12) {
|
||||
indicator = 'set-cars';
|
||||
} else if (step === 9) {
|
||||
id = 'set-cars';
|
||||
indicator = 'add-car';
|
||||
} else if (step === 10) {
|
||||
id = 'set-car-classes';
|
||||
indicator = 'set-car-classes';
|
||||
} else if (step === 11) {
|
||||
id = 'set-track';
|
||||
indicator = 'set-track';
|
||||
} else if (step === 12) {
|
||||
id = 'set-track';
|
||||
indicator = 'add-track';
|
||||
} else if (step === 13) {
|
||||
id = 'set-track-options';
|
||||
indicator = 'track-options';
|
||||
} else if (step === 14) {
|
||||
id = 'set-time-of-day';
|
||||
indicator = 'time-of-day';
|
||||
} else if (step === 15) {
|
||||
id = 'set-weather';
|
||||
indicator = 'weather';
|
||||
} else if (step === 16) {
|
||||
id = 'set-race-options';
|
||||
indicator = 'race-options';
|
||||
} else if (step === 17) {
|
||||
id = 'team-driving';
|
||||
indicator = 'team-driving';
|
||||
} else if (step === 18) {
|
||||
id = 'set-track-conditions';
|
||||
indicator = 'track-conditions';
|
||||
}
|
||||
|
||||
if (id) {
|
||||
@@ -182,13 +214,18 @@ export class FixtureServer implements IFixtureServer {
|
||||
var modal = document.getElementById('create-race-modal');
|
||||
if (modal) modal.classList.add('hidden');
|
||||
}
|
||||
|
||||
// Set data-indicator for step identification
|
||||
if (indicator) {
|
||||
document.body.setAttribute('data-indicator', indicator);
|
||||
}
|
||||
} catch (e) {
|
||||
// noop
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body data-step="${stepNum}">
|
||||
<body data-step="${stepNum}" data-indicator="">
|
||||
<nav>
|
||||
<button aria-label="Create a Race" id="create-race-btn">Create a Race</button>
|
||||
</nav>
|
||||
@@ -198,11 +235,21 @@ export class FixtureServer implements IFixtureServer {
|
||||
<div id="create-race-wizard">
|
||||
<aside class="wizard-sidebar">
|
||||
<a id="wizard-sidebar-link-set-session-information" data-indicator="race-information">Race Information</a>
|
||||
<a id="wizard-sidebar-link-set-server-details">Server Details</a>
|
||||
<a id="wizard-sidebar-link-set-admins">Admins</a>
|
||||
<a id="wizard-sidebar-link-set-time-limit">Time Limit</a>
|
||||
<a id="wizard-sidebar-link-set-cars">Cars</a>
|
||||
<a id="wizard-sidebar-link-set-track">Track</a>
|
||||
<a id="wizard-sidebar-link-set-server-details" data-indicator="server-details">Server Details</a>
|
||||
<a id="wizard-sidebar-link-set-admins" data-indicator="set-admins">Set Admins</a>
|
||||
<a id="wizard-sidebar-link-add-admin" data-indicator="add-admin">Add Admin</a>
|
||||
<a id="wizard-sidebar-link-time-limits" data-indicator="time-limits">Time Limits</a>
|
||||
<a id="wizard-sidebar-link-set-cars" data-indicator="set-cars">Set Cars</a>
|
||||
<a id="wizard-sidebar-link-add-car" data-indicator="add-car">Add Car</a>
|
||||
<a id="wizard-sidebar-link-set-car-classes" data-indicator="set-car-classes">Set Car Classes</a>
|
||||
<a id="wizard-sidebar-link-set-track" data-indicator="set-track">Set Track</a>
|
||||
<a id="wizard-sidebar-link-add-track" data-indicator="add-track">Add Track</a>
|
||||
<a id="wizard-sidebar-link-track-options" data-indicator="track-options">Track Options</a>
|
||||
<a id="wizard-sidebar-link-time-of-day" data-indicator="time-of-day">Time of Day</a>
|
||||
<a id="wizard-sidebar-link-weather" data-indicator="weather">Weather</a>
|
||||
<a id="wizard-sidebar-link-race-options" data-indicator="race-options">Race Options</a>
|
||||
<a id="wizard-sidebar-link-team-driving" data-indicator="team-driving">Team Driving</a>
|
||||
<a id="wizard-sidebar-link-track-conditions" data-indicator="track-conditions">Track Conditions</a>
|
||||
</aside>
|
||||
|
||||
<div class="wizard-content">
|
||||
@@ -235,17 +282,46 @@ export class FixtureServer implements IFixtureServer {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="set-time-limit" class="wizard-step hidden">
|
||||
<input placeholder="Time limit" data-field="timeLimit" />
|
||||
</section>
|
||||
|
||||
<section id="set-cars" class="wizard-step hidden">
|
||||
<input placeholder="Search" data-field="carSearch" />
|
||||
<div data-list="cars"></div>
|
||||
<a class="btn" data-modal-trigger="car">Add Car</a>
|
||||
</section>
|
||||
|
||||
<section id="set-car-classes" class="wizard-step hidden">
|
||||
<input placeholder="Search" data-field="carClassSearch" />
|
||||
<div data-list="car-classes"></div>
|
||||
</section>
|
||||
|
||||
<section id="set-track" class="wizard-step hidden">
|
||||
<input placeholder="Search" data-field="trackSearch" />
|
||||
<div data-list="tracks"></div>
|
||||
</section>
|
||||
|
||||
<section id="set-track-options" class="wizard-step hidden">
|
||||
<input placeholder="Track options" data-field="trackOptions" />
|
||||
</section>
|
||||
|
||||
<section id="set-time-of-day" class="wizard-step hidden">
|
||||
<input placeholder="Time of day" data-field="timeOfDay" />
|
||||
</section>
|
||||
|
||||
<section id="set-weather" class="wizard-step hidden">
|
||||
<input placeholder="Weather" data-field="weather" />
|
||||
</section>
|
||||
|
||||
<section id="set-race-options" class="wizard-step hidden">
|
||||
<input placeholder="Race options" data-field="raceOptions" />
|
||||
</section>
|
||||
|
||||
<section id="team-driving" class="wizard-step hidden">
|
||||
<input placeholder="Team driving" data-field="teamDriving" />
|
||||
</section>
|
||||
|
||||
<section id="set-track-conditions" class="wizard-step hidden">
|
||||
<select data-dropdown="trackState"></select>
|
||||
<input data-slider="rubberLevel" value="50" />
|
||||
|
||||
Reference in New Issue
Block a user