-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
136 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,71 @@ | ||
<script setup lang="ts"> | ||
import { onMounted, ref } from "vue"; | ||
import VerseComponent from "./VerseComponent.vue"; | ||
import { api } from "@/services/api"; | ||
// import type { PropType } from "vue"; | ||
import { buildVerseFromString } from "@/composables/useVerseUtils"; | ||
import { useAppLoader } from "@/composables/useAppLoader"; | ||
import { onMounted, ref, watch } from "vue"; | ||
import BaseButton from "../ui/BaseButton.vue"; | ||
// import VerseComponent from "./VerseComponent.vue"; | ||
import VerseList from "./VerseList.vue"; | ||
import { loadXr } from "@/utils/crossReferensesUtils"; | ||
import { loadVerse } from "@/composables/useVerseUtils"; | ||
const props = defineProps({ | ||
vid: String, | ||
}); | ||
const verse = ref(); | ||
const { startLoading, stopLoading } = useAppLoader(); | ||
const xrs = ref(); | ||
const currentXr = ref(); | ||
const verses = ref(); | ||
onMounted(async () => { | ||
startLoading(); | ||
const data = await api.bible.loadVerse(props.vid); | ||
verse.value = buildVerseFromString(props.vid, data.translations[1].tokens); | ||
console.log(verse.value); | ||
watch(currentXr, async () => { | ||
verses.value = []; | ||
currentXr.value?.vids.forEach(async (vid: string) => { | ||
const v = await loadVerse(vid); | ||
if (v) { | ||
verses.value.push(v); | ||
} | ||
}); | ||
// console.log(verses.value); | ||
}); | ||
stopLoading(); | ||
onMounted(async () => { | ||
xrs.value = await loadXr(props.vid); | ||
}); | ||
</script> | ||
|
||
<template> | ||
CrossReferences | ||
<!-- {{ xrs }} --> | ||
<ul> | ||
<li v-for="(xr, index) in xrs" :key="index"> | ||
<BaseButton | ||
class="item" | ||
@click="currentXr = xr" | ||
> | ||
{{ xr.title }} | ||
</BaseButton> | ||
</li> | ||
</ul> | ||
<div v-if="currentXr" class="details"> | ||
<VerseList :verses="verses" :show-pagination="false" /> | ||
</div> | ||
<!-- <VerseComponent :verse="verse" class="cross-references" /> --> | ||
</template> | ||
|
||
<style scoped> | ||
.masoretic-text :deep(.token > .lemma) { | ||
display: none; | ||
ul { | ||
display: flex; | ||
white-space: nowrap; | ||
flex-wrap: wrap; | ||
column-gap: 1em; | ||
row-gap: 0.5em; | ||
margin-bottom: 1em; | ||
li { | ||
.item { | ||
width: 9em; | ||
padding: 0 0.3em; | ||
} | ||
} | ||
} | ||
.details { | ||
margin-top: 2em; | ||
color: var(--bbl-c-text-2); | ||
font-size: 0.9em; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { api } from "@/services/api"; | ||
import { useAppLoader } from "@/composables/useAppLoader"; | ||
|
||
const xrCache: Map<string, Object> = new Map(); | ||
|
||
const { startLoading, stopLoading } = useAppLoader(); | ||
|
||
export async function loadXr(vid) { | ||
let xr = xrCache.get(vid); | ||
if (!xr) { | ||
startLoading(); | ||
const data = await api.bible.loadCrossReferences(vid); | ||
stopLoading(); | ||
const lines = data.split("\n"); | ||
for (let i = 0; i < lines.length; i++) { | ||
const [bookId, chapterId] = vid.split(":"); | ||
const _vid = `${bookId}:${chapterId}:${i + 1}`; | ||
xrCache.set( | ||
_vid, | ||
parseLine(lines[i]), | ||
); | ||
} | ||
xr = xrCache.get(vid); | ||
} | ||
return xr; | ||
} | ||
function parseLine(line: string) { | ||
const [, ...tokens] = line.split("🞍"); | ||
const xrs = []; | ||
if (tokens) { | ||
tokens.forEach((xr) => { | ||
xrs.push(parseXr(xr)); | ||
}); | ||
} | ||
return xrs; | ||
} | ||
export function parseXr(xr) { | ||
const tokens = xr.split("₋"); | ||
const vids = []; | ||
if (tokens.length > 1) { | ||
tokens[3].split(",").forEach((verseId) => { | ||
vids.push(`${tokens[1]}:${tokens[2]}:${verseId}`); | ||
}); | ||
} | ||
return { | ||
title: tokens[0], | ||
vids, | ||
}; | ||
} |