Move dialog open to its own function.

This commit is contained in:
Benjamin A. Shelton 2026-08-20 14:52:51 -06:00
commit 13e66e4f93
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01

View file

@ -79,6 +79,8 @@ class RenderScripture {
constructor(dialog) { constructor(dialog) {
this.dialog = dialog; this.dialog = dialog;
const url = new URL(document.URL);
console.log(parseRef(url.searchParams.get('cite')));
//history.replaceState({dialog: false}, ''); //history.replaceState({dialog: false}, '');
window.addEventListener('popstate', (evt) => { window.addEventListener('popstate', (evt) => {
@ -129,23 +131,9 @@ class RenderScripture {
} }
anchorClick(evt) { anchorClick(evt) {
const scripture = evt.target.attributes.getNamedItem('data-scripture'); const scripture = evt.target.attributes.getNamedItem('data-scripture')?.value;
const refs = parseRef(scripture.value);
const tx = refs.meta?.tx || 'BSB';
this.ref = refs;
evt.preventDefault(); evt.preventDefault();
this.dialog[0]?.showModal(); this.openDialog(scripture, evt.target.name);
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');
} }
buildTranslationList(sel) { buildTranslationList(sel) {
@ -173,6 +161,23 @@ class RenderScripture {
//history.back(); //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) { txnOnChange(evt) {
const tx = evt.target.selectedOptions[0].value; const tx = evt.target.selectedOptions[0].value;
this.translation = tx; this.translation = tx;