diff options
author | Ross Johnson <ross.johnson@homemail.com.au> | 2021-09-19 20:03:14 +1000 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@libreoffice.org> | 2021-09-20 16:15:36 +0200 |
commit | a03b2a3c515c5a15cbe22a24ee436fabd9ec272c (patch) | |
tree | 4e93b5a4b838c75a9c928d7d8261f7269e621afa /help3xsl/help.js | |
parent | f514d2c1eba9998ae67a9b8fd508441b1bebbf49 (diff) |
tdf#123506 - HTML Help pages - group search results under module headings
The "double entries" reported are because the search results
are never grouped according to module (CALC, WRITER, IMPRESS, etc).
Results are now grouped.
The HTML Help page search function uses a "fuzzy" algorithm to pick
matching results. This observation by the reporter is not a bug and
so the main Help page has been updated to include an explanation.
The main Help page has also been updated to draw attention to the
highlighing of the matching characters from the search term, to show
exactly how the match was made.
Change-Id: Ibdb9ac726b36b9dd6f605c854192ec644bfe09e1
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/122312
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Diffstat (limited to 'help3xsl/help.js')
-rw-r--r-- | help3xsl/help.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/help3xsl/help.js b/help3xsl/help.js index 48fdca8bb6..17d4909058 100644 --- a/help3xsl/help.js +++ b/help3xsl/help.js @@ -73,17 +73,29 @@ function fillIndex(indexEl, content, modules) { // filter the index list based on search field input function filter(indexList) { var results = null; + var group = []; var target = search.value.trim(); var filtered = ''; if (target.length < 1) { fillIndex(indexEl, fullLinks, modules); return; } + results = fuzzysort.go(target, bookmarks, {threshold: -15000, key:'text'}); + // tdf#123506 - Group the filtered list into module groups, keeping the ordering + modules.forEach(function(module) { + group[module] = ''; + }); results.forEach(function(result) { - filtered += '<a href="' + result.obj['url'] + '" class="' + result.obj['app'] + '">' + fuzzysort.highlight(result) + '</a>'; + group[result.obj['app']] += '<a href="' + result.obj['url'] + '" class="' + result.obj['app'] + '">' + fuzzysort.highlight(result) + '</a>'; }); + modules.forEach(function(module) { + if (group[module].length > 0) { + filtered += group[module]; + } + }); + fillIndex(indexList, filtered, modules); }; |