mirror of
https://github.com/meichthys/church.git
synced 2026-02-08 18:03:42 +00:00
Add AndBible Integration.
This commit is contained in:
parent
79d3ea9a76
commit
41b4b34d4f
@ -1,6 +1,38 @@
|
||||
frappe.ui.form.on("Church Bible Reference", {
|
||||
import_reference_text: frm => {
|
||||
fetch_bible_text(frm);
|
||||
},
|
||||
refresh: async function(frm) {
|
||||
frm.add_custom_button('Open in AndBible', async function() {
|
||||
const start_verse = await frappe.get_doc("Church Bible Verse", frm.doc.start_verse);
|
||||
if (!start_verse.book || !start_verse.chapter || !start_verse.verse) {
|
||||
frappe.msgprint(__('Please make sure reference Start Verse has a Chapter and Verse.'));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Fetch abbreviation from linked Church Bible Book record
|
||||
const book = await frappe.db.get_doc('Church Bible Book', start_verse.book);
|
||||
const abbreviation = book.abbreviation;
|
||||
|
||||
if (!abbreviation) {
|
||||
frappe.msgprint(__(`No abbreviation found for Book: ${book}.`));
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct OSIS reference (e.g., Gen.1.1)
|
||||
const osisRef = `${abbreviation}.${start_verse.chapter}.${start_verse.verse}`;
|
||||
|
||||
// Build AndBible deep link
|
||||
const url = `https://read.andbible.org/${osisRef}`;
|
||||
|
||||
// Open the link (will launch AndBible if installed)
|
||||
window.open(url, '_blank');
|
||||
} catch (error) {
|
||||
frappe.msgprint(__('Failed to open verse in AndBible.'));
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -31,6 +31,35 @@ frappe.ui.form.on('Church Bible Verse', {
|
||||
frm.set_df_property('verse', 'options', Array.from({ length: 176 }, (_, i) => i + 1).join('\n'));
|
||||
}
|
||||
}
|
||||
frm.add_custom_button('Open in AndBible', async function() {
|
||||
if (!frm.doc.book || !frm.doc.chapter || !frm.doc.verse) {
|
||||
frappe.msgprint(__('Please make sure Book, Chapter, and Verse are filled in.'));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Fetch abbreviation from linked Church Bible Book record
|
||||
const bookData = await frappe.db.get_doc('Church Bible Book', frm.doc.book);
|
||||
const abbreviation = bookData.abbreviation;
|
||||
|
||||
if (!abbreviation) {
|
||||
frappe.msgprint(__('No abbreviation found for this Book.'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct OSIS reference (e.g., Gen.1.1)
|
||||
const osisRef = `${abbreviation}.${frm.doc.chapter}.${frm.doc.verse}`;
|
||||
|
||||
// Build AndBible deep link
|
||||
const url = `https://read.andbible.org/${osisRef}`;
|
||||
|
||||
// Open the link (will launch AndBible if installed)
|
||||
window.open(url, '_blank');
|
||||
} catch (error) {
|
||||
frappe.msgprint(__('Failed to open verse in AndBible.'));
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
book: async function(frm) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user