Skip to content

Commit

Permalink
city error functionality done
Browse files Browse the repository at this point in the history
  • Loading branch information
Shu12388y committed Oct 18, 2023
1 parent 6542ac4 commit 278015f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,20 @@ let weather = {
.then((response) => {
if (!response.ok) {
toastFunction(`${translations[userLang].noWeatherFound}`);
document.getElementById("city").innerHTML = "City not Found";
document.getElementById("temp").style.display = "none";
document.querySelector(
".weather-component__data-wrapper"
).style.display = "none";
throw new Error(`${translations[userLang].noWeatherFound}`);
}
return response.json();
})
.then((data) => {
document.getElementById("temp").style.display = "block";
document.querySelector(
".weather-component__data-wrapper"
).style.display = "block";
this.displayWeather(data, city);
});
},
Expand Down Expand Up @@ -471,10 +480,11 @@ const scrollTop = function () {
};
scrollTop();


//Fetching Random Landscape Background Image From Unsplash
//Fetching Random Landscape Background Image From Unsplash
const fetchNewBackground = () => {
let url = `https://source.unsplash.com/${window.innerWidth < 768 ? "720x1280" : "1600x900"}/?landscape`;
let url = `https://source.unsplash.com/${
window.innerWidth < 768 ? "720x1280" : "1600x900"
}/?landscape`;
const bgElement = document.getElementById("background");
bgElement.style.backgroundImage = `url(${url})`;
};
Expand Down

0 comments on commit 278015f

Please sign in to comment.