-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsimple weather.html
More file actions
40 lines (28 loc) · 1.05 KB
/
simple weather.html
File metadata and controls
40 lines (28 loc) · 1.05 KB
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
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
var state = prompt("What state do you want to find out about the weather in?");
var city = prompt("How about a city?");
$.getJSON("http://cooper-union-weather-proxy.herokuapp.com/weather/" + state + "/" + city, function(response){
console.log(response);
//example of outputting the current temp
var currentTemp = response.current_observation.feelslike_f;
if(currentTemp > 47) {
$("#temperature").append("It is warm out! ");
} else {
$("#temperature").append("It is cold out! ");
}
$("#temperature").append(response.current_observation.feelslike_f + " degrees f");
//create image tag
var imageTag = '<img src="'+response.current_observation.icon_url+'" />';
//append image tag to #temperature
$('#temperature').append(imageTag);
});
</script>
</head>
<body>
<div id="temperature"></div>
</body>
</html>