Update src/client/api.ts
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
60508b99ae
commit
ad420b4528
@ -1,17 +1,18 @@
|
||||
export const throttle = (func: () => void, wait: number) => {
|
||||
let lastTime = 0;
|
||||
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
let lastArgs: any[];
|
||||
var lastTime = 0;
|
||||
var timeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
var lastArgs: any[];
|
||||
|
||||
return function (...args: any[]) {
|
||||
const now = Date.now();
|
||||
lastArgs = args;
|
||||
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
timeoutId = undefined;
|
||||
if (now - lastTime >= wait) {
|
||||
lastTime = now;
|
||||
func.apply(this, lastArgs);
|
||||
} else {
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
timeoutId = setTimeout(
|
||||
() => {
|
||||
lastTime = Date.now();
|
||||
@ -55,6 +56,7 @@ export const query_nominatim = (
|
||||
bb: any,
|
||||
f: (v: string) => Boolean = () => true
|
||||
) => {
|
||||
if (q.length == 0) return Promise.resolve([])
|
||||
let url = new URL("/api/place/" + q, window.location.origin);
|
||||
url.searchParams.append("id", q);
|
||||
url.searchParams.append("bb", JSON.stringify(bb));
|
||||
@ -95,7 +97,13 @@ export const is_attraction_type = (e: NominatimResult): boolean =>
|
||||
"protected_area",
|
||||
].indexOf(e.type) != -1;
|
||||
|
||||
export const icon_type = (item: NominatimResult): string => {
|
||||
export const is_hotel_type = (e: NominatimResult): boolean =>
|
||||
["hotel", "hostel", "guest_house"].indexOf(e.type) != -1
|
||||
|
||||
export const icon_type = (item: string | NominatimResult): string => {
|
||||
if (typeof (item) == "string") {
|
||||
return item
|
||||
}
|
||||
let t = item.type;
|
||||
let c = item.category;
|
||||
let types = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user