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