From f4a48e62e676897edffc0ea77c77c9357558c18d Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 25 Nov 2022 09:42:25 +0000 Subject: [PATCH] Added Util.close to allow interfaces to close the window Fix My Location that couldn't be installed after the most recent update --- apps/mylocation/ChangeLog | 1 + apps/mylocation/README.md | 9 ++++-- .../{custom.html => interface.html} | 31 +++++++++++++++---- apps/mylocation/metadata.json | 4 +-- core | 2 +- 5 files changed, 36 insertions(+), 11 deletions(-) rename apps/mylocation/{custom.html => interface.html} (79%) diff --git a/apps/mylocation/ChangeLog b/apps/mylocation/ChangeLog index b46b3b178..afe1810e9 100644 --- a/apps/mylocation/ChangeLog +++ b/apps/mylocation/ChangeLog @@ -6,3 +6,4 @@ 0.06: renamed source files to match standard 0.07: Move mylocation app into 'Settings -> Apps' 0.08: Allow setting location from webinterface in the AppLoader +0.09: Fix web interface so app can be installed (replaced custom with interface html) diff --git a/apps/mylocation/README.md b/apps/mylocation/README.md index b12ed5dcf..11a644262 100644 --- a/apps/mylocation/README.md +++ b/apps/mylocation/README.md @@ -1,8 +1,13 @@ # My Location - *Sets and stores GPS lat and lon of your preferred city* +*Sets and stores GPS lat and lon of your preferred city* -To access, go to `Settings -> Apps -> My Location` +To access, you have two options: + +**In the App Loader** once My Location is installed, click on the 'Save' icon +next to it - and you can choose your location on a map. + +**On Bangle.js** go to `Settings -> Apps -> My Location` * Select one of the preset Cities, setup through the GPS or use the webinterface from the AppLoader * Other Apps can read this information to do calculations based on location diff --git a/apps/mylocation/custom.html b/apps/mylocation/interface.html similarity index 79% rename from apps/mylocation/custom.html rename to apps/mylocation/interface.html index 5c0130199..79a122bf7 100644 --- a/apps/mylocation/custom.html +++ b/apps/mylocation/interface.html @@ -33,10 +33,11 @@
+ Click the map to select a location
- + @@ -68,15 +69,19 @@ let latlon; var marker; - - map.on('click', function(e){ - console.log(e); + + function setPosition(ll) { + latlon = ll; if (map.hasLayer(marker)) { map.removeLayer(marker); } - latlon = e.latlng; - marker = new L.marker(e.latlng).addTo(map); + marker = new L.marker(latlon).addTo(map); + document.getElementById("select-hint").style.display="none"; document.getElementById("select").style.display=""; + } + + map.on('click', function(e){ + setPosition(e.latlng); }); document.getElementById("select").addEventListener("click", function() { @@ -87,9 +92,23 @@ Util.showModal("Saving..."); Util.writeStorage("mylocation.json", JSON.stringify(settings), ()=>{ Util.hideModal(); + Util.close(); // close this window }); }); + function onInit() { + // read existing location + Util.readStorage("mylocation.json", function(data) { + if (data===undefined) return; // no file + try { + var j = JSON.parse(data); + setPosition(j); + } catch (e) { + console.error(e); + } + }); + } + diff --git a/apps/mylocation/metadata.json b/apps/mylocation/metadata.json index bef5b983c..1c2974030 100644 --- a/apps/mylocation/metadata.json +++ b/apps/mylocation/metadata.json @@ -4,12 +4,12 @@ "icon": "app.png", "type": "settings", "screenshots": [{"url":"screenshot_1.png"}], - "version":"0.08", + "version":"0.09", "description": "Sets and stores the latitude and longitude of your preferred City. It can be set from GPS or webinterface. `mylocation.json` can be used by other apps that need your main location. See README for details.", "readme": "README.md", "tags": "tool,utility", "supports": ["BANGLEJS", "BANGLEJS2"], - "custom": "custom.html","custom": "custom.html", + "interface": "interface.html", "storage": [ {"name":"mylocation.settings.js","url":"settings.js"} ], diff --git a/core b/core index db08367e0..aba9b6a51 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit db08367e0a2c25040449a4b556eaed459e8f47fc +Subproject commit aba9b6a51fe02dfbde307c303560b8382857916d