Skip to content

Commit d4ad959

Browse files
committed
2 parents 6dc17d4 + d11be95 commit d4ad959

8 files changed

Lines changed: 341 additions & 0 deletions

File tree

modules/navigation.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export async function randomPassage() {
125125
}
126126
}
127127
export function nextPassage() {
128+
<<<<<<< HEAD
128129
let bookIdx = BOOK_ORDER.indexOf(state.settings.manualBook);
129130
let chap = state.settings.manualChapter;
130131
const maxCh = CHAPTER_COUNTS[state.settings.manualBook];
@@ -157,21 +158,95 @@ export function prevPassage() {
157158
updateManualNavigation(nextBook, nextChapter);
158159
}
159160
function updateManualNavigation(book, chapter) {
161+
=======
162+
if (state.settings.readingMode === 'readingPlan') {
163+
const plan = getActivePlan();
164+
const len = plan.length;
165+
let newIndex = (state.settings.currentPassageIndex + 1) % len;
166+
if (newIndex < 0) newIndex = len - 1;
167+
state.settings.currentPassageIndex = newIndex;
168+
const passage = plan[newIndex];
169+
const translation = getCurrentTranslation();
170+
updateURL(translation, passage.book, passage.chapter);
171+
updateUIMode('readingPlan', translation, passage.displayRef);
172+
loadPassage(passage.book, passage.chapter, translation);
173+
syncSelectorsToReadingPlan();
174+
} else {
175+
let bookIdx = BOOK_ORDER.indexOf(state.settings.manualBook);
176+
let chap = state.settings.manualChapter;
177+
const maxCh = CHAPTER_COUNTS[state.settings.manualBook];
178+
let nextBook = state.settings.manualBook;
179+
let nextChapter = chap;
180+
if (chap < maxCh) {
181+
nextChapter = chap + 1;
182+
} else if (bookIdx < BOOK_ORDER.length - 1) {
183+
nextBook = BOOK_ORDER[bookIdx + 1];
184+
nextChapter = 1;
185+
} else {
186+
return;
187+
}
188+
updateManualNavigation(nextBook, nextChapter);
189+
}
190+
document.getElementById('scriptureSection').scrollTop = 0;
191+
}
192+
export function prevPassage() {
193+
if (state.settings.readingMode === 'readingPlan') {
194+
const plan = getActivePlan();
195+
const len = plan.length;
196+
let newIndex = (state.settings.currentPassageIndex - 1 + len) % len;
197+
state.settings.currentPassageIndex = newIndex;
198+
const passage = plan[newIndex];
199+
const translation = getCurrentTranslation();
200+
updateURL(translation, passage.book, passage.chapter);
201+
updateUIMode('readingPlan', translation, passage.displayRef);
202+
loadPassage(passage.book, passage.chapter, translation);
203+
syncSelectorsToReadingPlan();
204+
} else {
205+
let bookIdx = BOOK_ORDER.indexOf(state.settings.manualBook);
206+
let chap = state.settings.manualChapter;
207+
let nextBook = state.settings.manualBook;
208+
let nextChapter = chap;
209+
if (chap > 1) {
210+
nextChapter = chap - 1;
211+
} else if (bookIdx > 0) {
212+
const prevBook = BOOK_ORDER[bookIdx - 1];
213+
nextBook = prevBook;
214+
nextChapter = CHAPTER_COUNTS[prevBook];
215+
} else {
216+
return;
217+
}
218+
updateManualNavigation(nextBook, nextChapter);
219+
}
220+
document.getElementById('scriptureSection').scrollTop = 0;
221+
}
222+
function updateManualNavigation(book, chapter) {
223+
state.settings.readingMode = 'manual';
224+
>>>>>>> d11be95798768600c1b682f2957094b98cdb2d61
160225
state.settings.manualBook = book;
161226
state.settings.manualChapter = chapter;
162227
const translation = getCurrentTranslation();
163228
updateURL(translation, book, chapter);
164229
const displayRef = `${book} ${chapter}`;
230+
<<<<<<< HEAD
165231
updateUIMode(translation, displayRef);
232+
=======
233+
updateUIMode('manual', translation, displayRef);
234+
>>>>>>> d11be95798768600c1b682f2957094b98cdb2d61
166235
loadSelectedChapter(book, chapter);
167236
syncBookChapterSelectors();
168237
saveToStorage();
169238
if (state.settings.referencePanelOpen) {
170239
updateReferencePanel();
171240
}
172241
}
242+
<<<<<<< HEAD
173243
function updateUIMode(translation, displayRef) {
174244
const headerTitleEl = document.getElementById('passageHeaderTitle');
245+
=======
246+
function updateUIMode(mode, translation, displayRef) {
247+
const headerTitleEl = document.getElementById('passageHeaderTitle');
248+
const planLabelEl = document.getElementById('planLabel');
249+
>>>>>>> d11be95798768600c1b682f2957094b98cdb2d61
175250
const passageRefElement = document.getElementById('passageReference');
176251
if (headerTitleEl) {
177252
headerTitleEl.textContent = `Holy Bible: ${translation}`;
@@ -180,6 +255,16 @@ function updateUIMode(translation, displayRef) {
180255
passageRefElement.textContent = displayRef;
181256
state.currentPassageReference = displayRef;
182257
}
258+
<<<<<<< HEAD
259+
=======
260+
if (planLabelEl) {
261+
if (mode === 'readingPlan') {
262+
planLabelEl.textContent = `Reading plan: ${getCurrentPlanLabel()}`;
263+
} else {
264+
planLabelEl.textContent = '';
265+
}
266+
}
267+
>>>>>>> d11be95798768600c1b682f2957094b98cdb2d61
183268
}
184269
export function syncBookChapterSelectors() {
185270
const bookSel = document.getElementById('bookSelect');
@@ -260,6 +345,10 @@ export function navigateFromURL() {
260345
return false;
261346
}
262347
function loadDefaultPassage(params) {
348+
<<<<<<< HEAD
349+
=======
350+
state.settings.readingMode = 'readingPlan';
351+
>>>>>>> d11be95798768600c1b682f2957094b98cdb2d61
263352
state.settings.manualBook = params.book;
264353
state.settings.manualChapter = params.chapter;
265354
state.settings.bibleTranslation = params.translation;

modules/passage.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ export async function loadPassage(book = null, chapter = null, translation = nul
240240
if (window._isLoadingPassage) {
241241
return;
242242
}
243+
if (!book && !chapter && state.settings.readingMode === 'manual') {
244+
return;
245+
}
243246
window._isLoadingPassage = true;
244247
try {
245248
state.settings.manualBook = book || state.settings.manualBook;

modules/settings.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,30 @@ export function importData(ev) {
9191
reader.readAsText(file);
9292
ev.target.value = '';
9393
}
94+
<<<<<<< HEAD
95+
=======
96+
export function resumeReadingPlan() {
97+
const curBook = state.settings.manualBook;
98+
const curChapter = state.settings.manualChapter;
99+
const idx = findReadingPlanIndex(curBook, curChapter);
100+
const translation = getCurrentTranslation();
101+
updateURL(translation, curBook, curChapter);
102+
if (idx !== -1) {
103+
state.settings.currentPassageIndex = idx;
104+
}
105+
state.settings.readingMode = 'readingPlan';
106+
loadPassage();
107+
}
108+
function findReadingPlanIndex(book, chapter) {
109+
for (let i = 0; i < readingPlan.length; i++) {
110+
const p = readingPlan[i];
111+
if (p.book === book && p.chapter === chapter) {
112+
return i;
113+
}
114+
}
115+
return -1;
116+
}
117+
>>>>>>> d11be95798768600c1b682f2957094b98cdb2d61
94118
export function openSettings() {
95119
document.getElementById('bibleTranslationSetting').value =
96120
state.settings.bibleTranslation;
@@ -142,6 +166,22 @@ export async function saveSettings() {
142166
handleError(err, 'saveSettings');
143167
}
144168
}
169+
<<<<<<< HEAD
170+
=======
171+
export function restartReadingPlan() {
172+
if (confirm('Reset the reading plan to the very first passage? Highlights and notes will stay unchanged.')) {
173+
state.settings.currentPassageIndex = 0;
174+
state.settings.readingMode = 'readingPlan';
175+
saveToStorage();
176+
loadPassage();
177+
alert('Reading plan restarted – you are now at the beginning.');
178+
const curBook = state.settings.manualBook;
179+
const curChapter = state.settings.manualChapter;
180+
const translation = getCurrentTranslation();
181+
updateURL(translation, curBook, curChapter);
182+
}
183+
}
184+
>>>>>>> d11be95798768600c1b682f2957094b98cdb2d61
145185
export async function clearCache() {
146186
if (confirm('Clear all cached Bible data? This will remove offline access to previously viewed passages.')) {
147187
try {

modules/state.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { handleError } from '../main.js'
22
import { loadPDFFromIndexedDB } from './pdf.js'
3+
<<<<<<< HEAD
34
export const APP_VERSION = '1.1.05.2025.11.06';
5+
=======
6+
export const APP_VERSION = '1.1.04.2025.11.06';
7+
>>>>>>> d11be95798768600c1b682f2957094b98cdb2d61
48
let saveTimeout = null;
59
const SAVE_DEBOUNCE_MS = 500;
610
export const BOOK_ORDER = [

0 commit comments

Comments
 (0)