-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
35 lines (33 loc) · 1.54 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
$(document).ready(function(){
var typed = new Typed('.typed', {
strings: ['Hello', 'LIVE WeatherInfo here!'],
smartBackspace: true ,
loop:false,
typespeed:75,
});
$("#searchInput").on("keyup",function(e){
var cityname=e.target.value;
const APIKey="94515104f5547730ae5340fb72fed1bd";
//make request to server
$.ajax({
url:`https://api.openweathermap.org/data/2.5/weather?q=${cityname}&appid=${APIKey}&units=metric`
}).done(function(weatherdata){
console.log(weatherdata);
$("#profile").html(
`<div class=container>
<div class="row">
<div class="card" style="width: 18rem;">
<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>
<p class="card-text">Country:${weatherdata.sys.country}</p>
<a href="https://www.google.com/search?q=${cityname}" class="btn btn-primary">Learn more about this place</a>
</div>
</div>
</div>
</div>`
);
})
});
});