2021-01-22 04:08:53 -05:00
|
|
|
export default (search = '') => {
|
2020-03-23 05:09:42 -04:00
|
|
|
const highlightLineClass = 'hll';
|
|
|
|
const contentBody = document.getElementById('content-body');
|
2021-01-22 04:08:53 -05:00
|
|
|
const searchTerm = search.toLowerCase();
|
2021-08-31 05:08:57 -04:00
|
|
|
const blobs = contentBody.querySelectorAll('.js-blob-result');
|
2020-03-23 05:09:42 -04:00
|
|
|
|
2020-12-23 19:10:25 -05:00
|
|
|
blobs.forEach((blob) => {
|
2020-03-23 05:09:42 -04:00
|
|
|
const lines = blob.querySelectorAll('.line');
|
2020-12-23 19:10:25 -05:00
|
|
|
lines.forEach((line) => {
|
2020-03-23 05:09:42 -04:00
|
|
|
if (line.textContent.toLowerCase().includes(searchTerm)) {
|
|
|
|
line.classList.add(highlightLineClass);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|