Added refs parser and fetch.
This commit is contained in:
parent
d3d5ab0170
commit
cf7e8f6026
1 changed files with 63 additions and 3 deletions
|
|
@ -5,9 +5,60 @@ export const modal = (el) => {
|
|||
|
||||
function parseRef(ref) {
|
||||
console.log(ref);
|
||||
ref = ref.replace(/%3[Aa]/, ':');
|
||||
const m = ref.match(/((\d+\+)?[a-zA-Z]+)\+?([0-9]+)?\:([0-9]+(-?[0-9]+)?)?/);
|
||||
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]+)?)?/);
|
||||
|
||||
console.log(m);
|
||||
|
||||
const book = m[1];
|
||||
const chapter = m[5];
|
||||
const verses = m[6];
|
||||
|
||||
if (book === undefined) {
|
||||
return {};
|
||||
}
|
||||
|
||||
let refdata = {
|
||||
book: _map[book],
|
||||
meta: books[_map[book]]
|
||||
};
|
||||
|
||||
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)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export const bindModals = () => {
|
||||
|
|
@ -23,6 +74,16 @@ export const bindModals = () => {
|
|||
dialog[0]?.setAttribute('data-scripture', scripture);
|
||||
dialog[0]?.classList.remove("hidden");
|
||||
//document.body.classList.add("overflow-hidden");
|
||||
|
||||
fetch('https://aries.destrealm.org/bshelton/gen1.json')
|
||||
.then((response) => {
|
||||
console.log(response.ok);
|
||||
return response.json();
|
||||
})
|
||||
.then((response) => {
|
||||
const content = response?.chapter?.content;
|
||||
console.log(content);
|
||||
});
|
||||
});
|
||||
});
|
||||
dialog[0]?.addEventListener('click', (evt) => {
|
||||
|
|
@ -30,7 +91,6 @@ export const bindModals = () => {
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
const books = {
|
||||
"gen": {"title": "Genesis", "start": 1, "stop": 50, "count": 50,
|
||||
"aliases": ["gn"],
|
||||
|
|
|
|||
Loading…
Reference in a new issue