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
Empty file added .gitignore
Empty file.
Empty file added config.js
Empty file.
36 changes: 36 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!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="style.css" />
</head>
<body>
<div class="app-wrap">
<header>
<input
id="input"
type="text"
autocomplete="on"
class="search-box"
placeholder="Search for a city..."
onchange="apidata()"
/>
</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="weather.js"></script>
</body>
</html>
104 changes: 41 additions & 63 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,63 +1,41 @@
.grid-container {

display: grid;
grid-template-columns: 50% 50%;
background-color: white;
padding: 5px;
height: 100%;
}
.grid-item1{

background-color: royalblue;
display: grid;
}
.grid-item{

background-color: lightgrey;
display: grid;
}
h1, h3{
color: white;
font-weight: bolder;
margin-top: 25%;
}
span{
color: black;
font-weight: bolder;
}
p{
color: white;

}
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%;
}


body {
background-color: #6b029c;
text-align: center;
color: white;
font-size: 3rem;
}
input {
font-size: 3rem;
margin-top: 10%;
border-width: 0px;
border-top-left-radius: 2rem;
border-bottom-right-radius: 2rem;
padding: 10px;
background-color: #9e4ec2;
border-bottom: 3px solid #dc8a04;
}
.city {
margin-top: 2%;
}

.date {
font-size: 1.5rem;
}
.temp {
margin-top: 1%;
font-size: 8rem;
margin-bottom: 1%;
text-shadow: 0px 5px black;
font-weight: 900;
}
.weather {
font-size: 2rem;
font-style: italic;
font-weight: 900;
text-shadow: 0px 3px black;
}
.hi-low {
font-size: 1.5rem;
font-weight: 900;
text-shadow: 0px 3px black;
}
30 changes: 0 additions & 30 deletions weather.html

This file was deleted.

53 changes: 53 additions & 0 deletions weather.js
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
//Complete the Weather API Backend part using openweathermap api

function apidata() {
var weekDays = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
];
var month = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
var today = new Date();
var input = document.querySelector("#input").value;
const url = `https://api.openweathermap.org/data/2.5/weather?q=${input}&units=metric&appid=6a2547232fc58c844e7d59f7243fcd94`;
fetch(url)
.then((response) => response.json())
.then((data) => {
var temp = data.main.temp;
var temp_min = data.main.temp_min;
var temp_max = data.main.temp_max;
var country = data.sys.country;
var weather_status = data.weather[0].main;
var city = data.name;
console.log(temp, temp_min, temp_max, city, country, weather_status);
document.querySelector(".city").innerHTML = city + ", " + country;
document.querySelector(".date").innerHTML =
weekDays[today.getDay()] +
" " +
today.getDate() +
" " +
month[today.getMonth()] +
" " +
today.getFullYear();
document.querySelector(".temp").innerHTML = temp + "°c";
document.querySelector(".weather").innerHTML = weather_status
document.querySelector(".hi-low").innerHTML =
temp_min + "°c /" + temp_max + "°c";
});
}