Only match the displayed name of items when searching

Currently the search term is matched against the longname of members.
Because of this most members are matched when searching for a
class / module and also searching for 'mod' matches everything as
all longnames start with 'module:'
This commit is contained in:
Maximilian Krög
2020-02-09 17:13:26 +01:00
parent d3b9b25429
commit 7640bcd163
2 changed files with 5 additions and 5 deletions

View File

@@ -29,7 +29,7 @@ $(function () {
var getSearchWeight = function (searchTerm, $matchedItem) {
let weight = 0;
// We could get smarter on the weight here
if ($matchedItem.data('shortname') === searchTerm) {
if ($matchedItem.data('name') === searchTerm) {
weight++;
}
return weight;
@@ -48,7 +48,7 @@ $(function () {
.replace('module-', 'module:')
.replace(/_/g, '/')
.replace(/-/g, '~');
var $currentItem = $('.navigation .item[data-name*="' + longname.toLowerCase() + '"]:eq(0)');
var $currentItem = $('.navigation .item[data-longname="' + longname + '"]:eq(0)');
if ($currentItem.length) {
$currentItem

View File

@@ -15,11 +15,11 @@ function getItemCssClass(type) {
}
const printList = v => { ?>
<li data-name="<?js= v.longname.toLowerCase() ?>"><?js
<li data-name="<?js= toShortName(v.name).toLowerCase() ?>"><?js
}
const printListWithStability = v => {
const cls = v.stability && v.stability !== 'stable' ? ' class="unstable"' : ''; ?>
<li data-name="<?js= v.longname.toLowerCase() ?>"<?js= cls ?>><?js
<li data-name="<?js= toShortName(v.name).toLowerCase() ?>"<?js= cls ?>><?js
}
function listContent(item, title, listItemPrinter) {
@@ -42,7 +42,7 @@ function listContent(item, title, listItemPrinter) {
</div>
<ul class="list"><?js
this.nav.forEach(function (item) { ?>
<li class="item" data-name="<?js= item.longname.toLowerCase() ?>" data-shortname="<?js= item.name.toLowerCase() ?>">
<li class="item" data-longname="<?js= item.longname ?>" data-name="<?js= item.name.toLowerCase() ?>">
<span class="title">
<span class="glyphicon <?js= getItemCssClass(item.type) ?> toggle"></span>
<?js= self.linkto(item.longname, item.prettyname) ?>