From cba78193c72ea02cc0fe83df9b8d46ec325affc9 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Fri, 14 Mar 2025 08:01:24 +0100 Subject: refactor: remove unused name and zoom features --- script.js | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/script.js b/script.js index 5f07efb..9382d29 100644 --- a/script.js +++ b/script.js @@ -1,19 +1,7 @@ -const fragment = location.hash.substring(1); - -const i = fragment.indexOf('&'); -let latlon; -let params; -if (i != -1) { - latlon = fragment.slice(0, i); - params = Object.fromEntries(new URLSearchParams(fragment.slice(i+1)).entries()); -} else { - latlon = fragment; - params = {}; -} - +const latlon = location.hash.substring(1); const [lat, lon] = latlon.split(','); -function getLinks(lat, lon, zoom) { +function getLinks(lat, lon) { return [ { label: 'Google Maps', @@ -29,7 +17,7 @@ function getLinks(lat, lon, zoom) { }, { label: 'OpenStreetMap', - url: `https://www.openstreetmap.org/?mlat=${lat}&mlon=${lon}&zoom=${zoom}&layers=M` + url: `https://www.openstreetmap.org/?mlat=${lat}&mlon=${lon}&zoom=15&layers=M` }, ] } @@ -41,16 +29,12 @@ const heading = document.getElementById('heading'); if (isNaN(lat) || isNaN(lon)) { heading.textContent = 'not yet implemented'; } else { - const zoom = params.z || 15; const linkList = document.getElementById('links'); document.getElementById('instructions').hidden = false; - if (params.name) { - document.title = params.name; - heading.textContent = params.name; - } + document.title = 'Open location'; - for (const link of getLinks(lat, lon, zoom)) { + for (const link of getLinks(lat, lon)) { const li = document.createElement('li'); const a = document.createElement('a'); a.href = link.url; -- cgit v1.2.3