diff --git a/public/astronomical_conversions.php b/public/astronomical_conversions.php
index 43e7e12..99d21df 100644
--- a/public/astronomical_conversions.php
+++ b/public/astronomical_conversions.php
@@ -53,6 +53,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && (string) ($_POST['ajax'] ?? '') ===
trim((string) ($_POST['sourceUnit'] ?? '')),
trim((string) ($_POST['sourceValue'] ?? '')),
]);
+ } elseif ($kind === 'tools') {
+ $pythonResult = runPythonApi('astronomical_conversions', [
+ 'tools',
+ trim((string) ($_POST['tool'] ?? '')),
+ trim((string) ($_POST['dateTimeLocal'] ?? '')),
+ trim((string) ($_POST['latitude'] ?? '')),
+ trim((string) ($_POST['longitude'] ?? '')),
+ trim((string) ($_POST['timeZone'] ?? '')),
+ ]);
} else {
echo json_encode([
'ok' => false,
@@ -79,6 +88,15 @@ $timeLocationName = !empty($currentLocation['name']) ? (string) $currentLocation
$timeLocationLongitude = isset($currentLocation['longitude']) && is_numeric($currentLocation['longitude'])
? (float) $currentLocation['longitude']
: null;
+$toolLocationName = !empty($currentLocation['name']) ? (string) $currentLocation['name'] : 'Standard-Standort';
+$toolLocationLatitude = isset($currentLocation['latitude']) && is_numeric($currentLocation['latitude'])
+ ? (float) $currentLocation['latitude']
+ : 50.3597;
+$toolLocationLongitude = isset($currentLocation['longitude']) && is_numeric($currentLocation['longitude'])
+ ? (float) $currentLocation['longitude']
+ : 11.1907;
+$toolLocationTimezone = !empty($currentLocation['timezone']) ? (string) $currentLocation['timezone'] : 'Europe/Berlin';
+$toolDefaultLocalDateTime = (new DateTimeImmutable('now', new DateTimeZone($toolLocationTimezone)))->format('Y-m-d\TH:i');
?>
@@ -228,6 +246,7 @@ $timeLocationLongitude = isset($currentLocation['longitude']) && is_numeric($cur
+
@@ -497,6 +516,58 @@ $timeLocationLongitude = isset($currentLocation['longitude']) && is_numeric($cur
+
+
@@ -509,6 +580,12 @@ $timeLocationLongitude = isset($currentLocation['longitude']) && is_numeric($cur
name: = json_encode($timeLocationName, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>,
longitude: = $timeLocationLongitude !== null ? json_encode($timeLocationLongitude) : 'null' ?>
};
+ const USER_TOOL_LOCATION = {
+ name: = json_encode($toolLocationName, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>,
+ latitude: = json_encode($toolLocationLatitude) ?>,
+ longitude: = json_encode($toolLocationLongitude) ?>,
+ timeZone: = json_encode($toolLocationTimezone, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>
+ };
const SPEED_OF_LIGHT_KM_S = 299792.458;
const H0 = 70;
const OMEGA_M = 0.3;
@@ -570,6 +647,16 @@ $timeLocationLongitude = isset($currentLocation['longitude']) && is_numeric($cur
arcsec: document.getElementById('angleArcsec'),
rad: document.getElementById('angleRad')
};
+ const toolFields = {
+ dateTimeLocal: document.getElementById('toolsDateTimeLocal'),
+ locationName: document.getElementById('toolsLocationName'),
+ timeZone: document.getElementById('toolsTimeZone'),
+ latitude: document.getElementById('toolsLatitude'),
+ longitude: document.getElementById('toolsLongitude'),
+ dateTimeUtc: document.getElementById('toolsDateTimeUtc'),
+ altitude: document.getElementById('toolsSunAltitude'),
+ azimuth: document.getElementById('toolsSunAzimuth')
+ };
let isSyncingTimePicker = false;
let timeUtcPicker = null;
let distanceRequestId = 0;
@@ -577,6 +664,7 @@ $timeLocationLongitude = isset($currentLocation['longitude']) && is_numeric($cur
let timeRequestId = 0;
let coordinateRequestId = 0;
let angleRequestId = 0;
+ let toolRequestId = 0;
const DECIMAL_DIVISION_PRECISION = 32;
const pow10Cache = [1n];
@@ -1573,6 +1661,71 @@ $timeLocationLongitude = isset($currentLocation['longitude']) && is_numeric($cur
updateAngleFrom('arcsec');
});
+ const clearToolOutputs = function () {
+ toolFields.dateTimeUtc.value = '';
+ toolFields.altitude.value = '';
+ toolFields.azimuth.value = '';
+ updateTooltip(toolFields.dateTimeUtc);
+ updateTooltip(toolFields.altitude);
+ updateTooltip(toolFields.azimuth);
+ };
+
+ const updateSolarTool = async function () {
+ const localDateTime = toolFields.dateTimeLocal.value.trim();
+ if (localDateTime === '') {
+ clearToolOutputs();
+ return;
+ }
+
+ const requestId = ++toolRequestId;
+ try {
+ const result = await requestConversion({
+ kind: 'tools',
+ tool: 'solar_altaz',
+ dateTimeLocal: localDateTime,
+ latitude: USER_TOOL_LOCATION.latitude,
+ longitude: USER_TOOL_LOCATION.longitude,
+ timeZone: USER_TOOL_LOCATION.timeZone
+ });
+
+ if (requestId !== toolRequestId || !result.valid) {
+ return;
+ }
+
+ toolFields.dateTimeUtc.value = typeof result.fields.utc === 'string' ? result.fields.utc : '';
+ toolFields.altitude.value = typeof result.fields.altitude === 'string' ? result.fields.altitude : '';
+ toolFields.azimuth.value = typeof result.fields.azimuth === 'string' ? result.fields.azimuth : '';
+ updateTooltip(toolFields.dateTimeUtc);
+ updateTooltip(toolFields.altitude);
+ updateTooltip(toolFields.azimuth);
+ } catch (error) {
+ clearToolOutputs();
+ }
+ };
+
+ toolFields.dateTimeLocal.addEventListener('input', updateSolarTool);
+
+ document.getElementById('toolsClear').addEventListener('click', function () {
+ toolFields.dateTimeLocal.value = '';
+ clearToolOutputs();
+ toolFields.dateTimeLocal.focus();
+ });
+
+ document.getElementById('toolsNow').addEventListener('click', function () {
+ const now = new Date();
+ const formatter = new Intl.DateTimeFormat('sv-SE', {
+ timeZone: USER_TOOL_LOCATION.timeZone,
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit',
+ hour: '2-digit',
+ minute: '2-digit',
+ hourCycle: 'h23'
+ });
+ toolFields.dateTimeLocal.value = formatter.format(now).replace(' ', 'T');
+ updateSolarTool();
+ });
+
const tabs = Array.from(document.querySelectorAll('.astro-conv-tab'));
const tabPanels = Array.from(document.querySelectorAll('.astro-conv-tab-panel'));
@@ -1599,6 +1752,7 @@ $timeLocationLongitude = isset($currentLocation['longitude']) && is_numeric($cur
updateTimeFrom('utc');
updateCoordinatesFrom('equatorial');
updateAngleFrom('deg');
+ updateSolarTool();
})();
diff --git a/public/daemmerungszeiten.php b/public/daemmerungszeiten.php
index 5bef097..50a8b95 100644
--- a/public/daemmerungszeiten.php
+++ b/public/daemmerungszeiten.php
@@ -363,6 +363,8 @@ body.daemmerungszeiten-page main > .container {
+
+
@@ -392,7 +394,6 @@ body.daemmerungszeiten-page main > .container {
-