Commit 466f4247 authored by Troy A. Griffitts's avatar Troy A. Griffitts

first working release of Gospel Parallels support.

May not continue to show in popup as a table, but might find a better
format for display.
parent 5efd1f51
......@@ -49,6 +49,7 @@
<script type="text/javascript" src="js/dailydevo.js"></script>
<script type="text/javascript" src="js/installmgr.js"></script>
<script type="text/javascript" src="js/imagetools.js"></script>
<script type="text/javascript" src="js/eusebian.js"></script>
<script type="text/javascript" src="js/brand.js"></script>
......
This diff is collapsed.
var eusebian = {
// cached module objects
eusVs : null,
eusNum : null,
lastEusNum : null,
_cacheEusebianModules : function(callback) {
if (!eusebian.eusVs || !eusebian.eusNum) {
SWORD.mgr.getModuleByName('Eusebian_vs', function(m) {
eusebian.eusVs = m;
SWORD.mgr.getModuleByName('Eusebian_num', function(m) {
eusebian.eusNum = m;
return callback ? callback() : false;
});
});
}
else return (callback) ? callback() : false;
},
getEusebianLabel : function(keyText, callback) {
eusebian._cacheEusebianModules(function() {
// assert we have our eusebian modules
if (eusebian.eusVs == null || eusebian.eusNum == null) return (callback) ? callback('') : false;
var myEusNum = '';
eusebian.eusVs.setKeyText(keyText, function() {
eusebian.eusVs.getRenderText(function(mun) {
myEusNum = mun.trim();
if (eusebian.lastEusNum != myEusNum) {
eusebian.lastEusNum = myEusNum;
eusebian.eusNum.setKeyText(myEusNum, function() {
eusebian.eusNum.getRenderText(function(mun) {
console.log('keyText: ' + keyText + '; mun: ' + mun);
myEusNum = myEusNum.substring(myEusNum.indexOf('.')+1) + '<br/>' + $(mun).attr('table');
if (callback) callback(myEusNum);
return;
});
});
}
else {
if (callback) callback(false);
return;
}
});
});
});
},
buildEusebianData : function(renderData, callback) {
// assert we have work to do
if (!renderData || !renderData.length || !renderData[0].length) return (callback) ? callback() : false;
// do per-verse stuff
var verseLoop = function(i, callback) {
if (!i) i = 0;
if (!renderData || !renderData.length || i >= renderData[0].length) {
return (callback) ? callback() : false;
}
var verseKey = renderData[0][i].verse;
eusebian.getEusebianLabel(verseKey.osisRef, function (eusLabel) {
renderData[0][i].eusLabel = eusLabel;
return verseLoop(++i, callback);
});
}
// see if we're a Gospel
if (app.isShowGospelParallels() && renderData[0][0].verse.testament == 2 && renderData[0][0].verse.book <= 4) {
// clear cache of eusebian modules
eusebian.eusVs = false;
eusebian.eusNum = false;
verseLoop(0, function() {
return (callback) ? callback() : false;
});
}
else return (callback) ? callback() : false;
},
getEusebianGospelsText : function(activeModuleName, contextVerses, activeKey, callback) {
eusebian._cacheEusebianModules(function() {
console.log('activeModuleName: ' + activeModuleName);
SWORD.mgr.getModuleByName(activeModuleName, function(activeModule) {
var promoLine = activeModule.shortPromo;
console.log('activeKey: ' + activeKey);
eusebian.eusVs.setKeyText(activeKey, function(){
eusebian.eusVs.getRenderText(function(num) {
num = num.trim();
eusebian.eusNum.setKeyText(num, function() {
eusebian.eusNum.getRenderText(function(detailsText) {
var nums = (num + ' ' + $(detailsText).attr('assocates')).split(' ');
nums.sort();
var lang = activeModule.lang;
var rtol = activeModule.direction && 'RtoL'.toUpperCase() == activeModule.direction.toUpperCase();
var t = '';
t += '<table style="margin:100px 10px 10px 10px; border-collapse:collapse;" class="'+ lang + '">';
t += '<thead><tr>';
for (var j = 0; j < nums.length; ++j) {
var n = nums[j];
if (n.trim().length < 1) continue;
t += '<th>' + n + '</th>';
}
t += '</tr>';
var headerNums = function(i, callback) {
if (i >= nums.length) return callback ? callback() : false;
var n = nums[i];
if (n.trim().length < 1) return headerNums(++i, callback);
eusebian.eusNum.setKeyText(n.trim(), function() {
eusebian.eusNum.getRenderText(function(detailsText) {
t += '<th>' + $(detailsText).attr('osisRef') + '</th>';
return headerNums(++i, callback);
});
});
};
var keyLoop = function(keyList, i, callback) {
if (i >= keyList.length) return (callback) ? callback() : false;
var k = keyList[i];
activeModule.setKeyText(k, function() {
activeModule.getRenderText(function(v) {
activeModule.getKeyText(function(currentKeyText){
activeModule.getVerseKey(function(vk) {
if (rtol) {
t += '<bdo dir="rtl">';
}
t += '<span class="' + ((currentKeyText == activeKey) ? 'currentverse' : 'verse') + '">';
t += '<span class="verseNum"><bdo dir="ltr"><a href="passagestudy.jsp?key=' + activeModule.getKeyText()+'#cv">' + vk.verse + '</a></bdo></span>' + v;
if (rtol) {
t += '</bdo>';
}
t += '</span>';
keyLoop(keyList, ++i, callback);
});
});
});
});
};
var bodyNums = function(i, callback) {
if (i >= nums.length) return callback ? callback() : false;
var n = nums[i];
if (n.trim().length < 1) return headerNums(++i, callback);
t += '<td ' + (rtol ? 'dir="rtl"' : '') + '>';
eusebian.eusNum.setKeyText(n.trim(), function() {
eusebian.eusNum.getRawEntry(function(detailsText) {
var keyListText = $(detailsText).attr('osisRef');
activeModule.parseKeyList(keyListText, function(keyList) {
keyLoop(keyList, 0, function() {
t += '</td>';
return bodyNums(++i, callback);
});
});
});
});
};
t += '<tr>';
headerNums(0, function() {
t += '</tr></thead><tbody>';
t += '<tr>';
// Eusebian Row(s) Verse Ranges ----------------------------------------------------------
bodyNums(0, function() {
t += '</tr>';
t += '</tbody>';
t += '</table>';
return callback ? callback(t) : false;
});
});
});
});
});
});
});
});
},
};
/*
<tr>
<%
// Pre context -----------------------------------------------------------------------------
if (contextVerses > 0) {
for (String n : nums) {
if (n.trim().length() < 1) continue;
eusNum.setKeyText(n.trim());
eusNum.getRenderText();
detailsText = eusNum.getRawEntry();
XMLTag d = new XMLBlock(detailsText);
String keyList[] = activeModule.parseKeyList(d.getAttribute("osisRef"));
activeModule.setKeyText(keyList[0]);
activeModule.getRenderText();
String book = activeModule.getKeyChildren()[1];
String keyText = activeModule.getKeyText();
for (int c = 0; c < contextVerses; ++c) activeModule.previous();
// be sure we have an upper limit on the book
while (!book.equals(activeModule.getKeyChildren()[1])) activeModule.next();
%>
<td <%= rtol ? "dir=\"rtl\"" : "" %>>
<%
while (!keyText.equals(activeModule.getKeyText()) && activeModule.error() == 0) {
String v = activeModule.getRenderText();
String currentKeyText = activeModule.getKeyText();
if (rtol) {
%>
<bdo dir="rtl">
<%
}
%>
<span class="<%= (currentKeyText.equals(activeKey)) ? "currentverse" : "verse" %>">
<span class="verseNum"><bdo dir="ltr"><a href="passagestudy.jsp?key=<%=activeModule.getKeyText()%>#cv"><%= activeModule.getKeyChildren()[3]%></a></bdo></span><%= v %>
<%
if (rtol) {
%>
</bdo>
<%
}
%>
</span>
<%
activeModule.next();
}
%>
</td>
<%
}
%>
</tr>
<%
}
// Post context ----------------------------------------------------------------------------------------------
if (contextVerses > 0) {
%>
<tr>
<%
for (String n : nums) {
if (n.trim().length() < 1) continue;
eusNum.setKeyText(n.trim());
eusNum.getRenderText();
detailsText = eusNum.getRawEntry();
XMLTag d = new XMLBlock(detailsText);
String keyList[] = activeModule.parseKeyList(d.getAttribute("osisRef"));
activeModule.setKeyText(keyList[keyList.length-1]);
activeModule.getRenderText();
String book = activeModule.getKeyChildren()[1];
%>
<td <%= rtol ? "dir=\"rtl\"" : "" %>>
<%
activeModule.next();
for (int i = 0; i < contextVerses && activeModule.error() == 0 && book.equals(activeModule.getKeyChildren()[1]); ++i) {
String v = activeModule.getRenderText();
String currentKeyText = activeModule.getKeyText();
if (rtol) {
%>
<bdo dir="rtl">
<%
}
%>
<span class="<%= (currentKeyText.equals(activeKey)) ? "currentverse" : "verse" %>">
<span class="verseNum"><bdo dir="ltr"><a href="passagestudy.jsp?key=<%=activeModule.getKeyText()%>#cv"><%= activeModule.getKeyChildren()[3]%></a></bdo></span><%= v %>
<%
if (rtol) {
%>
</bdo>
<%
}
%>
</span>
<%
activeModule.next();
}
%>
</td>
<%
}
%>
</tr>
<%
} // end Post context -------------------------------------------------------------------------------------------------------
%>
*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment