Skip to content

Commit 8dca143

Browse files
commits
1 parent 37f91d4 commit 8dca143

File tree

4 files changed

+79
-65
lines changed

4 files changed

+79
-65
lines changed

bible/data/books/enoch.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
"2": "And he took up his parable and said..."
66
},
77
"2": {
8-
"1": "And behold! He comes with ten thousands of His holy ones..."
8+
"1": "And behold! He comes with ten thousands...",
9+
"2": "To execute judgment upon all..."
10+
},
11+
"3": {
12+
"1": "And the first heaven shall depart...",
13+
"2": "And the earth shall be rent in twain..."
914
}
1015
}
1116
}

bible/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ <h2>Books</h2>
1616

1717
<!-- Right Content Area -->
1818
<div class="main-content">
19+
<div id="navigation" style="display: none;">
20+
<button id="prevChapter">&lt;</button>
21+
<div id="chapter-numbers"></div>
22+
<button id="nextChapter">&gt;</button>
23+
</div>
1924
<div id="verses"></div>
2025
</div>
2126
</div>

bible/script.js

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,56 @@
1-
const bookManifest = [
2-
{ name: "Genesis", file: "genesis.json" },
3-
{ name: "1 Enoch", file: "enoch.json" }
4-
];
5-
61
let currentBook = null;
2+
let currentChapter = null;
3+
let bookData = null;
74
const bookCache = {};
85

9-
// Fetch book data
10-
async function loadBookData(bookFile) {
11-
if (!bookCache[bookFile]) {
12-
const response = await fetch(`data/books/${bookFile}`);
13-
const data = await response.json();
14-
bookCache[bookFile] = data;
15-
}
16-
return bookCache[bookFile];
17-
}
6+
// Navigation controls
7+
document.getElementById('prevChapter').addEventListener('click', () => {
8+
const prev = parseInt(currentChapter) - 1;
9+
if (prev >= 1) loadChapter(prev.toString());
10+
});
11+
12+
document.getElementById('nextChapter').addEventListener('click', () => {
13+
const next = parseInt(currentChapter) + 1;
14+
if (bookData[currentBook][next]) loadChapter(next.toString());
15+
});
1816

19-
// Load chapter 1 of a book automatically
2017
async function loadBook(bookFile) {
21-
const bookData = await loadBookData(bookFile);
22-
currentBook = Object.keys(bookData)[0]; // e.g., "1 Enoch"
23-
const firstChapter = Object.keys(bookData[currentBook])[0]; // Chapter 1
18+
bookData = await loadBookData(bookFile);
19+
currentBook = Object.keys(bookData)[0];
20+
currentChapter = Object.keys(bookData[currentBook])[0];
2421

25-
// Display verses
26-
const versesDiv = document.getElementById('verses');
27-
versesDiv.innerHTML = `
28-
<h2>${currentBook}</h2>
29-
${Object.entries(bookData[currentBook][firstChapter])
30-
.map(([verse, text]) => `
31-
<p class="verse"><b>${verse}:</b> ${text}</p>
32-
`).join('')}
33-
`;
22+
document.getElementById('navigation').style.display = 'flex';
23+
updateChapterNavigation();
24+
loadChapter(currentChapter);
25+
}
26+
27+
function updateChapterNavigation() {
28+
const chapters = Object.keys(bookData[currentBook]);
29+
const chapterNumbers = document.getElementById('chapter-numbers');
30+
31+
chapterNumbers.innerHTML = chapters.map(chapter => `
32+
<button class="chapter-btn ${chapter === currentChapter ? 'active' : ''}"
33+
onclick="loadChapter('${chapter}')">
34+
${chapter}
35+
</button>
36+
`).join('');
3437
}
3538

36-
// Initialize book list
37-
function initBooks() {
38-
const bookList = document.getElementById('book-list');
39-
bookList.innerHTML = bookManifest
40-
.map(book => `
41-
<button onclick="loadBook('${book.file}')">
42-
${book.name}
43-
</button>
44-
`)
45-
.join('');
39+
function loadChapter(chapter) {
40+
currentChapter = chapter;
41+
const chapterContent = bookData[currentBook][chapter];
42+
43+
// Update verses display
44+
document.getElementById('verses').innerHTML = `
45+
<h2>${currentBook} ${currentChapter}</h2>
46+
${Object.entries(chapterContent).map(([verse, text]) => `
47+
<p><b>${verse}:</b> ${text}</p>
48+
`).join('')}
49+
`;
50+
51+
// Update chapter navigation
52+
updateChapterNavigation();
4653
}
4754

48-
// Start
49-
initBooks();
55+
// Rest of the script remains the same until the init function
56+
// (Previous loadBookData and initBooks functions stay unchanged)

bible/styles.css

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
1-
body {
2-
margin: 0;
3-
font-family: Arial, sans-serif;
4-
}
5-
6-
.container {
1+
#navigation {
72
display: flex;
8-
height: 100vh;
3+
align-items: center;
4+
gap: 10px;
5+
margin-bottom: 20px;
96
}
107

11-
.sidebar {
12-
width: 250px;
13-
background: #f5f5f5;
14-
padding: 20px;
15-
overflow-y: auto;
8+
#chapter-numbers {
9+
display: flex;
10+
gap: 5px;
11+
overflow-x: auto;
12+
padding: 5px 0;
1613
}
1714

18-
.main-content {
19-
flex: 1;
20-
padding: 20px;
21-
overflow-y: auto;
15+
.chapter-btn {
16+
padding: 8px 12px;
17+
cursor: pointer;
18+
border: 1px solid #ddd;
19+
background: #f8f8f8;
20+
border-radius: 4px;
2221
}
2322

24-
#book-list button {
25-
display: block;
26-
width: 100%;
27-
padding: 10px;
28-
margin: 5px 0;
29-
text-align: left;
30-
cursor: pointer;
23+
.chapter-btn.active {
24+
background: #4CAF50;
25+
color: white;
26+
border-color: #45a049;
3127
}
3228

33-
.verse {
34-
margin: 10px 0;
29+
#prevChapter, #nextChapter {
30+
padding: 8px 16px;
31+
font-size: 1.2em;
3532
}

0 commit comments

Comments
 (0)