Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/chipzoller/hugo-clarity.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Boothe <git@rootwork.org>2022-06-16 03:37:29 +0300
committerIvan Boothe <git@rootwork.org>2022-06-16 03:37:29 +0300
commit1588c6f48f25220a30641bf660a91a0c7ff170b7 (patch)
tree36db7bdbada6b645f9dff1e0f5a7a430f22da74b
parentee188c3417982c04e1f75a8e4919f0192a0f020a (diff)
improved namingmark-mark-mark
Signed-off-by: Ivan Boothe <git@rootwork.org>
-rw-r--r--assets/js/functions.js1
-rw-r--r--assets/js/search.js12
2 files changed, 6 insertions, 7 deletions
diff --git a/assets/js/functions.js b/assets/js/functions.js
index 7271fae..0485b8e 100644
--- a/assets/js/functions.js
+++ b/assets/js/functions.js
@@ -192,7 +192,6 @@ function wrapText(text, context, wrapper = 'mark') {
let close = `</${wrapper}>`;
let escapedOpen = `%3C${wrapper}%3E`;
let escapedClose = `%3C/${wrapper}%3E`;
-
function wrap(context) {
let c = context.innerHTML;
let pattern = new RegExp(text, "gi");
diff --git a/assets/js/search.js b/assets/js/search.js
index deeaedb..06f4fdb 100644
--- a/assets/js/search.js
+++ b/assets/js/search.js
@@ -195,7 +195,7 @@ function initializeSearch(index) {
searchPageElement ? false : liveSearch();
passiveSearch();
- highlightSearch(findQuery(), '.post_body', 'mark', 'search-term');
+ highlightSearchTerms(findQuery(), '.post_body', 'mark', 'search-term');
onEscape(clearSearchResults);
@@ -208,14 +208,14 @@ function initializeSearch(index) {
});
}
-function highlightSearch(search, context, wrapper = 'mark', cssClass = '') {
- let container = document.querySelector(context);
+function highlightSearchTerms(search, context, wrapper = 'mark', cssClass = '') {
+ let container = elem(context);
let reg = new RegExp("(" + search + ")", "gi");
- function highlightSearchInNode(parentNode, search) {
+ function searchInNode(parentNode, search) {
forEach(parentNode, function (node) {
if (node.nodeType === 1) {
- highlightSearchInNode(node, search);
+ searchInNode(node, search);
} else if (
node.nodeType === 3 &&
reg.test(node.nodeValue)
@@ -229,7 +229,7 @@ function highlightSearch(search, context, wrapper = 'mark', cssClass = '') {
});
};
- highlightSearchInNode(container, search);
+ searchInNode(container, search);
}
window.addEventListener('load', function() {