working on search

This commit is contained in:
2025-07-04 23:03:33 +02:00
parent c934e19837
commit b07533eaa9
6 changed files with 161 additions and 141 deletions

View File

@@ -0,0 +1,44 @@
<script>
import {t} from '../../translations.svelte.js';
let key = "";
let fulltext = false;
let html = "";
async function doSearch(ev){
ev.preventDefault();
const params = new URLSearchParams()
params.set('key', key);
if (fulltext) params.set('fulltext',true);
const url = `${location.protocol}//${location.host.replace('5173','8080')}/legacy/search?${params.toString()}`;
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
html = await resp.text();
if (!html) html = t('search.nothing_found');
}
}
</script>
<fieldset class="search">
<legend>{t('search.search')}</legend>
<form onsubmit={doSearch}>
<label>
{t('search.key')}
<input type="text" bind:value={key} />
</label>
<label>
<input type="checkbox" bind:checked={fulltext} />
{t('search.fulltext')}
</label>
<button type="submit">{t('search.go')}</button>
</form>
</fieldset>
{#if html}
<fieldset>
<legend>
{t('search.results')}
</legend>
{@html html}
</fieldset>
{/if}