From fa0c4f8837bd3270a739ce5d7b4b82473ea67268 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 27 Jun 2021 11:16:07 +0200 Subject: show line types in stop search --- static/v0/js/geolocation.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'static/v0/js/geolocation.js') diff --git a/static/v0/js/geolocation.js b/static/v0/js/geolocation.js index 2f93db7..4e868b0 100644 --- a/static/v0/js/geolocation.js +++ b/static/v0/js/geolocation.js @@ -1,6 +1,13 @@ document.addEventListener("DOMContentLoaded", function() { const geoLocationButton = document.getElementById('geolocationsearch'); + const mkTextNode = function(className, textContent) { + const node = document.createElement("span"); + node.className = className; + node.textContent = textContent; + return node + } + const processResult = function(results) { const list = document.createElement("ul"); list.className = "stops"; @@ -9,6 +16,7 @@ document.addEventListener("DOMContentLoaded", function() { const listentry = document.createElement("li"); const link = document.createElement("a"); const note = document.createElement("span"); + const lines = document.createElement("span"); link.className = "name"; link.textContent = result.name; @@ -21,8 +29,39 @@ document.addEventListener("DOMContentLoaded", function() { note.textContent = result.distance + " m" } + lines.className = "lines"; + + if (result.products.nationalExpress) { + lines.appendChild(mkTextNode("longdistance", "ICE")); + } + if (result.products.national) { + lines.appendChild(mkTextNode("longdistance", "IC")); + } + if (result.products.regionalExp) { + lines.appendChild(mkTextNode("longdistance", "RE")); + } + if (result.products.regional) { + lines.appendChild(mkTextNode("longdistance", "R")); + } + if (result.products.suburban) { + lines.appendChild(mkTextNode("suburban", "S")); + } + if (result.products.tram) { + lines.appendChild(mkTextNode("tram", "T")); + } + if (result.products.bus) { + lines.appendChild(mkTextNode("bus", "Bus")); + } + if (result.products.ferry) { + lines.appendChild(mkTextNode("bus", "Fähre")); + } + if (result.products.taxi) { + lines.appendChild(mkTextNode("taxi", "AST")); + } + listentry.appendChild(link); listentry.appendChild(note); + listentry.appendChild(lines); list.appendChild(listentry); } geoLocationButton.replaceWith(list); -- cgit v1.2.3