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();
|
2020-03-23 05:09:42 -04:00
|
|
|
const blobs = contentBody.querySelectorAll('.blob-result');
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|