Skip to content

Commit

Permalink
Merge pull request #305 from Shu12388y/main
Browse files Browse the repository at this point in the history
city error functionality done issue no.  #255
  • Loading branch information
avinash201199 authored Oct 18, 2023
2 parents 8b80a33 + 278015f commit 0dd3a79
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 0dd3a79

Please sign in to comment.