2024-03-03 10:18:34 +00:00
|
|
|
export function initRepositorySearch() {
|
2024-12-11 08:29:04 +00:00
|
|
|
const repositorySearchForm = document.querySelector<HTMLFormElement>('#repo-search-form');
|
2024-03-03 10:18:34 +00:00
|
|
|
if (!repositorySearchForm) return;
|
|
|
|
|
2024-12-11 08:29:04 +00:00
|
|
|
repositorySearchForm.addEventListener('change', (e: Event & {target: HTMLFormElement}) => {
|
2024-03-03 10:18:34 +00:00
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
const formData = new FormData(repositorySearchForm);
|
|
|
|
const params = new URLSearchParams(formData);
|
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
}
|