Skip to content

Commit 82be6ed

Browse files
committed
Calculate phrase indices above 26 with double letters
i.e. 0-25 => a-z 26+ => aa, ab, ... zz Break index calculation into separate function
1 parent b24a38d commit 82be6ed

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/lib/components/ScriptureViewSofria.svelte

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ LOGGING:
137137
let displayingIntroduction = $state(false);
138138
139139
const fnc = 'abcdefghijklmnopqrstuvwxyz';
140+
/** calculate letter index from number
141+
*
142+
* 0-25 => a-z; 26+ => aa, ab, ... zz
143+
*/
144+
function createLetterIndex(index: number) {
145+
return (
146+
(index >= fnc.length ? fnc.charAt(Math.floor(index / fnc.length) - 1) : '') +
147+
fnc.charAt(index % fnc.length)
148+
);
149+
}
140150
let planDivObserver = $state(null); // To store the observer instance
141151
let planObservationCompleted = $state(false);
142152
// Function to observe the visibility of the plan div
@@ -290,7 +300,7 @@ LOGGING:
290300
default:
291301
break;
292302
}
293-
const phraseIndex = fnc.charAt(workspace.currentPhraseIndex);
303+
const phraseIndex = createLetterIndex(workspace.currentPhraseIndex);
294304
div.id = workspace.currentVerse + phraseIndex;
295305
div.setAttribute('data-verse', workspace.currentVerse);
296306
div.setAttribute('data-phrase', phraseIndex);

0 commit comments

Comments
 (0)