-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMars_Weather.html
More file actions
139 lines (116 loc) · 4.75 KB
/
Mars_Weather.html
File metadata and controls
139 lines (116 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mars Weather App</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
body {
font-family: 'Helvetica Neue', Arial, sans-serif;
background: url('https://mars.nasa.gov/system/news_items/main_images/9337_PIA25681-FigureA-web.jpg') no-repeat center center fixed;
background-size: cover;
color: #ffffff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
.weather-container {
background-color: rgba(68, 68, 68, 0.9);
padding: 30px;
border-radius: 20px;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
max-width: 500px;
width: 90%;
}
.weather-title {
font-size: 32px;
font-weight: 600;
margin-bottom: 20px;
}
.weather-info {
display: grid;
grid-template-columns: 1fr 2fr;
gap: 20px;
align-items: center;
margin-bottom: 20px;
}
.weather-info i {
font-size: 40px;
}
.weather-detail {
text-align: left;
font-size: 18px;
}
.advice {
margin-top: 20px;
font-size: 16px;
background-color: rgba(255, 255, 255, 0.15);
padding: 20px;
border-radius: 15px;
max-width: 500px;
text-align: left;
}
</style>
</head>
<body>
<div class="weather-container">
<div class="weather-title">Current Mars Weather</div>
<div class="weather-info" id="weather">Loading...</div>
<div class="advice" id="advice">Loading advice...</div>
</div>
<script>
async function getMarsWeather() {
try {
const response = await fetch('https://api.allorigins.win/get?url=' + encodeURIComponent('https://api.maas2.apollorion.com/'));
const data = await response.json();
const marsData = JSON.parse(data.contents);
const minTempF = (marsData.min_temp * 9/5) + 32;
const maxTempF = (marsData.max_temp * 9/5) + 32;
const weatherElement = document.getElementById('weather');
weatherElement.innerHTML = `
<div class="weather-detail">
<i class="fas fa-sun"></i>
<p>Sol: ${marsData.sol}</p>
</div>
<div class="weather-detail">
<i class="fas fa-thermometer-half"></i>
<p>Temperature: ${minTempF.toFixed(1)}℉ to ${maxTempF.toFixed(1)}℉</p>
</div>
<div class="weather-detail">
<i class="fas fa-tachometer-alt"></i>
<p>Pressure: ${marsData.pressure} Pa</p>
</div>
<div class="weather-detail">
<i class="fas fa-globe"></i>
<p>Season: ${marsData.season}</p>
</div>
`;
const adviceElement = document.getElementById('advice');
let advice = "";
if (marsData.min_temp < -100) {
advice += "<p><strong>Temperature Warning:</strong> Extremely cold conditions. Make sure to wear a heated spacesuit if you plan to go outside.</p>";
}
if (marsData.pressure < 700) {
advice += "<p><strong>Pressure Warning:</strong> Low atmospheric pressure. A pressurized suit is necessary to survive outside.</p>";
}
advice += "<p><strong>General Tips:</strong> Remember to check your oxygen supply before stepping outside, and always have a communication device to stay connected with your habitat base.</p>";
adviceElement.innerHTML = advice;
} catch (error) {
document.getElementById('weather').innerHTML = 'Failed to retrieve Mars weather.';
document.getElementById('advice').innerHTML = '';
console.error('Error fetching Mars weather:', error);
}
}
getMarsWeather();
setInterval(getMarsWeather, 600000); // Update weather every 10 minutes
</script>
</body>
</html>