From 5b0c3d3bf6ab35ca3ecb10914a350894e1e8cc7e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 27 Jun 2021 10:07:41 +0200 Subject: properly format stop list; show distance on geo lookup --- static/v0/js/geolocation.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'static/v0/js') diff --git a/static/v0/js/geolocation.js b/static/v0/js/geolocation.js index 1e93c88..2f93db7 100644 --- a/static/v0/js/geolocation.js +++ b/static/v0/js/geolocation.js @@ -3,15 +3,27 @@ document.addEventListener("DOMContentLoaded", function() { const processResult = function(results) { const list = document.createElement("ul"); - list.class = "stops"; + list.className = "stops"; for (var result in results) { result = results[result]; - var listentry = document.createElement("li"); - var link = document.createElement("a"); - link.text = result.name + const listentry = document.createElement("li"); + const link = document.createElement("a"); + const note = document.createElement("span"); + + link.className = "name"; + link.textContent = result.name; link.href = "/board/" + result.id; - listentry.appendChild(link) - list.appendChild(listentry) + + note.className = "note"; + if (result.distance >= 1000) { + note.textContent = result.distance.toFixed(1) + " km" + } else { + note.textContent = result.distance + " m" + } + + listentry.appendChild(link); + listentry.appendChild(note); + list.appendChild(listentry); } geoLocationButton.replaceWith(list); }; -- cgit v1.2.3