diff --git a/public/js/app.js b/public/js/app.js index e38d3bb..3463263 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -149,23 +149,29 @@ return nearestPendingPoi(poiMetrics(state.position)); } + function setRouteControlSummary(titleText, detailText) { + $('#route-control-title').text(titleText); + $('#route-control-next').text(detailText); + $('.route-control-summary').attr('aria-label', `${titleText}. ${detailText}`); + } + function updateRouteControlSummary() { - const title = $('#route-control-title'); - const next = $('#route-control-next'); if (!state.route) { - title.text('Route wählen'); - next.text('Aktive und lokale Strecken'); + setRouteControlSummary('Route wählen', 'Aktive und lokale Strecken'); return; } - title.text(state.route.name || 'Route'); + const titleText = state.route.name || 'Route'; const metric = nextPoiMetric(); if (!metric) { - next.text((state.route.pois || []).length ? 'Alle Streckenpunkte erreicht' : 'Keine Streckenpunkte vorhanden'); + const detailText = (state.route.pois || []).length + ? 'Alle Streckenpunkte erreicht' + : 'Keine Streckenpunkte vorhanden'; + setRouteControlSummary(titleText, detailText); return; } const distance = metric.distance == null ? '' : ` · ${Math.round(metric.distance)} m`; - next.text(`Nächster Streckenpunkt: ${metric.poi.title}${distance}`); + setRouteControlSummary(titleText, `Nächster Streckenpunkt: ${metric.poi.title}${distance}`); } function renderRouteControlList(selector, routes, source, emptyText) {