Skip to content

Instantly share code, notes, and snippets.

@eldhosejoys
Created April 18, 2025 03:05
Show Gist options
  • Save eldhosejoys/8a4d4edb5ddcc407ba813c249bec3f1a to your computer and use it in GitHub Desktop.
Save eldhosejoys/8a4d4edb5ddcc407ba813c249bec3f1a to your computer and use it in GitHub Desktop.
Bible Books with number from OpenBooks.info Cross Reference
[
{
"number": 1,
"book": "Gen"
},
{
"number": 2,
"book": "Exod"
},
{
"number": 3,
"book": "Lev"
},
{
"number": 4,
"book": "Num"
},
{
"number": 5,
"book": "Deut"
},
{
"number": 6,
"book": "Josh"
},
{
"number": 7,
"book": "Judg"
},
{
"number": 8,
"book": "Ruth"
},
{
"number": 9,
"book": "1Sam"
},
{
"number": 10,
"book": "2Sam"
},
{
"number": 11,
"book": "1Kgs"
},
{
"number": 12,
"book": "2Kgs"
},
{
"number": 13,
"book": "1Chr"
},
{
"number": 14,
"book": "2Chr"
},
{
"number": 15,
"book": "Ezra"
},
{
"number": 16,
"book": "Neh"
},
{
"number": 17,
"book": "Esth"
},
{
"number": 18,
"book": "Job"
},
{
"number": 19,
"book": "Ps"
},
{
"number": 20,
"book": "Prov"
},
{
"number": 21,
"book": "Eccl"
},
{
"number": 22,
"book": "Song"
},
{
"number": 23,
"book": "Isa"
},
{
"number": 24,
"book": "Jer"
},
{
"number": 25,
"book": "Lam"
},
{
"number": 26,
"book": "Ezek"
},
{
"number": 27,
"book": "Dan"
},
{
"number": 28,
"book": "Hos"
},
{
"number": 29,
"book": "Joel"
},
{
"number": 30,
"book": "Amos"
},
{
"number": 31,
"book": "Obad"
},
{
"number": 32,
"book": "Jonah"
},
{
"number": 33,
"book": "Mic"
},
{
"number": 34,
"book": "Nah"
},
{
"number": 35,
"book": "Hab"
},
{
"number": 36,
"book": "Zeph"
},
{
"number": 37,
"book": "Hag"
},
{
"number": 38,
"book": "Zech"
},
{
"number": 39,
"book": "Mal"
},
{
"number": 40,
"book": "Matt"
},
{
"number": 41,
"book": "Mark"
},
{
"number": 42,
"book": "Luke"
},
{
"number": 43,
"book": "John"
},
{
"number": 44,
"book": "Acts"
},
{
"number": 45,
"book": "Rom"
},
{
"number": 46,
"book": "1Cor"
},
{
"number": 47,
"book": "2Cor"
},
{
"number": 48,
"book": "Gal"
},
{
"number": 49,
"book": "Eph"
},
{
"number": 50,
"book": "Phil"
},
{
"number": 51,
"book": "Col"
},
{
"number": 52,
"book": "1Thess"
},
{
"number": 53,
"book": "2Thess"
},
{
"number": 54,
"book": "1Tim"
},
{
"number": 55,
"book": "2Tim"
},
{
"number": 56,
"book": "Titus"
},
{
"number": 57,
"book": "Phlm"
},
{
"number": 58,
"book": "Heb"
},
{
"number": 59,
"book": "Jas"
},
{
"number": 60,
"book": "1Pet"
},
{
"number": 61,
"book": "2Pet"
},
{
"number": 62,
"book": "1John"
},
{
"number": 63,
"book": "2John"
},
{
"number": 64,
"book": "3John"
},
{
"number": 65,
"book": "Jude"
},
{
"number": 66,
"book": "Rev"
}
]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bible Book List Generator</title>
<style>
body {
font-family: sans-serif;
padding: 20px;
line-height: 1.6;
}
#fileInputLabel {
display: inline-block;
padding: 8px 12px;
cursor: pointer;
border: 1px solid #ccc;
background-color: #f7f7f7;
border-radius: 4px;
margin-bottom: 10px;
}
#fileInput {
display: none; /* Hide the default ugly input */
}
#fileName {
margin-left: 10px;
font-style: italic;
color: #555;
}
button {
padding: 10px 15px;
margin: 5px;
cursor: pointer;
border: none;
border-radius: 4px;
background-color: #007bff;
color: white;
font-size: 1em;
}
button:disabled {
background-color: #cccccc;
cursor: not-allowed;
}
#jsonOutput {
width: 95%;
height: 400px;
margin-top: 15px;
font-family: monospace;
white-space: pre; /* Ensures formatting is kept */
border: 1px solid #ccc;
padding: 10px;
overflow: auto; /* Add scrollbars if needed */
}
.output-controls {
margin-top: 10px;
}
</style>
</head>
<body>
<h1>Generate Standard Bible Book List (JSON)</h1>
<p>Upload your sample text file (like the one provided) to trigger the generation of the standard 66-book JSON list.</p>
<!-- File Input -->
<label for="fileInput" id="fileInputLabel">Choose File</label>
<input type="file" id="fileInput" accept=".txt">
<span id="fileName">No file chosen</span>
<!-- Process Button -->
<button id="processButton" disabled>Generate JSON</button>
<!-- JSON Output Area -->
<textarea id="jsonOutput" readonly placeholder="JSON output will appear here..."></textarea>
<!-- Output Controls -->
<div class="output-controls">
<button id="copyButton" disabled>Copy JSON</button>
<button id="downloadButton" disabled>Download JSON</button>
<span id="copyFeedback" style="margin-left: 10px; color: green;"></span>
</div>
<script src="script.js"></script>
</body>
</html>
document.addEventListener('DOMContentLoaded', () => {
const fileInput = document.getElementById('fileInput');
const fileNameDisplay = document.getElementById('fileName');
const processButton = document.getElementById('processButton');
const jsonOutput = document.getElementById('jsonOutput');
const copyButton = document.getElementById('copyButton');
const downloadButton = document.getElementById('downloadButton');
const copyFeedback = document.getElementById('copyFeedback');
let generatedJsonString = ''; // To store the generated JSON
// --- List of 66 Books (Standard Protestant Canon Order & Common Abbreviations) ---
const bibleBooks = [
// Old Testament (39 Books)
"Gen", "Exod", "Lev", "Num", "Deut", "Josh", "Judg", "Ruth",
"1Sam", "2Sam", "1Kgs", "2Kgs", "1Chr", "2Chr", "Ezra", "Neh",
"Esth", "Job", "Ps", "Prov", "Eccl", "Song", "Isa", "Jer",
"Lam", "Ezek", "Dan", "Hos", "Joel", "Amos", "Obad", "Jonah",
"Mic", "Nah", "Hab", "Zeph", "Hag", "Zech", "Mal",
// New Testament (27 Books)
"Matt", "Mark", "Luke", "John", "Acts", "Rom", "1Cor", "2Cor",
"Gal", "Eph", "Phil", "Col", "1Thess", "2Thess", "1Tim", "2Tim",
"Titus", "Phlm", "Heb", "Jas", "1Pet", "2Pet", "1John", "2John",
"3John", "Jude", "Rev"
];
// --- Event Listeners ---
fileInput.addEventListener('change', (event) => {
if (event.target.files.length > 0) {
fileNameDisplay.textContent = event.target.files[0].name;
processButton.disabled = false; // Enable processing button
// Clear previous results if a new file is chosen
jsonOutput.value = '';
generatedJsonString = '';
copyButton.disabled = true;
downloadButton.disabled = true;
copyFeedback.textContent = '';
} else {
fileNameDisplay.textContent = 'No file chosen';
processButton.disabled = true;
}
});
processButton.addEventListener('click', () => {
// Generate the JSON based on the predefined list, NOT the file content
const bookListJson = [];
for (let i = 0; i < bibleBooks.length; i++) {
bookListJson.push({
number: i + 1,
book: bibleBooks[i]
});
}
// Convert array to pretty-printed JSON string
generatedJsonString = JSON.stringify(bookListJson, null, 2); // null, 2 for indentation
// Display the JSON
jsonOutput.value = generatedJsonString;
// Enable copy and download buttons
copyButton.disabled = false;
downloadButton.disabled = false;
copyFeedback.textContent = ''; // Clear any previous copy feedback
});
copyButton.addEventListener('click', () => {
if (!generatedJsonString) return; // Nothing to copy
navigator.clipboard.writeText(generatedJsonString)
.then(() => {
// Success feedback
copyFeedback.textContent = 'Copied!';
// Optional: clear feedback after a few seconds
setTimeout(() => { copyFeedback.textContent = ''; }, 2000);
})
.catch(err => {
// Error feedback (rare, but good practice)
copyFeedback.textContent = 'Copy failed!';
console.error('Failed to copy text: ', err);
setTimeout(() => { copyFeedback.textContent = ''; }, 2000);
});
});
downloadButton.addEventListener('click', () => {
if (!generatedJsonString) return; // Nothing to download
// Create a Blob (Binary Large Object) from the JSON string
const blob = new Blob([generatedJsonString], { type: 'application/json' });
// Create a temporary URL for the Blob
const url = URL.createObjectURL(blob);
// Create a temporary anchor element
const a = document.createElement('a');
a.href = url;
a.download = 'bible_books.json'; // Filename for the download
// Append the anchor to the body (required for Firefox), click it, and remove it
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
// Revoke the temporary URL to free up memory
URL.revokeObjectURL(url);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment