Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rpruim
Created January 17, 2020 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpruim/6f381be4bfaeb9d9059edb1de5ac0fb5 to your computer and use it in GitHub Desktop.
Save rpruim/6f381be4bfaeb9d9059edb1de5ac0fb5 to your computer and use it in GitHub Desktop.
Random Verse Generator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Random Verse</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
<style>
body {
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS',
sans-serif;
text-align: center;
}
h1 {
font-size: 50px;
}
button {
font-size: 20px;
}
.verse {
text-align: center;
font-size: 40px;
}
</style>
<h1>Random Verse Generator</h1>
<button id="verse-button">Generate Random Verse</button>
<br />
<br />
<div class="verse"></div>
<iframe src="" frameborder="0" width="800" height="600"></iframe>
<script>
let books = [
'Genesis',
'Exodus',
'Leviticus',
'Numbers',
'Deuteronomy',
'Joshua',
'Judges',
'Ruth',
'1 Samuel',
'2 Samuel',
'1 Kings',
'2 Kings',
'1 Chronicles',
'2 Chronicles',
'Ezra',
'Nehemiah',
'Esther',
'Job',
'Psalms',
'Proverbs',
'Ecclesiastes',
'Song of Solomon',
'Isaiah',
'Jeremiah',
'Lamentations',
'Ezekiel',
'Daniel',
'Hosea',
'Joel',
'Amos',
'Obadiah',
'Jonah',
'Micah',
'Nahum',
'Habakkuk',
'Zephaniah',
'Haggai',
'Zechariah',
'Malachi',
'Matthew',
'Mark',
'Luke',
'John',
'Acts',
'Romans',
'1 Corinthians',
'2 Corinthians',
'Galatians',
'Ephesians',
'Philippians',
'Colossians',
'1 Thessalonians',
'2 Thessalonians',
'1 Timothy',
'2 Timothy',
'Titus',
'Philemon',
'Hebrews',
'James',
'1 Peter',
'2 Peter',
'1 John',
'2 John',
'3 John',
'Jude',
'Revelation',
]
d3.select('#verse-button').on('click', generate_verse)
function generate_verse() {
let i = Math.trunc(Math.random() * books.length)
let book = books[i]
let verse = book + ' 3:16'
let url = `https://www.biblegateway.com/passage/?search=${book}+3%3A16&version=NIV`
console.log(verse)
d3.select('div.verse').text(verse)
d3.select('iframe').attr('src', url)
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment