$(function() {
var base = document.getElementById('html-base').href;
var wl = $(".weatherlocation");
var weatherloc = "Melbourne";
if (wl.length) weatherloc = $(wl[0]).text();
var url = base
+ 'load_xml.php?url=http%3A//www.google.com/ig/api?weather='
+ escape(weatherloc);
$.get(url, function(xml){
//alert('Data Loaded:');
$(xml).find('forecast_information city').each(function(){
var city = $(this).attr('data');
$('.weather').html('
' + city + '
');
});
var current = $(xml).find('current_conditions');
var temp = $(current).find('temp_c').attr('data');
var condition = $(current).find('condition').attr('data');
var humidity = $(current).find('humidity').attr('data');
var wind = $(current).find('wind_condition').attr('data');
var icon = base + "skin/weather/"
+ condition.toLowerCase().replace(/\s/g, "-") + ".png";
$('')
.append('
')
.append('Currently
')
.append('' + temp + '
')
.append('' + condition + '
')
.append('' + humidity + '
')
.append('' + wind + '
')
.appendTo('.weather');
var forecasts = $(xml).find('forecast_conditions');
var i = 0;
forecasts.each(function(){
if (i < 3) {
var day = $(this).find('day_of_week').attr('data');
var lowf = parseFloat($(this).find('low').attr('data'));
var low = Math.round((5 / 9) * (lowf - 32));
var highf = parseFloat($(this).find('high').attr('data'));
var high = Math.round((5 / 9) * (highf - 32));
var condition = $(this).find('condition').attr('data');
var icon = base + "skin/weather/"
+ condition.toLowerCase().replace(/\s/g, "-") + ".png";
$('')
.append('
')
.append('' + day + '
')
.append('' + high + '
')
.append('' + low + '
')
.append('' + condition + '
')
.appendTo('.weather');
i++;
}
});
});
});