Welcome to mirror list, hosted at ThFree Co, Russian Federation.

highlight_blob_search_result.js « search « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 07967434f37ca3a98a0e6780868f14041cdbf7b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export default (search = '') => {
  const highlightLineClass = 'hll';
  const contentBody = document.getElementById('content-body');
  const searchTerm = search.toLowerCase();
  const blobs = contentBody.querySelectorAll('.js-blob-result');

  blobs.forEach((blob) => {
    const lines = blob.querySelectorAll('.line');
    lines.forEach((line) => {
      if (line.textContent.toLowerCase().includes(searchTerm)) {
        line.classList.add(highlightLineClass);
      }
    });
  });
};