Blog overview

News & Views

Peter Schepers

Filter by topic
var BASE = "/en"; function getActiveCat() { var match = window.location.pathname.match(/\/tag\/([^\/]+)/); if (!match) return "all"; var slug = match[1]; for (var cat in KNOWN_TAGS) { if (KNOWN_TAGS[cat].indexOf(slug) !== -1) return cat; } return "all"; } var buttons = document.querySelectorAll(".iti-filter-btn"); var activeCat = getActiveCat(); buttons.forEach(function (btn) { var cat = btn.getAttribute("data-cat"); var active = (cat === activeCat); btn.classList.toggle("iti-active", active); btn.setAttribute("aria-pressed", active ? "true" : "false"); }); buttons.forEach(function (btn) { btn.addEventListener("click", function () { var cat = btn.getAttribute("data-cat"); buttons.forEach(function (b) { b.classList.remove("iti-active"); b.setAttribute("aria-pressed", "false"); }); btn.classList.add("iti-active"); btn.setAttribute("aria-pressed", "true"); if (cat === "all") { window.location.href = BASE; return; } window.location.href = BASE + "/tag/" + CATEGORY_TAG[cat]; }); }); })();