dev #160

Merged
sora merged 97 commits from dev into master 2025-03-02 01:09:30 +01:00
Showing only changes of commit ad420b4528 - Show all commits

View File

@ -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 = {