Skip to content

Commit d11be95

Browse files
committed
Attempted to fix reading plan issues but it still
needs more work
1 parent f9f93e8 commit d11be95

11 files changed

Lines changed: 240 additions & 310 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Access the site here: [https://provinent.org](https://provinent.org)
1212
- **Multi-Translation Support**: ASV, KJV, GNV, BSB, NET
1313
- **Verse Highlighting**: Right-click verses to highlight in 6 different colors for study emphasis
1414
- **Study Notes**: Full Markdown support with live preview and export capabilities
15-
- **Original Language Tools**: Click any verse for Strong's Concordance data (provided by [STEP Bible](https://www.stepbible.org))and Greek/Hebrew interlinear analysis (provided by [Bible Hub](https://biblehub.com/interlinear/))
15+
- **Original Language Tools**: Click any verse for Strong's Concordance data (provided by [STEP Bible](https://www.stepbible.org)) and Greek/Hebrew interlinear analysis (provided by [Bible Hub](https://biblehub.com/interlinear/))
1616
- **Reference Panel**: Side-by-side Bible comparison with multiple translation options (NASB 1995, NASB 2020, ASV, KJV, ESV, GNV, BSB, NET, CSB, NIV, NKJV, and NLT)
1717

1818
### Advanced Features

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ function renderHighlights(filterColor = 'all') {
507507
`;
508508
});
509509
});
510-
highlightsList.innerHTML = html || '<div class="no-highlights">No highlights match the selected filter.</div>';
510+
highlightsList.innerHTML = html || '<div class="no-highlights">No highlights match the selected filter</div>';
511511
document.querySelectorAll('.highlight-item').forEach(item => {
512512
item.addEventListener('click', () => {
513513
const reference = item.dataset.reference;

modules/navigation.js

Lines changed: 96 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -121,120 +121,120 @@ export function initBookChapterControls() {
121121
});
122122
populateChapterDropdown(BOOK_ORDER[0]);
123123
}
124-
export function manualPrevChapter() {
125-
let bookIdx = BOOK_ORDER.indexOf(state.settings.manualBook);
126-
let chap = state.settings.manualChapter;
127-
let nextBook = state.settings.manualBook;
128-
let nextChapter = chap;
129-
if (chap > 1) {
130-
nextChapter = chap - 1;
131-
} else {
132-
if (bookIdx > 0) {
133-
const prevBook = BOOK_ORDER[bookIdx - 1];
134-
const maxCh = CHAPTER_COUNTS[prevBook];
135-
nextBook = prevBook;
136-
nextChapter = maxCh;
137-
} else {
138-
return;
124+
export async function randomPassage() {
125+
try {
126+
state.settings.readingMode = 'manual';
127+
const randomLoc = await getRandomBibleLocation();
128+
state.settings.manualBook = randomLoc.book;
129+
state.settings.manualChapter = randomLoc.chapter;
130+
const translation = getCurrentTranslation();
131+
updateURL(translation, randomLoc.book, randomLoc.chapter);
132+
saveToStorage();
133+
await loadPassageFromAPI(randomLoc);
134+
document.getElementById('passageReference').textContent = randomLoc.displayRef;
135+
state.currentPassageReference = randomLoc.displayRef;
136+
syncBookChapterSelectors();
137+
if (state.settings.referencePanelOpen) {
138+
updateReferencePanel();
139139
}
140-
}
141-
state.settings.manualBook = nextBook;
142-
state.settings.manualChapter = nextChapter;
143-
state.settings.readingMode = 'manual';
144-
const translation = getCurrentTranslation();
145-
updateURL(translation, nextBook, nextChapter);
146-
const displayRef = `${nextBook} ${nextChapter}`;
147-
document.getElementById('passageReference').textContent = displayRef;
148-
state.currentPassageReference = displayRef;
149-
loadSelectedChapter(nextBook, nextChapter);
150-
syncBookChapterSelectors();
151-
saveToStorage();
152-
if (state.settings.referencePanelOpen) {
153-
updateReferencePanel();
140+
} catch (err) {
141+
handleError(err, 'randomPassage');
142+
showError('Could not load a random passage – see console for details.');
154143
}
155144
}
156-
export function manualNextChapter() {
157-
let bookIdx = BOOK_ORDER.indexOf(state.settings.manualBook);
158-
let chap = state.settings.manualChapter;
159-
const maxCh = CHAPTER_COUNTS[state.settings.manualBook];
160-
let nextBook = state.settings.manualBook;
161-
let nextChapter = chap;
162-
if (chap < maxCh) {
163-
nextChapter = chap + 1;
145+
export function nextPassage() {
146+
if (state.settings.readingMode === 'readingPlan') {
147+
const plan = getActivePlan();
148+
const len = plan.length;
149+
let newIndex = (state.settings.currentPassageIndex + 1) % len;
150+
if (newIndex < 0) newIndex = len - 1;
151+
state.settings.currentPassageIndex = newIndex;
152+
const passage = plan[newIndex];
153+
const translation = getCurrentTranslation();
154+
updateURL(translation, passage.book, passage.chapter);
155+
updateUIMode('readingPlan', translation, passage.displayRef);
156+
loadPassage(passage.book, passage.chapter, translation);
157+
syncSelectorsToReadingPlan();
164158
} else {
165-
if (bookIdx < BOOK_ORDER.length - 1) {
166-
const newBook = BOOK_ORDER[bookIdx + 1];
167-
nextBook = newBook;
159+
let bookIdx = BOOK_ORDER.indexOf(state.settings.manualBook);
160+
let chap = state.settings.manualChapter;
161+
const maxCh = CHAPTER_COUNTS[state.settings.manualBook];
162+
let nextBook = state.settings.manualBook;
163+
let nextChapter = chap;
164+
if (chap < maxCh) {
165+
nextChapter = chap + 1;
166+
} else if (bookIdx < BOOK_ORDER.length - 1) {
167+
nextBook = BOOK_ORDER[bookIdx + 1];
168168
nextChapter = 1;
169169
} else {
170170
return;
171171
}
172+
updateManualNavigation(nextBook, nextChapter);
172173
}
173-
state.settings.manualBook = nextBook;
174-
state.settings.manualChapter = nextChapter;
175-
state.settings.readingMode = 'manual';
176-
const translation = getCurrentTranslation();
177-
updateURL(translation, nextBook, nextChapter);
178-
const displayRef = `${nextBook} ${nextChapter}`;
179-
document.getElementById('passageReference').textContent = displayRef;
180-
state.currentPassageReference = displayRef;
181-
loadSelectedChapter(nextBook, nextChapter);
182-
syncBookChapterSelectors();
183-
saveToStorage();
184-
if (state.settings.referencePanelOpen) {
185-
updateReferencePanel();
186-
}
174+
document.getElementById('scriptureSection').scrollTop = 0;
187175
}
188176
export function prevPassage() {
189177
if (state.settings.readingMode === 'readingPlan') {
190-
const len = getActivePlan().length;
178+
const plan = getActivePlan();
179+
const len = plan.length;
191180
let newIndex = (state.settings.currentPassageIndex - 1 + len) % len;
192181
state.settings.currentPassageIndex = newIndex;
193-
const plan = getActivePlan();
194182
const passage = plan[newIndex];
195183
const translation = getCurrentTranslation();
196184
updateURL(translation, passage.book, passage.chapter);
185+
updateUIMode('readingPlan', translation, passage.displayRef);
197186
loadPassage(passage.book, passage.chapter, translation);
187+
syncSelectorsToReadingPlan();
198188
} else {
199-
manualPrevChapter();
189+
let bookIdx = BOOK_ORDER.indexOf(state.settings.manualBook);
190+
let chap = state.settings.manualChapter;
191+
let nextBook = state.settings.manualBook;
192+
let nextChapter = chap;
193+
if (chap > 1) {
194+
nextChapter = chap - 1;
195+
} else if (bookIdx > 0) {
196+
const prevBook = BOOK_ORDER[bookIdx - 1];
197+
nextBook = prevBook;
198+
nextChapter = CHAPTER_COUNTS[prevBook];
199+
} else {
200+
return;
201+
}
202+
updateManualNavigation(nextBook, nextChapter);
200203
}
201204
document.getElementById('scriptureSection').scrollTop = 0;
202205
}
203-
export function nextPassage() {
204-
if (state.settings.readingMode === 'readingPlan') {
205-
const len = getActivePlan().length;
206-
let newIndex = (state.settings.currentPassageIndex + 1) % len;
207-
if (newIndex < 0) newIndex = len - 1;
208-
state.settings.currentPassageIndex = newIndex;
209-
const plan = getActivePlan();
210-
const passage = plan[newIndex];
211-
const translation = getCurrentTranslation();
212-
updateURL(translation, passage.book, passage.chapter);
213-
loadPassage(passage.book, passage.chapter, translation);
214-
} else {
215-
manualNextChapter();
206+
function updateManualNavigation(book, chapter) {
207+
state.settings.readingMode = 'manual';
208+
state.settings.manualBook = book;
209+
state.settings.manualChapter = chapter;
210+
const translation = getCurrentTranslation();
211+
updateURL(translation, book, chapter);
212+
const displayRef = `${book} ${chapter}`;
213+
updateUIMode('manual', translation, displayRef);
214+
loadSelectedChapter(book, chapter);
215+
syncBookChapterSelectors();
216+
saveToStorage();
217+
if (state.settings.referencePanelOpen) {
218+
updateReferencePanel();
216219
}
217-
document.getElementById('scriptureSection').scrollTop = 0;
218220
}
219-
export async function randomPassage() {
220-
try {
221-
state.settings.readingMode = 'manual';
222-
const randomLoc = await getRandomBibleLocation();
223-
state.settings.manualBook = randomLoc.book;
224-
state.settings.manualChapter = randomLoc.chapter;
225-
const translation = getCurrentTranslation();
226-
updateURL(translation, randomLoc.book, randomLoc.chapter);
227-
saveToStorage();
228-
await loadPassageFromAPI(randomLoc);
229-
document.getElementById('passageReference').textContent = randomLoc.displayRef;
230-
state.currentPassageReference = randomLoc.displayRef;
231-
syncBookChapterSelectors();
232-
if (state.settings.referencePanelOpen) {
233-
updateReferencePanel();
221+
function updateUIMode(mode, translation, displayRef) {
222+
const headerTitleEl = document.getElementById('passageHeaderTitle');
223+
const planLabelEl = document.getElementById('planLabel');
224+
const passageRefElement = document.getElementById('passageReference');
225+
if (headerTitleEl) {
226+
headerTitleEl.textContent = `Holy Bible: ${translation}`;
227+
}
228+
if (passageRefElement) {
229+
passageRefElement.textContent = displayRef;
230+
state.currentPassageReference = displayRef;
231+
}
232+
if (planLabelEl) {
233+
if (mode === 'readingPlan') {
234+
planLabelEl.textContent = `Reading plan: ${getCurrentPlanLabel()}`;
235+
} else {
236+
planLabelEl.textContent = '';
234237
}
235-
} catch (err) {
236-
handleError(err, 'randomPassage');
237-
showError('Could not load a random passage – see console for details.');
238238
}
239239
}
240240
export function syncBookChapterSelectors() {
@@ -339,7 +339,7 @@ export function navigateFromURL() {
339339
return false;
340340
}
341341
function loadDefaultPassage(params) {
342-
state.settings.readingMode = 'manual';
342+
state.settings.readingMode = 'readingPlan';
343343
state.settings.manualBook = params.book;
344344
state.settings.manualChapter = params.chapter;
345345
state.settings.bibleTranslation = params.translation;
@@ -362,32 +362,22 @@ function loadDefaultPassage(params) {
362362
loadSelectedChapter(params.book, params.chapter);
363363
return true;
364364
}
365-
function updateNavigation(book, chapter, translation) {
366-
updateURL(translation, book, chapter);
367-
}
368365
export function setupPopStateListener() {
369-
window.addEventListener('popstate', (event) => {
370-
if (event.state) {
371-
const { translation, book, chapter } = event.state;
372-
loadPassage(book, chapter, translation);
373-
} else {
374-
navigateFromURL();
375-
}
376-
});
366+
window.addEventListener('popstate', navigateFromURL);
377367
}
378368
export function setupNavigationWithURL() {
379369
document.getElementById('bookSelect').addEventListener('change', (e) => {
380370
const book = e.target.value;
381-
const chapter = 1;
371+
const chapter = 1;
382372
const translation = getCurrentTranslation();
383-
updateNavigation(book, chapter, translation);
384-
loadPassage(book, chapter, translation);
373+
updateURL(translation, book, chapter);
374+
loadSelectedChapter(book, chapter);
385375
});
386376
document.getElementById('chapterSelect').addEventListener('change', (e) => {
387377
const book = document.getElementById('bookSelect').value;
388378
const chapter = parseInt(e.target.value);
389379
const translation = getCurrentTranslation();
390-
updateNavigation(book, chapter, translation);
391-
loadPassage(book, chapter, translation);
380+
updateURL(translation, book, chapter);
381+
loadSelectedChapter(book, chapter);
392382
});
393383
}

modules/passage.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ export async function loadPassage(book = null, chapter = null, translation = nul
248248
if (window._isLoadingPassage) {
249249
return;
250250
}
251+
if (!book && !chapter && state.settings.readingMode === 'manual') {
252+
return;
253+
}
251254
window._isLoadingPassage = true;
252255
try {
253256
if (book && chapter) {

modules/settings.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function resumeReadingPlan() {
102102
state.settings.currentPassageIndex = idx;
103103
}
104104
state.settings.readingMode = 'readingPlan';
105-
loadPassage();
105+
loadPassage();
106106
}
107107
function findReadingPlanIndex(book, chapter) {
108108
for (let i = 0; i < readingPlan.length; i++) {
@@ -180,6 +180,10 @@ export function restartReadingPlan() {
180180
saveToStorage();
181181
loadPassage();
182182
alert('Reading plan restarted – you are now at the beginning.');
183+
const curBook = state.settings.manualBook;
184+
const curChapter = state.settings.manualChapter;
185+
const translation = getCurrentTranslation();
186+
updateURL(translation, curBook, curChapter);
183187
}
184188
}
185189
export async function clearCache() {

modules/state.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { handleError } from '../main.js'
22
import { loadPDFFromIndexedDB } from './pdf.js'
3-
export const APP_VERSION = '1.1.03.2025.11.06';
3+
export const APP_VERSION = '1.1.04.2025.11.06';
44
let saveTimeout = null;
55
const SAVE_DEBOUNCE_MS = 500;
66
export const BOOK_ORDER = [

src/main.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,12 @@ function setupEventListeners() {
214214

215215
// Bible Gateway search button (dynamic translation searching)
216216
document.getElementById('referenceTranslation').addEventListener('change', function() {
217-
// Update the state temporarily for Bible Gateway
218217
const tempTranslation = this.value;
219218
const oldTranslation = state.settings.referenceVersion;
220219
state.settings.referenceVersion = tempTranslation;
221220

222221
updateBibleGatewayVersion();
223222

224-
// Restore the original translation (since settings aren't saved yet)
225223
state.settings.referenceVersion = oldTranslation;
226224
});
227225

@@ -248,7 +246,6 @@ function setupEventListeners() {
248246
if (!state.pdf.doc || state.pdf.currentPage <= 1) return;
249247

250248
try {
251-
// Cancel any current rendering
252249
if (state.pdf.renderTask) {
253250
await state.pdf.renderTask.cancel();
254251
state.pdf.renderTask = null;
@@ -258,7 +255,6 @@ function setupEventListeners() {
258255
await renderPage(state.pdf.currentPage);
259256
} catch (err) {
260257
console.warn('Error navigating to previous page:', err);
261-
// If there's an error, reload the PDF
262258
await loadPDF();
263259
}
264260
});
@@ -711,7 +707,7 @@ function renderHighlights(filterColor = 'all') {
711707
});
712708
});
713709

714-
highlightsList.innerHTML = html || '<div class="no-highlights">No highlights match the selected filter.</div>';
710+
highlightsList.innerHTML = html || '<div class="no-highlights">No highlights match the selected filter</div>';
715711

716712
// Add click handlers to navigate to verses
717713
document.querySelectorAll('.highlight-item').forEach(item => {
@@ -874,11 +870,8 @@ async function init() {
874870
// Start periodic updates
875871
setInterval(updateDateTime, 1_000);
876872

877-
// Only load default passage if we didn't navigate from URL
878873
const navigatedFromURL = navigateFromURL();
879874
if (!navigatedFromURL) {
880-
// Only load default passage if URL navigation didn't happen
881-
// AND we're not at the root path (which should have been redirected)
882875
if (window.location.pathname !== '/') {
883876
loadPassage();
884877
}

0 commit comments

Comments
 (0)