From 2179b432f7cc62dc7e9096b402a14803037c9a78 Mon Sep 17 00:00:00 2001 From: P3run Date: Mon, 5 Aug 2024 23:14:39 +0200 Subject: [PATCH 1/2] feat(shortcuts): add shortcut for SunCalc --- configuration.js.sample | 6 ++++++ src/services/shortcuts.js | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configuration.js.sample b/configuration.js.sample index 15e886c..648204a 100644 --- a/configuration.js.sample +++ b/configuration.js.sample @@ -69,6 +69,12 @@ self.configuration = { category: "🗺️ Maps", url: "https://shademap.app/@$lat,$lng,15z" }, + { + name: "SunCalc", + category: "🗺️ Maps", + url: "https://www.suncalc.org/#/$lat,$lng,15/$date/$time/1/1", + precision: 4, + }, { name: "EO Browser", category: "🗺️ Maps", diff --git a/src/services/shortcuts.js b/src/services/shortcuts.js index 566dac1..9854104 100644 --- a/src/services/shortcuts.js +++ b/src/services/shortcuts.js @@ -50,9 +50,12 @@ class Shortcuts { */ open(url, precision = null) { const coords = this.router.getCoordinates(); + const date = new Date(); url = url .replace("$lat", precision != null ? coords.lat.toFixed(precision) : coords.lat) - .replace("$lng", precision != null ? coords.lng.toFixed(precision) : coords.lng); + .replace("$lng", precision != null ? coords.lng.toFixed(precision) : coords.lng) + .replace("$date", date.toISOString().split('T')[0].replaceAll('-', '.')) + .replace("$time", date.toTimeString().slice(0,5)); window.open(url, '_blank'); } From ab08cfb474949cb2da3580421b638854fd7664ba Mon Sep 17 00:00:00 2001 From: P3run Date: Tue, 6 Aug 2024 14:22:37 +0200 Subject: [PATCH 2/2] refactor(shorcuts): change the url for SunCalc and revert the changes in shortcuts.js --- configuration.js.sample | 2 +- src/services/shortcuts.js | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/configuration.js.sample b/configuration.js.sample index 3f5e007..c7b0819 100644 --- a/configuration.js.sample +++ b/configuration.js.sample @@ -77,7 +77,7 @@ self.configuration = { { name: "SunCalc", category: "🗺️ Maps", - url: "https://www.suncalc.org/#/$lat,$lng,15/$date/$time/1/1", + url: "https://www.suncalc.org/#/$lat,$lng,15/null/null/null/1", precision: 4, }, { diff --git a/src/services/shortcuts.js b/src/services/shortcuts.js index 9854104..566dac1 100644 --- a/src/services/shortcuts.js +++ b/src/services/shortcuts.js @@ -50,12 +50,9 @@ class Shortcuts { */ open(url, precision = null) { const coords = this.router.getCoordinates(); - const date = new Date(); url = url .replace("$lat", precision != null ? coords.lat.toFixed(precision) : coords.lat) - .replace("$lng", precision != null ? coords.lng.toFixed(precision) : coords.lng) - .replace("$date", date.toISOString().split('T')[0].replaceAll('-', '.')) - .replace("$time", date.toTimeString().slice(0,5)); + .replace("$lng", precision != null ? coords.lng.toFixed(precision) : coords.lng); window.open(url, '_blank'); }