Skip to content

Commit 8115092

Browse files
committed
Formatting
1 parent a65600a commit 8115092

File tree

6 files changed

+41
-37
lines changed

6 files changed

+41
-37
lines changed

src/lib/components/LexiconXMLView.svelte

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<script>
2-
import { get } from 'svelte/store';
32
import config from '$lib/data/config';
43
import { convertStyle } from '$lib/data/stores';
5-
import { afterUpdate, onMount } from 'svelte';
64
import { initializeDatabase } from '$lib/data/stores/lexicon';
7-
import { selectedLanguageStore, vernacularLanguageStore, vernacularWordsStore } from '$lib/data/stores/lexicon.ts';
5+
import {
6+
selectedLanguageStore,
7+
vernacularLanguageStore,
8+
vernacularWordsStore
9+
} from '$lib/data/stores/lexicon.ts';
10+
import { afterUpdate, onMount } from 'svelte';
11+
import { get } from 'svelte/store';
812
913
export let wordIds;
1014
export let onSelectWord;
@@ -16,12 +20,10 @@
1620
let db = await initializeDatabase({ fetch });
1721
1822
let results;
19-
const dynamicQuery = wordIds
20-
.map(() => `id = ?`)
21-
.join(' OR ');
23+
const dynamicQuery = wordIds.map(() => `id = ?`).join(' OR ');
2224
const dynamicParams = wordIds.map((id) => id);
2325
results = db.exec(`SELECT xml FROM entries WHERE ${dynamicQuery}`, dynamicParams);
24-
console.log('results:' , results[0].values);
26+
console.log('results:', results[0].values);
2527
2628
return results[0].values;
2729
} catch (error) {
@@ -67,7 +69,9 @@
6769
const match = href.match(/E-(\d+)/); // Extract index number
6870
if (match) {
6971
const index = parseInt(match[1], 10); // Extracted number as integer
70-
const wordObject = get(vernacularWordsStore).find((item) => item.id === index);
72+
const wordObject = get(vernacularWordsStore).find(
73+
(item) => item.id === index
74+
);
7175
const word = wordObject ? wordObject.name : 'Unknown'; // Fallback if not found
7276
const homonymIndex = wordObject ? wordObject.homonym_index : 1; // Default to 1 if not found
7377

src/lib/components/SearchForm.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
1616
let specialCharacters = [];
1717
if (config.programType == 'SAB') {
18-
specialCharacters = config.mainFeatures['input-buttons']?.split(' ').filter((c) => c.length) ?? [];
18+
specialCharacters =
19+
config.mainFeatures['input-buttons']?.split(' ').filter((c) => c.length) ?? [];
1920
} else if (config.programType === 'DAB') {
2021
specialCharacters = Object.values(config.writingSystems)
2122
.filter((ws: any) => ws.type && ws.type.includes('main'))

src/lib/components/Sidebar.svelte

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,11 @@ The sidebar/drawer.
8585
})
8686
.join(', ');
8787
}
88-
async function goToSearch(){
88+
async function goToSearch() {
8989
if (config.programType === 'DAB') {
9090
await goto(getRoute(`/lexicon/search`));
91-
}
92-
else{
93-
await goto(getRoute(`/search/${$refs.collection}`))
91+
} else {
92+
await goto(getRoute(`/search/${$refs.collection}`));
9493
}
9594
}
9695
@@ -151,11 +150,7 @@ The sidebar/drawer.
151150
{/if}
152151
{#if showSearch}
153152
<li>
154-
<button
155-
class="btn"
156-
style:color={textColor}
157-
on:click={goToSearch}
158-
>
153+
<button class="btn" style:color={textColor} on:click={goToSearch}>
159154
<SearchIcon color={iconColor} />{$t['Menu_Search']}
160155
</button>
161156
</li>

src/lib/components/WordNavigationStrip.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import {
2+
import {
33
currentReversalWordsStore,
44
selectedLanguageStore,
55
vernacularLanguageStore,
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
import type { SearchOptions } from '$lib/search/domain/interfaces/data-interfaces';
21
import { initializeDatabase } from '$lib/data/stores/lexicon';
2+
import type { SearchOptions } from '$lib/search/domain/interfaces/data-interfaces';
33

44
// Search the dictionary based on the phrase and options
55
export async function searchDictionary(phrase: string, options: SearchOptions) {
6-
76
const searchWords = phrase.split(' ');
87

98
const column = options.accentsAndTones ? 'word' : 'word_no_accents';
10-
11-
let db = await initializeDatabase({ fetch })
9+
10+
let db = await initializeDatabase({ fetch });
1211
let results;
13-
const dynamicQuery = searchWords
14-
.map(() => `${column} LIKE ?`)
15-
.join(' OR ');
16-
const dynamicParams = searchWords.map(word => options.wholeWords ? word : `%${word}%`);
12+
const dynamicQuery = searchWords.map(() => `${column} LIKE ?`).join(' OR ');
13+
const dynamicParams = searchWords.map((word) => (options.wholeWords ? word : `%${word}%`));
1714
results = db.exec(`SELECT locations FROM search_words WHERE ${dynamicQuery}`, dynamicParams);
18-
console.log('results:' , results);
15+
console.log('results:', results);
1916

2017
if (!results?.length || !results[0]?.values?.length) {
2118
return [];
2219
}
2320

2421
// Extract and process locations from the query result
25-
let locations = results[0].values.flatMap(value =>
26-
value[0].split(' ').map(loc => {
27-
const [id, weight] = loc.split('(').map(v => v.replace(')', ''));
22+
let locations = results[0].values.flatMap((value) =>
23+
value[0].split(' ').map((loc) => {
24+
const [id, weight] = loc.split('(').map((v) => v.replace(')', ''));
2825
return { id: parseInt(id, 10), weight: parseInt(weight, 10) };
2926
})
3027
);
3128

3229
// Remove duplicates by creating a Map with unique IDs
3330
const uniqueLocationsMap = new Map();
34-
locations.forEach(location => {
35-
if (!uniqueLocationsMap.has(location.id) || uniqueLocationsMap.get(location.id).weight < location.weight) {
31+
locations.forEach((location) => {
32+
if (
33+
!uniqueLocationsMap.has(location.id) ||
34+
uniqueLocationsMap.get(location.id).weight < location.weight
35+
) {
3636
uniqueLocationsMap.set(location.id, location);
3737
}
3838
});
3939
locations = Array.from(uniqueLocationsMap.values());
4040

41-
locations = (locations.sort((a, b) => b.weight - a.weight));
42-
const ids = locations.map(location => location.id);
41+
locations = locations.sort((a, b) => b.weight - a.weight);
42+
const ids = locations.map((location) => location.id);
4343
return ids;
44-
}
44+
}

src/routes/lexicon/+page.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { base } from '$app/paths';
22
import type { DictionaryConfig } from '$config';
33
import config from '$lib/data/config';
4-
import { initializeDatabase, vernacularLanguageStore, vernacularWordsStore } from '$lib/data/stores/lexicon';
4+
import {
5+
initializeDatabase,
6+
vernacularLanguageStore,
7+
vernacularWordsStore
8+
} from '$lib/data/stores/lexicon';
59
import type { ReversalIndex } from '$lib/lexicon';
610

711
export async function load({ fetch }) {

0 commit comments

Comments
 (0)