Skip to content

Commit a8fd5f2

Browse files
committed
Add feature to filter easy, medium, and hard activities and resources
1 parent 1f0b920 commit a8fd5f2

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

_includes/filter-difficulty.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<p>
2+
You can filter the items on this page to show only
3+
<a href="#" onclick="filterCards('Easy')">Easy</a>,
4+
<a href="#" onclick="filterCards('Medium')">Medium</a>, or
5+
<a href="#" onclick="filterCards('Hard')">Hard</a> cards.
6+
If you want to, you can
7+
<a href="#" onclick="resetCards()">reset the cards</a> to
8+
show them all again.
9+
</p>

_includes/scripts.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,38 @@
3838
}
3939
</script>
4040

41+
<script type="text/javascript">
42+
if ("{{page.title}}" === "Activities" || "{{page.title}}" === "Resources") {
43+
allCards = $('div.align-items-stretch:has(span.badge)');
44+
45+
function resetCards() {
46+
$.each(allCards, function() {
47+
var card = $(this);
48+
if (!card.hasClass('d-flex')) {
49+
card.toggleClass('d-flex');
50+
}
51+
$(card).show();
52+
});
53+
}
54+
55+
function filterCards(filterText) {
56+
resetCards();
57+
filteredCards = $('div.align-items-stretch');
58+
59+
$.each(allCards, function() {
60+
var card = $(this);
61+
console.log(card);
62+
console.log(card.not(':has(span.badge:contains("' + filterText + '"))'));
63+
if (card.not(':has(span.badge:contains("' + filterText + '"))').length > 0) {
64+
card.toggleClass('d-flex');
65+
$(card).hide();
66+
}
67+
});
68+
}
69+
}
70+
</script>
71+
72+
4173
<!-- Placeholder for dynamic EventBrite integration script generation -->
4274
<script id="eventBriteWidgets" type="text/javascript">
4375
</script>

activities.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ <h1>{{page.title}}</h1>
2929
quite often we get people attending who are working their way through resources they've found elsewhere on
3030
the web. The following are just a few of the ones we see people on, along with some we recommend you try.
3131
</p>
32+
{% include filter-difficulty.html %}
3233
<p>
3334
Jump to: <a href="#activities-learning">Learning</a> | <a href="#activities-practice">Practice</a>
3435
</p>

resources.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ <h1>{{page.title}}</h1>
2727
On top of that, there are lots of places on the Internet which will do jobs that text editors just aren't built for.
2828
We've listed some of those too.
2929
</p>
30+
{% include filter-difficulty.html %}
3031
<p>
3132
Jump to:
3233
<a href="#resources-links">Useful Links</a> |

0 commit comments

Comments
 (0)