Skip to content

Commit

Permalink
Add JS clickable tab link functionality #1286
Browse files Browse the repository at this point in the history
Reference:

Signed-off-by: John M. Horan <johnmhoran@gmail.com>
  • Loading branch information
johnmhoran committed Aug 31, 2023
1 parent 2cb0e29 commit c08097a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions vulnerabilities/templates/vulnerability_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
{% if fixed_by_packages|length > 3 %}
<tr>
<td>
... see <i>Fixed by packages</i> tab for more
See <a href="#" onclick="goToTab('fixed-by')"><i>Fixed by packages</i></a> tab for more
</td>
</tr>
{% endif %}
Expand Down Expand Up @@ -167,7 +167,7 @@
{% if affected_packages|length > 3 %}
<tr>
<td>
... see <i>Affected packages</i> tab for more
See <a href="#" onclick="goToTab('affected-packages')"><i>Affected packages</i></a> tab for more
</td>
</tr>
{% endif %}
Expand Down Expand Up @@ -293,4 +293,21 @@

<script src="{% static 'js/main.js' %}" crossorigin="anonymous"></script>

<script>
function goToTab(tabName) {
const activeLink = document.querySelector('div.tabs.is-boxed li.is-active');
const activeTabContent = document.querySelector('div.tab-div.is-active');

activeLink.classList.remove('is-active');
activeTabContent.classList.remove('is-active');

const target_id = document.querySelector("[data-tab='" + tabName + "']");
const targetTabContent = document.querySelector("[data-content='" + tabName + "']");

target_id.classList.add('is-active');
targetTabContent.classList.add('is-active');
}
</script>


{% endblock %}

0 comments on commit c08097a

Please sign in to comment.