diff --git a/kjvstudy_org/templates/base.html b/kjvstudy_org/templates/base.html index fc1b65a..eb92216 100644 --- a/kjvstudy_org/templates/base.html +++ b/kjvstudy_org/templates/base.html @@ -1845,11 +1845,29 @@ showKeyboardHelp(); break; case ' ': - // Space: Read aloud selected text (green box selection or verse text) - var selectedText = KJVSpeech.getSelectedText(); - if (selectedText) { + // Space: Read aloud selected text (with optional resource-reader handling) + if (document.body && document.body.dataset && document.body.dataset.resourceReader === 'true') { e.preventDefault(); - KJVSpeech.toggle(selectedText); + var highlighted = document.querySelector('[style*="outline: 2px solid"]') || document.querySelector('[style*="outline:2px solid"]'); + var candidates = Array.from(document.querySelectorAll('article p, section p, li, blockquote')).filter(function(el) { + return (el.textContent || '').trim().length > 10; + }); + var target = highlighted || (candidates.length ? candidates[0] : null); + if (target) { + // Clone and strip sidenotes/marginnotes if present + var clone = target.cloneNode(true); + clone.querySelectorAll('.sidenote, .marginnote, .sidenote-number, .margin-toggle').forEach(function(el) { el.remove(); }); + var text = (clone.textContent || clone.innerText || '').trim(); + if (text && window.KJVSpeech && typeof window.KJVSpeech.toggle === 'function') { + KJVSpeech.toggle(text); + } + } + } else { + var selectedText = KJVSpeech.getSelectedText(); + if (selectedText) { + e.preventDefault(); + KJVSpeech.toggle(selectedText); + } } break; } diff --git a/kjvstudy_org/templates/biblical_angels.html b/kjvstudy_org/templates/biblical_angels.html index 13826bb..2e38ddb 100644 --- a/kjvstudy_org/templates/biblical_angels.html +++ b/kjvstudy_org/templates/biblical_angels.html @@ -187,6 +187,10 @@ {% endblock %} + + {% block content %}

Biblical Angels

Angelic Beings in Holy Scripture

diff --git a/kjvstudy_org/templates/biblical_covenants.html b/kjvstudy_org/templates/biblical_covenants.html index 4c34f7b..df8a4a5 100644 --- a/kjvstudy_org/templates/biblical_covenants.html +++ b/kjvstudy_org/templates/biblical_covenants.html @@ -187,6 +187,10 @@ {% endblock %} + + {% block content %}

Biblical Covenants

God's Covenantal Framework Throughout Redemptive History

diff --git a/kjvstudy_org/templates/biblical_festivals.html b/kjvstudy_org/templates/biblical_festivals.html index c5a5b9e..b0537c3 100644 --- a/kjvstudy_org/templates/biblical_festivals.html +++ b/kjvstudy_org/templates/biblical_festivals.html @@ -187,6 +187,10 @@ {% endblock %} + + {% block content %}

Biblical Festivals

The Sacred Feasts of Israel and Their Prophetic Significance

diff --git a/kjvstudy_org/templates/biblical_maps.html b/kjvstudy_org/templates/biblical_maps.html index 6eefab9..0ed34ad 100644 --- a/kjvstudy_org/templates/biblical_maps.html +++ b/kjvstudy_org/templates/biblical_maps.html @@ -81,6 +81,10 @@ {% endblock %} + + {% block content %}

Biblical Geography

The lands of Scripture

diff --git a/kjvstudy_org/templates/biblical_prophets.html b/kjvstudy_org/templates/biblical_prophets.html index 1df56b7..de7f35a 100644 --- a/kjvstudy_org/templates/biblical_prophets.html +++ b/kjvstudy_org/templates/biblical_prophets.html @@ -187,6 +187,10 @@ {% endblock %} + + {% block content %}

Biblical Prophets

Messengers of the Most High

diff --git a/kjvstudy_org/templates/biblical_timeline.html b/kjvstudy_org/templates/biblical_timeline.html index f7686d2..ac62eec 100644 --- a/kjvstudy_org/templates/biblical_timeline.html +++ b/kjvstudy_org/templates/biblical_timeline.html @@ -102,6 +102,10 @@ {% endblock %} + + {% block content %}

Biblical Timeline

Major events from Creation to the early Church

diff --git a/kjvstudy_org/templates/fruits_of_spirit.html b/kjvstudy_org/templates/fruits_of_spirit.html index dd7d456..c4ed322 100644 --- a/kjvstudy_org/templates/fruits_of_spirit.html +++ b/kjvstudy_org/templates/fruits_of_spirit.html @@ -187,6 +187,10 @@ {% endblock %} + + {% block content %}

Fruits of the Spirit

The Nine Graces of Galatians 5:22-23

diff --git a/kjvstudy_org/templates/names_of_god.html b/kjvstudy_org/templates/names_of_god.html index 10debb5..b1c8781 100644 --- a/kjvstudy_org/templates/names_of_god.html +++ b/kjvstudy_org/templates/names_of_god.html @@ -368,6 +368,30 @@ document.addEventListener('DOMContentLoaded', function() { return false; } + function getTextContent(el) { + if (!el) return ''; + const clone = el.cloneNode(true); + clone.querySelectorAll('.sidenote, .marginnote, .sidenote-number, .margin-toggle').forEach(x => x.remove()); + return (clone.textContent || clone.innerText || '').trim(); + } + + function readElement(el) { + if (!el || !('speechSynthesis' in window)) return; + if (window.KJVSpeech && typeof window.KJVSpeech.stop === 'function') { + window.KJVSpeech.stop(); + } + const text = getTextContent(el); + if (!text) return; + const utter = new SpeechSynthesisUtterance(text); + const voices = speechSynthesis.getVoices(); + const englishVoice = voices.find(v => v.lang && v.lang.toLowerCase().startsWith('en') && v.name.includes('Daniel')) || + voices.find(v => v.lang && v.lang.toLowerCase().startsWith('en-gb')) || + voices.find(v => v.lang && v.lang.toLowerCase().startsWith('en')); + if (englishVoice) utter.voice = englishVoice; + speechSynthesis.cancel(); + speechSynthesis.speak(utter); + } + document.addEventListener('keydown', function(e) { if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return; @@ -491,8 +515,24 @@ document.addEventListener('DOMContentLoaded', function() { } else if (e.key === 't') { e.preventDefault(); selectTocBlock(); + } else if (e.key === ' ') { + e.preventDefault(); + if (selectedIndex >= 0) { + readElement(contentElements[selectedIndex]); + } else { + // if nothing selected, read first visible content + const visibleIdx = KJVNav.findFirstVisibleIndex(contentElements); + if (visibleIdx >= 0) { + selectElement(visibleIdx); + readElement(contentElements[visibleIdx]); + } + } } }); }); {% endblock %} + + diff --git a/kjvstudy_org/templates/parables.html b/kjvstudy_org/templates/parables.html index 83e55be..08aa044 100644 --- a/kjvstudy_org/templates/parables.html +++ b/kjvstudy_org/templates/parables.html @@ -192,6 +192,10 @@ {% endblock %} + + {% block content %}

Parables of Jesus

Teaching in Earthly Stories with Heavenly Meanings

diff --git a/kjvstudy_org/templates/twelve_apostles.html b/kjvstudy_org/templates/twelve_apostles.html index 520b79d..119ffe5 100644 --- a/kjvstudy_org/templates/twelve_apostles.html +++ b/kjvstudy_org/templates/twelve_apostles.html @@ -187,6 +187,10 @@ {% endblock %} + + {% block content %}

The Twelve Apostles

Those Whom He Chose to Be With Him

diff --git a/kjvstudy_org/templates/women_of_the_bible.html b/kjvstudy_org/templates/women_of_the_bible.html index 6b72ba5..219c68c 100644 --- a/kjvstudy_org/templates/women_of_the_bible.html +++ b/kjvstudy_org/templates/women_of_the_bible.html @@ -187,6 +187,10 @@ {% endblock %} + + {% block content %}

Women of the Bible

Faithful Witnesses Throughout Redemptive History