2026-07-30 23:58:15 -06:00
|
|
|
|
2026-07-29 15:24:02 -06:00
|
|
|
export const modal = (el) => {
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2026-08-01 14:07:41 -06:00
|
|
|
function parseRef(ref) {
|
|
|
|
|
console.log(ref);
|
2026-08-03 15:34:10 -06:00
|
|
|
ref = ref.replace(/%3[Aa]/, ':').replace(/\+/, ' ');
|
|
|
|
|
console.log(ref);
|
|
|
|
|
const m = ref.match(/((\d+(\+|\s))?[a-zA-Z]+)(\+|\s)?([0-9]+)?\:?([0-9]+(-?[0-9]+)?)?/);
|
|
|
|
|
|
2026-08-01 14:07:41 -06:00
|
|
|
console.log(m);
|
2026-08-03 15:34:10 -06:00
|
|
|
|
|
|
|
|
const book = m[1];
|
|
|
|
|
const chapter = m[5];
|
|
|
|
|
const verses = m[6];
|
|
|
|
|
|
|
|
|
|
if (book === undefined) {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-05 11:17:39 -06:00
|
|
|
let refdata = {};
|
|
|
|
|
if (book in books) {
|
|
|
|
|
refdata.book = book;
|
|
|
|
|
} else if (book in _map) {
|
|
|
|
|
refdata.book = _map[book];
|
|
|
|
|
}
|
|
|
|
|
refdata.meta = books[refdata.book];
|
|
|
|
|
|
|
|
|
|
console.log('refdata:', refdata, book, _map);
|
2026-08-03 15:34:10 -06:00
|
|
|
|
|
|
|
|
if (chapter !== undefined) {
|
|
|
|
|
refdata['chapter'] = chapter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (verses !== undefined) {
|
|
|
|
|
if (verses.indexOf('-') < 0) {
|
|
|
|
|
refdata['verse'] = verses;
|
|
|
|
|
} else {
|
|
|
|
|
refdata['verses'] = {
|
|
|
|
|
start: verses.substring(0, verses.indexOf('-')),
|
|
|
|
|
end: verses.substring(verses.indexOf('-')+1)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-05 11:17:39 -06:00
|
|
|
console.log(refdata, book);
|
2026-08-03 15:34:10 -06:00
|
|
|
|
|
|
|
|
if ('verses' in refdata) {
|
|
|
|
|
if (refdata.verses.start < 1) {
|
|
|
|
|
refdata.verses.start = 1;
|
|
|
|
|
}
|
|
|
|
|
if (refdata.verses.start > refdata.meta.stop) {
|
|
|
|
|
refdata.verses.start = refdata.meta.stop;
|
|
|
|
|
}
|
|
|
|
|
if (refdata.verses.end < 1) {
|
|
|
|
|
refdata.verses.end = 1;
|
|
|
|
|
}
|
|
|
|
|
if (refdata.verses.end > refdata.meta.stop) {
|
|
|
|
|
refdata.verses.end = refdata.meta.stop;
|
|
|
|
|
}
|
|
|
|
|
if (refdata.verses.start > refdata.verses.end) {
|
|
|
|
|
refdata.verses.end = refdata.verses.start;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return refdata;
|
2026-08-01 14:07:41 -06:00
|
|
|
}
|
|
|
|
|
|
2026-08-05 11:17:39 -06:00
|
|
|
function render(dialog, response) {
|
|
|
|
|
const content = response?.chapter?.content;
|
|
|
|
|
const refs = parseRef('gen+1:1-4');
|
|
|
|
|
let inSpan = false;
|
|
|
|
|
|
|
|
|
|
if (dialog === null || dialog === undefined) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const section = document.createElement('section');
|
|
|
|
|
|
|
|
|
|
for (const c of content) {
|
|
|
|
|
if (c.type === 'heading') {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (c.type) {
|
|
|
|
|
case 'line_break':
|
|
|
|
|
if (inSpan) {
|
|
|
|
|
console.log('line break');
|
|
|
|
|
section.insertAdjacentElement('beforeend', document.createElement('br'));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'verse':
|
|
|
|
|
if (!('number' in c)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (c.number >= refs.verses.start && c.number <= refs.verses.end) {
|
|
|
|
|
inSpan = true;
|
|
|
|
|
} else {
|
|
|
|
|
inSpan = false;
|
|
|
|
|
}
|
|
|
|
|
if (inSpan) {
|
|
|
|
|
for (const v of c.content) {
|
|
|
|
|
if (typeof(v) === 'string') {
|
|
|
|
|
console.log("string:", v);
|
|
|
|
|
section.insertAdjacentText('beforebegin', document.createTextNode(v));
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if ('lineBreak' in v) {
|
|
|
|
|
section.insertAdjacentElement('beforeend', document.createElement('br'));
|
|
|
|
|
}
|
|
|
|
|
if ('text' in v) {
|
|
|
|
|
console.log('adding text:', v.text);
|
|
|
|
|
const span = document.createElement('span');
|
|
|
|
|
span.insertAdjacentText(v.text);
|
|
|
|
|
if ('poem' in v) {
|
|
|
|
|
span.classList.add('poem-'+v.poem);
|
|
|
|
|
section.insertAdjacentElement('beforeend', span);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
console.log('unhandled type:', c.type);
|
|
|
|
|
}
|
|
|
|
|
console.log(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dialog?.querySelector('article').insertAdjacentElement('beforeend', section);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-29 15:24:02 -06:00
|
|
|
export const bindModals = () => {
|
2026-07-29 22:55:24 -06:00
|
|
|
const elems = document.querySelectorAll('a[data-scripture]');
|
|
|
|
|
const dialog = document.querySelectorAll('dialog[data-scripture]');
|
2026-07-29 15:24:02 -06:00
|
|
|
elems.forEach((e) => {
|
2026-07-29 22:55:24 -06:00
|
|
|
e.addEventListener('click', (evt) => {
|
|
|
|
|
const scripture = e.attributes.getNamedItem('data-scripture');
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
console.log(scripture);
|
2026-08-01 14:07:41 -06:00
|
|
|
console.log(parseRef(scripture.value));
|
2026-07-29 22:55:24 -06:00
|
|
|
dialog[0]?.showModal();
|
|
|
|
|
dialog[0]?.setAttribute('data-scripture', scripture);
|
|
|
|
|
dialog[0]?.classList.remove("hidden");
|
|
|
|
|
//document.body.classList.add("overflow-hidden");
|
2026-08-03 15:34:10 -06:00
|
|
|
|
|
|
|
|
fetch('https://aries.destrealm.org/bshelton/gen1.json')
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log(response.ok);
|
|
|
|
|
return response.json();
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
2026-08-05 11:17:39 -06:00
|
|
|
render(dialog[0], response);
|
2026-08-03 15:34:10 -06:00
|
|
|
});
|
2026-07-29 22:55:24 -06:00
|
|
|
});
|
2026-07-29 15:24:02 -06:00
|
|
|
});
|
2026-07-30 16:17:31 -06:00
|
|
|
dialog[0]?.addEventListener('click', (evt) => {
|
|
|
|
|
evt.target === dialog[0] && dialog[0]?.close();
|
|
|
|
|
});
|
2026-07-30 23:58:15 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const books = {
|
|
|
|
|
"gen": {"title": "Genesis", "start": 1, "stop": 50, "count": 50,
|
|
|
|
|
"aliases": ["gn"],
|
|
|
|
|
},
|
|
|
|
|
"exo": {"title": "Exodus", "start": 1, "stop": 40, "count": 40,
|
|
|
|
|
"aliases": ["ex"],
|
|
|
|
|
},
|
|
|
|
|
"lev": {"title": "Leviticus", "start": 1, "stop": 27, "count": 27,
|
|
|
|
|
"aliases": ["lv"],
|
|
|
|
|
},
|
|
|
|
|
"num": {"title": "Numbers", "start": 1, "stop": 36, "count": 36,
|
|
|
|
|
"aliases": ["nm", "numb", "nmb", "nmbs"],
|
|
|
|
|
},
|
|
|
|
|
"deu": {"title": "Deuteronomy", "start": 1, "stop": 34, "count": 34,
|
|
|
|
|
"aliases": ["dt", "deut", "deuter"],
|
|
|
|
|
},
|
|
|
|
|
"jos": {"title": "Joshua", "start": 1, "stop": 24, "count": 24,
|
|
|
|
|
"aliases": ["js", "josh"],
|
|
|
|
|
},
|
|
|
|
|
"jdg": {"title": "Judges", "start": 1, "stop": 21, "count": 21,
|
|
|
|
|
"aliases": ["jd", "jdgs"],
|
|
|
|
|
},
|
|
|
|
|
"rut": {"title": "Ruth", "start": 1, "stop": 4, "count": 4,
|
|
|
|
|
"aliases": ["rt"],
|
|
|
|
|
},
|
|
|
|
|
"1sa": {"title": "1 Samuel", "start": 1, "stop": 31, "count": 31,
|
|
|
|
|
"aliases": ["1s", "1sam", "1 s", "1 sa", "1 sam"],
|
|
|
|
|
},
|
|
|
|
|
"2sa": {"title": "2 Samuel", "start": 1, "stop": 24, "count": 24,
|
|
|
|
|
"aliases": ["2s", "2sam", "2 s", "2 sa", "2 sam"],
|
|
|
|
|
},
|
|
|
|
|
"1ki": {"title": "1 Kings", "start": 1, "stop": 22, "count": 22,
|
|
|
|
|
"aliases": ["1k", "1kgs", "1king", "1 k", "1 ki", "1 kgs", "1 king"],
|
|
|
|
|
},
|
|
|
|
|
"2ki": {"title": "2 Kings", "start": 1, "stop": 25, "count": 25,
|
|
|
|
|
"aliases": ["2k", "2kgs", "2king", "2 k", "2 ki", "2 kgs", "2 king"],
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
"1ch": {"title": "1 Chronicles", "start": 1, "stop": 29, "count": 29,
|
|
|
|
|
"aliases": ["1c", "1chr", "1chron", "1 c", "1 ch", "1 chr", "1 chron"],
|
|
|
|
|
},
|
|
|
|
|
"2ch": {"title": "2 Chronicles", "start": 1, "stop": 36, "count": 36,
|
|
|
|
|
"aliases": ["2c", "2chr", "2chron", "2 c", "2 ch", "2 chr", "2 chron"],
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
"ezr": {"title": "Ezra", "start": 1, "stop": 10, "count": 10,
|
|
|
|
|
"aliases": ["ez"],
|
|
|
|
|
},
|
|
|
|
|
"neh": {"title": "Nehemiah", "start": 1, "stop": 13, "count": 13,
|
|
|
|
|
"aliases": ["nh"],
|
|
|
|
|
},
|
|
|
|
|
"est": {"title": "Esther", "start": 1, "stop": 10, "count": 10,
|
|
|
|
|
"aliases": ["es"],
|
|
|
|
|
},
|
|
|
|
|
"job": {"title": "Job", "start": 1, "stop": 42, "count": 42,
|
|
|
|
|
"aliases": ["jo"],
|
|
|
|
|
},
|
|
|
|
|
"psa": {"title": "Psalms", "start": 1, "stop": 150, "count": 150,
|
|
|
|
|
"aliases": ["ps", "pss"],
|
|
|
|
|
},
|
|
|
|
|
"pro": {"title": "Proverbs", "start": 1, "stop": 31, "count": 31,
|
|
|
|
|
"aliases": ["pr", "prov"],
|
|
|
|
|
},
|
|
|
|
|
"ecc": {"title": "Ecclesiastes", "start": 1, "stop": 12, "count": 12,
|
|
|
|
|
"aliases": ["ec", "eccl", "eccle"],
|
|
|
|
|
},
|
|
|
|
|
"sng": {"title": "Song of Solomon", "start": 1, "stop": 8, "count": 8,
|
|
|
|
|
"aliases": ["sn", "son", "song", "sol"],
|
|
|
|
|
},
|
|
|
|
|
"isa": {"title": "Isaiah", "start": 1, "stop": 66, "count": 66,
|
|
|
|
|
"aliases": ["is", "isai"],
|
|
|
|
|
},
|
|
|
|
|
"jer": {"title": "Jeremiah", "start": 1, "stop": 52, "count": 52,
|
|
|
|
|
"aliases": ["jr", "jere", "jerem"],
|
|
|
|
|
},
|
|
|
|
|
"lam": {"title": "Lamentations", "start": 1, "stop": 5, "count": 5,
|
|
|
|
|
"aliases": ["lm", "lamen"],
|
|
|
|
|
},
|
|
|
|
|
"ezk": {"title": "Ezekiel", "start": 1, "stop": 48, "count": 48,
|
|
|
|
|
"aliases": ["eze", "ezek"],
|
|
|
|
|
},
|
|
|
|
|
"dan": {"title": "Daniel", "start": 1, "stop": 12, "count": 12,
|
|
|
|
|
"aliases": ["dn"],
|
|
|
|
|
},
|
|
|
|
|
"hos": {"title": "Hosea", "start": 1, "stop": 14, "count": 14,
|
|
|
|
|
"aliases": ["hs"],
|
|
|
|
|
},
|
|
|
|
|
"jol": {"title": "Joel", "start": 1, "stop": 3, "count": 3,
|
|
|
|
|
"aliases": ["jl"],
|
|
|
|
|
},
|
|
|
|
|
"amo": {"title": "Amos", "start": 1, "stop": 9, "count": 9,
|
|
|
|
|
"aliases": ["am"],
|
|
|
|
|
},
|
|
|
|
|
"oba": {"title": "Obadiah", "start": 1, "stop": 1, "count": 1,
|
|
|
|
|
"aliases": ["ob", "obd", "obad"],
|
|
|
|
|
},
|
|
|
|
|
"jon": {"title": "Jonah", "start": 1, "stop": 4, "count": 4,
|
|
|
|
|
"aliases": ["jo"],
|
|
|
|
|
},
|
|
|
|
|
"mic": {"title": "Micah", "start": 1, "stop": 7, "count": 7,
|
|
|
|
|
"aliases": ["mc"],
|
|
|
|
|
},
|
|
|
|
|
"nam": {"title": "Nahum", "start": 1, "stop": 3, "count": 3,
|
|
|
|
|
"aliases": ["na"],
|
|
|
|
|
},
|
|
|
|
|
"hab": {"title": "Habakkuk", "start": 1, "stop": 3, "count": 3,
|
|
|
|
|
"aliases": ["hb", "haba", "habak"],
|
|
|
|
|
},
|
|
|
|
|
"zep": {"title": "Zephaniah", "start": 1, "stop": 3, "count": 3,
|
|
|
|
|
"aliases": ["ze", "zf", "zef"],
|
|
|
|
|
},
|
|
|
|
|
"hag": {"title": "Haggai", "start": 1, "stop": 2, "count": 2,
|
|
|
|
|
"aliases": ["hg"],
|
|
|
|
|
},
|
|
|
|
|
"zec": {"title": "Zechariah", "start": 1, "stop": 14, "count": 14,
|
|
|
|
|
"aliases": ["ze", "zech"],
|
|
|
|
|
},
|
|
|
|
|
"mal": {"title": "Malachi", "start": 1, "stop": 4, "count": 4,
|
|
|
|
|
"aliases": ["ml", "mala"],
|
|
|
|
|
},
|
|
|
|
|
"mat": {"title": "Matthew", "start": 1, "stop": 28, "count": 28,
|
|
|
|
|
"aliases": ["mt", "matt"],
|
|
|
|
|
},
|
|
|
|
|
"mrk": {"title": "Mark", "start": 1, "stop": 16, "count": 16,
|
|
|
|
|
"aliases": ["mk"],
|
|
|
|
|
},
|
|
|
|
|
"luk": {"title": "Luke", "start": 1, "stop": 24, "count": 24,
|
|
|
|
|
"aliases": ["lk"],
|
|
|
|
|
},
|
|
|
|
|
"jhn": {"title": "John", "start": 1, "stop": 21, "count": 21,
|
|
|
|
|
"aliases": ["jn"],
|
|
|
|
|
},
|
|
|
|
|
"act": {"title": "Acts", "start": 1, "stop": 28, "count": 28,
|
|
|
|
|
"aliases": ["ac"],
|
|
|
|
|
},
|
|
|
|
|
"rom": {"title": "Romans", "start": 1, "stop": 16, "count": 16,
|
|
|
|
|
"aliases": ["rm", "rms"],
|
|
|
|
|
},
|
|
|
|
|
"1co": {"title": "1 Corinthians", "start": 1, "stop": 16, "count": 16,
|
|
|
|
|
"aliases": ["1cor", "1corin", "1 co", "1 cor", "1 corin"],
|
|
|
|
|
},
|
|
|
|
|
"2co": {"title": "2 Corinthians", "start": 1, "stop": 13, "count": 13,
|
|
|
|
|
"aliases": ["2cor", "2corin", "2 co", "2 cor", "2 corin"],
|
|
|
|
|
},
|
|
|
|
|
"gal": {"title": "Galatians", "start": 1, "stop": 6, "count": 6,
|
|
|
|
|
"aliases": ["gl"],
|
|
|
|
|
},
|
|
|
|
|
"eph": {"title": "Ephesians", "start": 1, "stop": 6, "count": 6,
|
|
|
|
|
"aliases": ["ep", "ef"],
|
|
|
|
|
},
|
|
|
|
|
"php": {"title": "Philippians", "start": 1, "stop": 4, "count": 4,
|
|
|
|
|
"aliases": ["ph", "phil"],
|
|
|
|
|
},
|
|
|
|
|
"col": {"title": "Colossians", "start": 1, "stop": 4, "count": 4,
|
|
|
|
|
"aliases": ["cl", "colo"],
|
|
|
|
|
},
|
|
|
|
|
"1th": {"title": "1 Thessalonians", "start": 1, "stop": 5, "count": 5,
|
|
|
|
|
"aliases": ["1thes", "1thess", "1 thes", "1 thess"],
|
|
|
|
|
},
|
|
|
|
|
"2th": {"title": "2 Thessalonians", "start": 1, "stop": 3, "count": 3,
|
|
|
|
|
"aliases": ["2thes", "2thess", "2 thes", "2 thess"],
|
|
|
|
|
},
|
|
|
|
|
"1ti": {"title": "1 Timothy", "start": 1, "stop": 6, "count": 6,
|
|
|
|
|
"aliases": ["1tim", "1 ti", "1 tim"],
|
|
|
|
|
},
|
|
|
|
|
"2ti": {"title": "2 Timothy", "start": 1, "stop": 4, "count": 4,
|
|
|
|
|
"aliases": ["2tim", "2 ti", "2 tim"],
|
|
|
|
|
},
|
|
|
|
|
"tit": {"title": "Titus", "start": 1, "stop": 3, "count": 3,
|
|
|
|
|
"aliases": ["ti"],
|
|
|
|
|
},
|
|
|
|
|
"phm": {"title": "Philemon", "start": 1, "stop": 1, "count": 1,
|
|
|
|
|
"aliases": ["pi", "philm", "philem"],
|
|
|
|
|
},
|
|
|
|
|
"heb": {"title": "Hebrews", "start": 1, "stop": 13, "count": 13,
|
|
|
|
|
"aliases": ["he"],
|
|
|
|
|
},
|
|
|
|
|
"jas": {"title": "James", "start": 1, "stop": 5, "count": 5,
|
|
|
|
|
"aliases": ["ja", "jam"],
|
|
|
|
|
},
|
|
|
|
|
"1pe": {"title": "1 Peter", "start": 1, "stop": 5, "count": 5,
|
|
|
|
|
"aliases": ["1p", "1pt", "1pet", "1 p", "1 pe", "1 pt", "1 pet"],
|
|
|
|
|
},
|
|
|
|
|
"2pe": {"title": "2 Peter", "start": 1, "stop": 3, "count": 3,
|
|
|
|
|
"aliases": ["2p", "2pt", "2pet", "2 p", "2 pe", "2 pt", "2 pet"],
|
|
|
|
|
},
|
|
|
|
|
"1jn": {"title": "1 John", "start": 1, "stop": 5, "count": 5,
|
|
|
|
|
"aliases": ["1jon", "1 jn", "1 jon"],
|
|
|
|
|
},
|
|
|
|
|
"2jn": {"title": "2 John", "start": 1, "stop": 1, "count": 1,
|
|
|
|
|
"aliases": ["2jon", "2 jn", "2 jon"],
|
|
|
|
|
},
|
|
|
|
|
"3jn": {"title": "3 John", "start": 1, "stop": 1, "count": 1,
|
|
|
|
|
"aliases": ["3jon", "3 jn", "3 jon"],
|
|
|
|
|
},
|
|
|
|
|
"jud": {"title": "Jude", "start": 1, "stop": 1, "count": 1,
|
|
|
|
|
"aliases": ["ju"],
|
|
|
|
|
},
|
|
|
|
|
"rev": {"title": "Revelation", "start": 1, "stop": 22, "count": 22,
|
|
|
|
|
"aliases": ["rv", "reve"],
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function buildBookMap() {
|
|
|
|
|
let mp = {};
|
|
|
|
|
for (const book in books) {
|
|
|
|
|
if (!("aliases" in books[book])) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (const alias of books[book]?.aliases) {
|
|
|
|
|
mp[alias] = book;
|
|
|
|
|
}
|
|
|
|
|
mp[books[book]["title"].toLowerCase()] = book;
|
|
|
|
|
}
|
|
|
|
|
console.log(mp.length);
|
|
|
|
|
return mp;
|
2026-08-01 14:07:41 -06:00
|
|
|
}
|
|
|
|
|
const _map = buildBookMap();
|