diff --git a/scripts/mobile.js b/scripts/mobile.js index f3e1ada..1c74c62 100644 --- a/scripts/mobile.js +++ b/scripts/mobile.js @@ -64,6 +64,9 @@ cityInputMobile.addEventListener("keyup", function (event) { .then(response => response.json()) .then(data => { const forecastContainer = document.getElementById('forecast-container'); + + forecastContainer.innerHTML = ''; + const dailyForecasts = {}; data.list.forEach(entry => { const dateTime = new Date(entry.dt * 1000); @@ -91,14 +94,14 @@ cityInputMobile.addEventListener("keyup", function (event) { forecastCard.classList.add('daily-forecast-card'); forecastCard.innerHTML = ` -

${day.date}

- -
- ${Math.round(day.maxTemp - 273.15)}oC - ${Math.round(day.minTemp - 273.15)}oC -
-

${day.weatherType}

- `; +

${day.date}

+ +
+ ${Math.round(day.maxTemp - 273.15)}oC + ${Math.round(day.minTemp - 273.15)}oC +
+

${day.weatherType}

+ `; forecastContainer.appendChild(forecastCard); }); diff --git a/scripts/script.js b/scripts/script.js index d1e8cd3..4705c1c 100644 --- a/scripts/script.js +++ b/scripts/script.js @@ -91,6 +91,9 @@ cityInput.addEventListener("keyup", function (event) { .then(response => response.json()) .then(data => { const forecastContainer = document.getElementById('forecast-container'); + + forecastContainer.innerHTML = ''; + const dailyForecasts = {}; data.list.forEach(entry => { const dateTime = new Date(entry.dt * 1000); @@ -118,14 +121,14 @@ cityInput.addEventListener("keyup", function (event) { forecastCard.classList.add('daily-forecast-card'); forecastCard.innerHTML = ` -

${day.date}

- -
- ${Math.round(day.maxTemp - 273.15)}oC - ${Math.round(day.minTemp - 273.15)}oC -
-

${day.weatherType}

- `; +

${day.date}

+ +
+ ${Math.round(day.maxTemp - 273.15)}oC + ${Math.round(day.minTemp - 273.15)}oC +
+

${day.weatherType}

+ `; forecastContainer.appendChild(forecastCard); }); @@ -135,6 +138,7 @@ cityInput.addEventListener("keyup", function (event) { }); + document.getElementById("locationName").innerHTML = location; document.getElementById("temperatureValue").innerHTML = temperature + "oC"; document.getElementById("weatherType").innerHTML = weatherType;