Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ekramasif committed Aug 4, 2021
1 parent b08d9cc commit 62e3a33
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 61 deletions.
Binary file added asset/fabicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 4 additions & 61 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,13 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="asset/fabicon.png" type="image/x-icon">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css"
integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css2?family=Abel&display=swap" rel="stylesheet">
<title>Temperature-API</title>
<link rel="stylesheet" href="style.css">
<title>Today's Weather</title>
</head>
<style>
* {
box-sizing: border-box;
}

body {
font-family: 'Abel', sans-serif;
font-size: large;
margin: 0;
font-size: 17px;
}

#myVideo {
width: 100vw;
height: 100vh;
object-fit: cover;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: -1;
}

text {
color: rgb(27, 23, 23);
}

footer {
padding: 10%;
}
</style>

<body>
<video autoplay muted loop id="myVideo">
<source src="asset/BG-2.mp4" type="video/mp4">
Expand Down Expand Up @@ -77,34 +46,8 @@ <h1 id="weather_status" class="lead"></h1>
</div>
</footer>

<script src="script.js"></script>

<script>
const apiKey = 'b6cc4392568a3586e950307c86a22bbd';
const apiBase = 'https://api.openweathermap.org/data/2.5/weather';

const getWeatherData = city => {
const url = `${apiBase}?q=${city}&units=metric&appid=${apiKey}`;
fetch(url)
.then(response => response.json())
.then(data => updateUI(data))
}

const searchBtn = document.getElementById('search_button');
searchBtn.addEventListener('click', () => {
const inputCity = document.getElementById('city').value;
getWeatherData(inputCity)
})

const updateUI = data => {
document.getElementById('show_city').innerText = data.name || "Unknown Location!";
document.getElementById('show_temperature').innerText = data.main.temp;
document.getElementById('weather_status').innerText = data.weather[0].main;
document.getElementById('icon').setAttribute('src', `https://openweathermap.org/img/wn/${data.weather[0].icon}@2x.png`);
document.getElementById('city').value = "";
}

getWeatherData('Chittagong');
</script>


</body>
Expand Down
25 changes: 25 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const apiKey = 'b6cc4392568a3586e950307c86a22bbd';
const apiBase = 'https://api.openweathermap.org/data/2.5/weather';

const getWeatherData = city => {
const url = `${apiBase}?q=${city}&units=metric&appid=${apiKey}`;
fetch(url)
.then(response => response.json())
.then(data => updateUI(data))
}

const searchBtn = document.getElementById('search_button');
searchBtn.addEventListener('click', () => {
const inputCity = document.getElementById('city').value;
getWeatherData(inputCity)
})

const updateUI = data => {
document.getElementById('show_city').innerText = data.name || "Unknown Location!";
document.getElementById('show_temperature').innerText = data.main.temp;
document.getElementById('weather_status').innerText = data.weather[0].main;
document.getElementById('icon').setAttribute('src', `https://openweathermap.org/img/wn/${data.weather[0].icon}@2x.png`);
document.getElementById('city').value = "";
}

getWeatherData('Chittagong');
30 changes: 30 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

* {
box-sizing: border-box;
}

body {
font-family: 'Abel', sans-serif;
font-size: large;
margin: 0;
}

#myVideo {
width: 100vw;
height: 100vh;
object-fit: cover;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: -1;
}

text {
color: rgb(27, 23, 23);
}

footer {
padding: 10%;
}

0 comments on commit 62e3a33

Please sign in to comment.