Skip to content

Commit

Permalink
deploy: d6a442a
Browse files Browse the repository at this point in the history
  • Loading branch information
JoostBuitink committed Nov 13, 2024
1 parent 9e6bf02 commit 3995d56
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions quarto/_static/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ window.onload = function () {
// Create a new a element
const a = document.createElement('a');
a.className = 'dropdown-item';
a.href = item.url; // Use the 'url' property as the href
a.href = item.href; // Use the 'url' property as the href
a.textContent = item.name; // Use the 'name' property as the text

// Add the a element to the li
Expand Down Expand Up @@ -94,39 +94,44 @@ window.onload = function () {

// Get the clicked item's text
var itemText = this.textContent;
// var itemHref = this.getAttribute('href')
var itemHref = this.getAttribute('href')

// Loop through each dropdown item again to find a match in the current page's path
for (var j = 0; j < dropdownItems.length; j++) {
// Get the dropdown item's text
var dropdownText = dropdownItems[j].textContent;
console.log('Dropdown item:', dropdownText);

// Find the index of the dropdownText in the current page's path
var index = currentPagePath.indexOf(dropdownText);

// If the dropdownText is found in the current page's path
if (index !== -1) {
// Construct the new URL relative to the dropdownText and append the itemText
addElements = currentPagePath.slice(index + 1,)
relativePath = '../'.repeat(addElements.length)
var newUrl = relativePath + itemText + '/' + addElements.join('/')
console.log('Clicked item:', newUrl);

// Redirect to the new URL
checkPathExists(newUrl)
.then(exists => {
if (exists) {
window.location.href = newUrl;
} else {
console.log('Path does not exist, referring to home page');
window.location.href = relativePath + itemText + '/';
}
})

// Exit the loop
break;
}
window.location.href = itemHref;

// The code below is taken from Delft-FIAT, and is in place to switch
// to the same page but on a different version (if that exists). This
// is currently overruled with the line above this comment, which
// redirects to the new URL (home page).

// // Find the index of the dropdownText in the current page's path
// var index = currentPagePath.indexOf(dropdownText);
// // If the dropdownText is found in the current page's path
// if (index !== -1) {
// // Construct the new URL relative to the dropdownText and append the itemText
// addElements = currentPagePath.slice(index + 1,)
// var newUrl = itemHref + '/' + addElements.join('/')
// console.log('Clicked item:', newUrl);
// window.location.href = itemHref;
// // // Redirect to the new URL
// // checkPathExists(newUrl)
// // .then(exists => {
// // if (exists) {
// // window.location.href = newUrl;
// // } else {
// // console.log('Path does not exist, referring to home page');
// // window.location.href = itemHref;
// // }
// // })

// // Exit the loop
// break;
// }
}
});
}
Expand Down

0 comments on commit 3995d56

Please sign in to comment.