Skip to content

Commit 69b8151

Browse files
authored
Merge pull request #77 from econ-ark/master
Merge homepage link updates and material tag filter auto-population
2 parents 8dc2d3a + 4e419d4 commit 69b8151

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

_layouts/home.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ <h2 class="heading">REMARK</h2>
4040
</div>
4141
<p class="subtitle">R[eplications/eproductions] and Explorations Made using ARK</p>
4242
<div class="desc">
43-
<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>
43+
<p>A REMARK is an executable archive that reproduces its own results on any computer</p>
4444
</div>
45-
<p class="link"><a href="/materials/">REMARKs</a></p>
45+
<p class="link"><a href="/materials/?select=REMARK">REMARKs</a></p>
4646
</div>
4747

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

6060
</div>

_layouts/materials.html

+41
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,47 @@ <h2 class="title"><a href="{{ material.url }}">
166166
li.addEventListener('click', addTagToFilter);
167167
});
168168

169+
170+
// Get the already initialized Choices.js instance
171+
//const selectElement = document.getElementById('mySelect');
172+
//const choicesInstance = choices;
173+
174+
// Function to get the value from query string or anchor hash
175+
function getSelectionFromUrl() {
176+
const urlParams = new URLSearchParams(window.location.search);
177+
const hash = window.location.hash.substring(1);
178+
179+
// Check for query string parameter 'select' first
180+
if (urlParams.has('select')) {
181+
return urlParams.get('select');
182+
}
183+
// If not found, check for hash value
184+
else if (hash) {
185+
return hash;
186+
}
187+
return null;
188+
}
189+
190+
// Auto-select the option based on the URL
191+
function autoSelectOption() {
192+
const selection = getSelectionFromUrl();
193+
if (selection) {
194+
const option = choices.setChoiceByValue(selection);
195+
196+
let evt = document.createEvent("Event");
197+
evt.initEvent("change", true, true);
198+
tagSelect.dispatchEvent(evt);
199+
200+
// Check if the option exists
201+
if (!option) {
202+
console.warn(`Option with value "${selection}" not found.`);
203+
}
204+
}
205+
}
206+
207+
// Call the autoSelectOption function on page load
208+
autoSelectOption();
209+
169210
});
170211

171212
</script>

0 commit comments

Comments
 (0)