Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork592
Added an Weather Application.#16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Closed
Uh oh!
There was an error while loading.Please reload this page.
Closed
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Binary file addedWeather_App/images/clear.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file addedWeather_App/images/clouds.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file addedWeather_App/images/drizzle.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file addedWeather_App/images/haze.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file addedWeather_App/images/humidity.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file addedWeather_App/images/mist.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file addedWeather_App/images/rain.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file addedWeather_App/images/snow.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file addedWeather_App/images/wind.png
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletionsWeather_App/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;600&display=swap" rel="stylesheet"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Weather Application</title> | ||
</head> | ||
<body> | ||
<div class="card"> | ||
<div class="searchSection"> | ||
<input type="text" name="" id="cityGiven" placeholder="Enter City Name"> | ||
<i class="fa-solid fa-magnifying-glass" id="search"></i> | ||
</div> | ||
<main id="mainSection"> | ||
<div class="weather"> | ||
<img src="images/mist.png" alt="weather" id="weatherIcon"> | ||
<p class="temp">10°C</p> | ||
<p class="cityName">Paris</p> | ||
</div> | ||
<div class="extras"> | ||
<div class="humidity"> | ||
<img src="images/humidity.png" alt="humidity"> | ||
<section> | ||
<p id="humidityValue">40%</p> | ||
<p style="color: rgb(64, 204, 255);">Humidity</p> | ||
</section> | ||
</div> | ||
<div class="windSpeed"> | ||
<p> | ||
<img src="images/wind.png" alt="windSpeed"> | ||
<section> | ||
<p id="windSpeedValue">30 Km/hr</p> | ||
<p style="color: rgb(64, 204, 255);">Wind Speed</p> | ||
</section> | ||
</p> | ||
</div> | ||
</div> | ||
</main> | ||
</div> | ||
</body> | ||
<script src="script.js"></script> | ||
</html> |
49 changes: 49 additions & 0 deletionsWeather_App/script.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const getWeather = async (cityProvided) => { | ||
let weatherImage = document.querySelector("#weatherIcon"); | ||
let city = cityProvided | ||
const apiKey = "8313e9397d477560c4071df640d6a1fe"; | ||
let url = "https://api.openweathermap.org/data/2.5/weather?q="+city+"&appid="+apiKey+"&units=metric"; | ||
let data = await fetch(url); | ||
data = await data.json(); | ||
console.log(data) | ||
let cityName = data.name; | ||
let temp = data.main.temp; | ||
let windSpeed = data.wind.speed; | ||
let humidity = data.main.humidity; | ||
let condition = data.weather[0].main; | ||
// alert(condition) | ||
if(condition=="Clouds") | ||
weatherImage.src = "images/clouds.png"; | ||
else if(condition == "Clear") | ||
weatherImage.src = "images/clear.png"; | ||
else if(condition == "Rain") | ||
weatherImage.src = "images/rain.png"; | ||
else if(condition == "Drizzle") | ||
weatherImage.src = "images/drizzle.png"; | ||
else if(condition == "Mist") | ||
weatherImage.src = "images/mist.png"; | ||
else if(condition == "Haze") | ||
weatherImage.src = "images/haze.png" | ||
document.querySelector(".cityName").innerHTML = cityName; | ||
document.querySelector(".temp").innerHTML = Math.round(temp) + " °C," +" " + condition; | ||
document.querySelector("#humidityValue").innerHTML = humidity + " %"; | ||
document.querySelector("#windSpeedValue").innerHTML = windSpeed + " Km/hr" | ||
console.log(data.clouds) | ||
} | ||
document.querySelector("#search").addEventListener("click", () => { | ||
let mainSection = document.querySelector("#mainSection"); | ||
mainSection.classList.add("active") | ||
let city = document.querySelector("#cityGiven").value; | ||
getWeather(city); | ||
}) | ||
getWeather(); |
146 changes: 146 additions & 0 deletionsWeather_App/style.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
*{ | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
font-family: 'Poppins', sans-serif; | ||
color: white; | ||
} | ||
.appName{ | ||
background-color: transparent; | ||
width: 100%; | ||
text-align: center; | ||
border-radius: 25px 25px 0px 0px; | ||
padding: 20px 0px; | ||
border-bottom: 2px solid rgb(255, 0, 225); | ||
} | ||
main{ | ||
display: none; | ||
} | ||
.active{ | ||
display: block; | ||
} | ||
body{ | ||
display: flex; | ||
justify-content: center; | ||
background: linear-gradient(89deg, rgb(24, 24, 24), rgb(39, 39, 39), rgb(39, 39, 39)); | ||
height: 100vh; | ||
align-items: center; | ||
/* overflow-x: scroll; */ | ||
} | ||
.card{ | ||
background: linear-gradient(45deg, #0f0c29,#302b63, #24243e); | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
padding-bottom: 60px; | ||
width: 38%; | ||
/* margin-top: 15px; */ | ||
box-shadow: 4px 2px 30px black; | ||
border-radius: 25px; | ||
transition: 0.5s ease; | ||
} | ||
input{ | ||
width: 250px; | ||
background: transparent; | ||
border: none; | ||
border-bottom: 3px solid white; | ||
text-align: center; | ||
padding: 8px 8px; | ||
color: white; | ||
font-size: 1.4rem; | ||
margin-top: 30px; | ||
} | ||
input:focus{ | ||
outline: none; | ||
} | ||
i{ | ||
font-weight: bold; | ||
font-size: 1.6rem; | ||
color: white; | ||
position: relative; | ||
top: 4px; | ||
transition: 0.4s ease; | ||
} | ||
i:hover{ | ||
cursor: pointer; | ||
transform: scale(1.4); | ||
} | ||
.weather{ | ||
text-align: center; | ||
margin: 60px 0px 60px 0px; | ||
} | ||
.weather img { | ||
height: 100px; | ||
width: 100px; | ||
} | ||
.weather p{ | ||
font-size: 1.7rem; | ||
font-weight: 600; | ||
color: white; | ||
} | ||
.weather .temp{ | ||
font-size: 2.6rem; | ||
} | ||
.extras{ | ||
display: flex; | ||
gap: 40px; | ||
} | ||
.extras img { | ||
height: 33px; | ||
width: 33px; | ||
} | ||
.humidity, .windSpeed { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 0.9rem; | ||
font-weight: bold; | ||
} | ||
section{ | ||
margin-left: 10px; | ||
} | ||
#humidityValue, #windSpeedValue { | ||
font-size: 1.5rem; | ||
font-weight: normal; | ||
color: white; | ||
} | ||
@media only screen and (min-width: 0px) and (max-width: 600px) { | ||
.card{ | ||
width: 100%; | ||
border-radius: 0px; | ||
/* height: 100%; */ | ||
height: 100%; | ||
padding-bottom: 65px; | ||
} | ||
#humidityValue, #windSpeedValue { | ||
font-size: 1.3rem; | ||
} | ||
input { | ||
width: 240px; | ||
} | ||
.weather{ | ||
margin: 110px 0px 110px 0px; | ||
} | ||
.extras { | ||
justify-content: space-between; | ||
width: 100%; | ||
} | ||
.appName{ | ||
border-radius: 0px; | ||
position: relative; | ||
bottom: 93px; | ||
} | ||
} | ||
@media only screen and (min-width: 600px) and (max-width: 1090px) { | ||
.card{ | ||
width: 80%; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.