`; } return html; } async function fetchWeather(loc){ const params=new URLSearchParams({ latitude:loc.lat, longitude:loc.lon, timezone:"America/New_York", temperature_unit:"fahrenheit", wind_speed_unit:"mph", forecast_days:"7", current:"temperature_2m,apparent_temperature,weather_code,wind_speed_10m,wind_direction_10m", hourly:"temperature_2m,apparent_temperature,precipitation_probability,weather_code,wind_speed_10m", daily:"weather_code,temperature_2m_max,temperature_2m_min,apparent_temperature_max,precipitation_probability_max,wind_speed_10m_max" }); const response=await fetch( "https://api.open-meteo.com/v1/forecast?"+params.toString() ); if(!response.ok)throw new Error("Weather request failed"); return response.json(); } async function loadWeather(){ try{ const dataList=await Promise.all(locations.map(fetchWeather)); const today=dataList[0].daily.time[0]; const cards=dataList.map((data,i)=>{ const current=data.current; return `
${locations[i].name}
${weatherIcon(current.weather_code)}
${fmt(current.temperature_2m,"°F")}
High ${fmt(data.daily.temperature_2m_max[0],"°")} / Low ${fmt(data.daily.temperature_2m_min[0],"°")}
${weatherText(current.weather_code)}
💧 Rain today: ${fmt(data.daily.precipitation_probability_max[0],"%")}
`; }).join(""); const high=max(dataList.map(d=>d.daily.temperature_2m_max[0])); const low=min(dataList.map(d=>d.daily.temperature_2m_min[0])); const rain=max(dataList.map(d=>d.daily.precipitation_probability_max[0])); const feels=max(dataList.map(d=>d.daily.apparent_temperature_max[0])); const wind=max(dataList.map(d=>d.daily.wind_speed_10m_max[0])); const morning=dataList.flatMap(d=>hoursFor(d,6,12,today)); const afternoon=dataList.flatMap(d=>hoursFor(d,12,18,today)); const tonight=dataList.flatMap(d=>hoursFor(d,18,24,today)); const updated=new Date().toLocaleString("en-US",{ timeZone:"America/New_York", month:"short",day:"numeric", hour:"numeric",minute:"2-digit", timeZoneName:"short" }); content.innerHTML=`
📍 Current Florida Weather by City
${cards}
Statewide High / Low
${fmt(high,"°")} / ${fmt(low,"°")}
Highest Rain Chance
☔ ${fmt(rain,"%")}
Max Feels Like
🌡️ ${fmt(feels,"°F")}
💨 Florida Winds: Forecast sustained wind speeds up to ${fmt(wind," mph")} among the selected cities today.
🌅 Morning
${summarize(morning)}
☀️ Afternoon
${summarize(afternoon)}
🌙 Tonight
${summarize(tonight)}
⭐ Best Outdoor Window: ${bestWindow(dataList,today)}
📅 Florida 7-Day Weather Outlook
${sevenDay(dataList)}
Temperatures show the highest and lowest forecasts among the 12 cities. Rain chances represent the highest probability at any selected location, not the probability statewide.
Updated ${updated} • Forecast data: Open-Meteo
`; }catch(error){ content.innerHTML=`
Florida weather information is temporarily unavailable. Please try again shortly.
`; console.error("Florida weather:",error); } } loadWeather(); setInterval(loadWeather,1800000); })();