-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPotaApi.js
39 lines (27 loc) · 1.01 KB
/
PotaApi.js
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
// Takes park id and returns the lat long for the parks marker
// moderate checking on the park name
export default async function getParkLocation(park) {
const re = /[A-Z]{2}-[0-9]*/;
park = park.toUpperCase();
let b = re.test(park);
if (b == false) return;
let url = "https://api.pota.app/park/" + park;
const parkData = await $.ajax({ url: url });
return { 'lat': parkData.latitude, 'lon': parkData.longitude };
}
async function getParkLastActx(park) {
const re = /[A-Z]{2}-[0-9]*/;
park = park.toUpperCase();
let b = re.test(park);
if (b == false) return;
let url = "https://api.pota.app/park/activations/" + park;
const parkData = await $.ajax({ url: url, data: { "count": 1 } });
let dt = parkData[0].qso_date.slice(0,4) + '-' +
parkData[0].qso_date.slice(4,6) + '-' +
parkData[0].qso_date.slice(6);
return {
'lastActivator': parkData[0].activeCallsign,
'date': dt
};
}
export { getParkLocation, getParkLastActx };