-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweather.js
More file actions
165 lines (148 loc) · 4.78 KB
/
Copy pathweather.js
File metadata and controls
165 lines (148 loc) · 4.78 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
+(function(window, document) {
'use strict';
function weather_aqi(callback) {
var replyMsg = '';
$.post('https://script.google.com/macros/s/AKfycbxfzHxi1ok-NxVGBN5vAU-VuyGpYV0VQt8TSGeMe8w0Ompvw6o/exec', {
type: 'weather'
},
function(data) {
callback([data, 'aqi']);
});
}
function weather_aqi_data(name, type, e) {
let arr = e[0];
if (e[1] == 'aqi') {
for (let i = 0; i < arr.length; i++) {
if (arr[i].SiteName == name) {
if (type == 'all') {
let replyMsg = arr[i].SiteName + '的' + arr[i].note + ' ( PM2.5:' + arr[i].PM25 + ',PM10:' + arr[i].PM10 + ',臭氧:' + arr[i].O3 + ',一氧化碳:' + arr[i].CO + ',二氧化氮:' + arr[i].NO2 + ',二氧化硫:' + arr[i].SO2 + ' )';
return replyMsg;
} else {
return arr[i][type];
}
}
}
} else {
return '資料格式錯誤';
}
}
function weather_observe(callback) {
$.post('https://script.google.com/macros/s/AKfycbyvTOcbo0mM1ecyWxTUsv4sBzfdEupD04q0LeZ7IGGgGMiHgRHx/exec', {
type: 'weather'
},
function(data) {
callback([data, 'observe']);
});
}
function weather_observe_data(name, type, e) {
let arr = e[0];
let num = type * 1;
if (e[1] == 'observe') {
let result = arr[name];
if (num == 0) {
return name + '現在的溫度 ' + result[0] + ' 度,當日累積雨量 ' + result[4] + ' mm,相對濕度 ' + result[1] + '%,風力 ' + result[2] + ' 級,天氣概況:' + result[3];
} else {
return result[num - 1];
}
} else {
return '資料格式錯誤';
}
}
function weather_forecast(callback) {
$.post('https://script.google.com/macros/s/AKfycbygv1-_U7y5ieMYKASXI0l4hLsMKekasUpzl4gKiL0BwNyE1vU/exec', {
type: 'weather'
},
function(data) {
callback([data, 'forecast']);
});
}
function weather_forecast_data(name, type, e) {
if (e[1] == 'forecast') {
let num = type * 1;
let result = e[0][name][num];
let note;
if (num == 0) {
note = '未來 6 小時預報:';
} else if (num == 1) {
note = '未來 18 小時預報:';
} else {
note = '未來 36 小時預報:';
}
return name + note + '氣溫 ' + result[0] + 'C,降雨機率 ' + result[1] + ',' + result[2];
} else {
return '資料格式錯誤';
}
}
function weather_reservoir(callback) {
$.post('https://script.google.com/macros/s/AKfycbwKdkbIJdBp47LQdUwdGj3Bx6G--VLhPbTb-hrNbxQFee-WEikL/exec', {
type: 'weather'
},
function(data) {
callback([data, 'reservoir']);
});
}
function weather_reservoir_data(name, type, e) {
if (e[1] == 'reservoir') {
let result = e[0][name];
if (type == 'all') {
return name + '蓄水百分比:' + result.CapacityRate + '%,有效蓄水量:' + result.Capacity + ' 萬立方公尺,本日降雨:' + result.Basin_Rain;
} else {
return result[type];
}
} else {
return '資料格式錯誤';
}
}
function weather_quake(callback) {
$.post('https://script.google.com/macros/s/AKfycbxDyp2rmO7iVURZWT3Qg8UsDOuzgxrFjKm1FGxsrm2FAJWG8BE/exec', {
type: 'weather'
},
function(data) {
callback([data, 'quake']);
});
}
function weather_quake_data(num, e) {
if (e[1] == 'quake') {
let result = e[0];
let content;
if (num == '0') {
content = result[0];
} else if (num == '1') {
content = result[0] + '、' + result[1];
} else if (num == '2') {
content = result[0] + '、' + result[1] + '、' + result[2];
}
return content;
} else {
return '資料格式錯誤';
}
}
function weather_radar(callback) {
$.post('https://script.google.com/macros/s/AKfycbyxRFGpRm0N0D_7u_abAqZrd259uHTi8habrSw0H6v20TEj21g/exec', {
type: 'weather'
},
function(data) {
callback([data, 'radar']);
});
}
function weather_radar_data(e) {
if (e[1] == 'radar') {
let result = e[0];
return result;
} else {
return '資料格式錯誤';
}
}
window.weather_radar_data = weather_radar_data;
window.weather_radar = weather_radar;
window.weather_quake_data = weather_quake_data;
window.weather_quake = weather_quake;
window.weather_reservoir_data = weather_reservoir_data;
window.weather_reservoir = weather_reservoir;
window.weather_forecast_data = weather_forecast_data;
window.weather_forecast = weather_forecast;
window.weather_observe_data = weather_observe_data;
window.weather_observe = weather_observe;
window.weather_aqi_data = weather_aqi_data;
window.weather_aqi = weather_aqi;
}(window, window.document));