Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 61 additions & 56 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,63 +1,68 @@
.grid-container {

display: grid;
grid-template-columns: 50% 50%;
background-color: white;
padding: 5px;
body{
background-image: linear-gradient(rgb(159, 63, 214), rgb(42, 4, 65));
height: 100%;
margin: 0;
background-repeat: no-repeat;
background-attachment: fixed;

}
input{
background-color: rgba(155, 95, 212, 0.568);
height: 50px;
width: 400px;
font-family: 'Times New Roman', Times, serif;
font-weight: bold;
font-size: 25px;
margin: 2%;
color: rgb(207, 194, 194);
border:none;
box-shadow: 2px 5px 3px rgb(219, 112, 12);
border-radius: 20px 0px 20px 0px;
}
button{
background-color: rgba(155, 95, 212, 0.568);
height: 50px;
width: 100px;
font-family: 'Times New Roman', Times, serif;
font-weight: bold;
font-size: 25px;
margin: 2%;
color: rgb(228, 215, 215);
border:none;
box-shadow: 2px 4px 3px rgb(219, 112, 12);
border-radius: 0px 20px 0px 20px;
}
.location{
margin: 1%;
font-family: 'Times New Roman', Times, serif;
color: rgb(252, 252, 252);
}
.grid-item1{

background-color: royalblue;
display: grid;
.city{
font-size: 300%;
font-weight: bold;
}
.grid-item{

background-color: lightgrey;
display: grid;
.date{
font-size: 150%;
}
h1, h3{
color: white;
font-weight: bolder;
margin-top: 25%;
.temp{
font-size: 800%;
font-weight: bolder;
margin: 1%;
font-family: 'Times New Roman', Times, serif;
color: rgb(252, 252, 252);
}
span{
color: black;
font-weight: bolder;
.weather{
margin-top: 1%;
font-family: 'Times New Roman', Times, serif;
color: rgb(252, 252, 252);
font-size: 200%;
font-style: italic;
font-weight: bold;
}
p{
color: white;

.high-low{
font-family: 'Times New Roman', Times, serif;
color: rgb(252, 252, 252);
font-size: 150%;
font-style: italic;

}
li{
color: white;

}
.bdy{
margin-left: 20%;
}
.dd{
margin-left: 25%;
margin-top: 10%;
}
#pp{
color: black;
}
#show{
color: black;
font-size: xx-large;
}
#show1,#show3{
color: black;
font-size: medium;
}
#show2{
color: black;
font-size: xx-large;
}
#tt{
margin-left: 20%;
margin-top: 20%;
}


63 changes: 35 additions & 28 deletions weather.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Weather app</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<div class="app-wrap">
<header>
<input type="text" autocomplete="on" class="search-box"
placeholder="Search for a city..." />
</header>
<main>
<section class="location">
<div class="city"></div>
<div class="date"></div>
</section>
<div class="current">
<div class="temp"><span>°c</span></div>
<div class="weather"></div>
<div class="hi-low">°c / °c</div>
</div>
</main>
</div>
<script src="main.js"></script>
</body>
</html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Weather app</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<center>
<div class="app-wrap">
<header>
<input
type="text"
autocomplete="on"
class="search-box"
placeholder="Enter the city..."
/>
<button class="search">Search</button>
</header>
<main>
<section class="location">
<div class="city"></div>
<div class="date"></div>
</section>
<div class="current">
<div class="temp"></div>
<div class="weather"></div>
<div class="high-low"></div>
</div>
</main>
</div>
</center>
<script src="weather.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions weather.js
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
//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 a city!");
return;
}
fetch(`https://api.openweathermap.org/data/2.5/weather?q=${input}&appid=8b22c819da152fc94d78034caddcfb13`)
.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("Wrong city entered !");
})
});