add navbar

This commit is contained in:
ThePetrovich 2025-04-05 01:23:03 +08:00
parent cd98f04622
commit 859966c48d
5 changed files with 118 additions and 61 deletions

View file

@ -109,59 +109,6 @@
`;
});
});
// Forecast request function
const getForecast = async () => {
// Create request object
const request = {
ascent_rate: parseFloat(ascentRate),
burst_altitude: parseFloat(burstAltitude),
dataset: new Date().toISOString(), // Current time as dataset timestamp
descent_rate: parseFloat(descentRate),
format: "json",
launch_altitude: parseFloat(startHeight),
launch_datetime: new Date(
`${startDate.getFullYear()}-${startDate.getMonth() + 1}-${startDate.getDate()}T${startTime}:00Z`
).toISOString(),
launch_latitude: parseFloat(inputLat),
launch_longitude: parseFloat(inputLng),
profile: flightProfile === 'Normal' ? 'standard_profile' : 'custom_profile',
version: 2
};
console.log("Sending request:", request);
try {
// Example POST request - replace with your actual API endpoint
const response = await fetch('https://api.example.com/forecast', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(request)
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log("Forecast response:", data);
alert("Forecast request successful!");
// Handle the response data as needed
} catch (error) {
console.error("Error sending forecast request:", error);
alert("Error getting forecast: " + error.message);
}
};
// Helper function to format date as YYYY-MM-DD
const formatDateForAPI = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
};
</script>
<div class="container-fluid position-relative h-100">