dies und das

This commit is contained in:
2026-07-13 19:11:59 +02:00
parent 5aacd861de
commit dc5292735f
4 changed files with 315 additions and 37 deletions
+154
View File
@@ -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');
?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
@@ -228,6 +246,7 @@ $timeLocationLongitude = isset($currentLocation['longitude']) && is_numeric($cur
<button type="button" class="astro-conv-tab" data-tab-target="timeTab" role="tab" aria-selected="false">Zeit</button>
<button type="button" class="astro-conv-tab" data-tab-target="coordinatesTab" role="tab" aria-selected="false">Koordinaten</button>
<button type="button" class="astro-conv-tab" data-tab-target="angleTab" role="tab" aria-selected="false">Winkel</button>
<button type="button" class="astro-conv-tab" data-tab-target="toolsTab" role="tab" aria-selected="false">Diverse Tools</button>
</div>
<section class="card astro-conv-panel astro-conv-tab-panel is-active" id="distanceTab" role="tabpanel">
@@ -497,6 +516,58 @@ $timeLocationLongitude = isset($currentLocation['longitude']) && is_numeric($cur
<button type="button" class="btn btn-primary" id="angleArcsecond">1 Bogensekunde</button>
</div>
</section>
<section class="card astro-conv-panel astro-conv-tab-panel" id="toolsTab" role="tabpanel">
<h2>Diverse Tools</h2>
<p>Sonnenstand für den Standard-Standort aus dem Header berechnen. Datum und Uhrzeit werden in der lokalen Zeitzone des Standorts interpretiert.</p>
<div class="astro-conv-grid" id="toolsConverter">
<div class="astro-conv-field">
<label for="toolsDateTimeLocal">Datum und Uhrzeit lokal</label>
<input class="astro-conv-input" id="toolsDateTimeLocal" type="datetime-local" value="<?= h($toolDefaultLocalDateTime) ?>">
</div>
<div class="astro-conv-field">
<label for="toolsLocationName">Standort</label>
<input class="astro-conv-input" id="toolsLocationName" type="text" value="<?= h($toolLocationName) ?>" readonly>
</div>
<div class="astro-conv-field">
<label for="toolsTimeZone">Zeitzone</label>
<input class="astro-conv-input" id="toolsTimeZone" type="text" value="<?= h($toolLocationTimezone) ?>" readonly>
</div>
<div class="astro-conv-field">
<label for="toolsLatitude">Breitengrad</label>
<input class="astro-conv-input" id="toolsLatitude" type="text" value="<?= h(number_format($toolLocationLatitude, 4, '.', '')) ?>" readonly>
</div>
<div class="astro-conv-field">
<label for="toolsLongitude">Längengrad</label>
<input class="astro-conv-input" id="toolsLongitude" type="text" value="<?= h(number_format($toolLocationLongitude, 4, '.', '')) ?>" readonly>
</div>
<div class="astro-conv-field">
<label for="toolsDateTimeUtc">UTC</label>
<input class="astro-conv-input" id="toolsDateTimeUtc" type="text" readonly>
</div>
<div class="astro-conv-field">
<label for="toolsSunAltitude">Sonnenhöhe Alt (°)</label>
<input class="astro-conv-input" id="toolsSunAltitude" type="text" readonly>
</div>
<div class="astro-conv-field">
<label for="toolsSunAzimuth">Azimut Azi (°)</label>
<input class="astro-conv-input" id="toolsSunAzimuth" type="text" readonly>
</div>
</div>
<div class="astro-conv-actions">
<button type="button" class="btn btn-secondary" id="toolsClear">Leeren</button>
<button type="button" class="btn btn-primary" id="toolsNow">Jetzt am Standort</button>
</div>
</section>
</div>
<script src="js/number_to_german_words.js"></script>
@@ -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();
})();
</script>