From f27e91cef8457f8ca4f14721a09ff58091cae771 Mon Sep 17 00:00:00 2001 From: Pucas01 <129163556+Pucas01@users.noreply.github.com> Date: Wed, 24 Jun 2026 23:26:23 +0200 Subject: [PATCH] Don't reload page when filtering projects by platform --- js/projects.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/projects.ts b/js/projects.ts index c76a7da..585d434 100644 --- a/js/projects.ts +++ b/js/projects.ts @@ -16,16 +16,19 @@ function updateProjectVisibility() { cb.checked = true; } } + const url = new URL(window.location.href); if (allSelected) { - if (url.searchParams.has('platform')) { - url.searchParams.delete('platform'); - window.location.replace(url); - } + url.searchParams.delete('platform'); } else { url.searchParams.set('platform', selectedPlatforms.join(',')); - window.location.replace(url.toString().replace(/%2C/g, ',')); } + history.replaceState(null, '', url.toString().replace(/%2C/g, ',')); + + document.querySelectorAll('article.project[data-platform]').forEach((el) => { + const p = el.dataset.platform ?? ''; + el.style.display = allSelected || selectedPlatforms.includes(p) ? '' : 'none'; + }); } document.querySelectorAll('.platform-item').forEach((item) => {