From 9630ec6656892cb72be35b9ec13ba79cf5a347c4 Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Wed, 13 Nov 2024 08:41:40 -0800 Subject: [PATCH] Support pasting lat,lon coordinates into either lat or lon map field (#1687) --- files/app/main/status/e/location.ut | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/files/app/main/status/e/location.ut b/files/app/main/status/e/location.ut index c762b36f..caf87725 100755 --- a/files/app/main/status/e/location.ut +++ b/files/app/main/status/e/location.ut @@ -201,8 +201,26 @@ const mapurl = map ? replace(replace(map, "(lat)", lat), "(lon)", lon) : null; }); } } + function llpaste() { + const txt = event.clipboardData.getData("text/plain"); + if (!txt) { + return; + } + event.stopPropagation(); + event.preventDefault(); + const ll = txt.split(","); + const latv = parseFloat(ll[0]); + const lonv = parseFloat(ll[1]); + if (!isNaN(latv) && !isNaN(lonv)) { + lat.value = latv; + lon.value = lonv; + llchange(); + } + } lat.addEventListener("change", llchange); lon.addEventListener("change", llchange); + lat.addEventListener("paste", llpaste); + lon.addEventListener("paste", llpaste); gridsquare.addEventListener("change", function() { if (gridsquare.value !== "") { gridsquare2latlon();