219 lines
7.3 KiB
HTML
219 lines
7.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Cartoon Weather Dashboard</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Arial Black', sans-serif;
|
|
background: #000;
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
|
|
h1 {
|
|
color: #FFD700;
|
|
font-size: 3em;
|
|
text-shadow: 4px 4px 0 #000;
|
|
text-align: center;
|
|
margin-bottom: 20px;
|
|
letter-spacing: 2px;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.dashboard {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
gap: 20px;
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.city-card {
|
|
background: #FFF;
|
|
border: 6px solid #000;
|
|
border-radius: 15px;
|
|
padding: 20px;
|
|
text-align: center;
|
|
box-shadow: 6px 6px 0 #DC143C;
|
|
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.city-card:nth-child(1) { background: linear-gradient(45deg, #FF6B6B, #FFE66D); border-color: #4ECDC4; box-shadow: 6px 6px 0 #4ECDC4; }
|
|
.city-card:nth-child(2) { background: linear-gradient(45deg, #4ECDC4, #45B7D1); border-color: #96CEB4; box-shadow: 6px 6px 0 #96CEB4; }
|
|
.city-card:nth-child(3) { background: linear-gradient(45deg, #96CEB4, #FECA57); border-color: #FF9FF3; box-shadow: 6px 6px 0 #FF9FF3; }
|
|
.city-card:nth-child(4) { background: linear-gradient(45deg, #FECA57, #FF9FF3); border-color: #54A0FF; box-shadow: 6px 6px 0 #54A0FF; }
|
|
.city-card:nth-child(5) { background: linear-gradient(45deg, #FF9FF3, #54A0FF); border-color: #5F27CD; box-shadow: 6px 6px 0 #5F27CD; }
|
|
.city-card:nth-child(6) { background: linear-gradient(45deg, #54A0FF, #5F27CD); border-color: #FF6B6B; box-shadow: 6px 6px 0 #FF6B6B; }
|
|
|
|
.city-card:hover {
|
|
transform: scale(1.05);
|
|
box-shadow: 8px 8px 0 currentColor;
|
|
}
|
|
|
|
.city-name {
|
|
font-size: 1.5em;
|
|
color: #000;
|
|
margin-bottom: 10px;
|
|
text-shadow: 2px 2px 0 rgba(255,255,255,0.5);
|
|
}
|
|
|
|
.weather-info {
|
|
margin: 10px 0;
|
|
}
|
|
|
|
.temperature {
|
|
font-size: 2.5em;
|
|
font-weight: bold;
|
|
text-shadow: 3px 3px 0 rgba(0,0,0,0.5);
|
|
color: #000;
|
|
}
|
|
|
|
.weather-desc {
|
|
font-size: 1.2em;
|
|
margin: 10px 0;
|
|
color: #000;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.weather-icon {
|
|
width: 60px;
|
|
height: 60px;
|
|
margin: 10px auto;
|
|
border: 4px solid #000;
|
|
border-radius: 50%;
|
|
background: #FFD700;
|
|
box-shadow: 3px 3px 0 #DC143C;
|
|
}
|
|
|
|
.cloud {
|
|
background: #FFF;
|
|
border-radius: 30px;
|
|
animation: bounce 2s ease-in-out infinite;
|
|
}
|
|
|
|
.rain::after {
|
|
content: '💧💧';
|
|
display: block;
|
|
font-size: 1.5em;
|
|
animation: drip 0.5s infinite;
|
|
}
|
|
|
|
.sun {
|
|
animation: spin 10s linear infinite;
|
|
}
|
|
|
|
@keyframes spin {
|
|
from { transform: rotate(0deg); }
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
@keyframes bounce {
|
|
0%, 100% { transform: translateY(0); }
|
|
50% { transform: translateY(-10px); }
|
|
}
|
|
|
|
@keyframes drip {
|
|
0%, 100% { transform: translateY(-3px); opacity: 1; }
|
|
50% { transform: translateY(3px); opacity: 0.5; }
|
|
}
|
|
|
|
.footer {
|
|
text-align: center;
|
|
color: #FFD700;
|
|
font-size: 0.9em;
|
|
margin-top: 20px;
|
|
text-shadow: 1px 1px 0 #000;
|
|
}
|
|
|
|
.error {
|
|
background: #DC143C;
|
|
color: #FFF;
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
margin: 5px 0;
|
|
border: 2px solid #000;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1> CARTOON WEATHER DASHBOARD </h1>
|
|
<div class="dashboard" id="dashboard">
|
|
<!-- City cards will be generated by JS -->
|
|
</div>
|
|
<div class="footer">
|
|
💾 Real-time Data 💾
|
|
</div>
|
|
|
|
<script>
|
|
const cities = [
|
|
{ name: 'Bucharest', display: 'Bucharest' },
|
|
{ name: 'Cluj', display: 'Cluj-Napoca' },
|
|
{ name: 'Timisoara', display: 'Timișoara' },
|
|
{ name: 'Brasov', display: 'Brașov' },
|
|
{ name: 'Constanta', display: 'Constanța' },
|
|
{ name: 'Iasi', display: 'Iași' }
|
|
];
|
|
|
|
function createDashboard() {
|
|
const dashboard = document.getElementById('dashboard');
|
|
cities.forEach(city => {
|
|
const card = document.createElement('div');
|
|
card.className = 'city-card';
|
|
card.innerHTML = `
|
|
<div class="city-name">${city.display}</div>
|
|
<div class="weather-info">
|
|
<div class="weather-icon sun" id="icon-${city.name}"></div>
|
|
<div class="temperature" id="temp-${city.name}">--°C</div>
|
|
<div class="weather-desc" id="desc-${city.name}">Loading...</div>
|
|
</div>
|
|
`;
|
|
card.addEventListener('click', () => {
|
|
card.style.transform = card.style.transform === 'scale(1.1)' ? 'scale(1)' : 'scale(1.1)';
|
|
});
|
|
dashboard.appendChild(card);
|
|
});
|
|
}
|
|
|
|
function getWeatherForAll() {
|
|
cities.forEach(city => {
|
|
const url = `https://wttr.in/${city.display}?format=j1`;
|
|
fetch(url)
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
const temp = data.current_condition[0].temp_C;
|
|
const desc = data.current_condition[0].weatherDesc[0].value;
|
|
document.getElementById(`temp-${city.name}`).textContent = Math.round(temp) + '°C';
|
|
document.getElementById(`desc-${city.name}`).textContent = desc.toUpperCase();
|
|
updateIcon(city.name, desc);
|
|
})
|
|
.catch(err => {
|
|
document.getElementById(`desc-${city.name}`).textContent = 'Error';
|
|
console.error(err);
|
|
});
|
|
});
|
|
}
|
|
|
|
function updateIcon(cityName, weather) {
|
|
const icon = document.getElementById(`icon-${cityName}`);
|
|
icon.className = 'weather-icon';
|
|
if (weather.includes('Cloud')) icon.classList.add('cloud');
|
|
else if (weather.includes('Rain') || weather.includes('Shower')) icon.classList.add('cloud', 'rain');
|
|
else if (weather.includes('Sunny') || weather.includes('Clear')) icon.classList.add('sun');
|
|
else icon.classList.add('sun');
|
|
}
|
|
|
|
createDashboard();
|
|
getWeatherForAll();
|
|
setInterval(getWeatherForAll, 600000); // Update every 10 minutes
|
|
</script>
|
|
</body>
|
|
</html> |