Spaces:
Running
Running
Download index.html from phlehmann/cosmic-explorer: direct link, hf CLI and curl.
- Browser
- Download file 32.7 kB
-
https://huggingface.co/spaces/phlehmann/cosmic-explorer/resolve/main/index.html
- Command line
-
hf download hf://spaces/phlehmann/cosmic-explorer/index.html
-
curl -L -o index.html https://huggingface.co/spaces/phlehmann/cosmic-explorer/resolve/main/index.html
32.7 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Cosmic Explorer - Exoplanet Database</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap'); | |
| body { | |
| font-family: 'Space Grotesk', sans-serif; | |
| background-color: #0a0e17; | |
| color: #e0e0e0; | |
| } | |
| .planet-card { | |
| background: linear-gradient(135deg, #1a2035 0%, #0d1221 100%); | |
| border: 1px solid #2a3a5a; | |
| transition: all 0.3s ease; | |
| } | |
| .planet-card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3); | |
| border-color: #3d5a80; | |
| } | |
| .search-input { | |
| background-color: rgba(26, 32, 53, 0.7); | |
| border: 1px solid #2a3a5a; | |
| } | |
| .search-input:focus { | |
| border-color: #3d5a80; | |
| box-shadow: 0 0 0 2px rgba(61, 90, 128, 0.3); | |
| } | |
| .loading-spinner { | |
| border-top-color: #3d5a80; | |
| animation: spin 1s linear infinite; | |
| } | |
| @keyframes spin { | |
| 0% { transform: rotate(0deg); } | |
| 100% { transform: rotate(360deg); } | |
| } | |
| .planet-detail { | |
| background: linear-gradient(135deg, #1a2035 0%, #0d1221 100%); | |
| border: 1px solid #2a3a5a; | |
| } | |
| .planet-feature { | |
| background-color: rgba(26, 32, 53, 0.5); | |
| } | |
| .pagination-btn { | |
| background-color: rgba(26, 32, 53, 0.7); | |
| border: 1px solid #2a3a5a; | |
| } | |
| .pagination-btn:hover { | |
| background-color: rgba(61, 90, 128, 0.5); | |
| } | |
| .pagination-btn.active { | |
| background-color: #3d5a80; | |
| } | |
| .planet-visualization { | |
| background: radial-gradient(circle, #1a2035 0%, #0d1221 100%); | |
| border: 1px solid #2a3a5a; | |
| } | |
| </style> | |
| </head> | |
| <body class="min-h-screen"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <!-- Header --> | |
| <header class="mb-10 text-center"> | |
| <div class="flex items-center justify-center mb-4"> | |
| <i class="fas fa-globe-americas text-4xl text-blue-400 mr-3"></i> | |
| <h1 class="text-4xl font-bold bg-gradient-to-r from-blue-400 to-purple-500 bg-clip-text text-transparent">Cosmic Explorer</h1> | |
| </div> | |
| <p class="text-lg text-gray-400 max-w-2xl mx-auto"> | |
| Explore the vast database of exoplanets discovered beyond our solar system. Search, filter, and visualize these distant worlds. | |
| </p> | |
| </header> | |
| <!-- Search and Filter Section --> | |
| <div class="mb-8"> | |
| <div class="flex flex-col md:flex-row gap-4 mb-6"> | |
| <div class="relative flex-grow"> | |
| <i class="fas fa-search absolute left-3 top-3 text-gray-500"></i> | |
| <input type="text" id="searchInput" placeholder="Search by planet name, star, or discovery method..." | |
| class="w-full py-2 pl-10 pr-4 rounded-lg text-white search-input focus:outline-none"> | |
| </div> | |
| <select id="filterDiscovery" class="py-2 px-4 rounded-lg text-white search-input focus:outline-none"> | |
| <option value="">All Discovery Methods</option> | |
| <option value="Transit">Transit</option> | |
| <option value="Radial Velocity">Radial Velocity</option> | |
| <option value="Imaging">Imaging</option> | |
| <option value="Microlensing">Microlensing</option> | |
| </select> | |
| <select id="filterHabitable" class="py-2 px-4 rounded-lg text-white search-input focus:outline-none"> | |
| <option value="">All Planets</option> | |
| <option value="true">Potentially Habitable</option> | |
| </select> | |
| </div> | |
| <div class="flex flex-wrap gap-2"> | |
| <button id="sortMass" class="px-4 py-2 rounded-lg planet-feature text-sm flex items-center"> | |
| <i class="fas fa-weight-hanging mr-2"></i> Sort by Mass | |
| </button> | |
| <button id="sortDistance" class="px-4 py-2 rounded-lg planet-feature text-sm flex items-center"> | |
| <i class="fas fa-map-marker-alt mr-2"></i> Sort by Distance | |
| </button> | |
| <button id="sortYear" class="px-4 py-2 rounded-lg planet-feature text-sm flex items-center"> | |
| <i class="fas fa-calendar-alt mr-2"></i> Sort by Discovery Year | |
| </button> | |
| <button id="sortTemp" class="px-4 py-2 rounded-lg planet-feature text-sm flex items-center"> | |
| <i class="fas fa-temperature-low mr-2"></i> Sort by Temperature | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Loading Indicator --> | |
| <div id="loading" class="flex justify-center items-center py-20 hidden"> | |
| <div class="w-12 h-12 border-4 border-blue-500 border-dotted rounded-full loading-spinner"></div> | |
| </div> | |
| <!-- Main Content --> | |
| <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6" id="planetsContainer"> | |
| <!-- Planets will be loaded here --> | |
| </div> | |
| <!-- Pagination --> | |
| <div class="flex justify-center mt-10 gap-2" id="pagination"> | |
| <!-- Pagination buttons will be added here --> | |
| </div> | |
| <!-- Planet Detail Modal --> | |
| <div id="planetModal" class="fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50 hidden"> | |
| <div class="planet-detail rounded-lg p-6 max-w-4xl w-full mx-4 max-h-[90vh] overflow-y-auto"> | |
| <div class="flex justify-between items-start mb-6"> | |
| <div> | |
| <h2 id="modalPlanetName" class="text-2xl font-bold text-blue-400"></h2> | |
| <p id="modalPlanetSystem" class="text-gray-400"></p> | |
| </div> | |
| <button id="closeModal" class="text-gray-400 hover:text-white"> | |
| <i class="fas fa-times text-2xl"></i> | |
| </button> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> | |
| <div class="planet-visualization rounded-lg p-6 flex flex-col items-center justify-center"> | |
| <div id="planetVisual" class="w-40 h-40 rounded-full mb-4"></div> | |
| <canvas id="planetOrbit" width="300" height="300" class="w-full max-w-xs"></canvas> | |
| </div> | |
| <div> | |
| <h3 class="text-xl font-semibold mb-4 text-purple-400">Planet Characteristics</h3> | |
| <div class="grid grid-cols-2 gap-4 mb-6"> | |
| <div class="planet-feature p-3 rounded-lg"> | |
| <p class="text-sm text-gray-400">Mass</p> | |
| <p id="modalPlanetMass" class="font-bold"></p> | |
| </div> | |
| <div class="planet-feature p-3 rounded-lg"> | |
| <p class="text-sm text-gray-400">Radius</p> | |
| <p id="modalPlanetRadius" class="font-bold"></p> | |
| </div> | |
| <div class="planet-feature p-3 rounded-lg"> | |
| <p class="text-sm text-gray-400">Temperature</p> | |
| <p id="modalPlanetTemp" class="font-bold"></p> | |
| </div> | |
| <div class="planet-feature p-3 rounded-lg"> | |
| <p class="text-sm text-gray-400">Orbital Period</p> | |
| <p id="modalPlanetPeriod" class="font-bold"></p> | |
| </div> | |
| </div> | |
| <h3 class="text-xl font-semibold mb-4 text-purple-400">Host Star</h3> | |
| <div class="grid grid-cols-2 gap-4 mb-6"> | |
| <div class="planet-feature p-3 rounded-lg"> | |
| <p class="text-sm text-gray-400">Star Name</p> | |
| <p id="modalStarName" class="font-bold"></p> | |
| </div> | |
| <div class="planet-feature p-3 rounded-lg"> | |
| <p class="text-sm text-gray-400">Star Type</p> | |
| <p id="modalStarType" class="font-bold"></p> | |
| </div> | |
| <div class="planet-feature p-3 rounded-lg"> | |
| <p class="text-sm text-gray-400">Distance</p> | |
| <p id="modalStarDistance" class="font-bold"></p> | |
| </div> | |
| <div class="planet-feature p-3 rounded-lg"> | |
| <p class="text-sm text-gray-400">Star Temperature</p> | |
| <p id="modalStarTemp" class="font-bold"></p> | |
| </div> | |
| </div> | |
| <div class="planet-feature p-4 rounded-lg mb-4"> | |
| <p class="text-sm text-gray-400">Discovery Details</p> | |
| <p id="modalDiscovery" class="font-bold"></p> | |
| </div> | |
| <div id="habitabilityBadge" class="inline-block px-4 py-2 rounded-full bg-green-900 text-green-300 hidden"> | |
| <i class="fas fa-leaf mr-2"></i> Potentially Habitable | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // Sample exoplanet data (in a real app, this would come from an API) | |
| const exoplanets = [ | |
| { | |
| name: "Kepler-186f", | |
| hostStar: "Kepler-186", | |
| discoveryYear: 2014, | |
| discoveryMethod: "Transit", | |
| mass: 1.44, | |
| radius: 1.17, | |
| orbitalPeriod: 129.9, | |
| distance: 492, | |
| equilibriumTemp: 188, | |
| starType: "M1V", | |
| starTemp: 3755, | |
| potentiallyHabitable: true | |
| }, | |
| { | |
| name: "TRAPPIST-1e", | |
| hostStar: "TRAPPIST-1", | |
| discoveryYear: 2017, | |
| discoveryMethod: "Transit", | |
| mass: 0.62, | |
| radius: 0.92, | |
| orbitalPeriod: 6.1, | |
| distance: 39, | |
| equilibriumTemp: 251, | |
| starType: "M8V", | |
| starTemp: 2550, | |
| potentiallyHabitable: true | |
| }, | |
| { | |
| name: "Proxima Centauri b", | |
| hostStar: "Proxima Centauri", | |
| discoveryYear: 2016, | |
| discoveryMethod: "Radial Velocity", | |
| mass: 1.27, | |
| radius: 1.08, | |
| orbitalPeriod: 11.2, | |
| distance: 4.2, | |
| equilibriumTemp: 234, | |
| starType: "M5.5V", | |
| starTemp: 3042, | |
| potentiallyHabitable: true | |
| }, | |
| { | |
| name: "HD 209458 b", | |
| hostStar: "HD 209458", | |
| discoveryYear: 1999, | |
| discoveryMethod: "Transit", | |
| mass: 0.69, | |
| radius: 1.38, | |
| orbitalPeriod: 3.5, | |
| distance: 159, | |
| equilibriumTemp: 1459, | |
| starType: "G0V", | |
| starTemp: 6071, | |
| potentiallyHabitable: false | |
| }, | |
| { | |
| name: "51 Pegasi b", | |
| hostStar: "51 Pegasi", | |
| discoveryYear: 1995, | |
| discoveryMethod: "Radial Velocity", | |
| mass: 0.46, | |
| radius: 1.9, | |
| orbitalPeriod: 4.2, | |
| distance: 50, | |
| equilibriumTemp: 1284, | |
| starType: "G2IV", | |
| starTemp: 5793, | |
| potentiallyHabitable: false | |
| }, | |
| { | |
| name: "GJ 1214 b", | |
| hostStar: "GJ 1214", | |
| discoveryYear: 2009, | |
| discoveryMethod: "Transit", | |
| mass: 6.26, | |
| radius: 2.74, | |
| orbitalPeriod: 1.6, | |
| distance: 48, | |
| equilibriumTemp: 547, | |
| starType: "M4.5V", | |
| starTemp: 3250, | |
| potentiallyHabitable: false | |
| }, | |
| { | |
| name: "Kepler-22b", | |
| hostStar: "Kepler-22", | |
| discoveryYear: 2011, | |
| discoveryMethod: "Transit", | |
| mass: 36, | |
| radius: 2.38, | |
| orbitalPeriod: 289.9, | |
| distance: 638, | |
| equilibriumTemp: 262, | |
| starType: "G5V", | |
| starTemp: 5518, | |
| potentiallyHabitable: true | |
| }, | |
| { | |
| name: "WASP-17b", | |
| hostStar: "WASP-17", | |
| discoveryYear: 2009, | |
| discoveryMethod: "Transit", | |
| mass: 0.49, | |
| radius: 1.99, | |
| orbitalPeriod: 3.7, | |
| distance: 1337, | |
| equilibriumTemp: 1740, | |
| starType: "F6V", | |
| starTemp: 6550, | |
| potentiallyHabitable: false | |
| }, | |
| { | |
| name: "Gliese 581 g", | |
| hostStar: "Gliese 581", | |
| discoveryYear: 2010, | |
| discoveryMethod: "Radial Velocity", | |
| mass: 3.1, | |
| radius: 1.5, | |
| orbitalPeriod: 36.6, | |
| distance: 20, | |
| equilibriumTemp: 209, | |
| starType: "M3V", | |
| starTemp: 3480, | |
| potentiallyHabitable: true | |
| }, | |
| { | |
| name: "HD 189733 b", | |
| hostStar: "HD 189733", | |
| discoveryYear: 2005, | |
| discoveryMethod: "Transit", | |
| mass: 1.13, | |
| radius: 1.14, | |
| orbitalPeriod: 2.2, | |
| distance: 63, | |
| equilibriumTemp: 1200, | |
| starType: "K1V", | |
| starTemp: 4980, | |
| potentiallyHabitable: false | |
| } | |
| ]; | |
| // DOM elements | |
| const planetsContainer = document.getElementById('planetsContainer'); | |
| const searchInput = document.getElementById('searchInput'); | |
| const filterDiscovery = document.getElementById('filterDiscovery'); | |
| const filterHabitable = document.getElementById('filterHabitable'); | |
| const loading = document.getElementById('loading'); | |
| const planetModal = document.getElementById('planetModal'); | |
| const closeModal = document.getElementById('closeModal'); | |
| const sortMass = document.getElementById('sortMass'); | |
| const sortDistance = document.getElementById('sortDistance'); | |
| const sortYear = document.getElementById('sortYear'); | |
| const sortTemp = document.getElementById('sortTemp'); | |
| // Pagination variables | |
| let currentPage = 1; | |
| const planetsPerPage = 9; | |
| let filteredPlanets = [...exoplanets]; | |
| let currentSort = null; | |
| let sortAscending = true; | |
| // Initialize the app | |
| function init() { | |
| renderPlanets(); | |
| setupEventListeners(); | |
| } | |
| // Set up event listeners | |
| function setupEventListeners() { | |
| searchInput.addEventListener('input', () => { | |
| currentPage = 1; | |
| filterPlanets(); | |
| }); | |
| filterDiscovery.addEventListener('change', () => { | |
| currentPage = 1; | |
| filterPlanets(); | |
| }); | |
| filterHabitable.addEventListener('change', () => { | |
| currentPage = 1; | |
| filterPlanets(); | |
| }); | |
| closeModal.addEventListener('click', () => { | |
| planetModal.classList.add('hidden'); | |
| }); | |
| // Sorting buttons | |
| sortMass.addEventListener('click', () => toggleSort('mass')); | |
| sortDistance.addEventListener('click', () => toggleSort('distance')); | |
| sortYear.addEventListener('click', () => toggleSort('discoveryYear')); | |
| sortTemp.addEventListener('click', () => toggleSort('equilibriumTemp')); | |
| } | |
| // Filter planets based on search and filters | |
| function filterPlanets() { | |
| const searchTerm = searchInput.value.toLowerCase(); | |
| const discoveryMethod = filterDiscovery.value; | |
| const habitableOnly = filterHabitable.value === 'true'; | |
| filteredPlanets = exoplanets.filter(planet => { | |
| const matchesSearch = planet.name.toLowerCase().includes(searchTerm) || | |
| planet.hostStar.toLowerCase().includes(searchTerm) || | |
| planet.discoveryMethod.toLowerCase().includes(searchTerm); | |
| const matchesDiscovery = discoveryMethod ? planet.discoveryMethod === discoveryMethod : true; | |
| const matchesHabitable = habitableOnly ? planet.potentiallyHabitable : true; | |
| return matchesSearch && matchesDiscovery && matchesHabitable; | |
| }); | |
| if (currentSort) { | |
| sortPlanets(currentSort, sortAscending); | |
| } | |
| renderPlanets(); | |
| } | |
| // Toggle sorting | |
| function toggleSort(sortKey) { | |
| if (currentSort === sortKey) { | |
| sortAscending = !sortAscending; | |
| } else { | |
| currentSort = sortKey; | |
| sortAscending = true; | |
| } | |
| sortPlanets(sortKey, sortAscending); | |
| renderPlanets(); | |
| // Update active state for sort buttons | |
| document.querySelectorAll('[id^="sort"]').forEach(btn => { | |
| btn.classList.remove('bg-blue-800', 'text-white'); | |
| }); | |
| const activeBtn = document.getElementById(`sort${sortKey.charAt(0).toUpperCase() + sortKey.slice(1)}`); | |
| if (activeBtn) { | |
| activeBtn.classList.add('bg-blue-800', 'text-white'); | |
| } | |
| } | |
| // Sort planets | |
| function sortPlanets(sortKey, ascending) { | |
| filteredPlanets.sort((a, b) => { | |
| let comparison = 0; | |
| if (sortKey === 'mass') { | |
| comparison = a.mass - b.mass; | |
| } else if (sortKey === 'distance') { | |
| comparison = a.distance - b.distance; | |
| } else if (sortKey === 'discoveryYear') { | |
| comparison = a.discoveryYear - b.discoveryYear; | |
| } else if (sortKey === 'equilibriumTemp') { | |
| comparison = a.equilibriumTemp - b.equilibriumTemp; | |
| } | |
| return ascending ? comparison : -comparison; | |
| }); | |
| } | |
| // Render planets to the DOM | |
| function renderPlanets() { | |
| // Show loading indicator | |
| loading.classList.remove('hidden'); | |
| planetsContainer.innerHTML = ''; | |
| // Calculate pagination | |
| const totalPages = Math.ceil(filteredPlanets.length / planetsPerPage); | |
| const startIndex = (currentPage - 1) * planetsPerPage; | |
| const endIndex = Math.min(startIndex + planetsPerPage, filteredPlanets.length); | |
| const planetsToShow = filteredPlanets.slice(startIndex, endIndex); | |
| // Simulate loading delay | |
| setTimeout(() => { | |
| if (planetsToShow.length === 0) { | |
| planetsContainer.innerHTML = ` | |
| <div class="col-span-full text-center py-10"> | |
| <i class="fas fa-search text-5xl text-gray-600 mb-4"></i> | |
| <h3 class="text-xl font-semibold text-gray-300">No planets found</h3> | |
| <p class="text-gray-500">Try adjusting your search or filters</p> | |
| </div> | |
| `; | |
| } else { | |
| planetsToShow.forEach(planet => { | |
| const planetCard = createPlanetCard(planet); | |
| planetsContainer.appendChild(planetCard); | |
| }); | |
| } | |
| // Render pagination | |
| renderPagination(totalPages); | |
| // Hide loading indicator | |
| loading.classList.add('hidden'); | |
| }, 500); | |
| } | |
| // Create a planet card element | |
| function createPlanetCard(planet) { | |
| const card = document.createElement('div'); | |
| card.className = 'planet-card rounded-lg p-6 cursor-pointer hover:shadow-lg'; | |
| card.innerHTML = ` | |
| <div class="flex items-start justify-between mb-4"> | |
| <div> | |
| <h3 class="text-xl font-bold text-blue-400">${planet.name}</h3> | |
| <p class="text-sm text-gray-400">${planet.hostStar}</p> | |
| </div> | |
| ${planet.potentiallyHabitable ? | |
| '<span class="px-2 py-1 text-xs rounded-full bg-green-900 text-green-300 flex items-center"><i class="fas fa-leaf mr-1"></i> Habitable</span>' : ''} | |
| </div> | |
| <div class="flex justify-center mb-4"> | |
| <div class="w-20 h-20 rounded-full ${getPlanetColorClass(planet)} flex items-center justify-center"> | |
| <i class="fas ${getPlanetIcon(planet)} text-2xl"></i> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-2 gap-3 text-sm"> | |
| <div class="planet-feature p-2 rounded-lg"> | |
| <p class="text-gray-400">Mass</p> | |
| <p class="font-bold">${planet.mass} M⊕</p> | |
| </div> | |
| <div class="planet-feature p-2 rounded-lg"> | |
| <p class="text-gray-400">Distance</p> | |
| <p class="font-bold">${planet.distance} ly</p> | |
| </div> | |
| <div class="planet-feature p-2 rounded-lg"> | |
| <p class="text-gray-400">Temperature</p> | |
| <p class="font-bold">${planet.equilibriumTemp} K</p> | |
| </div> | |
| <div class="planet-feature p-2 rounded-lg"> | |
| <p class="text-gray-400">Discovered</p> | |
| <p class="font-bold">${planet.discoveryYear}</p> | |
| </div> | |
| </div> | |
| <div class="mt-4 pt-3 border-t border-gray-800 flex justify-between items-center"> | |
| <span class="text-xs px-2 py-1 rounded ${getDiscoveryMethodClass(planet.discoveryMethod)}"> | |
| ${planet.discoveryMethod} | |
| </span> | |
| <button class="text-blue-400 hover:text-blue-300 text-sm flex items-center"> | |
| Details <i class="fas fa-chevron-right ml-1 text-xs"></i> | |
| </button> | |
| </div> | |
| `; | |
| card.addEventListener('click', () => showPlanetDetails(planet)); | |
| return card; | |
| } | |
| // Render pagination controls | |
| function renderPagination(totalPages) { | |
| const paginationContainer = document.getElementById('pagination'); | |
| paginationContainer.innerHTML = ''; | |
| if (totalPages <= 1) return; | |
| // Previous button | |
| const prevBtn = document.createElement('button'); | |
| prevBtn.className = `pagination-btn px-4 py-2 rounded-l-lg ${currentPage === 1 ? 'opacity-50 cursor-not-allowed' : ''}`; | |
| prevBtn.innerHTML = '<i class="fas fa-chevron-left"></i>'; | |
| prevBtn.disabled = currentPage === 1; | |
| prevBtn.addEventListener('click', () => { | |
| if (currentPage > 1) { | |
| currentPage--; | |
| renderPlanets(); | |
| } | |
| }); | |
| paginationContainer.appendChild(prevBtn); | |
| // Page buttons | |
| const maxVisiblePages = 5; | |
| let startPage = Math.max(1, currentPage - Math.floor(maxVisiblePages / 2)); | |
| let endPage = Math.min(totalPages, startPage + maxVisiblePages - 1); | |
| if (endPage - startPage + 1 < maxVisiblePages) { | |
| startPage = Math.max(1, endPage - maxVisiblePages + 1); | |
| } | |
| for (let i = startPage; i <= endPage; i++) { | |
| const pageBtn = document.createElement('button'); | |
| pageBtn.className = `pagination-btn px-4 py-2 ${currentPage === i ? 'active' : ''}`; | |
| pageBtn.textContent = i; | |
| pageBtn.addEventListener('click', () => { | |
| currentPage = i; | |
| renderPlanets(); | |
| }); | |
| paginationContainer.appendChild(pageBtn); | |
| } | |
| // Next button | |
| const nextBtn = document.createElement('button'); | |
| nextBtn.className = `pagination-btn px-4 py-2 rounded-r-lg ${currentPage === totalPages ? 'opacity-50 cursor-not-allowed' : ''}`; | |
| nextBtn.innerHTML = '<i class="fas fa-chevron-right"></i>'; | |
| nextBtn.disabled = currentPage === totalPages; | |
| nextBtn.addEventListener('click', () => { | |
| if (currentPage < totalPages) { | |
| currentPage++; | |
| renderPlanets(); | |
| } | |
| }); | |
| paginationContainer.appendChild(nextBtn); | |
| } | |
| // Show planet details modal | |
| function showPlanetDetails(planet) { | |
| // Set modal content | |
| document.getElementById('modalPlanetName').textContent = planet.name; | |
| document.getElementById('modalPlanetSystem').textContent = `Planet in the ${planet.hostStar} system`; | |
| document.getElementById('modalPlanetMass').textContent = `${planet.mass} Earth masses`; | |
| document.getElementById('modalPlanetRadius').textContent = planet.radius ? `${planet.radius} Earth radii` : 'Unknown'; | |
| document.getElementById('modalPlanetTemp').textContent = `${planet.equilibriumTemp} K`; | |
| document.getElementById('modalPlanetPeriod').textContent = `${planet.orbitalPeriod} Earth days`; | |
| document.getElementById('modalStarName').textContent = planet.hostStar; | |
| document.getElementById('modalStarType').textContent = planet.starType || 'Unknown'; | |
| document.getElementById('modalStarDistance').textContent = `${planet.distance} light years`; | |
| document.getElementById('modalStarTemp').textContent = planet.starTemp ? `${planet.starTemp} K` : 'Unknown'; | |
| document.getElementById('modalDiscovery').textContent = `Discovered in ${planet.discoveryYear} using ${planet.discoveryMethod} method`; | |
| // Show habitable badge if applicable | |
| const habitabilityBadge = document.getElementById('habitabilityBadge'); | |
| if (planet.potentiallyHabitable) { | |
| habitabilityBadge.classList.remove('hidden'); | |
| } else { | |
| habitabilityBadge.classList.add('hidden'); | |
| } | |
| // Set planet visualization | |
| const planetVisual = document.getElementById('planetVisual'); | |
| planetVisual.className = `w-40 h-40 rounded-full mb-4 ${getPlanetColorClass(planet)} flex items-center justify-center`; | |
| planetVisual.innerHTML = `<i class="fas ${getPlanetIcon(planet)} text-4xl"></i>`; | |
| // Draw orbit visualization | |
| drawOrbit(planet); | |
| // Show modal | |
| planetModal.classList.remove('hidden'); | |
| } | |
| // Draw orbit visualization | |
| function drawOrbit(planet) { | |
| const canvas = document.getElementById('planetOrbit'); | |
| const ctx = canvas.getContext('2d'); | |
| // Clear canvas | |
| ctx.clearRect(0, 0, canvas.width, canvas.height); | |
| // Draw star | |
| ctx.fillStyle = '#FFD700'; | |
| ctx.beginPath(); | |
| ctx.arc(canvas.width / 2, canvas.height / 2, 10, 0, Math.PI * 2); | |
| ctx.fill(); | |
| // Draw orbit | |
| ctx.strokeStyle = 'rgba(255, 255, 255, 0.2)'; | |
| ctx.lineWidth = 1; | |
| ctx.beginPath(); | |
| ctx.ellipse(canvas.width / 2, canvas.height / 2, 100, 50, 0, 0, Math.PI * 2); | |
| ctx.stroke(); | |
| // Draw planet | |
| const planetSize = Math.max(5, Math.min(20, planet.radius * 5)); | |
| const angle = (Date.now() / 2000) % (Math.PI * 2); | |
| const planetX = canvas.width / 2 + Math.cos(angle) * 100; | |
| const planetY = canvas.height / 2 + Math.sin(angle) * 50; | |
| ctx.fillStyle = getPlanetColor(planet); | |
| ctx.beginPath(); | |
| ctx.arc(planetX, planetY, planetSize, 0, Math.PI * 2); | |
| ctx.fill(); | |
| // Animation | |
| if (!planetModal.classList.contains('hidden')) { | |
| requestAnimationFrame(() => drawOrbit(planet)); | |
| } | |
| } | |
| // Helper functions for planet styling | |
| function getPlanetColorClass(planet) { | |
| if (planet.potentiallyHabitable) return 'bg-green-900'; | |
| if (planet.equilibriumTemp > 1000) return 'bg-red-900'; | |
| if (planet.mass > 10) return 'bg-purple-900'; | |
| return 'bg-blue-900'; | |
| } | |
| function getPlanetColor(planet) { | |
| if (planet.potentiallyHabitable) return '#3D9970'; | |
| if (planet.equilibriumTemp > 1000) return '#FF4136'; | |
| if (planet.mass > 10) return '#B10DC9'; | |
| return '#0074D9'; | |
| } | |
| function getPlanetIcon(planet) { | |
| if (planet.potentiallyHabitable) return 'fa-globe-americas'; | |
| if (planet.equilibriumTemp > 1000) return 'fa-fire'; | |
| if (planet.mass > 10) return 'fa-ring'; | |
| return 'fa-globe'; | |
| } | |
| function getDiscoveryMethodClass(method) { | |
| switch(method) { | |
| case 'Transit': return 'bg-blue-900 text-blue-300'; | |
| case 'Radial Velocity': return 'bg-purple-900 text-purple-300'; | |
| case 'Imaging': return 'bg-yellow-900 text-yellow-300'; | |
| case 'Microlensing': return 'bg-pink-900 text-pink-300'; | |
| default: return 'bg-gray-800 text-gray-300'; | |
| } | |
| } | |
| // Initialize the app | |
| init(); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=phlehmann/cosmic-explorer" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |