From a03b2a3c515c5a15cbe22a24ee436fabd9ec272c Mon Sep 17 00:00:00 2001 From: Ross Johnson Date: Sun, 19 Sep 2021 20:03:14 +1000 Subject: 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 --- help3xsl/help.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'help3xsl/help.js') 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 += '' + fuzzysort.highlight(result) + ''; + group[result.obj['app']] += '' + fuzzysort.highlight(result) + ''; }); + modules.forEach(function(module) { + if (group[module].length > 0) { + filtered += group[module]; + } + }); + fillIndex(indexList, filtered, modules); }; -- cgit