-
Notifications
You must be signed in to change notification settings - Fork 128
feat(index): Added search bar for template filtering #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ jobs: | |
|
|
||
| strategy: | ||
| matrix: | ||
| node-version: [14.x] | ||
| node-version: [20.x] | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,15 @@ | |
| <section class="section"> | ||
| <div class="container"> | ||
| <h2 class="title is-2">Templates</h2> | ||
| <table class="table box versions"> | ||
|
|
||
| <!-- Search Bar --> | ||
| <div class="field"> | ||
| <div class="control"> | ||
| <input type="text" id="searchInput" class="input" placeholder="SEARCH FOR TEMPLATE" onkeyup="filterTable()"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @teja-pola if I am not wrong this is for searching templates, possible to make the id more related to that. |
||
| </div> | ||
| </div> | ||
|
|
||
| <table class="table box versions" id="templateTable"> | ||
| <thead> | ||
| <tr> | ||
| <th>Name</th> | ||
|
|
@@ -26,8 +34,8 @@ | |
| <th>Type</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {% for name, val in templateIndex |dictsort%} | ||
| <tbody id="tableBody"> | ||
| {% for name, val in templateIndex | dictsort %} | ||
| <tr> | ||
| <th> | ||
| <a href="{{name}}.html"> | ||
|
|
@@ -36,12 +44,19 @@ | |
| {% else %} | ||
| {{name}} | ||
| {% endif %} | ||
| <a> | ||
| </a> | ||
| </th> | ||
| <td>{{val.description}}</td> | ||
| <td>{{val.ciceroVersion}}</td> | ||
| <td>{% if val.type === 0 %}Contract{% else %}Clause{% endif %}</td> | ||
| </tr> | ||
| {% endfor %} | ||
|
|
||
| <!-- No Results Row (Hidden by Default) --> | ||
| <tr id="noResultsRow" style="display: none;"> | ||
| <td colspan="4" class="has-text-centered">No results found</td> | ||
| </tr> | ||
|
|
||
| </tbody> | ||
| <tfoot> | ||
| <tr> | ||
|
|
@@ -58,4 +73,32 @@ | |
| </div> | ||
| </section> | ||
|
|
||
| {% endblock %} | ||
| <!-- JavaScript for Search Functionality --> | ||
| <script> | ||
| function filterTable() { | ||
teja-pola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let input = document.getElementById("searchInput"); | ||
| let filter = input.value.toLowerCase(); | ||
| let table = document.getElementById("templateTable"); | ||
| let rows = table.getElementsByTagName("tr"); | ||
| let noResultsRow = document.getElementById("noResultsRow"); | ||
| let matchFound = false; | ||
|
|
||
| for (let i = 1; i < rows.length - 1; i++) { // Exclude the last row (noResultsRow) | ||
| let td = rows[i].getElementsByTagName("th")[0]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getElementsByTagName is not the most concise way to access the first element, possible to use What do you say? |
||
| if (td) { | ||
| let textValue = td.textContent || td.innerText; | ||
| if (textValue.toLowerCase().indexOf(filter) > -1) { | ||
| rows[i].style.display = ""; | ||
| matchFound = true; | ||
| } else { | ||
| rows[i].style.display = "none"; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Show "No results found" row if no matches are found | ||
| noResultsRow.style.display = matchFound ? "none" : ""; | ||
| } | ||
| </script> | ||
|
|
||
| {% endblock %} | ||
Uh oh!
There was an error while loading. Please reload this page.