-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (16 loc) · 691 Bytes
/
Copy pathscript.js
File metadata and controls
24 lines (16 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var cities = ["Birmingham", "london", "new york", "york", "leeds"];
function getRandomInteger(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
var city = cities[getRandomInteger(0, 6)];
$.getJSON("http://api.openweathermap.org/data/2.5/weather?q=" + city + "&APPID=85a1341a3190f51f161d3fd6b2f4cb3a", function(data) {
console.log(data);
var icon = 'http://openweathermap.org/img/w/' + data.weather[0].icon + '.png';
var temp = Math.floor(data.main.temp);
var weather = data.weather[0].main;
$('.icon').attr('src', icon);
$('.weather').append(weather);
$('.temp').append(temp);
});