-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgalaxy.html
More file actions
402 lines (354 loc) · 11.7 KB
/
Copy pathgalaxy.html
File metadata and controls
402 lines (354 loc) · 11.7 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>3D Solar System</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
background-color: #000000;
background-image: url("https://wallpaperaccess.com/full/1268312.jpg");
overflow: hidden;
perspective: 1000px;
font-family: Arial, sans-serif;
}
.space {
width: 100vw;
height: 100vh;
position: relative;
}
.sun {
position: absolute;
top: 50%;
left: 50%;
width: 170px;
height: 170px;
margin-left: -70px;
margin-top: -70px;
background: url('https://media.istockphoto.com/id/1156217551/photo/sun-isolated-in-deep-black-background.jpg?s=170667a&w=0&k=20&c=xNwq9wnV03oXcnnx01VfVcvsLOHe84pxgeMIUrHHZI4=') no-repeat center/cover;
border-radius: 50%;
z-index: 0;
}
.system {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
transform: translate(-50%, -50%) rotateX(60deg);
transform-style: preserve-3d;
}
.orbit {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 1px dashed rgba(255, 255, 255, 0.2);
border-radius: 50%;
pointer-events: none;
}
.planet {
position: absolute;
border-radius: 50%;
background-size: cover;
background-position: center;
transform: translate(-50%, -50%) rotateX(-60deg);
z-index: 5;
}
.menu-container {
position: fixed;
top: 0;
left: 0;
z-index: 20;
height: 90%;
display: flex;
align-items: flex-start;
flex-direction: column;
}
.hamburger {
margin: 20px;
width: 35px;
cursor: pointer;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 22px;
z-index: 21;
}
.hamburger span {
height: 4px;
width: 100%;
background-color: #ccc;
border-radius: 4px;
transition: background 0.3s ease;
}
/* Full-height sliding popup */
.menu-popup {
position: fixed;
top: 0;
left: -250px; /* hidden by default */
width: 250px;
height: 100vh;
background-color: rgba(30, 30, 30, 0.85);
backdrop-filter: blur(8px);
padding-top: 80px;
box-shadow: 4px 0 15px rgba(0,0,0,0.5);
transition: left 0.3s ease;
}
.menu-popup ul {
list-style: none;
padding: 0 20px;
margin: 0;
}
.menu-popup li {
color: #fff;
padding: 15px 10px;
font-size: 18px;
cursor: pointer;
border-radius: 6px;
transition: background 0.2s ease;
}
.menu-popup li:hover {
background-color: rgba(255, 255, 255, 0.15);
}
/* Show popup on hover */
.menu-container:hover .menu-popup {
left: 0;
}
.data-popup {
position: fixed;
top: 10%;
left: 10%;
width: 80%;
height: 70%;
background-color: rgba(0, 0, 0, 0.7);
color: white;
overflow: auto;
border: 1px solid white;
border-radius: 10px;
padding: 20px;
display: none;
z-index: 25;
}
.table-container table {
width: 100%;
border-collapse: collapse;
}
.table-container th, .table-container td {
border: 1px solid white;
padding: 8px;
text-align: center;
}
.solar-heading {
position: fixed;
top: 18px;
left: 70px; /* right beside hamburger */
color: white;
font-size: 28px;
z-index: 21;
text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
font-family: 'Arial', sans-serif;
}
.sun {
position: absolute;
top: 50%;
left: 50%;
width: 170px;
height: 170px;
margin-left: -70px;
margin-top: -70px;
background: url('https://media.istockphoto.com/id/1156217551/photo/sun-isolated-in-deep-black-background.jpg?s=170667a&w=0&k=20&c=xNwq9wnV03oXcnnx01VfVcvsLOHe84pxgeMIUrHHZI4=') no-repeat center/cover;
border-radius: 50%;
z-index: 0;
/* Add the animation for rotating the sun */
animation: rotateSun 10s infinite linear; /* Adjust the timing as needed */
}
/* Keyframes to rotate the sun anticlockwise */
@keyframes rotateSun {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(-360deg); /* Negative value for anticlockwise rotation */
}
}
</style>
</head>
<body>
<h1 class="solar-heading"> Galaxies</h1>
<!-- Hamburger Menu -->
<div class="menu-container">
<div class="hamburger">
<span></span>
<span></span>
<span></span>
</div>
<div class="menu-popup">
<ul>
<li>Tables</li>
<li>Search</li>
</ul>
</div>
</div>
<!-- Table Popup -->
<div id="data-table-popup" class="data-popup">
<div class="table-container">
<table id="planets-table">
<thead>
<tr>
<th>Galaxy ID</th>
<th>Name</th>
<th>Type</th>
<th>Distance (ly)</th>
<th>Number of Stars</th>
<th>Discovery Date</th>
</tr>
</thead>
<tbody>
<!-- Data will be filled here -->
</tbody>
</table>
</div>
</div>
<!-- Search Popup -->
<div id="search-popup" class="data-popup">
<h2>Search Galaxies</h2>
<input type="text" id="search-input" placeholder="Enter galaxy name..." style="width: 50%; padding: 10px; margin: 10px 0; border-radius: 5px;">
<button id="search-btn" style="padding: 10px 20px; border-radius: 5px;">Search</button>
<div class="table-container">
<table id="search-results-table">
<thead>
<tr>
<th>Galaxy ID</th>
<th>Name</th>
<th>Type</th>
<th>Distance (ly)</th>
<th>Number of Stars</th>
<th>Discovery Date</th>
</tr>
</thead>
<tbody>
<!-- Results will go here -->
</tbody>
</table>
</div>
</div>
<div class="space">
<div class="sun"></div>
<div class="system">
<!-- Orbits -->
<div class="orbit" style="width: 300px; height: 180px;"></div>
<div class="orbit" style="width: 420px; height: 252px;"></div>
<div class="orbit" style="width: 540px; height: 324px;"></div>
<div class="orbit" style="width: 660px; height: 396px;"></div>
<div class="orbit" style="width: 780px; height: 468px;"></div>
<div class="orbit" style="width: 900px; height: 540px;"></div>
<div class="orbit" style="width: 1020px; height: 612px;"></div>
<div class="orbit" style="width: 1140px; height: 684px;"></div>
<!-- Planets -->
<div class="planet" style="width: 50px; height: 50px; background-image: url('https://upload.wikimedia.org/wikipedia/commons/4/4a/Mercury_in_true_color.jpg');"></div>
<div class="planet" style="width: 60px; height: 60px; background-image: url('https://upload.wikimedia.org/wikipedia/commons/e/e5/Venus-real_color.jpg');"></div>
<div class="planet" style="width: 55px; height: 55px; background-image: url('https://upload.wikimedia.org/wikipedia/commons/9/97/The_Earth_seen_from_Apollo_17.jpg');"></div>
<div class="planet" style="width: 50px; height: 50px; background-image: url('https://upload.wikimedia.org/wikipedia/commons/0/02/OSIRIS_Mars_true_color.jpg');"></div>
<div class="planet" style="width: 90px; height: 90px; background-image: url('https://upload.wikimedia.org/wikipedia/commons/e/e2/Jupiter.jpg');"></div>
<div class="planet" style="width: 75px; height: 75px; background-image: url('https://upload.wikimedia.org/wikipedia/commons/c/c7/Saturn_during_Equinox.jpg');"></div>
<div class="planet" style="width: 65px; height: 65px; background-image: url('https://upload.wikimedia.org/wikipedia/commons/3/3d/Uranus2.jpg');"></div>
<div class="planet" style="width: 65px; height: 65px; background-image: url('https://upload.wikimedia.org/wikipedia/commons/5/56/Neptune_Full.jpg');"></div>
</div>
</div>
<script>
const planetElems = document.querySelectorAll('.planet');
const orbitX = [150, 210, 270, 330, 390, 450, 510, 570];
const orbitY = orbitX.map(r => r * 0.6);
const speeds = [0.025, 0.02, 0.015, 0.012, 0.008, 0.007, 0.004, 0.003];
let angles = new Array(8).fill(0);
function animate() {
const centerX = window.innerWidth / 2;
const centerY = window.innerHeight / 2;
planetElems.forEach((planet, i) => {
angles[i] += speeds[i];
const x = centerX + Math.cos(angles[i]) * orbitX[i];
const y = centerY + Math.sin(angles[i]) * orbitY[i];
planet.style.left = `${x}px`;
planet.style.top = `${y}px`;
});
requestAnimationFrame(animate);
}
animate();
</script>
<script>
const tableMenuItem = document.querySelector('.menu-popup li:first-child');
const tablePopup = document.getElementById('data-table-popup');
tableMenuItem.addEventListener('click', () => {
// Toggle visibility
tablePopup.style.display = tablePopup.style.display === 'block' ? 'none' : 'block';
// Fetch data if not already loaded
if (tablePopup.style.display === 'block') {
fetch('getgalaxies.php')
.then(response => response.json())
.then(data => {
const tbody = document.querySelector('#planets-table tbody');
tbody.innerHTML = ''; // Clear old data
data.forEach(row => {
const tr = document.createElement('tr');
tr.innerHTML = `
<td>${row.Galaxy_ID}</td>
<td>${row.Name}</td>
<td>${row.Type}</td>
<td>${row.Distance_From_Earth}</td>
<td>${row.Number_Of_Stars}</td>
<td>${row.Discovery_Date}</td>
`;
tbody.appendChild(tr);
});
});
}
});
</script>
<script>
// Target the third menu item properly
const searchMenuItem = document.querySelector('.menu-popup li:nth-child(2)'); // Second item is 'Search', not third
// The search popup element
const searchPopup = document.getElementById('search-popup');
// Search button and input
const searchBtn = document.getElementById('search-btn');
const searchInput = document.getElementById('search-input');
// Search results table body
const searchResultsTbody = document.querySelector('#search-results-table tbody');
// Event listener to toggle the visibility of the search popup
searchMenuItem.addEventListener('click', () => {
searchPopup.style.display = searchPopup.style.display === 'block' ? 'none' : 'block';
});
// Event listener for the search button to perform the search
searchBtn.addEventListener('click', () => {
const query = searchInput.value.trim();
if (!query) return;
// Fetch search results from the server
fetch(`searchgalaxy.php?name=${encodeURIComponent(query)}`)
.then(response => response.json())
.then(data => {
searchResultsTbody.innerHTML = '';
if (data.length === 0) {
searchResultsTbody.innerHTML = `<tr><td colspan="6">No galaxies found</td></tr>`;
} else {
data.forEach(row => {
const tr = document.createElement('tr');
tr.innerHTML = `
<td>${row.Galaxy_ID}</td>
<td>${row.Name}</td>
<td>${row.Type}</td>
<td>${row.Distance_From_Earth}</td>
<td>${row.Number_Of_Stars}</td>
<td>${row.Discovery_Date}</td>
`;
searchResultsTbody.appendChild(tr);
});
}
});
});
</script>
</body>
</html>