diff --git a/config/jupiter_grs.json b/config/jupiter_grs.json index e1c8ff3..a9f2f7a 100644 --- a/config/jupiter_grs.json +++ b/config/jupiter_grs.json @@ -1,6 +1,32 @@ { - "refDate": "2026-04-13T00:31:40.897Z", - "refAngle": 312227.6287687423, - "calibratedAt": "2026-04-12T09:26:52+00:00", - "calibratedBy": "Eskimue" + "refDate": "2026-04-13T04:07:00.000Z", + "refAngle": 312229.88248732366, + "calibratedAt": "2026-04-12T09:35:41+00:00", + "calibratedBy": "Eskimue", + "history": [ + { + "refDate": "2025-04-12T01:08:00.000Z", + "refAngle": 306668.75732167566, + "calibratedAt": "2026-04-12T09:33:58+00:00", + "calibratedBy": "Eskimue" + }, + { + "refDate": "2026-01-01T09:49:00.000Z", + "refAngle": 310684.2913082397, + "calibratedAt": "2026-04-12T09:38:07+00:00", + "calibratedBy": "Eskimue" + }, + { + "refDate": "2026-04-12T08:15:00.000Z", + "refAngle": 312217.3093069398, + "calibratedAt": "2026-04-12T09:32:29+00:00", + "calibratedBy": "Eskimue" + }, + { + "refDate": "2026-04-13T04:07:00.000Z", + "refAngle": 312229.88248732366, + "calibratedAt": "2026-04-12T09:35:41+00:00", + "calibratedBy": "Eskimue" + } + ] } \ No newline at end of file diff --git a/public/jupitersystem.php b/public/jupitersystem.php index 34369e8..9a667b5 100644 --- a/public/jupitersystem.php +++ b/public/jupitersystem.php @@ -24,12 +24,26 @@ if (isset($_GET['grs_api'])) { if (!$isAdmin) { http_response_code(403); echo json_encode(['error' => 'Nicht autorisiert']); exit; } $body = json_decode(file_get_contents('php://input'), true); if (!$body || !isset($body['refDate'], $body['refAngle'])) { http_response_code(400); echo json_encode(['error' => 'Ungültige Daten']); exit; } - $data = [ + $existing = []; + if (file_exists($dataFile)) { + $existing = json_decode(file_get_contents($dataFile), true) ?? []; + } + $history = $existing['history'] ?? []; + $history[] = [ 'refDate' => (string) $body['refDate'], 'refAngle' => (float) $body['refAngle'], 'calibratedAt' => date('c'), 'calibratedBy' => $_SESSION['username'] ?? 'admin', ]; + usort($history, fn($a, $b) => strcmp((string) $a['refDate'], (string) $b['refDate'])); + $latest = end($history); + $data = [ + 'refDate' => $latest['refDate'], + 'refAngle' => $latest['refAngle'], + 'calibratedAt' => $latest['calibratedAt'], + 'calibratedBy' => $latest['calibratedBy'], + 'history' => $history, + ]; $written = file_put_contents($dataFile, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); echo $written !== false ? json_encode(['ok' => true]) : json_encode(['error' => 'Schreibfehler – Dateiberechtigung prüfen']); exit; @@ -140,6 +154,15 @@ $bodyClass = 'solarsystem-page jupitersystem-page';
+ + @@ -779,6 +802,60 @@ function parseGrsTransitInput(str) { return isNaN(d.getTime()) ? null : d; } +function renderGrsDrift(history) { + const section = document.getElementById('grsDriftSection'); + const table = document.getElementById('grsDriftTable'); + const avgEl = document.getElementById('grsDriftAvg'); + if (!section || !table || !avgEl || !Array.isArray(history) || history.length < 2) { + if (section) section.style.display = 'none'; + return; + } + + const RAD_TO_DEG = 180 / Math.PI; + + let rows = ''; + const driftRates = []; + + for (let i = 1; i < history.length; i++) { + const prev = history[i - 1]; + const curr = history[i]; + const t1 = new Date(prev.refDate).getTime(); + const t2 = new Date(curr.refDate).getTime(); + const elapsedDays = (t2 - t1) / 86400000; + if (elapsedDays <= 0) continue; + + const expectedDeg = (elapsedDays / GRS_SYSTEM_II_PERIOD_DAYS) * 360; + const actualDeg = (curr.refAngle - prev.refAngle) * RAD_TO_DEG; + // Drift auf den Bereich [-180, 180] normieren + let drift = ((actualDeg - expectedDeg) % 360 + 540) % 360 - 180; + const driftPerDay = drift / elapsedDays; + driftRates.push(driftPerDay); + + const sign = driftPerDay >= 0 ? '+' : ''; + const color = Math.abs(driftPerDay) < 0.05 ? 'var(--text-dim)' : (driftPerDay > 0 ? 'var(--gold-pale)' : 'var(--cyan)'); + const dateStr = new Date(curr.refDate).toLocaleString('de-DE', { timeZone: 'UTC', dateStyle: 'short', timeStyle: 'short' }); + + rows += `