diff --git a/apps/ktb-static/script.js b/apps/ktb-static/script.js index 5dfc6e4..0beaf9a 100644 --- a/apps/ktb-static/script.js +++ b/apps/ktb-static/script.js @@ -2,7 +2,7 @@ document.addEventListener("alpine:init", () => { Alpine.store("dictionary", { search_results: { - terms: 0, + terms: 1, results: [ { lemma_name: "wiigel", @@ -136,6 +136,20 @@ document.addEventListener("alpine:init", () => { } }, + async delete_definition(definition_id, definition_text) { + if ( + window.confirm(`Du keshite imi ${definition_id}.\nPravda?`) + ) { + try { + const res = await axios.delete( + `http://localhost:1225/definition/${definition_id}`, + ); + } catch (e) { + console.error(e); + } + } + }, + async put_example(example_id, example_text, lemma_name) { try { const res = await axios.put("http://localhost:1225/example", { @@ -149,6 +163,20 @@ document.addEventListener("alpine:init", () => { } }, + async delete_example(example_id, example_text) { + if ( + window.confirm(`Du keshite tato ${example_id}.\nPravda?`) + ) { + try { + const res = await axios.delete( + `http://localhost:1225/example/${example_id}`, + ); + } catch (e) { + console.error(e); + } + } + }, + async put_word_form_text(word_form_id, word_form_text) { try { const res = await axios.put("http://localhost:1225/word-form", { @@ -162,6 +190,12 @@ document.addEventListener("alpine:init", () => { }, async post_new_word_form(lemma_name, lect_name, word_form_text) { + if(!lemma_name || !lect_name || !word_form_text) { + console.error(`Missing parameter:\n${JSON.stringify({ + lemma_name, lect_name, word_form_text + })}`); + } + try { const res = await axios.post( "http://localhost:1225/word-form", @@ -199,7 +233,7 @@ document.addEventListener("alpine:init", () => { }, md(text){ - console.log(marked.parse(text)); + console.debug(marked.parse(text)); return DOMPurify.sanitize(marked.parse(text), {ALLOWED_TAGS: ['br', 'em', 'strong', 'code', '#text']}); }, }); diff --git a/apps/ktb-static/search.html b/apps/ktb-static/search.html index cb50c3f..9f12af3 100644 --- a/apps/ktb-static/search.html +++ b/apps/ktb-static/search.html @@ -19,6 +19,8 @@ search_term: '', showPrefs: false, lects: [], + current_result_page: 0, + results_per_page: 30, md(text){ return $store.dictionary.md(text); }, @@ -92,9 +94,31 @@ @keydown.enter="$store.dictionary.fetch_all_terms(search_term)" placeholder="Tasta ko(tel) her..." /> +