-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
196 lines (174 loc) · 5.43 KB
/
index.html
File metadata and controls
196 lines (174 loc) · 5.43 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="favicon.png">
<title>Mars Rover Photos</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');
body {
font-family: 'Share Tech Mono', monospace;
background: linear-gradient(to bottom, #0b0c10, #000000);
color: #23e640;
margin: 0;
padding: 20px;
text-align: center;
background-image: url('https://plus.unsplash.com/premium_photo-1666232903265-ba0419aa3ef7?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8OXx8c3RhcmR1c3R8ZW58MHx8MHx8fDA%3D');
background-repeat: repeat;
}
h1 {
font-size: 2.5rem;
color:#e4ef0b;
text-shadow: 0 0 5px #1f2833;
margin-bottom: 20px;
}
.controls {
margin-bottom: 20px;
}
input, select, button {
padding: 10px;
margin: 10px;
border-radius: 8px;
border: 1px solid #45a29e;
background-color: #1f2833;
color: #ffffff;
font-size: 1rem;
box-shadow: inset 0 0 5px #0b0c10;
outline: none;
transition: 0.2s ease-in-out;
}
input:focus, select:focus, button:hover {
border-color: #66fcf1;
box-shadow: 0 0 10px #66fcf1;
}
button {
cursor: pointer;
background-color: #0b0c10;
color: #66fcf1;
font-weight: bold;
text-transform: uppercase;
border: 1px solid #66fcf1;
}
#photos {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin-top: 20px;
}
.photo-card {
background: #0f1115;
margin: 15px;
padding: 15px;
border-radius: 12px;
width: 300px;
box-shadow: 0 0 15px rgba(255, 255, 255, 0.05);
transition: 0.3s ease-in-out;
border: 1px solid #2d2e33;
}
.photo-card:hover {
transform: translateY(-5px);
box-shadow: 0 0 20px rgba(102, 252, 241, 0.15);
}
.photo-card img {
max-width: 100%;
border-radius: 10px;
margin-bottom: 10px;
border: 1px solid #2b2d31;
}
.download-btn {
padding: 8px 12px;
border-radius: 6px;
background-color: transparent;
color: #66fcf1;
border: 1px solid #66fcf1;
font-weight: bold;
cursor: pointer;
transition: 0.2s;
}
.download-btn:hover {
background-color: #66fcf1;
color: #0b0c10;
}
#about {
max-width: 800px;
margin: 40px auto 20px;
background: #111418;
padding: 15px;
border-radius: 8px;
border: 1px solid #2d2e33;
box-shadow: 0 0 10px rgba(255, 255, 255, 0.05);
text-align: left;
}
#about h2 {
margin-top: 0;
color: #66fcf1;
}
#about p {
line-height: 1.5;
margin-bottom: 10px;
}
</style>
</head>
<body>
<h1>📸 Mars Rover Photo Viewer</h1>
<div class="controls">
<label for="roverSelect">Choose a Rover:</label>
<select id="roverSelect">
<option value="curiosity">Curiosity</option>
<option value="opportunity">Opportunity</option>
<option value="spirit">Spirit</option>
</select>
<label for="dateInput">Choose a Date:</label>
<input type="date" id="dateInput" />
<button onclick="getPhotos()">Get Photos</button>
</div>
<div id="photos"></div>
<section id="about">
<h2>About Mars and the Rovers</h2>
<p>Mars, often called the Red Planet, is the fourth planet from the Sun and has fascinated humanity for centuries. NASA has sent several rovers to explore its surface, seeking to understand its geology, climate, and potential for past life.</p>
<p><strong>Curiosity</strong> landed in 2012 and continues to study Mars' habitability, analyzing soil samples and capturing stunning images.</p>
<p><strong>Opportunity</strong> explored Mars from 2004 to 2018, traveling over 45 kilometers and revealing evidence of past water activity.</p>
<p><strong>Spirit</strong> operated from 2004 to 2010, investigating ancient Martian terrain and contributing invaluable data before getting stuck in soft soil.</p>
</section>
<script>
function viewAndGuide(url) {
alert("💡 Right-click the image and choose 'Save image as...' to download it.");
window.open(url, '_blank');
}
async function getPhotos() {
const rover = document.getElementById('roverSelect').value;
const date = document.getElementById('dateInput').value;
const apiKey = 'BRkKo0fQW4iiCnJei9SVyQsEtJIFCLVUk8DC46cl'; //
const url = `https://api.nasa.gov/mars-photos/api/v1/rovers/${rover}/photos?earth_date=${date}&api_key=${apiKey}`;
try {
const response = await fetch(url);
const data = await response.json();
const photos = data.photos;
const photoDiv = document.getElementById('photos');
photoDiv.innerHTML = '';
if (photos.length === 0) {
photoDiv.innerHTML = '<p>No photos found for this rover on this date.</p>';
return;
}
photos.forEach(photo => {
const card = document.createElement('div');
card.className = 'photo-card';
card.innerHTML = `
<img src="${photo.img_src}" alt="Mars Rover Photo" />
<p><strong>Rover:</strong> ${photo.rover.name}</p>
<p><strong>Camera:</strong> ${photo.camera.full_name}</p>
<p><strong>Date:</strong> ${photo.earth_date}</p>
<button class="download-btn" onclick="viewAndGuide('${photo.img_src}')">⬇️ View & Download</button>
`;
photoDiv.appendChild(card);
});
} catch (err) {
console.error(err);
document.getElementById('photos').innerHTML = '<p>Something went wrong.</p>';
}
}
</script>
</body>
</html>