working on search
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
<script>
|
||||
import { logout, user } from '../user.svelte.js';
|
||||
import { onMount } from 'sevelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { t } from '../translations.svelte.js';
|
||||
|
||||
const router = useTinyRouter();
|
||||
|
||||
function gotoAbout(){
|
||||
router.navigate('/about');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<nav>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import {t} from '../../translations.svelte.js';
|
||||
|
||||
let key = "";
|
||||
@@ -6,18 +7,27 @@
|
||||
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 (ev) ev.preventDefault();
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/legacy/search`;
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method : 'POST',
|
||||
body: JSON.stringify({key:key,fulltext:fulltext?'on':'off'})
|
||||
});
|
||||
if (resp.ok){
|
||||
html = await resp.text();
|
||||
if (!html) html = t('search.nothing_found');
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
console.log(location.search);
|
||||
let params = new URLSearchParams(location.search);
|
||||
key = params.get('key');
|
||||
console.log({param:key});
|
||||
if (key) doSearch();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<fieldset class="search">
|
||||
|
||||
Reference in New Issue
Block a user