-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
40 lines (30 loc) · 1.39 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$(document).ready(function () {
var typed = new Typed('.typed', {
strings: ['Hello,', 'You can find weather info'],
smartBackspace: true,
loop: true,
typeSpeed: 100,
});
$("#searchInput").on("keyup", function (e) {
var cityname = e.target.value;
const APIKey = "2205cb189d1eff9b1ce9a0453cb27dc0";
//make request to the server
$.ajax({
url: `https://api.openweathermap.org/data/2.5/weather?q=${cityname}&appid=${APIKey}&units=metric`,
}).done(function (weatherdata) {
$("#profile").html(`
<div class="container">
<div class="row">
<div class="card" style="width: 18rem; justify-content= center">
<img class="card-img-top" src="http://openweathermap.org/img/wn/${weatherdata.weather[0].icon}@2x.png" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Weather: ${weatherdata.weather[0].description}</h5>
<p class="card-text">The temperature at ${cityname} is = ${weatherdata.main.temp} ℃ and it feels like it is ${weatherdata.main.feels_like} ℃</p>
<a href="https://www.google.com/search?q=${cityname}" class="btn btn-primary">Learn more about this place </a>
</div>
</div>
</div>
</div> `);
});
});
});