-
Notifications
You must be signed in to change notification settings - Fork 12
/
weather.js
44 lines (38 loc) · 1.1 KB
/
weather.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
41
42
43
44
// v3.1.0
//Docs at http://simpleweatherjs.com
// This code has been modified by RiquezJP
function loadWeather(wdays,wloc,wunit){
$.simpleWeather({
location: wloc,
woeid: '',
unit: wunit,
success: function(weather) {
city = weather.city;
temp = weather.temp+'°'+wunit;
wcode = '<img class="weathericon" src="images/weathericons/' + weather.code + '.svg">';
wind = weather.wind.speed + ' ' + weather.units.speed;
humidity = weather.humidity + ' %';
updated = weather.updated;
// new loop for days
if(wdays>9){wdays=9}
var iconcode='';
var fi= new Array();
var fd= new Array();
for (var i=1;i<=wdays;i++){
fi[i]= weather.forecast[i].code;
fd[i] = weather.forecast[i].day;
iconcode += '<span><img src="images/weathericons/' + fi[i] + '.svg" /><br />' + fd[i] + '</span>';
}
$(".location").text(city);
$(".temperature").html(temp);
$(".climate_bg").html(wcode);
$(".windspeed").html(wind);
$(".humidity").text(humidity);
$(".updated").text(updated);
$(".forecast").html(iconcode);
},
error: function(error) {
$(".error").html('<p>'+error+'</p>');
}
});
}