Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
davner committed Nov 21, 2023
1 parent a420438 commit 507cd6e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
{% for observation in observations %}
<tr>
<td>{{ observation.facility }}</td>
<td>{{ observation.observation_id }}</td>
{% if observation.url %}
<td><a href="{{ observation.url }}">{{ observation.observation_id }}</a></td>
{% else %}
<td>{{ observation.observation_id }}</td>
{% endif %}
<td>{{ observation.created }}</td>
<td>{{ observation.status }}</td>
<td>{{ observation.scheduled_start }}</td>
Expand Down
39 changes: 22 additions & 17 deletions tom_targets/templates/tom_targets/target_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@
{% endblock %}
{% block content %}
<script>
document.addEventListener("DOMContentLoaded", function() {
// Fetch the URL and look for the 'tab' query parameter.
const url = new URL(window.location.href);
const tabQuery = url.searchParams.get('tab');

// If a tab is specified in the URL, make it active.
if (tabQuery) {
const activeTab = '#' + tabQuery;
// Remove the 'tab' query parameter to avoid unwanted persistence across
// page reloads.
url.searchParams.delete('tab');
// Function to update the URL.
const updateUrlWithTab = (tabId) => {
const url = new URL(window.location.href);
url.searchParams.set('tab', tabId);
history.replaceState({}, document.title, url.toString());
};

document.addEventListener("DOMContentLoaded", function() {
// Listen for tab changes.
document.querySelectorAll('#tabs .nav-link').forEach(tab => {
tab.addEventListener('click', function() {
updateUrlWithTab(this.id.replace('-tab', ''));
});
});

// Show the active tab, if any.
const tabElement = document.querySelector(`a[href="${activeTab}"]`);
if (tabElement) {
tabElement.click();
// Initial tab selection from URL.
const tabQuery = new URL(window.location.href).searchParams.get('tab');
if (tabQuery) {
const activeTab = '#' + tabQuery;
const tabElement = document.querySelector(`a[href="${activeTab}"]`);
if (tabElement) {
tabElement.click();
}
}
}
});
});
</script>
<div class="row">
<div class="col-md-4">
Expand Down

0 comments on commit 507cd6e

Please sign in to comment.