2024-03-03 11:18:34 +01:00
|
|
|
export function initRepositorySearch() {
|
2024-12-11 09:29:04 +01:00
|
|
|
const repositorySearchForm = document.querySelector<HTMLFormElement>('#repo-search-form');
|
2024-03-03 11:18:34 +01:00
|
|
|
if (!repositorySearchForm) return;
|
|
|
|
|
2024-12-11 09:29:04 +01:00
|
|
|
repositorySearchForm.addEventListener('change', (e: Event & {target: HTMLFormElement}) => {
|
2024-03-03 11:18:34 +01:00
|
|
|
e.preventDefault();
|
|
|
|
|
2024-12-15 22:02:32 +01:00
|
|
|
const params = new URLSearchParams();
|
|
|
|
for (const [key, value] of new FormData(repositorySearchForm).entries()) {
|
|
|
|
params.set(key, value.toString());
|
|
|
|
}
|
2024-03-03 11:18:34 +01:00
|
|
|
if (e.target.name === 'clear-filter') {
|
|
|
|
params.delete('archived');
|
|
|
|
params.delete('fork');
|
|
|
|
params.delete('mirror');
|
|
|
|
params.delete('template');
|
|
|
|
params.delete('private');
|
|
|
|
}
|
|
|
|
|
|
|
|
params.delete('clear-filter');
|
|
|
|
window.location.search = params.toString();
|
|
|
|
});
|
|
|
|
}
|