Skip to content

Commit

Permalink
Merge pull request #77 from econ-ark/master
Browse files Browse the repository at this point in the history
Merge homepage link updates and material tag filter auto-population
  • Loading branch information
DrDrij authored Oct 8, 2024
2 parents 8dc2d3a + 4e419d4 commit 69b8151
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
6 changes: 3 additions & 3 deletions _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ <h2 class="heading">REMARK</h2>
</div>
<p class="subtitle">R[eplications/eproductions] and Explorations Made using ARK</p>
<div class="desc">
<p>A <a href="https://github.com/econ-ark/REMARK">REMARK</a> is an executable archive that reproduces its own results on any computer using <a href="https://en.wikipedia.org/wiki/Docker_software">docker</a></p>
<p>A REMARK is an executable archive that reproduces its own results on any computer</p>
</div>
<p class="link"><a href="/materials/">REMARKs</a></p>
<p class="link"><a href="/materials/?select=REMARK">REMARKs</a></p>
</div>

<div class="part col-md-4 px-5 my-5">
Expand All @@ -54,7 +54,7 @@ <h2 class="heading">OTHER</h2>
<div class="desc">
<p>View the complete collection of our tools, materials, demonstrations, tutorials, blogs, assignments, documentation, and teaching</p>
</div>
<p class="link"><a href="https://github.com/econ-ark/DemARK">DemARK</a></p>
<p class="link"><a href="/materials/?select=DemARK">DemARK</a></p>
</div>

</div>
Expand Down
41 changes: 41 additions & 0 deletions _layouts/materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,47 @@ <h2 class="title"><a href="{{ material.url }}">
li.addEventListener('click', addTagToFilter);
});


// Get the already initialized Choices.js instance
//const selectElement = document.getElementById('mySelect');
//const choicesInstance = choices;

// Function to get the value from query string or anchor hash
function getSelectionFromUrl() {
const urlParams = new URLSearchParams(window.location.search);
const hash = window.location.hash.substring(1);

// Check for query string parameter 'select' first
if (urlParams.has('select')) {
return urlParams.get('select');
}
// If not found, check for hash value
else if (hash) {
return hash;
}
return null;
}

// Auto-select the option based on the URL
function autoSelectOption() {
const selection = getSelectionFromUrl();
if (selection) {
const option = choices.setChoiceByValue(selection);

let evt = document.createEvent("Event");
evt.initEvent("change", true, true);
tagSelect.dispatchEvent(evt);

// Check if the option exists
if (!option) {
console.warn(`Option with value "${selection}" not found.`);
}
}
}

// Call the autoSelectOption function on page load
autoSelectOption();

});

</script>

0 comments on commit 69b8151

Please sign in to comment.