|
1 | 1 | function weatherGet(city, day) {
|
2 | 2 | var httpRequest = new XMLHttpRequest();
|
3 | 3 | day = day - 1;
|
| 4 | + |
| 5 | + function dayTo(str) { |
| 6 | + return str.match(/\(([^)]*)\)/); |
| 7 | + } |
| 8 | + function dayTo2(str) { |
| 9 | + return str.split(/\(.*?\)/); |
| 10 | + } |
| 11 | + |
| 12 | + var weatherTime = ''; |
| 13 | + |
4 | 14 | httpRequest.open('GET', 'https://query.asilu.com/weather/baidu/?city=' + city, true);
|
5 | 15 | httpRequest.send();
|
6 | 16 |
|
@@ -40,7 +50,14 @@ function weatherGet(city, day) {
|
40 | 50 | } else {
|
41 | 51 | weatherImg = 'imgs/dLinkIcon.png';
|
42 | 52 | }
|
43 |
| - elemenetGetId('time' + dayfea).innerText = obj.weather[dayfea - 1].date; |
| 53 | + |
| 54 | + if (dayfea < 4) { |
| 55 | + weatherTime = dayTo(obj.weather[dayfea - 1].date)[1]; |
| 56 | + } else { |
| 57 | + weatherTime = dayTo2(obj.weather[dayfea - 1].date)[0] |
| 58 | + } |
| 59 | + |
| 60 | + elemenetGetId('time' + dayfea).innerText = weatherTime; |
44 | 61 | elemenetGetId('day' + dayfea + 'Weather').innerText = obj.weather[dayfea - 1].weather;
|
45 | 62 | elemenetGetId('day' + dayfea + 'Img').src = weatherImg;
|
46 | 63 | elemenetGetId('day' + dayfea + 'Temp').innerText = obj.weather[dayfea - 1].temp;
|
@@ -127,6 +144,13 @@ function weatherUse() {
|
127 | 144 | weatherHide = !weatherHide;
|
128 | 145 | }
|
129 | 146 | } else {
|
| 147 | + elemenetGetClass('feaWeatherbox')[0].style.marginLeft = '-3px'; |
| 148 | + elemenetGetClass('feaWeatherbox')[2].style.marginRight = '-3px'; |
| 149 | + elemenetGetClass('feaWeatherbox')[0].style.width = '74px'; |
| 150 | + elemenetGetClass('feaWeatherbox')[1].style.width = '74px'; |
| 151 | + elemenetGetClass('feaWeatherbox')[2].style.width = '74px'; |
| 152 | + elemenetGetClass('feaWeather')[0].style.marginBottom = '4px'; |
| 153 | + elemenetGetId('weather').style.height = '250px' |
130 | 154 | setTimeout(function () {
|
131 | 155 | elemenetGetId('weatherMain').style.display = '';
|
132 | 156 | if (elemenetGetId('button').innerText == '暂时没有有连接到可以访问互联网的网络哦~') {
|
|
0 commit comments