Conditional and case-insensitive search highlighting
This commit is contained in:
parent
c60456e113
commit
b418afafcb
|
@ -77,7 +77,7 @@ input[type=checkbox] {
|
||||||
}
|
}
|
||||||
|
|
||||||
#dictionaryContainer {
|
#dictionaryContainer {
|
||||||
margin: 15px 0 36px; /* bottom margin must clear footer */
|
margin: 15px 0 36px 15px; /* bottom margin must clear footer */
|
||||||
width: 50%;
|
width: 50%;
|
||||||
min-width: 350px;
|
min-width: 350px;
|
||||||
float: left;
|
float: left;
|
||||||
|
|
|
@ -269,9 +269,9 @@ function DictionaryEntry(itemIndex) {
|
||||||
var entryText = "<entry>";
|
var entryText = "<entry>";
|
||||||
|
|
||||||
var searchTerm = htmlEntities(document.getElementById("searchBox").value);
|
var searchTerm = htmlEntities(document.getElementById("searchBox").value);
|
||||||
var searchRegEx = new RegExp(searchTerm, "g");
|
var searchRegEx = new RegExp(searchTerm, "gi");
|
||||||
|
|
||||||
entryText += "<word>" + ((searchTerm != "") ? currentDictionary.words[itemIndex].name.replace(searchRegEx, "<searchTerm>" + searchTerm + "</searchterm>") : currentDictionary.words[itemIndex].name) + "</word>";
|
entryText += "<word>" + ((searchTerm != "" && document.getElementById("searchOptionWord").checked) ? currentDictionary.words[itemIndex].name.replace(searchRegEx, "<searchTerm>" + searchTerm + "</searchterm>") : currentDictionary.words[itemIndex].name) + "</word>";
|
||||||
|
|
||||||
if (currentDictionary.words[itemIndex].partOfSpeech != "") {
|
if (currentDictionary.words[itemIndex].partOfSpeech != "") {
|
||||||
entryText += " <partofspeech>" + currentDictionary.words[itemIndex].partOfSpeech + "</partofspeech>";
|
entryText += " <partofspeech>" + currentDictionary.words[itemIndex].partOfSpeech + "</partofspeech>";
|
||||||
|
@ -280,11 +280,11 @@ function DictionaryEntry(itemIndex) {
|
||||||
entryText += "<br>";
|
entryText += "<br>";
|
||||||
|
|
||||||
if (currentDictionary.words[itemIndex].simpleDefinition != "") {
|
if (currentDictionary.words[itemIndex].simpleDefinition != "") {
|
||||||
entryText += "<simpledefinition>" + ((searchTerm != "") ? currentDictionary.words[itemIndex].simpleDefinition.replace(searchRegEx, "<searchTerm>" + searchTerm + "</searchterm>") : currentDictionary.words[itemIndex].simpleDefinition) + "</simpledefinition>";
|
entryText += "<simpledefinition>" + ((searchTerm != "" && document.getElementById("searchOptionSimple").checked) ? currentDictionary.words[itemIndex].simpleDefinition.replace(searchRegEx, "<searchTerm>" + searchTerm + "</searchterm>") : currentDictionary.words[itemIndex].simpleDefinition) + "</simpledefinition>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentDictionary.words[itemIndex].longDefinition != "") {
|
if (currentDictionary.words[itemIndex].longDefinition != "") {
|
||||||
entryText += "<longdefinition>" + ((searchTerm != "") ? markdown.toHTML(htmlEntitiesParse(currentDictionary.words[itemIndex].longDefinition)).replace(searchRegEx, "<searchTerm>" + searchTerm + "</searchterm>") : markdown.toHTML(htmlEntitiesParse(currentDictionary.words[itemIndex].longDefinition))) + "</longdefinition>";
|
entryText += "<longdefinition>" + ((searchTerm != "" && document.getElementById("searchOptionLong").checked) ? markdown.toHTML(htmlEntitiesParse(currentDictionary.words[itemIndex].longDefinition)).replace(searchRegEx, "<searchTerm>" + searchTerm + "</searchterm>") : markdown.toHTML(htmlEntitiesParse(currentDictionary.words[itemIndex].longDefinition))) + "</longdefinition>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentDictionary.settings.isComplete) {
|
if (!currentDictionary.settings.isComplete) {
|
||||||
|
|
Loading…
Reference in New Issue