-
Notifications
You must be signed in to change notification settings - Fork 9
/
example.js
32 lines (28 loc) · 1 KB
/
example.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
$( document ).ready( function() {
$.simplerWeather( {
location: '40.785091,73.96828',
units: 'f',
apikey: 'YOUR_API_KEY',
success: function( weather ) {
currentWeather = '<h2> <i class="icon ' + weather.icon +
'"></i> ' +
Math.round( weather.temp ) + '°' + weather.unit.toUpperCase();
currentWeather += '<p> Currently: ' + weather.currently +
'</p>';
$( "#weather" ).html( currentWeather );
//return forcast to unordered list.
forecast = '<ul>';
// the first value in the array is the current date so set i to 1 to get future weather
for( var i = 1; i < 4; i++ ) {
forecast += '<li><i class="icon ' + weather.forecast[ i ].icon +
'"></i>';
forecast += weather.forecast[ i ].summary; + '</li>';
}
forecast += '</ul>';
$( "#forecast" ).html( forecast );
},
error: function( error ) {
$( "#weather" ).html( '<p>' + error + '</p>' );
}
} ); //end main weather display
} );