Skip to content

Instantly share code, notes, and snippets.

@tomhamming
Created July 19, 2018 17:15
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 tomhamming/4fb053a01c8c712f4c733bc2a404d54b to your computer and use it in GitHub Desktop.
Save tomhamming/4fb053a01c8c712f4c733bc2a404d54b to your computer and use it in GitHub Desktop.
Parsing EJS
<%
function lemmaClass(lemma) {
if (lemma.isHebrew == "true") return "hebrew-face";
if (lemma.isGreek == "true") return "greek-face";
return "";
}
%>
<!--=====================================================
We create the full article for each parsingSection JSON object
======================================================-->
<% for(var i=0; i<this.length; i++) {
var section = this[i];
%>
<div class="parsing-popup">
<!--=====================================================
This is the header section with the lemma and strongs
======================================================-->
<header>
<!-- Put in the lemmas -->
<% for(var l=0; section.lemmas && l<section.lemmas.length; l++) {
var lemma = section.lemmas[l];
%>
<h1 class="<%= lemmaClass(lemma) %>"><%= lemma.searchForm %></h1>
<% } %>
<!-- Put in the strongs number -->
<% if (section.gk) { %>
<p class='strongs_number'>G/K NUMBER:
<b><%=section.gk.join("</b>, <b>")%></b>
</p>
<% } %>
<% if (section.strongs) { %>
<p class='strongs_number'>STRONG’S NUMBER:
<b><%=section.strongs.join("</b>, <b>")%></b>
</p>
<% } %>
</header>
<!--=====================================================
Gloss section
======================================================-->
<% if (section.gloss) { %>
<section class='gloss'>
<label>GLOSS</label>
<%= section.gloss %>
</section>
<% } %>
<!--=====================================================
Parsing section
======================================================-->
<% if (section.parsing) {
for(var p=0; p<section.parsing.length; p++) {
var parsing = section.parsing[p];
%>
<section class='parsings'>
<!-- If there is more than 1 parsing we put OR between them -->
<% if (p > 0) { %>
<p class="bold">OR</p>
<% } %>
<!-- The full parsing description -->
<label>PARSING</label>
<%= parsing.description %>
<!-- The parsing code for search -->
<label>CODE</label>
<div><%= parsing.code %></div>
<% if (section.showSearch) { %>
<label>SEARCH &amp; LOOKUP</label>
<!-- The search this form links. We need a search for this form for each lemma -->
<% for(var l=0; section.lemmas && l<section.lemmas.length; l++) {
var lemma = section.lemmas[l];
var data = {
"type":9,
"productId":section.prodId,
"data": {
"lemma": lemma.searchForm,
"parsing": parsing.code,
"productId": section.prodId
}
};
%>
<a class="link_button search-link" onClick='return BiblePlus.Core.Hyperlinks.postHyperlinkData(<%= JSON.stringify(data) %>, this);'>
Search <span class="<%= lemmaClass(lemma) %>"><%= lemma.searchForm %></span> in this form
</a>
<% } %>
<!-- Link to search for all words that have this parsing form -->
<%
var searchAllData = {
"type":9,
"productId": section.prodId,
"data": {
"parsing": parsing.code,
"productId": section.prodId
}
};
%>
<a class="link_button search-link" onClick='return BiblePlus.Core.Hyperlinks.postHyperlinkData(<%= JSON.stringify(searchAllData) %>, this);'>
Search all words in this form
</a>
<a class="link_button search-link" onClick='return BiblePlus.Core.Hyperlinks.postHyperlinkData(<%= JSON.stringify({"type":12,"data":{"lemma":lemma.searchForm}}) %>, this);'>
Lookup <span class="<%= lemmaClass(lemma) %>"><%= lemma.searchForm %></span>
</a>
<% } %>
</section>
<% }
} %>
<!--=====================================================
The definition from the dictionary or lexicon
======================================================-->
<% for(var d=0; section.definition && d<section.definition.length; d++) {
var definition = section.definition[d];
var data = {
"type":8,
"productId":section.prodId,
"data": {
"lexeme":definition.lexeme,
"anchor":definition.lexiconAnchor,
"productId": section.prodId
}
};
%>
<section class='definition'>
<label class='dictionary_type'><%= definition.title %></label>
<%= definition.content %>
<% if (definition.lexiconAnchor && definition.atWordLimit) { %>
<a class="link_button" onClick='return BiblePlus.Core.Hyperlinks.postHyperlinkData(<%= JSON.stringify(data) %>, this);'>
View Full Definition
</a>
<% } %>
</section>
<% } %>
<% if ((section.gk || section.strongs || section.lemmas) && section.showSearch) { %>
<section class='search'>
<label>SEARCH FOR</label>
<% var searches = (/* gk numbers aren't in search? section.gk || */[]).concat(section.strongs || [], section.lemmas || []);
for(var s=0; s<searches.length; s++) {
var search = searches[s];
var data = {
"type":9,
"productId": section.prodId,
"data": {
"parsing": search.searchForm || search,
"productId": section.prodId
}
};
var options = {
"class": "search-button " + lemmaClass(search),
"onclick": "return BiblePlus.Core.Hyperlinks.postHyperlinkData("+JSON.stringify(data)+", this);"
}
%>
<%= tag("a", options)+(search.searchForm || search)+tag_end("a") %>
<% } %>
</section>
<% } %>
</div>
<% } %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment