Profiles in a dialog, the chip in the map's bottom-left corner picks one (the Design canvas' Vehicle): a car gains fuel, Euro class, stickers and vignettes / toll units with dates; drive mode's Menu steps through them. Speed limits by country for cars and over 3.5 t (public/js/speed_limits.js, sources in it): the route's roads (km, road class, country), the limit shown the lower of the sign and the profile's; the Route panel's countries with their limits and how the motorways are paid; past a border a card in drive mode (GridBorder). The itinerary in the Route panel (Itinerary): the trip's name, leave time, days start; per stop a night, stay and note, planned times, day headers; another screen's change shown where it happened with Undo
CI / check (push) Successful in 24s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-12-03 19:00:09 +01:00
1 parent a6158f4083
commit 5e31dfaba9
15 files changed
+733 -169

No files matched your search

+47 -1
View File
@@ -4,6 +4,8 @@ import { pauseFollow, resumeFollow, isFollowing } from "/js/gnss.js";
import { formatDuration } from "/js/route.js";
import { isLoggedIn } from "/js/auth.js";
import { watchDashboard, maneuverSvg, laneSvg, distance, VOICE_KEY } from "/js/dashboard.js";
import { SPEED_LIMITS, COUNTRY_NAMES, isHeavy, motorwayPayment } from "/js/speed_limits.js";
import { currentVehicle, onVehicle } from "/js/panels.js";
import { formatSunInfo } from "/js/sun.js";
import { pointsMenu, layersMenu, terrainMenu, elevationHtml, cellButton, bindKey, emptyRow as empty, escapeHtml } from "/js/drive_menus.js";
@@ -17,7 +19,8 @@ import { pointsMenu, layersMenu, terrainMenu, elevationHtml, cellButton, bindKey
const KEY = "drivingMode";
const PROFILE_URL = "/drive/road.json";
const PITCH_3D = 60; // as map.js's 3D toggle
const RENDER_MS = 1000; // the clock, the follow state; the dashboard's polls render too
const RENDER_MS = 1000;
const BORDER_MS = 20000; // the border card's time on the screen // the clock, the follow state; the dashboard's polls render too
const SEARCH_DELAY_MS = 300; // after the last key
const LOG_POLL_MS = 5000; // the trip log's state and new points
const DRIVEN_SOURCE = "trip-driven";
@@ -105,6 +108,7 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
<button type="button" class="drive-menu__row" data-action="overview">The whole route <small>the follow pauses</small></button>
<button type="button" class="drive-menu__row" data-action="terrain-auto"></button>
<button type="button" class="drive-menu__row" data-action="voice"></button>
<button type="button" class="drive-menu__row" data-action="profile"></button>
<button type="button" class="drive-menu__row" data-action="leave">Leave driving mode</button>`;
// auto: opens off-road and closes back on the road; stay: opens and stays (the inclinometer all along); hand: neither
const TERRAIN_MODES = { auto: "opens and closes by itself", stay: "opens by itself, stays", hand: "by hand" };
@@ -127,6 +131,19 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
renderVoice();
});
renderVoice();
// the profile: a tap goes to the next one (re-routes); the dialog is the desktop's
const profileButton = menuPanel.querySelector('[data-action="profile"]');
const renderProfile = () => {
const { current } = routePanel?.profiles() || {};
profileButton.innerHTML = `Profile: ${escapeHtml(current?.name ?? "—")} <small>tap for the next one</small>`;
};
profileButton.addEventListener("click", () => {
const { list, current } = routePanel?.profiles() || { list: [] };
if (!list.length) return;
routePanel.pickProfile(list[(list.indexOf(current) + 1) % list.length].id);
});
onVehicle(renderProfile);
renderProfile();
menuPanel.querySelector('[data-action="overview"]').addEventListener("click", overview);
menuPanel.querySelector('[data-action="leave"]').addEventListener("click", () => set(false));
const crosshair = document.createElement("div");
@@ -479,6 +496,34 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
(signal != null ? `<span class="drive-ahead__signal"><span class="dash-signal"></span>${distance(signal)}</span>` : "");
};
// Past a border (the country along the route, or of the road driven):
// the new country's limits for the profile and how its motorways are
// paid, for BORDER_MS or until tapped (the Design canvas' GridBorder).
let country = null;
let border = null; // { code, until }
const renderBorder = (el) => {
const code = dash?.nav?.country;
if (code && code !== country) {
if (country) border = { code, until: Date.now() + BORDER_MS };
country = code;
}
el.hidden = !border || Date.now() > border.until;
if (el.hidden) return;
if (!el.dataset.wired) {
el.dataset.wired = "1";
el.addEventListener("click", () => { border = null; el.hidden = true; });
}
const heavy = isHeavy(currentVehicle);
const row = SPEED_LIMITS[border.code]?.[heavy ? "heavy" : "car"];
const pay = motorwayPayment(border.code, currentVehicle);
const sign = (v, k) => `<span class="drive-border__limit"><span class="drive-speed__limit"><b>${v ?? "–"}</b></span><small>${k}</small></span>`;
let name = border.code;
try { name = COUNTRY_NAMES.of(border.code); } catch { /* not a region code */ }
el.innerHTML = `<div class="drive-border__head"><b>${escapeHtml(name)}</b><span class="drive-cell__muted">${border.code}${currentVehicle ? ` · ${escapeHtml(currentVehicle.name)}` : ""}</span></div>` +
(row ? `<div class="drive-border__signs">${sign(row[0], "Motorway")}${sign(row[2], "Outside towns")}${sign(row[3], "In towns")}</div>` : `<span class="drive-cell__muted">No limits known for ${border.code}</span>`) +
(pay.how ? `<span class="drive-border__pays">Motorways: ${pay.how} ${pay.has ? "✓" : "— not in the profile"}</span>` : "");
};
const renderManeuver = (el) => {
const n = dash?.nav;
if (n?.offRoute) {
@@ -530,6 +575,7 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
el.innerHTML = `${extra}<span class="drive-cell__label">${FIELDS[name] || name}</span><span class="drive-cell__value ${cls}">${escapeHtml(value)} <small>${escapeHtml(unit)}</small></span>`;
} else if (cell.widget === "maneuver") renderManeuver(el);
else if (cell.widget === "ahead") renderAhead(el);
else if (cell.widget === "border") renderBorder(el);
else if (cell.widget === "status") {
el.innerHTML = `<b class="drive-status__brand">MAPTOOL</b><span class="drive-cell__muted"><span class="${navigator.onLine ? "drive-status--ok" : ""}">●</span> ${navigator.onLine ? "online" : "offline"}${log?.active ? ` · <span class="drive-status--rec">● rec</span>` : ""}</span>`;
} else if (cell.widget === "elevation") renderElevation(el, cell);