$("#tianqia").html("");
document.write("");
document.write("");
document.write("");
;var jqueryweatherconfig = {
lang : {
day : '白天',
night : '夜晚',
temp : '°c',
wind : '级风',
wangzimo : '萧山商业城'
},
convert : function(sky){
var weatherinfo = {
cloudy : ['多云','多云转阴','晴转多云','阴转多云'],
overcast : ['阴','雾','沙尘暴','浮尘','扬沙','强沙尘暴'],
rainy : ['多云转小雨','小雨转多云','小雨','中雨','大雨','暴雨','大暴雨','特大暴雨','冻雨','小雨转中雨','中雨转大雨','大雨转暴雨','暴雨转大暴雨','大暴雨转特大暴雨','阵雨','雷阵雨','雷阵雨伴有冰雹'],
sleet : ['雨夹雪'],
snow : ['阵雪','小雪','中雪','大雪','暴雪','小雪转中雪','中雪转大雪','大雪转暴雪','中雪转小雪','大雪转中雪','暴雪转大雪'],
sunshine : ['晴']
},
weather = '',
state = '';
for( state in weatherinfo ){
if( $.inarray( sky , weatherinfo[state] ) > -1 ){
weather = state;
break;
}
}
return weather || state || 'sunshine' ;
}
};
$(function(){
$.getscript('http://php.weather.sina.com.cn/iframe/index/w_cl.php?code=js&day=0&city=&charset=utf-8', function(){
//window.swther 这是返回的天气情况
var city, datainfo = window.swther.w ;
for( var city in datainfo ); //获取 天气
datainfo = datainfo[city][0];
//jqueryweatherconfig
var weatherdata = {
city : city ,
date : swther.add.now.split(' ')[0] || '',
day_weather: datainfo.s1,
night_weather :datainfo.s2,
day_temp: datainfo.t1,
night_temp: datainfo.t2,
day_wind:datainfo.p1,
night_wind: datainfo.p2
};
var hour = (new date( swther.add.now )).gethours();
var sky = hour > 18 ? weatherdata.day_weather : weatherdata.night_weather ;
var weatherbox = $('#tianqia').weather({ sky : jqueryweatherconfig.convert( sky ), weatherdata : weatherdata , config : jqueryweatherconfig });
//weatherbox 是 整个天气图标的跟节点的 jquery ,所以可以直接操作,可以自己随意扩展效果。
settimeout(function(){
weatherbox.hide( );
}, 1000 );
settimeout(function(){
weatherbox.show();
}, 2000 );
});
});