This commit is contained in:
REJack 2020-12-03 11:03:10 +01:00
commit bfc26debdc
2 changed files with 22 additions and 19 deletions

View file

@ -101,7 +101,7 @@ class SidebarSearch {
this._addNotFound() this._addNotFound()
} else { } else {
endResults.each((i, result) => { endResults.each((i, result) => {
$(SELECTOR_SEARCH_RESULTS_GROUP).append(this._renderItem(escape(result.name), escape(result.link), escape(result.path))) $(SELECTOR_SEARCH_RESULTS_GROUP).append(this._renderItem(escape(result.name), escape(result.link), result.path))
}) })
} }
@ -160,6 +160,7 @@ class SidebarSearch {
_renderItem(name, link, path) { _renderItem(name, link, path) {
path = path.join(` ${this.options.arrowSign} `) path = path.join(` ${this.options.arrowSign} `)
name = unescape(name)
if (this.options.highlightName || this.options.highlightPath) { if (this.options.highlightName || this.options.highlightPath) {
const searchValue = $(SELECTOR_SEARCH_INPUT).val().toLowerCase() const searchValue = $(SELECTOR_SEARCH_INPUT).val().toLowerCase()
@ -169,7 +170,7 @@ class SidebarSearch {
name = name.replace( name = name.replace(
regExp, regExp,
str => { str => {
return `<b class="${this.options.highlightClass}">${str}</b>` return `<strong class="${this.options.highlightClass}">${str}</strong>`
} }
) )
} }
@ -178,20 +179,26 @@ class SidebarSearch {
path = path.replace( path = path.replace(
regExp, regExp,
str => { str => {
return `<b class="${this.options.highlightClass}">${str}</b>` return `<strong class="${this.options.highlightClass}">${str}</strong>`
} }
) )
} }
} }
return `<a href="${link}" class="list-group-item"> const groupItemElement = $('<a/>', {
<div class="search-title"> href: link,
${name} class: 'list-group-item'
</div> })
<div class="search-path"> const searchTitleElement = $('<div/>', {
${path} class: 'search-title'
</div> }).html(name)
</a>` const searchPathElement = $('<div/>', {
class: 'search-path'
}).html(path)
groupItemElement.append(searchTitleElement).append(searchPathElement)
return groupItemElement
} }
_addNotFound() { _addNotFound() {
@ -243,9 +250,7 @@ $(document).on('keyup', SELECTOR_SEARCH_INPUT, event => {
return return
} }
let timer = 0 setTimeout(() => {
clearTimeout(timer)
timer = setTimeout(() => {
SidebarSearch._jQueryInterface.call($(SELECTOR_DATA_WIDGET), 'search') SidebarSearch._jQueryInterface.call($(SELECTOR_DATA_WIDGET), 'search')
}, 100) }, 100)
}) })

View file

@ -166,7 +166,7 @@ $(function () {
// This will get the first returned node in the jQuery collection. // This will get the first returned node in the jQuery collection.
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
var salesChart = new Chart(salesChartCanvas, { var salesChart = new Chart(salesChartCanvas, { // lgtm[js/unused-local-variable]
type: 'line', type: 'line',
data: salesChartData, data: salesChartData,
options: salesChartOptions options: salesChartOptions
@ -197,7 +197,7 @@ $(function () {
// Create pie or douhnut chart // Create pie or douhnut chart
// You can switch between pie and douhnut using the method below. // You can switch between pie and douhnut using the method below.
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
var pieChart = new Chart(pieChartCanvas, { var pieChart = new Chart(pieChartCanvas, { // lgtm[js/unused-local-variable]
type: 'doughnut', type: 'doughnut',
data: pieData, data: pieData,
options: pieOptions options: pieOptions
@ -259,11 +259,9 @@ $(function () {
// This will get the first returned node in the jQuery collection. // This will get the first returned node in the jQuery collection.
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
var salesGraphChart = new Chart(salesGraphChartCanvas, { var salesGraphChart = new Chart(salesGraphChartCanvas, { // lgtm[js/unused-local-variable]
type: 'line', type: 'line',
data: salesGraphChartData, data: salesGraphChartData,
options: salesGraphChartOptions options: salesGraphChartOptions
}) })
}) })
// lgtm [js/unused-local-variable]