Skip to content

Commit

Permalink
Fixed the baseUrl and updated the MP icon
Browse files Browse the repository at this point in the history
  • Loading branch information
natashapl committed Mar 29, 2024
1 parent 46aa845 commit 8f93d37
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions _includes/filterpanel.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h4 class="site-preview-heading">Resource Level</h4>
</aside>

<script>
const baseUrl = '{{ pathPrefix }}';
var baseUrl = '{{ pathPrefix }}';

document.addEventListener('DOMContentLoaded', function () {
// Function to toggle visibility of sections
Expand All @@ -67,13 +67,28 @@ <h4 class="site-preview-heading">Resource Level</h4>
}
}

//Build state url
function buildStateUrl(selectedState) {
var pathname = window.location.pathname;
// Split the pathname into segments
var segments = pathname.split('/');

// Extract the base path up to "/states/"
var stateIndex = segments.indexOf('states');
var basePath = segments.slice(0, stateIndex).join('/');

// Build the new URL
var newUrl = basePath + '/states/' + selectedState + '/';
return newUrl;
}

// Attach event listener directly to state dropdown
const stateSelect = document.getElementById('state');
if (stateSelect) {
stateSelect.addEventListener('change', function () {
var selectedState = this.value;
if (/^[A-Za-z]{2}$/.test(selectedState)) {
window.location.href = baseUrl + '/states/' + selectedState + '/';
window.location.href = buildStateUrl(selectedState);
} else {
console.error('Invalid state selected');
}
Expand Down
Binary file modified theme/img/states/MP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8f93d37

Please sign in to comment.