@@ -125,6 +125,7 @@ export async function randomPassage() {
125125 }
126126}
127127export 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}
159160function 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
173243function 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}
184269export function syncBookChapterSelectors ( ) {
185270 const bookSel = document . getElementById ( 'bookSelect' ) ;
@@ -260,6 +345,10 @@ export function navigateFromURL() {
260345 return false ;
261346}
262347function 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 ;
0 commit comments