Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions read/Script/Read.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* @fileOverview Read is the JavaScript controller for OSHB Read.
* @version 1.0
* @version 1.1
* Version 1.1: Factored in Reference Location, to link to the current verse (marcstober).
* @author David
*/
(function() {
Expand All @@ -9,7 +10,8 @@
"book": document.getElementById('book'),
"chapter": document.getElementById('chapter'),
"verse": document.getElementById('verse'),
"display": document.getElementById('display')
"display": document.getElementById('display'),
"link": document.getElementById('link')
};
// Utility functions.
// Utility function to clear child nodes from an element.
Expand Down Expand Up @@ -74,7 +76,9 @@
for (; i <= num; i++) {
elements.verse.options[elements.verse.options.length] = new Option(i);
}
getChapter();
elements.verse[initialVerse].selected = "selected";
initialVerse = 0;
getChapter();
};
// Extracts the XML chapter from bookText.
var setChapterFile = function() {
Expand All @@ -93,6 +97,11 @@
return loadFile("../wlc/" + book + ".xml", setChapters);
};
// Interface elements.
// Marks up the link.
function linkMark() {
var address = refLocation.getLocation(elements.book.value, elements.chapter.value, elements.verse.value);
return '<a href="' + address + '">' + address + '</a>'
}
var chapterMarkup = window.chapterMarkup;
// Marks up the chapter.
function getChapter() {
Expand All @@ -101,14 +110,18 @@
elements.display.appendChild(chapterMarkup(chapter));
// Highlight the selected verse.
selectVerse(document.getElementById("v." + elements.verse.value));
elements.link.innerHTML = linkMark();
}
// Initialize.
var initialChapter = elements.chapter.value - 1,
var refLocation = window.refLocation,
initialChapter = refLocation.chapterIndex(),
initialVerse = refLocation.verseIndex(),
selectVerse = window.selectVerse;
elements.book.onchange = setBookFile;
elements.chapter.onchange = setChapterFile;
elements.verse.onchange = function() {
selectVerse(document.getElementById("v." + elements.verse.value));
elements.link.innerHTML = linkMark();
};
setBookFile();
})();
57 changes: 57 additions & 0 deletions read/Script/ReferenceLocation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @fileOverview Reference Location manages URL locations.
* @version 1.0
* @author David
*/
refLocation = function() {
// Assemble an array of SBL book abbreviations.
var book = document.getElementById("book"),
sblNames = [], i = 0;
while (book.options[i]) {
sblNames.push(book.options[i].value);
i++;
}
// Parses the URL.
function parseURL() {
var parts = {book: "Gen", chapter: 1, verse: 1},
url = window.location,
results;
if (url.length > 75) {return parts;} // Excessively long URL.
results = url.search.match(/b=(\w+)/);
if (results && results[1]) {
if (sblNames.indexOf(results[1]) >= 0) {
parts.book = results[1];
} else {
mtNum = parseInt(results[1]);
if (mtNum > 0 && mtNum < 40) {
parts.book = sblNames[mtNum - 1];
} else {
return parts; // Unknown book number.
}
}
} else {
return parts; // Unknown book abbreviation.
}
results = url.search.match(/c=(\d+)/);
if (results) {parts.chapter = parseInt(results[1]);}
results = url.search.match(/v=(\d+)/);
if (results) {parts.verse = parseInt(results[1]);}
return parts;
}
// Apply the results.
var ref = parseURL(),
homePage = window.location.protocol + "//" + window.location.host + "/read/index.html";
book[sblNames.indexOf(ref.book)].selected = "selected";
// Return the public interface.
return {
chapterIndex: function() {
return ref.chapter - 1;
},
verseIndex: function() {
return ref.verse - 1;
},
getLocation: function(sblBook, chapter, verse) {
return homePage + "?b=" + sblBook + "&c=" + chapter + "&v=" + verse;
}
}
}();
10 changes: 10 additions & 0 deletions read/Style/ReadStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ section#work
{
margin: 0.5em;
}
section#work aside
{
padding: 0 1em 0.5em 1em;
background-color: rgba(255, 251, 208, 0.7);
border: 3px double #217438;
width: intrinsic; /* Safari/WebKit uses a non-standard name */
width: -moz-max-content; /* Firefox/Gecko */
width: -webkit-max-content; /* Chrome */
margin-top: 0.5em;
}
/* Passage Styles */
section.passage
{
Expand Down
12 changes: 9 additions & 3 deletions read/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ <h1><span class="logo"><span>The OpenScriptures</span><br />Hebrew Bible</span>
<form>
<label for="book">Book</label>
<select id="book">
<!-- Haggai selected for testing. -->
<option value="Gen">Genesis</option>
<option value="Exod">Exodus</option>
<option value="Lev">Leviticus</option>
Expand All @@ -38,7 +37,7 @@ <h1><span class="logo"><span>The OpenScriptures</span><br />Hebrew Bible</span>
<option value="Nah">Nahum</option>
<option value="Hab">Habakkuk</option>
<option value="Zeph">Zephaniah</option>
<option value="Hag" selected="selected">Haggai</option>
<option value="Hag">Haggai</option>
<option value="Zech">Zechariah</option>
<option value="Mal">Malachi</option>
<option value="Ps">Psalms</option>
Expand Down Expand Up @@ -71,14 +70,21 @@ <h1><span class="logo"><span>The OpenScriptures</span><br />Hebrew Bible</span>
<h2>Chapter Display</h2>
</section>
<section id="morphDisplay" title="Morphology Display"></section>
</section>
<aside>
<p><strong>Link to this verse:</strong><br />
<code><span id="link"></span></code><br />
(<em>Right-click</em> on the link, and Copy.<br />
You can paste the link into an email, or make a bookmark for it.)</p>
</aside>
</section>
<div class="footer">
Read is part of the
<a href="https://openscriptures.github.io/morphhb/index.html">Open Scriptures Hebrew Bible</a> project.<br/>
This demo allows reading a chapter of the Hebrew bible. You can hover over a specific word for more information.<br/>
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img
alt="Creative Commons License" style="border-width:0; margin:0.3ex" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a>
</div>
<script src="Script/ReferenceLocation.js"></script>
<script src="Script/MorphologyParser.js"></script>
<script src="Script/ClickWord.js"></script>
<script src="Script/SelectVerse.js"></script>
Expand Down
4 changes: 4 additions & 0 deletions read/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Several components have been adapted from
[OSHB Verse](https://hb.openscriptures.org/structure/OshbVerse/),
we have:

- ReferenceLocation.js (Added 4/19/2024) manages URL locations, to
make and process the link.

- AccentCatalog.js catalogs the accents by type and scope.

- Books.js records book data for navigation.
Expand Down Expand Up @@ -69,6 +72,7 @@ OSHB Read is licensed under a
license. For attribution purposes, credit the Open Scriptures Hebrew Bible
Project.

Updated April 19, 2024 (marcstober)
Updated September 18, 2019
Updated August 30, 2019
Updated July 27, 2019
Expand Down