Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>RainPredictor - Weather Forecasting</title> | |
| <link rel="icon" type="image/x-icon" href="/static/favicon.ico"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | |
| <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet"> | |
| <script> | |
| tailwind.config = { | |
| theme: { | |
| extend: { | |
| colors: { | |
| primary: '#3b82f6', | |
| secondary: '#8b5cf6', | |
| dark: '#1e293b', | |
| light: '#f8fafc' | |
| } | |
| } | |
| } | |
| } | |
| </script> | |
| <style> | |
| body { | |
| font-family: 'Poppins', sans-serif; | |
| background: linear-gradient(135deg, #1e3c72, #2a5298); | |
| min-height: 100vh; | |
| } | |
| .weather-card { | |
| backdrop-filter: blur(10px); | |
| background: rgba(255, 255, 255, 0.1); | |
| border: 1px solid rgba(255, 255, 255, 0.2); | |
| box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); | |
| } | |
| .prediction-card { | |
| transition: all 0.3s ease; | |
| } | |
| .prediction-card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); | |
| } | |
| .rain-chance-bar { | |
| height: 8px; | |
| border-radius: 4px; | |
| background: linear-gradient(to right, #3b82f6, #8b5cf6); | |
| } | |
| .temperature-display { | |
| font-size: 4rem; | |
| font-weight: 700; | |
| background: linear-gradient(to right, #3b82f6, #8b5cf6); | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| } | |
| </style> | |
| </head> | |
| <body class="text-light"> | |
| <!-- Header --> | |
| <header class="py-6 px-4 sm:px-8"> | |
| <div class="container mx-auto flex justify-between items-center"> | |
| <div class="flex items-center space-x-2"> | |
| <i data-feather="cloud" class="text-primary w-8 h-8"></i> | |
| <h1 class="text-2xl font-bold">RainPredictor</h1> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <button id="theme-toggle" class="p-2 rounded-full bg-dark bg-opacity-30 hover:bg-opacity-50 transition"> | |
| <i data-feather="moon" class="w-5 h-5"></i> | |
| </button> | |
| <div class="relative"> | |
| <input type="text" id="city-input" placeholder="Search city..." class="py-2 px-4 pr-10 rounded-full bg-dark bg-opacity-30 placeholder-light placeholder-opacity-70 focus:outline-none focus:ring-2 focus:ring-primary"> | |
| <i data-feather="search" class="absolute right-3 top-2.5 w-5 h-5"></i> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <main class="container mx-auto px-4 py-8"> | |
| <!-- Current Weather Section --> | |
| <section class="mb-12"> | |
| <div class="weather-card rounded-2xl p-6 mb-8"> | |
| <div class="flex flex-col md:flex-row justify-between items-center"> | |
| <div class="mb-6 md:mb-0"> | |
| <h2 class="text-3xl font-bold" id="city-name">New York, US</h2> | |
| <p class="text-light text-opacity-80 mt-2" id="current-date">Monday, June 12, 2023</p> | |
| <div class="flex items-center mt-4"> | |
| <i data-feather="sun" class="w-12 h-12 text-yellow-300 mr-4"></i> | |
| <div> | |
| <div class="temperature-display" id="current-temp">24°</div> | |
| <p class="text-light text-opacity-80" id="weather-description">Sunny</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-2 gap-4"> | |
| <div class="text-center p-4 bg-dark bg-opacity-20 rounded-xl"> | |
| <p class="text-light text-opacity-80">Humidity</p> | |
| <p class="text-xl font-bold" id="humidity">65%</p> | |
| </div> | |
| <div class="text-center p-4 bg-dark bg-opacity-20 rounded-xl"> | |
| <p class="text-light text-opacity-80">Wind</p> | |
| <p class="text-xl font-bold" id="wind-speed">12 km/h</p> | |
| </div> | |
| <div class="text-center p-4 bg-dark bg-opacity-20 rounded-xl"> | |
| <p class="text-light text-opacity-80">Pressure</p> | |
| <p class="text-xl font-bold" id="pressure">1013 hPa</p> | |
| </div> | |
| <div class="text-center p-4 bg-dark bg-opacity-20 rounded-xl"> | |
| <p class="text-light text-opacity-80">Feels Like</p> | |
| <p class="text-xl font-bold" id="feels-like">26°</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Rain Prediction Section --> | |
| <section class="mb-12"> | |
| <h2 class="text-2xl font-bold mb-6">Rain Prediction</h2> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> | |
| <div class="prediction-card weather-card rounded-2xl p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-xl font-semibold">Today's Forecast</h3> | |
| <span class="px-3 py-1 bg-primary bg-opacity-20 rounded-full text-primary" id="today-date">Jun 12</span> | |
| </div> | |
| <div class="flex items-center justify-between"> | |
| <div class="flex items-center"> | |
| <i data-feather="cloud-drizzle" class="w-10 h-10 text-primary mr-4"></i> | |
| <div> | |
| <p class="text-2xl font-bold" id="today-rain-chance">75%</p> | |
| <p class="text-light text-opacity-80">Chance of Rain</p> | |
| </div> | |
| </div> | |
| <div class="text-right"> | |
| <p class="text-light text-opacity-80">Precipitation</p> | |
| <p class="text-xl font-bold" id="today-precipitation">5.2mm</p> | |
| </div> | |
| </div> | |
| <div class="mt-6"> | |
| <p class="text-light text-opacity-80 mb-2">Rain Probability</p> | |
| <div class="w-full bg-dark bg-opacity-30 rounded-full h-2"> | |
| <div class="rain-chance-bar" id="today-rain-bar" style="width: 75%"></div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="prediction-card weather-card rounded-2xl p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-xl font-semibold">Tomorrow's Forecast</h3> | |
| <span class="px-3 py-1 bg-secondary bg-opacity-20 rounded-full text-secondary" id="tomorrow-date">Jun 13</span> | |
| </div> | |
| <div class="flex items-center justify-between"> | |
| <div class="flex items-center"> | |
| <i data-feather="cloud" class="w-10 h-10 text-secondary mr-4"></i> | |
| <div> | |
| <p class="text-2xl font-bold" id="tomorrow-rain-chance">30%</p> | |
| <p class="text-light text-opacity-80">Chance of Rain</p> | |
| </div> | |
| </div> | |
| <div class="text-right"> | |
| <p class="text-light text-opacity-80">Precipitation</p> | |
| <p class="text-xl font-bold" id="tomorrow-precipitation">0.5mm</p> | |
| </div> | |
| </div> | |
| <div class="mt-6"> | |
| <p class="text-light text-opacity-80 mb-2">Rain Probability</p> | |
| <div class="w-full bg-dark bg-opacity-30 rounded-full h-2"> | |
| <div class="rain-chance-bar" id="tomorrow-rain-bar" style="width: 30%"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- 7-Day Forecast --> | |
| <section> | |
| <h2 class="text-2xl font-bold mb-6">7-Day Forecast</h2> | |
| <div class="weather-card rounded-2xl p-6"> | |
| <canvas id="forecast-chart" height="100"></canvas> | |
| </div> | |
| </section> | |
| </main> | |
| <!-- Footer --> | |
| <footer class="py-8 px-4 mt-12"> | |
| <div class="container mx-auto text-center text-light text-opacity-70"> | |
| <p>© 2023 RainPredictor. All weather data provided by OpenWeatherMap.</p> | |
| <p class="mt-2">Using historical data for accurate rain predictions.</p> | |
| </div> | |
| </footer> | |
| <script> | |
| // Initialize Feather Icons | |
| feather.replace(); | |
| // Set current date | |
| const now = new Date(); | |
| const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; | |
| document.getElementById('current-date').textContent = now.toLocaleDateString('en-US', options); | |
| // Format dates for forecast | |
| const today = new Date(); | |
| const tomorrow = new Date(today); | |
| tomorrow.setDate(tomorrow.getDate() + 1); | |
| document.getElementById('today-date').textContent = today.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); | |
| document.getElementById('tomorrow-date').textContent = tomorrow.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); | |
| // Mock data for Jaipur | |
| const mockWeatherData = { | |
| cityName: "Jaipur, India", | |
| temperature: 38, | |
| description: "Clear Sky", | |
| humidity: 25, | |
| windSpeed: 8, | |
| pressure: 1005, | |
| feelsLike: 41, | |
| todayRainChance: 5, | |
| todayPrecipitation: 0.0, | |
| tomorrowRainChance: 10, | |
| tomorrowPrecipitation: 0.2 | |
| }; | |
| // Update UI with mock data | |
| document.getElementById('city-name').textContent = mockWeatherData.cityName; | |
| document.getElementById('current-temp').textContent = `${mockWeatherData.temperature}°`; | |
| document.getElementById('weather-description').textContent = mockWeatherData.description; | |
| document.getElementById('humidity').textContent = `${mockWeatherData.humidity}%`; | |
| document.getElementById('wind-speed').textContent = `${mockWeatherData.windSpeed} km/h`; | |
| document.getElementById('pressure').textContent = `${mockWeatherData.pressure} hPa`; | |
| document.getElementById('feels-like').textContent = `${mockWeatherData.feelsLike}°`; | |
| document.getElementById('today-rain-chance').textContent = `${mockWeatherData.todayRainChance}%`; | |
| document.getElementById('today-precipitation').textContent = `${mockWeatherData.todayPrecipitation}mm`; | |
| document.getElementById('tomorrow-rain-chance').textContent = `${mockWeatherData.tomorrowRainChance}%`; | |
| document.getElementById('tomorrow-precipitation').textContent = `${mockWeatherData.tomorrowPrecipitation}mm`; | |
| document.getElementById('today-rain-bar').style.width = `${mockWeatherData.todayRainChance}%`; | |
| document.getElementById('tomorrow-rain-bar').style.width = `${mockWeatherData.tomorrowRainChance}%`; | |
| // 7-day forecast chart | |
| const ctx = document.getElementById('forecast-chart').getContext('2d'); | |
| const forecastChart = new Chart(ctx, { | |
| type: 'bar', | |
| data: { | |
| labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], | |
| datasets: [{ | |
| label: 'Rain Chance %', | |
| data: [5, 10, 15, 5, 10, 20, 25], | |
| backgroundColor: [ | |
| 'rgba(59, 130, 246, 0.7)', | |
| 'rgba(59, 130, 246, 0.7)', | |
| 'rgba(59, 130, 246, 0.7)', | |
| 'rgba(59, 130, 246, 0.7)', | |
| 'rgba(59, 130, 246, 0.7)', | |
| 'rgba(139, 92, 246, 0.7)', | |
| 'rgba(139, 92, 246, 0.7)' | |
| ], | |
| borderColor: [ | |
| 'rgba(59, 130, 246, 1)', | |
| 'rgba(59, 130, 246, 1)', | |
| 'rgba(59, 130, 246, 1)', | |
| 'rgba(59, 130, 246, 1)', | |
| 'rgba(59, 130, 246, 1)', | |
| 'rgba(139, 92, 246, 1)', | |
| 'rgba(139, 92, 246, 1)' | |
| ], | |
| borderWidth: 1 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| plugins: { | |
| legend: { | |
| display: false | |
| } | |
| }, | |
| scales: { | |
| y: { | |
| beginAtZero: true, | |
| max: 100, | |
| ticks: { | |
| color: 'rgba(255, 255, 255, 0.7)', | |
| callback: function(value) { | |
| return value + '%'; | |
| } | |
| }, | |
| grid: { | |
| color: 'rgba(255, 255, 255, 0.1)' | |
| } | |
| }, | |
| x: { | |
| ticks: { | |
| color: 'rgba(255, 255, 255, 0.7)' | |
| }, | |
| grid: { | |
| display: false | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| // Theme toggle functionality | |
| const themeToggle = document.getElementById('theme-toggle'); | |
| const moonIcon = themeToggle.querySelector('i'); | |
| themeToggle.addEventListener('click', () => { | |
| document.body.classList.toggle('dark'); | |
| if (document.body.classList.contains('dark')) { | |
| moonIcon.setAttribute('data-feather', 'sun'); | |
| } else { | |
| moonIcon.setAttribute('data-feather', 'moon'); | |
| } | |
| feather.replace(); | |
| }); | |
| // City search functionality | |
| const cityInput = document.getElementById('city-input'); | |
| cityInput.addEventListener('keypress', function(e) { | |
| if (e.key === 'Enter') { | |
| const city = cityInput.value.trim(); | |
| if (city) { | |
| // In a real app, this would fetch data from OpenWeatherMap API | |
| console.log(`Searching for weather in ${city}`); | |
| // Update the city name in the UI | |
| document.getElementById('city-name').textContent = city + ", India"; | |
| cityInput.value = ''; | |
| } | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |