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