layout | title | description | nav_exclude |
---|---|---|---|
page |
Course Calendar |
Listing of course modules and topics. |
true |
{% for module in site.modules %} {{ module }} {% endfor %}
<script> const LABELS = ['Lecture', 'Section', 'Posted', 'Due', 'Exam']; const modules = document.getElementsByClassName('module'); const moduleDls = [...modules].map(module => module.children[0]); const items = [...moduleDls].map(module => module.children); const ddApplyClasses = (children, classDecider) => { for (const child of children){ if (child.nodeName != 'DD') { continue; } child.className = ''; // necessary ... for some reason? const newClass = classDecider(child); child.className = newClass; } } const ddPredicateBuilder = (labels) => { return (ddNode) => { return labels // this toUpperCase is a hack to only catch the label .map(label => ddNode.innerText.includes(label.toUpperCase())) .some(v => v) } } const ddClassDecider = (predicate) => { return (ddNode) => predicate(ddNode) ? '' : 'd-none' } const rerenderItems = () => { const activeLabels = LABELS .map(label => document.getElementById(label).checked ? label : '') .filter(label => label !== ''); for (const item of items) { ddApplyClasses(item, ddClassDecider(ddPredicateBuilder(activeLabels))) } } const filterForm = document.getElementById('filter-form'); filterForm.addEventListener('change', rerenderItems); </script>