-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSDMS.html
More file actions
260 lines (234 loc) · 9.02 KB
/
SDMS.html
File metadata and controls
260 lines (234 loc) · 9.02 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<html lang="zh-Hant">
<head>
<title id="title">TREM SDMS</title>
<meta charset="utf-8" />
<meta content="TREM SDMS" property="og:title" />
<meta content="Seismic Data Management System | 地震資料管理系統" property="og:description" />
<meta content="https://exptechtw.github.io/" property="og:url" />
<meta content="https://cdn.jsdelivr.net/gh/ExpTechTW/API@master/image/Icon/ExpTech.png" property="og:image" />
</head>
<body style="background-color: #333439;">
<div class="main">
<div class="body">
<div class="title">Seismic Data Management System</div>
<div class="subtitle">地震資料管理系統</div>
<div class="stations_box">
<div class="stations_title">觀測網</div>
<select class="stations_text" id="Network">
<option value="MS" selected>MS-Net | 微地震觀測網</option>
<option value="SE">SE-Net | 強震觀測網</option>
</select>
</div>
<div class="stations_box">
<div class="stations_title">測站代碼</div>
<select class="stations_text" id="stations"></select>
</div>
<div class="time">
<div class="start_box">
<div class="start_title">起始時間</div>
<input class="start_text" id="start" type="text">
</div>
<div class="end_box">
<div class="end_title">結束時間</div>
<input class="end_text" id="end" type="text">
</div>
</div>
<div class="button_box">
<button class="button_text" id="button" type="button" onclick="download()">下載</button>
</div>
</div>
</div>
<style>
.main {
width: 100%;
height: 100%;
align-items: center;
display: grid;
justify-items: center;
color: white;
}
.body {
text-align: center;
padding: 4%;
border: 3px solid black;
border-radius: 5px;
background-color: #535353;
}
.title {
font-size: 28px;
font-weight: 900;
}
.subtitle {
font-size: 26px;
font-weight: 600;
}
.stations_box {
padding: 2%;
}
.stations_title {
font-size: 20px;
font-weight: 900;
}
.stations_text {
border-radius: 5px;
text-align: center;
color: white;
background-color: #333439;
border: 1px solid black;
outline: none;
}
.time {
display: flex;
}
.start_box {
padding: 1%;
width: 50%;
}
.start_title {
font-size: 16px;
font-weight: 600;
}
.start_text {
border-radius: 5px;
width: 80%;
text-align: center;
color: white;
background-color: #333439;
border: 1px solid black;
outline: none;
}
.end_box {
padding: 1%;
width: 50%;
}
.end_title {
font-size: 16px;
font-weight: 600;
}
.end_text {
border-radius: 5px;
width: 80%;
text-align: center;
color: white;
background-color: #333439;
border: 1px solid black;
outline: none;
}
.button_box {
padding: 1%;
align-items: center;
}
.button_text {
color: white;
background-color: #333439;
border-radius: 5px;
font-size: 16px;
margin: 2%;
padding: 1%;
width: 60%;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.0.0/axios.min.js"></script>
<script>
let utc = new Date();
let NOW = new Date(utc.getTime() + utc.getTimezoneOffset() * 60 * 1000 + 3600 * 8 * 1000);
const now = new Date(NOW.getTime() - 310000);
const Now = now.getFullYear() +
"-" + (now.getMonth() + 1) +
"-" + now.getDate() +
" " + now.getHours() +
":" + now.getMinutes() +
":" + now.getSeconds();
const now1 = new Date(NOW.getTime() - 10000);
const Now1 = now1.getFullYear() +
"-" + (now1.getMonth() + 1) +
"-" + now1.getDate() +
" " + now1.getHours() +
":" + now1.getMinutes() +
":" + now1.getSeconds();
const _stations = document.getElementById("stations");
const _button = document.getElementById("button");
const _start = document.getElementById("start");
const _end = document.getElementById("end");
_start.value = Now;
_end.value = Now1;
let station_data;
axios.get("https://cdn.jsdelivr.net/gh/ExpTechTW/API@master/Json/earthquake/station.json")
.then((res) => {
station_data = res.data;
_stations.innerHTML = "";
for (let i = 0; i < Object.keys(station_data).length; i++) {
const station = Object.keys(station_data)[i];
if (station.startsWith("L")) continue;
const opt_station = document.createElement("option");
opt_station.value = station;
opt_station.innerHTML = `${station} ${station_data[station].Loc}`;
_stations.appendChild(opt_station);
}
})
const Network = document.getElementById("Network");
Network.onchange = () => {
_stations.innerHTML = "";
for (let i = 0; i < Object.keys(station_data).length; i++) {
const station = Object.keys(station_data)[i];
if ((Network.value == "MS" && station.startsWith("L")) || (Network.value == "SE" && station.startsWith("H"))) continue;
const opt_station = document.createElement("option");
opt_station.value = station;
opt_station.innerHTML = `${station} ${station_data[station].Loc}`;
_stations.appendChild(opt_station);
}
}
function download() {
_button.disabled = true;
_button.textContent = "正在準備檔案...";
_stations.disabled = true;
_start.disabled = true;
_end.disabled = true;
axios.get(`https://exptech.com.tw/api/v1/trem/waveform?station=${_stations.value}&start=${convertDate(_start.value).getTime()}&end=${convertDate(_end.value).getTime()}`)
.then((res) => {
console.log(res.data);
file(res.data);
}).catch((err) => {
console.error(err);
exit();
const res = err.request.response;
if (res == "End Time Error") alert("結束時間 錯誤!");
else if (res == "Can Not Found File") alert("起始時間 錯誤!");
else if (res == "Unknown Error, please report to the Developer (data-waveform)") alert("未知錯誤!");
else if (res == "Can Not Found File") alert("起始時間 錯誤!");
else if (res == "Time Too Long") alert("時間段過長!");
else if (res == "Time Error") alert("時間 錯誤!");
})
}
function convertDate(date) {
const arr = date.split(/[- :]/);
return new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4], arr[5]);
}
function file(file) {
axios({
url: `https://exptech.com.tw/api/v1/file?path=/Download/${file}.zip`,
method: 'GET',
responseType: 'blob'
}).then((res) => {
const link = document.createElement('a');
link.href = window.URL.createObjectURL(new Blob([res.data]));
link.setAttribute('download', `${_stations.value}_${_start.value}_${_end.value}.zip`);
document.body.appendChild(link);
link.click();
exit();
}).catch((err) => {
console.error(err);
exit();
alert("下載 錯誤!");
})
}
function exit() {
_button.textContent = "下載";
_stations.disabled = false;
_start.disabled = false;
_end.disabled = false;
_button.disabled = false;
}
</script>
</body>
</html>