From f7871d61036c7f50185008820c67c147ce0ebc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Thu, 13 Feb 2020 23:53:14 +0100 Subject: [PATCH] Store search data in lowercase and compare in lowercase This way we can do the search case-sensitive after only converting the search term to lowercase. --- config/jsdoc/api/template/static/scripts/main.js | 7 ++++--- config/jsdoc/api/template/tmpl/navigation.tmpl | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/jsdoc/api/template/static/scripts/main.js b/config/jsdoc/api/template/static/scripts/main.js index d6c755b948..ca2ddb64b4 100644 --- a/config/jsdoc/api/template/static/scripts/main.js +++ b/config/jsdoc/api/template/static/scripts/main.js @@ -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').toLowerCase() === searchTerm.toLowerCase()) { + if ($matchedItem.data('shortname') === searchTerm) { weight++; } return weight; @@ -48,7 +48,7 @@ $(function () { .replace('module-', 'module:') .replace(/_/g, '/') .replace(/-/g, '~'); - var $currentItem = $('.navigation .item[data-name*="' + longname + '"]:eq(0)'); + var $currentItem = $('.navigation .item[data-name*="' + longname.toLowerCase() + '"]:eq(0)'); if ($currentItem.length) { $currentItem @@ -62,8 +62,9 @@ $(function () { var $el = $('.navigation'); if (searchTerm.length > 1) { + searchTerm = searchTerm.toLowerCase(); const regexp = constructRegex(searchTerm, function (searchTerm) { - return new RegExp(searchTerm, 'i'); + return new RegExp(searchTerm); }, allowRegex); $el.find('li, .member-list').hide(); diff --git a/config/jsdoc/api/template/tmpl/navigation.tmpl b/config/jsdoc/api/template/tmpl/navigation.tmpl index 074e99672f..90e7e854e2 100644 --- a/config/jsdoc/api/template/tmpl/navigation.tmpl +++ b/config/jsdoc/api/template/tmpl/navigation.tmpl @@ -15,11 +15,11 @@ function getItemCssClass(type) { } const printList = v => { ?> -
  • "> { const cls = v.stability && v.stability !== 'stable' ? ' class="unstable"' : ''; ?> -
  • >">