cleaning up javascript code

This commit is contained in:
2025-07-29 09:01:37 +02:00
parent 89abbf5c62
commit 90a936b07f
13 changed files with 138 additions and 114 deletions

View File

@@ -1,18 +1,25 @@
<script>
import {onMount} from 'svelte';
import {t} from '../translations.svelte.js';
let { caption, onselect = (contact) => console.log('selected '+contact.FN||contact.ORG) } = $props();
let message = t('loading');
import {api} from '../urls.svelte.js';
import {t} from '../translations.svelte.js';
let {
caption,
onselect = (contact) => console.log('selected '+contact.FN||contact.ORG)
} = $props();
let contacts = $state(null);
let value = 0;
let message = t('loading');
let value = 0;
async function loadContacts(){
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/contacts`;
var resp = await fetch(url,{ credentials: 'include'});
const url = api('document/contacts');
const resp = await fetch(url,{ credentials: 'include'});
if (resp.ok){
contacts = await resp.json();
} else {
message = await resp.text();
message = await resp.text();
}
}
@@ -21,7 +28,6 @@
}
onMount(loadContacts)
</script>
{#if contacts}