Skip to content

Commit e5e94ef

Browse files
correccion de errores
1 parent 4e1def8 commit e5e94ef

2 files changed

Lines changed: 39 additions & 16 deletions

File tree

js/ui.js

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,38 @@
6363

6464
mainView.innerHTML = `
6565
<div class="verse-card">
66-
<h2>${v.book} ${v.reference}</h2>
67-
<p style="font-size:1.4rem; font-style:italic;">"${v.text || ''}"</p>
66+
<div style="display:flex;justify-content:space-between;align-items:flex-start;gap:8px;flex-wrap:wrap;">
67+
<h2 style="margin:0;">${v.book} ${v.reference}</h2>
68+
<button id="btn-ver-capitulo" style="background:var(--primary);color:white;border:none;border-radius:8px;padding:6px 14px;cursor:pointer;font-size:0.85rem;font-weight:bold;flex-shrink:0;">📖 Ver Capítulo</button>
69+
</div>
70+
<p style="font-size:1.4rem; font-style:italic; margin-top:12px;">&ldquo;${v.text || ''}&rdquo;</p>
6871
${v.tags && v.tags.length > 0 ? `<div class="verse-tags">${v.tags.map(t => `<span>#${t}</span>`).join('')}</div>` : ''}
6972
</div>
7073
<div id="v-sections">
71-
${v.base_perspectives ? `<h3 class="study-section-title">📚 Estudio Bíblico</h3><div class="perspective-selector" id="b-btns"></div><div id="b-cont" class="perspective-content" style="display:none; border-color:var(--secondary);"></div>` : ''}
72-
<h3 class="study-section-title">✍️ Mis Notas Personales</h3><div class="perspective-selector" id="p-btns"></div><div id="p-cont" class="perspective-content" style="display:none;"></div>
74+
${v.base_perspectives ? `<h3 class="study-section-title">📚 Notas de Estudio <span style="font-size:0.75rem;font-weight:400;color:var(--text-muted);">(libro/capítulo)</span></h3><div class="perspective-selector" id="b-btns"></div><div id="b-cont" class="perspective-content" style="display:none; border-color:var(--secondary);"></div>` : ''}
75+
<h3 class="study-section-title">✍️ Mis Notas Personales <span style="font-size:0.75rem;font-weight:400;color:var(--text-muted);">(este versículo)</span></h3><div class="perspective-selector" id="p-btns"></div><div id="p-cont" class="perspective-content" style="display:none;"></div>
7376
${v.cross_references && v.cross_references.length > 0 ? `<h3 class="study-section-title">🔗 Referencias Cruzadas</h3><div id="cross-ref-list" style="margin-top:8px;"></div>` : ''}
7477
</div>
7578
`;
79+
// Botón Ver Capítulo
80+
const btnVerCap = document.getElementById('btn-ver-capitulo');
81+
if (btnVerCap) {
82+
btnVerCap.onmouseenter = () => btnVerCap.style.opacity = '0.85';
83+
btnVerCap.onmouseleave = () => btnVerCap.style.opacity = '1';
84+
btnVerCap.onclick = () => {
85+
const chapNum = parseInt((v.reference || '').split(':')[0]) || parseInt(v.chapter) || 1;
86+
const allVersesInChap = currentData.filter(x =>
87+
x.type === 'verse' && normalizeBookName(x.book) === normalizeBookName(v.book) &&
88+
(parseInt(x.chapter) === chapNum || parseInt((x.reference||'').split(':')[0]) === chapNum)
89+
);
90+
if (allVersesInChap.length > 0) {
91+
window.viewReading(`${v.book} ${chapNum}`, allVersesInChap,
92+
{ type: 'chapter', version: v.version, book: v.book, chapter: chapNum.toString() });
93+
const verseNum = parseInt((v.reference || '').split(':')[1]) || 1;
94+
setTimeout(() => window.scrollToVerseAndHighlight(normalizeBookName(v.book), chapNum, verseNum), 200);
95+
}
96+
};
97+
}
7698
setEditor({ type: 'verse', id: v.id }, "Título de mi nota personal...");
7799

78100
const fill = (data, btnDivId, contDivId, isBase) => {
@@ -276,8 +298,6 @@
276298
const match = refStr.match(/^(.*?)\s+(\d+):(\d+)(?:\s*-\s*\d+)?$/);
277299
if (!match) return;
278300
window.currentTrackerRef = { book: match[1], chapter: parseInt(match[2]), verse: parseInt(match[3]), version: version || (window.currentTrackerRef && window.currentTrackerRef.version) || null };
279-
const t = document.getElementById('tracker-ref');
280-
if (!t) return;
281301

282302
// Calcular límites dinámicos para el libro/capítulo actual
283303
const allVerses = currentData.filter(x => x.type === 'verse');
@@ -330,8 +350,8 @@
330350
trackerBarEl.style.display = 'flex';
331351
}
332352
// Limpiar también tracker-ref si existe (por compatibilidad)
333-
const t = document.getElementById('tracker-ref');
334-
if (t) t.style.display = 'none';
353+
const oldT = document.getElementById('tracker-ref');
354+
if (oldT) oldT.style.display = 'none';
335355

336356

337357
// ── Lógica del autocompletar de Libro ──────────────────────────────
@@ -498,18 +518,17 @@
498518
}
499519
let pFiltered = v.perspectives ? Object.entries(v.perspectives).map(([k,val]) => `<b>${k.replace(/_/g,' ').toUpperCase()}:</b><br>${val}`) : [];
500520

501-
// Construir tooltip: tags + notas únicas + referencias cruzadas con contenido
521+
// Tooltip: SOLO referencias cruzadas + tags (las notas de estudio son del capítulo, no del versículo)
502522
let ttParts = [];
503523
if (v.tags?.length) ttParts.push(`<span style="font-size:0.8em;opacity:0.75;">${v.tags.map(t=>'#'+t).join(' ')}</span>`);
504-
if (bFiltered.length) ttParts.push(...bFiltered);
524+
// Notas personales del versículo (perspectives) sí pueden aparecer en tooltip
505525
if (pFiltered.length) ttParts.push(...pFiltered);
506526

507527
// Referencias cruzadas con texto — búsqueda O(1) con el mapa preconstruido
508528
if (v.cross_references?.length) {
509529
let crHtml = '<b>🔗 REFERENCIAS:</b>';
510530
let lastCrBook = null, lastCrChap = null;
511-
// Limitar a 4 refs en el tooltip para no retrasar el render
512-
v.cross_references.slice(0, 4).forEach(ref => {
531+
v.cross_references.slice(0, 6).forEach(ref => {
513532
const m = ref.trim().match(/^(.+?)\s+(\d+):(\d+)$/);
514533
if (!m) return;
515534
const found = findVerseByRef(ref);
@@ -521,9 +540,13 @@
521540
}
522541

523542
const tt = ttParts.join('<hr style="margin:4px 0;opacity:0.3;">');
524-
const hasDot = bFiltered.length > 0 || pFiltered.length > 0;
525-
const hasRef = v.cross_references?.length > 0;
526-
const dot = (hasDot ? `<span class="has-persp-dot base"></span>` : '') + (hasRef ? `<span class="has-persp-dot" style="background:#3498db;width:6px;height:6px;"></span>` : '');
543+
const hasDot = pFiltered.length > 0; // nota personal del vers.
544+
const hasStudy = v.base_perspectives && Object.keys(v.base_perspectives).length > 0; // notas de capítulo
545+
const hasRef = v.cross_references?.length > 0; // referencias cruzadas
546+
// ● naranja = notas de estudio (cap/libro) ● verde = nota personal ● azul = ref cruzada
547+
const dot = (hasStudy ? `<span class="has-persp-dot base" title="Notas de estudio"></span>` : '')
548+
+ (hasDot ? `<span class="has-persp-dot" style="background:#27ae60;width:6px;height:6px;" title="Nota personal"></span>` : '')
549+
+ (hasRef ? `<span class="has-persp-dot" style="background:#3498db;width:6px;height:6px;" title="Referencias cruzadas"></span>` : '');
527550

528551
let span = document.createElement('span');
529552
span.className = 'verse-text-span';

sw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const CACHE_NAME = 'biblia-estudio-v4';
1+
const CACHE_NAME = 'biblia-estudio-v5';
22
const ASSETS_TO_CACHE = [
33
'./',
44
'./index.html',

0 commit comments

Comments
 (0)