From 407530320eca78783a1d6e068c0b6e3c4491bb0b Mon Sep 17 00:00:00 2001 From: sachinsh01 <89263668+sachinsh01@users.noreply.github.com> Date: Mon, 28 Mar 2022 04:02:44 +0530 Subject: [PATCH 1/4] Update weather.html --- weather.html | 60 +++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/weather.html b/weather.html index bb2d461..b42fc27 100644 --- a/weather.html +++ b/weather.html @@ -1,30 +1,36 @@ - - - - - Weather app - - - -
-
- -
-
-
-
-
-
-
-
°c
-
-
°c / °c
-
-
-
- - + + + + + Weather app + + + + +
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+ + From 98520e15e09e2758f74108349aa29cdb87a980a2 Mon Sep 17 00:00:00 2001 From: sachinsh01 <89263668+sachinsh01@users.noreply.github.com> Date: Mon, 28 Mar 2022 04:03:08 +0530 Subject: [PATCH 2/4] Update weather.js --- weather.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/weather.js b/weather.js index c5e0068..2dd887e 100644 --- a/weather.js +++ b/weather.js @@ -1 +1,28 @@ //Complete the Weather API Backend part using openweathermap api +//Complete the Weather API Backend part using openweathermap api +let day = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; +let month = ['January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'Octomber', 'November', 'December']; + + + +document.querySelector('.search').addEventListener('click', () => { + let input = document.querySelector('.search-box').value; + if (input === "") { + alert("Please enter the city!"); + return; + } + fetch(`https://api.openweathermap.org/data/2.5/weather?q=${input}&appid=563ab618a11ed790dbc9970f64fa4f81`) + .then((response) => response.json()) + .then((data) => { + console.log(data); + document.querySelector('.city').textContent = `${data.name}, ${data.sys.country}`; + let date = new Date(); + document.querySelector('.date').textContent = `${day[date.getDay()]} ${date.getDate()} ${month[date.getMonth()]} ${date.getFullYear()}`; + document.querySelector('.temp').textContent = `${parseInt(data.main.temp-273.15)}°c`; + document.querySelector('.weather').textContent = `${data.weather[0].main}`; + document.querySelector('.high-low').textContent = `${parseInt(data.main.temp_min-273.15)}°c / ${parseInt(data.main.temp_max-273.15)}°c`; + }) + .catch(() => { + alert("The city you entered is incorrect!"); + }) +}); From 89c697cb5d32090a9dcf5fe814de6a653964c796 Mon Sep 17 00:00:00 2001 From: sachinsh01 <89263668+sachinsh01@users.noreply.github.com> Date: Fri, 8 Apr 2022 00:06:32 +0530 Subject: [PATCH 3/4] ProGrad ID : 8731 --- weather.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weather.html b/weather.html index b42fc27..7f53877 100644 --- a/weather.html +++ b/weather.html @@ -33,4 +33,4 @@ - + From dd6a93db2f76572614c7a005c29aee2082436666 Mon Sep 17 00:00:00 2001 From: sachinsh01 <89263668+sachinsh01@users.noreply.github.com> Date: Fri, 8 Apr 2022 00:06:47 +0530 Subject: [PATCH 4/4] ProGrad ID : 8731 --- weather.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weather.js b/weather.js index 2dd887e..46c28df 100644 --- a/weather.js +++ b/weather.js @@ -25,4 +25,4 @@ document.querySelector('.search').addEventListener('click', () => { .catch(() => { alert("The city you entered is incorrect!"); }) -}); +});