-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Documentation] Search bar for tables within docs (#646)
* input and output tables search bar js * Remove site folder from tracking and update .gitignore * new js function for search box and md file div updated * remove site folder * update search box and move js file * minor style changes and rounded box edge * remove extra javascripts * update border color box
- Loading branch information
1 parent
7b8b018
commit cd107b6
Showing
45 changed files
with
430 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
cromwell* | ||
_LAST | ||
2024* | ||
2024*site/ | ||
site/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
function addTableSearch() { | ||
// Select all containers with the class 'searchable-table' | ||
const containers = document.querySelectorAll('.searchable-table'); | ||
|
||
containers.forEach((container) => { | ||
// Find the table within this container | ||
const table = container.querySelector('table'); | ||
|
||
if (table) { | ||
// Ensure we don't add multiple search boxes | ||
if (!container.querySelector('input[type="search"]')) { | ||
// Create the search input element | ||
const searchInput = document.createElement("input"); | ||
searchInput.setAttribute("type", "search"); | ||
searchInput.setAttribute("placeholder", "Search table..."); | ||
searchInput.classList.add('table-search-input'); | ||
searchInput.style.marginBottom = "10px"; | ||
searchInput.style.display = "block"; | ||
|
||
// Insert the search input before the table | ||
container.insertBefore(searchInput, container.firstChild); | ||
|
||
// Add event listener for table search | ||
searchInput.addEventListener("input", function () { | ||
const filter = searchInput.value.toUpperCase(); | ||
const rows = table.getElementsByTagName("tr"); | ||
|
||
for (let i = 1; i < rows.length; i++) { // Skip header row | ||
const cells = rows[i].getElementsByTagName("td"); | ||
let match = false; | ||
|
||
for (let j = 0; j < cells.length; j++) { | ||
if (cells[j].innerText.toUpperCase().includes(filter)) { | ||
match = true; | ||
break; | ||
} | ||
} | ||
|
||
rows[i].style.display = match ? "" : "none"; | ||
} | ||
}); | ||
} | ||
} else { | ||
console.log('Table not found within container.'); | ||
} | ||
}); | ||
} | ||
|
||
// Run on page load | ||
addTableSearch(); | ||
|
||
// Reapply search bar on page change | ||
function observeDOMChanges() { | ||
const targetNode = document.querySelector('body'); | ||
const config = { childList: true, subtree: true }; | ||
|
||
const observer = new MutationObserver(() => { | ||
addTableSearch(); | ||
}); | ||
|
||
observer.observe(targetNode, config); | ||
} | ||
|
||
observeDOMChanges(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.