From d1d997826baac44d7e168a8a51644013c3ba6962 Mon Sep 17 00:00:00 2001 From: Patrick Tang Date: Tue, 18 Jun 2024 18:02:00 -0700 Subject: [PATCH] Support morph in verse vocab --- .../search/StrongCountsAndSubjects.java | 18 +++ .../service/jsword/JSwordPassageService.java | 2 +- .../helpers/JSwordStrongNumberHelper.java | 3 + .../js/backbone/views/view_quick_lexicon.js | 25 +++- .../webapp/js/backbone/views/view_sidebar.js | 36 +++-- .../src/main/webapp/js/search_selection.js | 4 +- step-web/src/main/webapp/js/step.util.js | 128 +++++++++++++----- 7 files changed, 165 insertions(+), 51 deletions(-) diff --git a/step-core/src/main/java/com/tyndalehouse/step/core/models/search/StrongCountsAndSubjects.java b/step-core/src/main/java/com/tyndalehouse/step/core/models/search/StrongCountsAndSubjects.java index c053e58c7a..e2213e7ddc 100644 --- a/step-core/src/main/java/com/tyndalehouse/step/core/models/search/StrongCountsAndSubjects.java +++ b/step-core/src/main/java/com/tyndalehouse/step/core/models/search/StrongCountsAndSubjects.java @@ -14,6 +14,8 @@ public class StrongCountsAndSubjects { private boolean ot; private String verse; private boolean multipleVerses; + private String allMorphsInVerse; + private String translationTipsFN; /** * Sets the counts. @@ -33,6 +35,22 @@ public void setStrongData(final Map> strongData) this.strongData = strongData; } + public void setTranslationTipsFN(final String translationTipsFN) { + this.translationTipsFN = translationTipsFN; + } + + public String getTranslationTipsFN() { + return this.translationTipsFN; + } + + public void setAllMorphsInVerse(final String allMorphsInVerse) { + this.allMorphsInVerse = allMorphsInVerse; + } + + public String getAllMorphsInVerse() { + return this.allMorphsInVerse; + } + /** * @return the strongData */ diff --git a/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/JSwordPassageService.java b/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/JSwordPassageService.java index df3d21b2f1..dc53fa4c31 100644 --- a/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/JSwordPassageService.java +++ b/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/JSwordPassageService.java @@ -12,7 +12,7 @@ public interface JSwordPassageService { String REFERENCE_BOOK = "ESV_th"; String SECONDARY_REFERENCE_BOOK = "NIV"; - String OT_BOOK = "OSMHB"; + String OT_BOOK = "THOT"; // "OSMHB"; String BEST_VERSIFICATION = "KJV"; int MAX_VERSES_RETRIEVED = 200; diff --git a/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/helpers/JSwordStrongNumberHelper.java b/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/helpers/JSwordStrongNumberHelper.java index 711f874877..861e0a1beb 100644 --- a/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/helpers/JSwordStrongNumberHelper.java +++ b/step-core/src/main/java/com/tyndalehouse/step/core/service/jsword/helpers/JSwordStrongNumberHelper.java @@ -58,6 +58,7 @@ public class JSwordStrongNumberHelper { private Map> verseStrongs; private Map allStrongs; private boolean isOT; + private String allMorph; private String translationTipsFN; /** @@ -135,6 +136,8 @@ else if (customFN.containsKey(curOrdinal)) final List elements = JSwordUtils.getOsisElements(new BookData(preferredCountBook, key)); Set strongAlreadyIncluded = new HashSet(); for (final Element e : elements) { + if (elements.size() == 1) // If it is from verseVocabuary, it will only has one morphology + allMorph = OSISUtil.getMorphologiesWithStrong(e); final String verseRef = e.getAttributeValue(OSISUtil.OSIS_ATTR_OSISID); final String strongsNumbers = OSISUtil.getStrongsNumbers(e); if (StringUtils.isBlank(strongsNumbers)) { diff --git a/step-web/src/main/webapp/js/backbone/views/view_quick_lexicon.js b/step-web/src/main/webapp/js/backbone/views/view_quick_lexicon.js index 29414749c2..3463c6aff9 100644 --- a/step-web/src/main/webapp/js/backbone/views/view_quick_lexicon.js +++ b/step-web/src/main/webapp/js/backbone/views/view_quick_lexicon.js @@ -58,6 +58,7 @@ var QuickLexicon = Backbone.View.extend({ this.position = opts.position; this.height = opts.height; this.type = opts.type; + this.morphCount = opts.morphCount; this.touchEvent = opts.touchEvent || false; this.passageContainer = step.util.getPassageContainer(opts.target); if (typeof opts.variant !== "string") @@ -72,6 +73,7 @@ var QuickLexicon = Backbone.View.extend({ var self = parameters[0]; var strongsNotToDisplay = parameters[1]; var multipleStrongTextFromSearchModal = parameters[2]; + var morphCount = parameters[3]; $("#quickLexicon").remove(); var morphOnly = false; var data = JSON.parse(JSON.stringify(origData)); @@ -134,6 +136,8 @@ var QuickLexicon = Backbone.View.extend({ data.vocabInfos[i].mediumDef = data.vocabInfos[i].mediumDef.replace(/
/g, " ").replace(/
/g, " ").trim(); } } + if (morphCount > 1) + morph_information[0] += " - 1st of " + morphCount + " different grammar for this word in this verse."; lexicon = $(_.template(self.templateDef)({ data: data.vocabInfos, brief_morph_info: morph_information, fontClass: step.util.ui.getFontForStrong(self.strong), @@ -215,8 +219,8 @@ var QuickLexicon = Backbone.View.extend({ strongsNotToDisplay = step.util.fixStrongNumForVocabInfo(strongsNotToDisplay, false); } var multipleStrongText = (typeof self.options.txtForMultiStrong === "string") ? self.options.txtForMultiStrong : ""; - var callBackCreateDefParams = [ self, strongsNotToDisplay, multipleStrongText ]; - var callBackLoadDefFromAPIParams = [ this.version, this.reference, strongsToUse, this.morph, step.userLanguageCode, self, strongsNotToDisplay, multipleStrongText, self.processQuickInfo ]; + var callBackCreateDefParams = [ self, strongsNotToDisplay, multipleStrongText, this.morphCount ]; + var callBackLoadDefFromAPIParams = [ this.version, this.reference, strongsToUse, this.morph, step.userLanguageCode, self, strongsNotToDisplay, multipleStrongText, self.processQuickInfo, this.morphCount ]; step.util.getVocabMorphInfoFromJson(strongsToUse, this.morph, this.version, self.processQuickInfo, callBackCreateDefParams, self.loadDefinitionFromRestAPI, callBackLoadDefFromAPIParams); }, @@ -230,12 +234,13 @@ var QuickLexicon = Backbone.View.extend({ var strongsNotToDisplay = paramArray[6]; var multipleStrongText = paramArray[7]; var callBackProcessQuickInfo = paramArray[8]; + var morphCount = paramArray[9]; $.getSafe(MODULE_GET_QUICK_INFO, [version, reference, strongsToUse, morph, userLanguageCode], function (data) { - callBackProcessQuickInfo(data, [ callerSelf, strongsNotToDisplay, multipleStrongText ]); + callBackProcessQuickInfo(data, [ callerSelf, strongsNotToDisplay, multipleStrongText, morphCount ]); }).error(function() { if (changeBaseURL()) $.getSafe(MODULE_GET_QUICK_INFO, [version, reference, strongsToUse, morph, userLanguageCode], function (data) { - callBackProcessQuickInfo(data, [ callerSelf, strongsNotToDisplay, multipleStrongText ]); + callBackProcessQuickInfo(data, [ callerSelf, strongsNotToDisplay, multipleStrongText, morphCount ]); }) }); return false; @@ -267,7 +272,17 @@ var QuickLexicon = Backbone.View.extend({ var self = this; if ((typeof augStrongNum === "string") && (augStrongNum !== "")) self.augStrong = augStrongNum; var quickDefPositionAtTop = true; // Try to show it on top first. Swap to bottom if it overlaps with current mouse/touch position. - if (step.touchDevice) + var versePopupLocations = $(".versePopup"); + var hasVersePopup = false; + for (var i = versePopupLocations.length -1; i >= 0; i --) { + var versePopupLoc = $(versePopupLocations[i]); + if ((typeof versePopupLoc.position === "function") && (typeof versePopupLoc.position().top === "number")) { + self.position = versePopupLoc.position().top; + hasVersePopup = true; + break; + } + } + if ((step.touchDevice) || (hasVersePopup)) // If versePopup is close to the top, the quick lexicon should go to the bottom. quickDefPositionAtTop = ((self.position / self.height) > 0.35 ); // 0.35 (touch screen) to put most of the quick lexicon on top if (quickDefPositionAtTop) lexicon.css({"top": "0", "bottom": "auto"}); diff --git a/step-web/src/main/webapp/js/backbone/views/view_sidebar.js b/step-web/src/main/webapp/js/backbone/views/view_sidebar.js index 0882b97fd0..c7fbc7dee0 100644 --- a/step-web/src/main/webapp/js/backbone/views/view_sidebar.js +++ b/step-web/src/main/webapp/js/backbone/views/view_sidebar.js @@ -61,6 +61,7 @@ var SidebarView = Backbone.View.extend({ var curMorphs = step.util.convertMorphOSHM2TOS( this.model.get("morph") ); if (curMorphs != undefined) lastMorphCode = curMorphs; + var morphCount = this.model.get("morphCount"); var ref = this.model.get("ref"); var version = this.model.get("version"); var allVersions = this.model.get("allVersions"); @@ -85,8 +86,8 @@ var SidebarView = Backbone.View.extend({ return; } strong = step.util.fixStrongNumForVocabInfo(strong, false); - var callBackCreateDefParams = [ ref, allVersions, variant ]; - var callBackLoadDefFromAPIParams = [ version, ref, strong, curMorphs, allVersions, variant, self.createDefinition]; + var callBackCreateDefParams = [ ref, allVersions, variant, morphCount ]; + var callBackLoadDefFromAPIParams = [ version, ref, strong, curMorphs, allVersions, variant, self.createDefinition, morphCount ]; step.util.getVocabMorphInfoFromJson(strong, curMorphs, version, self.createDefinition, callBackCreateDefParams, self.loadDefinitionFromRestAPI, callBackLoadDefFromAPIParams); } else if (this.model.get("mode") == 'analysis') { @@ -104,7 +105,7 @@ var SidebarView = Backbone.View.extend({ var C_numOfAnimationsAlreadyPerformedOnSamePage = 16; // TBRBMR if ((cv[C_numOfAnimationsAlreadyPerformedOnSamePage] !== undefined) && (cv[C_numOfAnimationsAlreadyPerformedOnSamePage] !== null)) cv[C_numOfAnimationsAlreadyPerformedOnSamePage] = 0; - return false; // Return false so this will not be called 2 times. + return false; // Return false so this will not be called 2 times.s }, loadDefinitionFromRestAPI: function (parameters) { var version = parameters[0]; @@ -114,13 +115,14 @@ var SidebarView = Backbone.View.extend({ var allVersions = parameters[4]; var variant = parameters[5]; var callBackCreateDef = parameters[6]; + var morphCount = parameters[7]; $.getSafe(MODULE_GET_INFO, [version, ref, strong, morph, step.userLanguageCode], function (data) { - callBackCreateDef(data, [ ref, allVersions, variant ]); + callBackCreateDef(data, [ ref, allVersions, variant, morphCount ]); //return false; }).error(function() { if (changeBaseURL()) $.getSafe(MODULE_GET_INFO, [version, ref, strong, morph, step.userLanguageCode], function (data) { - callBackCreateDef(data, [ ref, allVersions, variant ]); + callBackCreateDef(data, [ ref, allVersions, variant, morphCount ]); }) }); //return false; @@ -175,6 +177,7 @@ var SidebarView = Backbone.View.extend({ var ref = parameters[0]; var allVersions = parameters[1]; var variant = parameters[2]; + var morphCount = parameters[3]; var allMorphsForBackButton; var allStrongsForBackButton; if (!Array.isArray(variant)) variant = [""]; // Initialize in case it is not. @@ -283,7 +286,7 @@ var SidebarView = Backbone.View.extend({ panelBody.append("
Only in " + variant[0] + " manuscript
"); // need to handle multiple morphInfo (array) if (data.morphInfos.length > 0) { - this._createBriefMorphInfo(panelBody, data.morphInfos[0]); + this._createBriefMorphInfo(panelBody, data.morphInfos[0], morphCount, ref, data.vocabInfos[0].strongNumber); } this._createWordPanel(panelBody, data.vocabInfos[0], currentUserLang, allVersions, isOTorNT, headerType, data.morphInfos[0]); if (data.morphInfos.length > 0) { @@ -300,7 +303,7 @@ var SidebarView = Backbone.View.extend({ } else console.log("this.lexicon length is " + this.lexicon.length); - if ((typeof allStrongsForBackButton === "string") && (allStrongsForBackButton !== allStrongsForNextBackButton)) { + if ((typeof allStrongsForBackButton === "string") && (allStrongsForBackButton !== allStrongsForNextBackButton)) { var lexiconElement = $(this.lexicon[0]); lexiconElement.prepend(""); } @@ -932,7 +935,7 @@ var SidebarView = Backbone.View.extend({ require(['quick_lexicon'], function () { step.util.delay(function () { // do the quick lexicon - step.util.ui.displayNewQuickLexiconForVerseVocab(searchString, '', bibleVersion, step.util.activePassageId(), ev, ev.pageY, null, ""); + step.util.ui.displayNewQuickLexiconForVerseVocab(searchString, '', '', bibleVersion, step.util.activePassageId(), ev, ev.pageY, null, ""); }, MOUSE_PAUSE, 'show-quick-lexicon'); }); }, @@ -948,7 +951,7 @@ var SidebarView = Backbone.View.extend({ this._doSideNotes(panel, bibleVersion); }, // for one-line morphology - _createBriefMorphInfo: function (panel, info) { + _createBriefMorphInfo: function (panel, info, morphCount, ref, strongNum) { if (typeof info === "undefined") { panel.append("
"); return; @@ -968,7 +971,20 @@ var SidebarView = Backbone.View.extend({ this.renderBriefMorphItem(panel, info, "gender"); this.renderBriefMorphItem(panel, info, "state"); this.renderBriefMorphItem(panel, info, "suffix"); - panel.append(")
"); + panel.append(")"); + if (morphCount > 1) { + if ((typeof ref === "string") && (ref !== "") && (typeof strongNum === "string") && + ((strongNum.substring(0,1) === "G") || (strongNum.substring(0,1) === "H"))) { + panel.append(" - 1st of "); + var version = (strongNum.substring(0,1) === "G") ? "THGNT" : "OSHB"; + strongNum = step.util.fixStrongNumForVocabInfo(strongNum, true); + panel.append("" + morphCount + " different grammars"); + } + else + panel.append(" - 1st of " + morphCount + " different grammars"); + panel.append(" for this word in this verse."); + } + panel.append("
"); }, renderBriefMorphItem: function (panel, morphInfo, param) { if(morphInfo && param && morphInfo[param]) { diff --git a/step-web/src/main/webapp/js/search_selection.js b/step-web/src/main/webapp/js/search_selection.js index 9e15a018f5..a72f87f0a9 100644 --- a/step-web/src/main/webapp/js/search_selection.js +++ b/step-web/src/main/webapp/js/search_selection.js @@ -552,6 +552,7 @@ step.searchSelect = { else $("#searchButton").hide(); }, + goBackToPreviousPage: function() { $('#quickLexicon').remove(); $('#searchSelectError').text(""); @@ -619,6 +620,7 @@ step.searchSelect = { '' + + //'' + // '' + // using https://www.iconfinder.com/icons/326655/history_icon @@ -2098,7 +2100,7 @@ step.searchSelect = { require(['quick_lexicon'], function () { step.util.delay(function () { // do the quick lexicon - step.util.ui.displayNewQuickLexiconForVerseVocab(searchString, '', version, step.util.activePassageId(), ev, ev.pageY, null, multipleStrongText); + step.util.ui.displayNewQuickLexiconForVerseVocab(searchString, '', '', version, step.util.activePassageId(), ev, ev.pageY, null, multipleStrongText); }, MOUSE_PAUSE, 'show-quick-lexicon'); }); }, diff --git a/step-web/src/main/webapp/js/step.util.js b/step-web/src/main/webapp/js/step.util.js index effcbaab9a..eed618b84b 100644 --- a/step-web/src/main/webapp/js/step.util.js +++ b/step-web/src/main/webapp/js/step.util.js @@ -1377,7 +1377,7 @@ step.util = { * called when click on a piece of text. */ showDef: function (source, sourceVersion) { - var strong, morph, ref, version, allVersions, variant; + var strong, morph, ref, version, allVersions, variant, morphCount; if (typeof source === "string") { strong = source; if (typeof sourceVersion === "string") @@ -1388,6 +1388,7 @@ step.util = { morph = source.morph; version = source.version; variant = source.variant; + morphCount = source.morphCount; } else { var s = $(source); strong = s.attr("strong"); @@ -1402,13 +1403,13 @@ step.util = { if (version === '') version = firstVersion; allVersions = firstVersion + "," + step.passages.findWhere({ passageId: step.passage.getPassageId(s) }).get("extraVersions"); - step.historyStrong = []; step.historyMorph = []; + step.historyStrong = []; } variant = variant || ""; - step.util.ui.initSidebar('lexicon', { strong: strong, morph: morph, ref: ref, variant: variant, version: version, allVersions: allVersions }); + step.util.ui.initSidebar('lexicon', { strong: strong, morph: morph, ref: ref, variant: variant, version: version, allVersions: allVersions, morphCount: morphCount }); require(["sidebar"], function (module) { - step.util.ui.openStrongNumber(strong, morph, ref, version, allVersions, variant); + step.util.ui.openStrongNumber(strong, morph, ref, version, allVersions, variant, morphCount); }); }, initSidebar: function (mode, data) { @@ -1427,7 +1428,8 @@ step.util = { variant: data.variant, version: data.version, allVersions: data.allVersions, - mode: mode == null ? 'analysis' : mode + mode: mode == null ? 'analysis' : mode, + morphCount: data.morphCount }); new SidebarList().add(step.sidebar); new SidebarView({ @@ -1445,7 +1447,7 @@ step.util = { } }); }, - openStrongNumber: function (strong, morph, reference, version, allVersions, variant) { + openStrongNumber: function (strong, morph, reference, version, allVersions, variant, morphCount) { if (step.sidebar != null) { if (!step.touchDevice || step.touchWideDevice) step.sidebar.save({ @@ -1455,7 +1457,8 @@ step.util = { ref: reference, version: version, allVersions: allVersions, - variant: variant + variant: variant, + morphCount: morphCount }); else step.sidebar = null; @@ -1612,9 +1615,15 @@ step.util = { } }, - displayNewQuickLexiconForVerseVocab: function (strong, reference, version, passageId, touchEvent, pageYParam, hoverContext, txtForMultipleStrong) { + displayNewQuickLexiconForVerseVocab: function (strong, morph, reference, version, passageId, touchEvent, pageYParam, hoverContext, txtForMultipleStrong, morphCount) { var quickLexiconEnabled = step.passages.findWhere({ passageId: passageId}).get("isQuickLexicon"); var pageY = 0; + if (typeof morph === "string") + morph = morph.split("/")[0].replace("oshm:", "TOS:"); // If there are multiple morphs separated by /, only use the first one + else + morph = ""; + if ((strong.substring(0,1) === "H") && (morph.indexOf("TOS:") == -1)) + morph = "TOS:" + morph; if (typeof pageYParam === "number") pageY = pageYParam; else if ((event) && (typeof event.clientY === "number")) @@ -1624,7 +1633,7 @@ step.util = { require(['quick_lexicon'], function () { step.util.delay(function () { // do the quick lexicon - step.util.ui.displayNewQuickLexiconForVerseVocab(strong, reference, version, passageId, touchEvent, pageYParam, hoverContext, txtForMultipleStrong); + step.util.ui.displayNewQuickLexiconForVerseVocab(strong, morph, reference, version, passageId, touchEvent, pageYParam, hoverContext, txtForMultipleStrong, morphCount); }, MOUSE_PAUSE, 'show-quick-lexicon'); }); } @@ -1632,11 +1641,13 @@ step.util = { if (quickLexiconEnabled == true || quickLexiconEnabled == null) { new QuickLexicon({ strong: strong, + morph: morph, txtForMultiStrong: txtForMultipleStrong, version: version, reference: reference, target: hoverContext, position: pageY, touchEvent: touchEvent, height: $(window).height(), - passageId: passageId + passageId: passageId, + morphCount: morphCount }); } } @@ -1814,7 +1825,6 @@ step.util = { if (typeof verseNumTimer !== "undefined") // clear previous timeout clearTimeout(verseNumTimer); verseNumTimer = setTimeout(step.util.ui._addSubjectAndRelatedWordsPopup, 500, passageId, $(this), version, isSearch); - } }, function() { if (typeof verseNumTimer !== "undefined") @@ -1823,6 +1833,30 @@ step.util = { } }, + _showVerseWithStrongInBookPopup: function (bookName, dataStrong, dataOtherStrongs, evPageY, wordInfo, passageHtml) { + fetch("https://www.stepbible.org/rest/search/masterSearch/version=ESV|reference=" + bookName + + step.util._createStrongSearchArg(dataStrong, dataOtherStrongs) + + "/HNVUG//////en?lang=en") + .then(function(response) { + return response.json(); + }) + .then(function(data) { + step.util.ui.showListOfVersesInQLexArea(data, evPageY, wordInfo, passageHtml); + }); + }, + + _showVerseWithStrongInBiblePopup: function (dataStrong, dataOtherStrongs, evPageY, wordInfo, passageHtml) { + fetch("https://www.stepbible.org/rest/search/masterSearch/version=ESV|" + + step.util._createStrongSearchArg(dataStrong, dataOtherStrongs) + + "/HNVUG//////en?lang=en") + .then(function(response) { + return response.json(); + }) + .then(function(data) { + step.util.ui.showListOfVersesInQLexArea(data, evPageY, wordInfo, passageHtml); + }); + }, + _addSubjectAndRelatedWordsPopup: function (passageId, element, version, isSearch) { var reference = element.attr("name"); var self = this; @@ -1839,12 +1873,21 @@ step.util = { '' + '<% _.each(rows, function(row, i) { %>' + ' 0) { %>' + + 'data-morph="<%= row.morph %>" ' + + '<% if (row.morphCount > 1) { %>' + + 'data-morphcount="<%= row.morphCount %>" ' + + '<% } %>' + + '<% } %>' + + '<% if (row.strongData._detailLexicalTag !== "") { %>' + // add information to search all words in lexical group or detailLexicalTag 'data-otherstrongs="<%= row.strongData._detailLexicalTag %>"' + '<% } %>' + '>' + '"><%= row.strongData.gloss %> ' + - '(<%= row.strongData.stepTransliteration %> - <%= row.strongData.matchingForm %>)' + + '(<%= row.strongData.stepTransliteration %> - <%= row.strongData.matchingForm %>)' + + '' + '<%= sprintf("%d×", row.counts.book) %>' + '<%= sprintf("%d×", row.counts.bible) %>' + '<% }); %>' + @@ -1864,6 +1907,8 @@ step.util = { var currentLang = step.userLanguageCode.toLowerCase(); if (urlLang === "zh_tw") currentLang = "zh_tw"; else if (urlLang === "zh") currentLang = "zh"; + var allMorphs = []; + if (typeof data.allMorphsInVerse === "string") allMorphs = data.allMorphsInVerse.split(" "); for (var key in data.strongData) { var verseData = data.strongData[key]; for (var strong in verseData) { @@ -1874,9 +1919,24 @@ step.util = { else if ((currentLang === "zh") && (strongData._zh_Gloss)) strongData.gloss = strongData._zh_Gloss; else if ((currentLang === "zh_tw") && (strongData._zh_tw_Gloss)) strongData.gloss = strongData._zh_tw_Gloss; else if ((currentLang === "km") && (strongData._km_Gloss)) strongData.gloss = strongData._km_Gloss; + var morph = ""; + allMorphsOfThisWord = []; + var morphCount = 0; + for (var z = 0; z < allMorphs.length; z++) { + var twoParts = allMorphs[z].split("@"); + if ((strongData.strongNumber === twoParts[0]) && (typeof twoParts[1] === "string")) { + if (allMorphsOfThisWord.indexOf(twoParts[1].trim()) == -1) { + allMorphsOfThisWord.push(twoParts[1].trim()); + morphCount ++; + } + allMorphs[z] = ""; // don't want to process twice + } + } rows.push({ - strongData: strongData, - counts: counts + strongData: strongData, + counts: counts, + morph: allMorphsOfThisWord[0], + morphCount: morphCount }); } } @@ -1892,9 +1952,14 @@ step.util = { })); templatedTable.find(".definition").click(function () { + step.historyMorph = []; + step.historyStrong = []; var strongParameterForCall = $(this).parent().data("strong"); + var morphParameterForCall = step.util.convertMorphOSHM2TOS($(this).parent().data("morph")); + var morphCountParameterForCall = $(this).parent().data("morphcount"); var refParameterForCall = (strongParameterForCall.search(/^([GH]\d{4,5})[A-Za-z]$/) == 0) ? "" : reference; // if it is augmented Strong, don't include the reference - step.util.ui.showDef({strong: strongParameterForCall, ref: refParameterForCall, version: version }); + step.util.ui.showDef({strong: strongParameterForCall, ref: refParameterForCall, version: version, + morph: morphParameterForCall, morphCount: morphCountParameterForCall}); if (step.touchDevice && !step.touchWideDevice) $(".versePopup").hide(); }); @@ -1902,6 +1967,8 @@ step.util = { templatedTable.find(".definition").hover(function (ev) { // mouse pointer starts hover (enter) if (step.touchDevice || step.util.keepQuickLexiconOpen) return; var strongParameterForCall = $(this).parent().data("strong"); + var morphParameterForCall = step.util.convertMorphOSHM2TOS($(this).parent().data("morph")); + var morphCountParameterForCall = $(this).parent().data("morphcount"); var refParameterForCall = (strongParameterForCall.search(/^([GH]\d{4,5})[A-Za-z]$/) == 0) ? "" : reference; // if it is augmented Strong, don't include the reference step.passage.higlightStrongs({ passageId: undefined, @@ -1913,7 +1980,8 @@ step.util = { require(['quick_lexicon'], function () { step.util.delay(function () { // do the quick lexicon - step.util.ui.displayNewQuickLexiconForVerseVocab(strongParameterForCall, refParameterForCall, version, passageId, ev, ev.pageY, hoverContext); + step.util.ui.displayNewQuickLexiconForVerseVocab(strongParameterForCall, morphParameterForCall, refParameterForCall, version, + passageId, ev, ev.pageY, hoverContext, "", morphCountParameterForCall); }, MOUSE_PAUSE, 'show-quick-lexicon'); }); }, function () { // mouse pointer ends hover (leave) @@ -1940,17 +2008,13 @@ step.util = { if (step.touchDevice) return; var bookName = key.substring(0, key.indexOf('.')); var wordInfo = $($(this).parent().find('a')[0]).html(); - fetch("https://www.stepbible.org/rest/search/masterSearch/version=ESV|reference=" + bookName + - step.util._createStrongSearchArg($(this).parent().data("strong"), $(this).parent().data("otherstrongs")) + - "/HNVUG//////en?lang=en") - .then(function(response) { - return response.json(); - }) - .then(function(data) { - step.util.ui.showListOfVersesInQLexArea(data, ev.pageY, wordInfo, passageHtml); - }); + if (typeof bookCountTimer !== "undefined") // clear previous timeout + clearTimeout(bookCountTimer); + bookCountTimer = setTimeout(step.util.ui._showVerseWithStrongInBookPopup, 750, bookName, $(this).parent().data("strong"), $(this).parent().data("otherstrongs"), ev.pageY, wordInfo, passageHtml); }, function () { // mouse pointer ends hover (leave) if (step.touchDevice) return + if (typeof bookCountTimer !== "undefined") + clearTimeout(bookCountTimer); step.util.delay(undefined, 0, 'show-quick-lexicon'); if (!step.util.keepQuickLexiconOpen) { $("#quickLexicon").remove(); @@ -1970,17 +2034,13 @@ step.util = { templatedTable.find(".bibleCount").hover(function (ev) { if (step.touchDevice) return var wordInfo = $($(this).parent().find('a')[0]).html(); - fetch("https://www.stepbible.org/rest/search/masterSearch/version=ESV|" + - step.util._createStrongSearchArg($(this).parent().data("strong"), $(this).parent().data("otherstrongs")) + - "/HNVUG//////en?lang=en") - .then(function(response) { - return response.json(); - }) - .then(function(data) { - step.util.ui.showListOfVersesInQLexArea(data, ev.pageY, wordInfo, passageHtml); - }); + if (typeof bibleCountTimer !== "undefined") // clear previous timeout + clearTimeout(bibleCountTimer); + bibleCountTimer = setTimeout(step.util.ui._showVerseWithStrongInBiblePopup, 750, $(this).parent().data("strong"), $(this).parent().data("otherstrongs"), ev.pageY, wordInfo, passageHtml); }, function () { // mouse pointer ends hover (leave) if (step.touchDevice) return + if (typeof bibleCountTimer !== "undefined") + clearTimeout(bibleCountTimer); step.util.delay(undefined, 0, 'show-quick-lexicon'); if (!step.util.keepQuickLexiconOpen) { $("#quickLexicon").remove();