Parcourir la source

Change humidity to dew point.

Lee Morgan il y a 2 mois
Parent
commit
25a4bec17e
3 fichiers modifiés avec 8 ajouts et 9 suppressions
  1. 0 1
      index.css
  2. 2 2
      index.html
  3. 6 6
      index.js

+ 0 - 1
index.css

@@ -182,7 +182,6 @@ body{
   border:1px solid rgba(0,255,234,.25);
   font-size:var(--info-size);
   line-height:1.00;
-  color:var(--muted);
   display:flex;
   align-items:center;
   justify-content:center;

+ 2 - 2
index.html

@@ -26,7 +26,7 @@
                                 <p></p>
                                 <svg width="24px" height="24px" viewBox="0 0 24 24" stroke-width="1.5" fill="none" color="#000000"><path d="M12 21L12 3M12 3L20.5 11.5M12 3L3.5 11.5" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>
                             </div>
-                            <p id="humidity" class="weatherItem"></p>
+                            <p id="dewPoint" class="weatherItem"></p>
                         </div>
                     </div>
                 </div>
@@ -52,7 +52,7 @@
                             <td></td>
                         </tr>
                         <tr>
-                            <td>Humidity</td>
+                            <td>Dew Point (&deg;F)</td>
                             <td></td>
                             <td></td>
                             <td></td>

+ 6 - 6
index.js

@@ -33,10 +33,10 @@ const renderForecast = (f)=>{
             day: "numeric",
             year: "2-digit"
         });
-        tbody.children[0].children[i+1].textContent = `${f.apparent_temperature_min[i]} - ${f.apparent_temperature_max[i]}`;
-        tbody.children[1].children[i+1].textContent = `${f.relative_humidity_2m_mean[i]}%`;
+        tbody.children[0].children[i+1].textContent = `${f.temperature_2m_min[i]} - ${f.temperature_2m_max[i]}`;
+        tbody.children[1].children[i+1].textContent = f.dew_point_2m_mean[i];
         tbody.children[2].children[i+1].textContent = `${f.precipitation_probability_max[i]}%`;
-        tbody.children[3].children[i+1].textContent = (f.precipitation_sum[i] / 25.4).toFixed(2);
+        tbody.children[3].children[i+1].textContent = f.precipitation_sum[i].toFixed(2);
         tbody.children[4].children[i+1].textContent = f.wind_speed_10m_max[i];
         tbody.children[5].children[i+1].textContent = sunrise.toLocaleTimeString("en-US", timeOptions);
         tbody.children[6].children[i+1].textContent = sunset.toLocaleTimeString("en-US", timeOptions);
@@ -44,7 +44,7 @@ const renderForecast = (f)=>{
 }
 
 const getWeather = ()=>{
-    fetch("https://api.open-meteo.com/v1/forecast?latitude=33.54&longitude=-79.05&daily=temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,sunrise,sunset,rain_sum,precipitation_sum,precipitation_probability_max,wind_speed_10m_max,wind_gusts_10m_max,wind_direction_10m_dominant,relative_humidity_2m_mean,weather_code&current=temperature_2m,relative_humidity_2m,apparent_temperature,weather_code,wind_speed_10m,wind_direction_10m,is_day&timezone=America%2FNew_York&forecast_days=3&temperature_unit=fahrenheit", {method: "GET"})
+    fetch("https://api.open-meteo.com/v1/forecast?latitude=33.54&longitude=-79.05&daily=temperature_2m_max,temperature_2m_min,sunrise,sunset,rain_sum,precipitation_probability_max,wind_speed_10m_max,wind_gusts_10m_max,precipitation_sum,wind_direction_10m_dominant,weather_code,dew_point_2m_mean&current=temperature_2m,apparent_temperature,weather_code,wind_speed_10m,wind_direction_10m,is_day,dew_point_2m&timezone=America%2FNew_York&wind_speed_unit=mph&temperature_unit=fahrenheit&precipitation_unit=inch", {method: "GET"})
         .then(r=>r.json())
         .then((response)=>{
             const tempDisplay = `${response.current.temperature_2m}\u00B0F`;
@@ -65,8 +65,8 @@ const getWeather = ()=>{
 
             document.querySelector("#wind svg").style.transform = `rotate(${response.current.wind_direction_10m}deg)`;
 
-            const humidity = `${response.current.relative_humidity_2m}% humidity`;
-            document.getElementById("humidity").textContent = humidity;
+            const dewPoint = `Dew Point: ${response.current.dew_point_2m}\u00B0F`;
+            document.getElementById("dewPoint").textContent = dewPoint;
 
             renderForecast(response.daily);
         })