Dialog WIP, mostly working.
Styling still needs tweaking and the Bible Gateway link needs to be fixed.
This commit is contained in:
parent
118e1ab98e
commit
69bb3f4ad3
3 changed files with 59 additions and 9 deletions
|
|
@ -35,7 +35,10 @@ function parseRef(ref) {
|
|||
|
||||
if (verses !== undefined) {
|
||||
if (verses.indexOf('-') < 0) {
|
||||
refdata['verse'] = verses;
|
||||
refdata['verses'] = {
|
||||
start: verses,
|
||||
end: verses
|
||||
};
|
||||
} else {
|
||||
refdata['verses'] = {
|
||||
start: verses.substring(0, verses.indexOf('-')),
|
||||
|
|
@ -68,7 +71,7 @@ function parseRef(ref) {
|
|||
|
||||
function render(dialog, response) {
|
||||
const content = response?.chapter?.content;
|
||||
const refs = parseRef('gen+1');
|
||||
const refs = parseRef('gen+1:4');
|
||||
let inSpan = false;
|
||||
|
||||
if (dialog === null || dialog === undefined) {
|
||||
|
|
@ -112,15 +115,22 @@ function render(dialog, response) {
|
|||
continue
|
||||
}
|
||||
if ('lineBreak' in v) {
|
||||
para.insertAdjacentElement('beforeend', document.createElement('br'));
|
||||
if (para.innerHTML.length != 0 || para.innerText.length != 0) {
|
||||
section.insertAdjacentElement('beforeend', para);
|
||||
para = document.createElement('p');
|
||||
}
|
||||
//para.insertAdjacentElement('beforeend', document.createElement('br'));
|
||||
//para = document.createElement('p');
|
||||
}
|
||||
if ('text' in v) {
|
||||
const span = document.createElement('span');
|
||||
span.insertAdjacentText('beforeend', v.text);
|
||||
para.insertAdjacentElement('beforeend', span);
|
||||
para.insertAdjacentText('beforeend', v.text);
|
||||
if ('poem' in v) {
|
||||
span.classList.add('poem-'+v.poem);
|
||||
para.classList.add('poem-'+v.poem);
|
||||
if (para.innerHTML.length != 0 || para.innerText.length != 0) {
|
||||
section.insertAdjacentElement('beforeend',
|
||||
para);
|
||||
}
|
||||
para = document.createElement('p');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -162,6 +172,13 @@ export const bindModals = () => {
|
|||
});
|
||||
dialog[0]?.addEventListener('click', (evt) => {
|
||||
evt.target === dialog[0] && dialog[0]?.close();
|
||||
dialog[0]?.querySelector('article')?.replaceChildren();
|
||||
|
||||
});
|
||||
dialog[0]?.querySelector('button[data-close]')?.addEventListener('click', (evt) => {
|
||||
evt.preventDefault();
|
||||
dialog[0]?.close();
|
||||
dialog[0]?.querySelector('article')?.replaceChildren();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue