Before any obstacles can be placed or visualized, the application needs a road. The road defines the coordinate space — specifically, it sets the maximum X boundary for obstacle placement and measures the visible canvas height so that every obstacle lands within the rendered area. Creating a road also resets the backend AVL tree, giving you a clean slate for a new session.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tutosrive/avl_tree_car_front/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Create Road button is always enabled on the home screen. Clicking it opens a small modal dialog where you supply a road width. Once confirmed, the application sets up the road dimensions, resets the backend tree, and automatically opens the Add Obstacles dialog so you can begin inserting obstacles right away.Steps
Open the home screen
Navigate to the application root. The home screen renders five action buttons on the left panel. The Create Road button (
#btn-create-road) is always active — it does not require any prior state.Click Create Road
Click the Create Road button. The
RoadController.init() method is called, which:- Fetches
roadAddMenu.htmland injects it as the modal content. - Inserts the road canvas into
<main>by loadingroad.html. - Displays the modal dialog titled Create Road.
Set the Road Width
The modal contains a single form field:
Enter a value of 500 or greater (in pixels). This value defines the maximum X coordinate that obstacles may occupy. The form also displays a reminder: Minimum: 500.
| Field | Type | Min | Step | Default | Element ID |
|---|---|---|---|---|---|
| Road Width | number | 500 | 10 | 500 | #inp-road-width |
Confirm the dialog
Click Accept. The
RoadController.#addActionMenu() method runs the following sequence:- Validates the form — if the input is empty or invalid, a warning toast is shown and the action stops.
- Shows a success toast: Road created succesfully!
- Reads dimensions from the live DOM and calls
road.setSizes({ width, height, top })on theRoadmodel:width— the numeric value from#inp-road-width.height— computed from the#road-containerelement’s CSS height.top— computed from the#road-containerelement’s CSStopproperty (defaults to0ifNaN).
- Emits
reset_avlvia Socket.IO (TreeService.emit_reset_avl()) to clear the backend tree. - Dispatches the
road-createdDOM event, whichHomeControllerlistens for and uses to automatically trigger a click on the Insert Obstacles button — opening the Add Obstacles dialog immediately. - Closes the modal.
Road model properties
After creation, theRoad model instance holds three geometry properties used throughout the application:
| Property | Source | Description |
|---|---|---|
width | #inp-road-width input value | Maximum X coordinate for obstacle placement |
height | #road-container computed CSS height | Maximum Y coordinate for obstacle placement |
top | #road-container computed CSS top | Vertical offset of the road canvas |
ObstaclesController to compute the valid min/max ranges for X and Y when adding obstacles:
The
Road model is instantiated once per RoadController and reused throughout the session. Clicking Create Road a second time will not create a second controller instance — HomeController guards against overwriting the existing one.