-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweather.js
28 lines (27 loc) · 849 Bytes
/
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
jQuery(document).ready(function ($) {
setTimeout(updateWeather, 500);
// Update weather every half hour
setInterval(updateWeather, 30 * 60 * 1000);
});
function updateWeather() {
jQuery('.weather').each(function(){
var elem = jQuery(this);
jQuery.simpleWeather({
location: elem.attr('data-place'),
unit: elem.attr('data-unit'),
success: function(weather) {
//elem.css('background-image', 'url(' + weather.image + ')');
html = '';
html += '<i class="icon weather-'+weather.code+'"></i>';
html += '<span class="temperature">'+weather.temp+'° '+weather.units.temp+'';
html += '<span class="condition">'+weather.currently+'</span>';
html += '</span>';
elem.html(html);
},
error: function(error) {
elem.html('<p>'+error+'</p>');
setTimeout(updateWeather, 1 * 60 * 1000);
}
});
});
}