diff --git a/src/utils/modal.js b/src/utils/modal.js index 8a548ab..5c0fafd 100644 --- a/src/utils/modal.js +++ b/src/utils/modal.js @@ -79,6 +79,8 @@ class RenderScripture { constructor(dialog) { this.dialog = dialog; + const url = new URL(document.URL); + console.log(parseRef(url.searchParams.get('cite'))); //history.replaceState({dialog: false}, ''); window.addEventListener('popstate', (evt) => { @@ -129,23 +131,9 @@ class RenderScripture { } anchorClick(evt) { - const scripture = evt.target.attributes.getNamedItem('data-scripture'); - const refs = parseRef(scripture.value); - const tx = refs.meta?.tx || 'BSB'; - this.ref = refs; + const scripture = evt.target.attributes.getNamedItem('data-scripture')?.value; evt.preventDefault(); - this.dialog[0]?.showModal(); - this.dialog[0]?.setAttribute('data-scripture', scripture.value); - this.dialog[0]?.classList.remove("hidden"); - this.dialog[0]?.querySelector('.spinner svg') - .classList.remove('hidden'); - this.buildTranslationList(this.sel); - this.readScripture(refs); - history.pushState({ - dialog: true, - scripture: scripture.value, - tx: this.translation - }, '', '#dialog'); + this.openDialog(scripture, evt.target.name); } buildTranslationList(sel) { @@ -173,6 +161,23 @@ class RenderScripture { //history.back(); } + openDialog(scripture, hash) { + const refs = parseRef(scripture); + this.ref = refs; + this.dialog[0]?.showModal(); + this.dialog[0]?.setAttribute('data-scripture', scripture); + this.dialog[0]?.classList.remove("hidden"); + this.dialog[0]?.querySelector('.spinner svg') + .classList.remove('hidden'); + this.buildTranslationList(this.sel); + this.readScripture(refs); + history.pushState({ + dialog: true, + scripture: scripture.value, + tx: this.translation + }, '', `?cite=${scripture}#${hash}`); + } + txnOnChange(evt) { const tx = evt.target.selectedOptions[0].value; this.translation = tx;