feat: Initial commit of existing overlay files
This commit is contained in:
79
weather_overlay/index.html
Normal file
79
weather_overlay/index.html
Normal file
@@ -0,0 +1,79 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Weather Overlay</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
color: white;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
#weather-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
#weather-icon {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="weather-container">
|
||||
<img id="weather-icon" src="" alt="Weather Icon">
|
||||
<div>
|
||||
<h1 id="temperature"></h1>
|
||||
<p id="weather-description"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const latitude = 40.71;
|
||||
const longitude = -74.01;
|
||||
const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t_weather=true`;
|
||||
|
||||
fetch(apiUrl)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const temperature = data.current_weather.temperature;
|
||||
const weatherCode = data.current_weather.weathercode;
|
||||
|
||||
document.getElementById('temperature').textContent = `${temperature}°C`;
|
||||
document.getElementById('weather-description').textContent = getWeatherDescription(weatherCode);
|
||||
document.getElementById('weather-icon').src = getWeatherIcon(weatherCode);
|
||||
})
|
||||
.catch(error => console.error('Error fetching weather data:', error));
|
||||
|
||||
function getWeatherDescription(code) {
|
||||
// This is a simplified mapping. You can expand it for more detailed descriptions.
|
||||
if (code === 0) return "Clear sky";
|
||||
if (code > 0 && code < 4) return "Partly cloudy";
|
||||
if (code > 44 && code < 49) return "Fog";
|
||||
if (code > 50 && code < 58) return "Drizzle";
|
||||
if (code > 60 && code < 68) return "Rain";
|
||||
if (code > 70 && code < 78) return "Snow";
|
||||
if (code > 80 && code < 83) return "Rain showers";
|
||||
if (code > 94) return "Thunderstorm";
|
||||
return "Cloudy";
|
||||
}
|
||||
|
||||
function getWeatherIcon(code) {
|
||||
// This is a simplified mapping. You can expand it with more icons.
|
||||
if (code === 0) return "https://openweathermap.org/img/wn/01d@2x.png"; // Clear sky
|
||||
if (code > 0 && code < 4) return "https://openweathermap.org/img/wn/02d@2x.png"; // Partly cloudy
|
||||
if (code > 44 && code < 49) return "https://openweathermap.org/img/wn/50d@2x.png"; // Fog
|
||||
if (code > 50 && code < 58) return "https://openweathermap.org/img/wn/09d@2x.png"; // Drizzle
|
||||
if (code > 60 && code < 68) return "https://openweathermap.org/img/wn/10d@2x.png"; // Rain
|
||||
if (code > 70 && code < 78) return "https://openweathermap.org/img/wn/13d@2x.png"; // Snow
|
||||
if (code > 80 && code < 83) return "https://openweathermap.org/img/wn/09d@2x.png"; // Rain showers
|
||||
if (code > 94) return "https://openweathermap.org/img/wn/11d@2x.png"; // Thunderstorm
|
||||
return "https://openweathermap.org/img/wn/03d@2x.png"; // Cloudy
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user