Preliminary logic for selection translation.
This commit is contained in:
parent
5bbdf4e4b5
commit
35cb0f1f6a
1 changed files with 19 additions and 6 deletions
|
|
@ -1,15 +1,10 @@
|
||||||
import { aliases, meta } from './meta.js';
|
import { aliases, meta, translations } from './meta.js';
|
||||||
|
|
||||||
|
|
||||||
export const modal = (el) => {
|
export const modal = (el) => {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const translations = {
|
|
||||||
'BSB': 'Berean Standard Bible',
|
|
||||||
'MSB': 'Majority Standard Bible',
|
|
||||||
};
|
|
||||||
|
|
||||||
function parseRef(ref) {
|
function parseRef(ref) {
|
||||||
ref = ref.replace(/%3[Aa]/, ':').replace(/\+/, ' ');
|
ref = ref.replace(/%3[Aa]/, ':').replace(/\+/, ' ');
|
||||||
const m = ref.match(/((\d+(\+|\s))?[a-zA-Z]+)(\+|\s)?([0-9]+)?\:?([0-9]+(-?[0-9]+)?)?/);
|
const m = ref.match(/((\d+(\+|\s))?[a-zA-Z]+)(\+|\s)?([0-9]+)?\:?([0-9]+(-?[0-9]+)?)?/);
|
||||||
|
|
@ -159,6 +154,7 @@ function render(dialog, response, refs) {
|
||||||
export const bindModals = () => {
|
export const bindModals = () => {
|
||||||
const elems = document.querySelectorAll('a[data-scripture]');
|
const elems = document.querySelectorAll('a[data-scripture]');
|
||||||
const dialog = document.querySelectorAll('dialog[data-scripture]');
|
const dialog = document.querySelectorAll('dialog[data-scripture]');
|
||||||
|
let translation = 'BSB';
|
||||||
elems.forEach((e) => {
|
elems.forEach((e) => {
|
||||||
e.addEventListener('click', (evt) => {
|
e.addEventListener('click', (evt) => {
|
||||||
const scripture = e.attributes.getNamedItem('data-scripture');
|
const scripture = e.attributes.getNamedItem('data-scripture');
|
||||||
|
|
@ -196,4 +192,21 @@ export const bindModals = () => {
|
||||||
dialog[0]?.classList.add('hidden');
|
dialog[0]?.classList.add('hidden');
|
||||||
dialog[0]?.querySelector('article')?.replaceChildren();
|
dialog[0]?.querySelector('article')?.replaceChildren();
|
||||||
});
|
});
|
||||||
|
const sel = dialog[0]?.querySelector('select.translation');
|
||||||
|
console.log(sel);
|
||||||
|
sel?.replaceChildren();
|
||||||
|
for (const tx in translations) {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.setAttribute('value', tx);
|
||||||
|
opt.insertAdjacentText('beforeend', translations[tx][0]);
|
||||||
|
if (tx == translation) {
|
||||||
|
opt.setAttribute('selected', 'selected');
|
||||||
|
}
|
||||||
|
sel?.insertAdjacentElement('beforeend', opt);
|
||||||
|
}
|
||||||
|
sel?.addEventListener('change', (evt) => {
|
||||||
|
console.log('onchange');
|
||||||
|
console.log(evt);
|
||||||
|
console.log(evt.target.selectedOptions[0].value);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
Loading…
Reference in a new issue