mirror of
https://github.com/go-gitea/gitea
synced 2025-01-03 14:34:30 +00:00
c0e80dbe26
1. Enable [strictFunctionTypes](https://www.typescriptlang.org/tsconfig/#strictFunctionTypes) 2. Introduce `DOMEvent` helper type which sets `e.target`. Surely not totally correct with that `Partial` but seems to work. 3. Various type-related refactors, change objects in `eventsource.sharedworker.ts` to `Map`.
26 lines
807 B
TypeScript
26 lines
807 B
TypeScript
import type {DOMEvent} from '../utils/dom.ts';
|
|
|
|
export function initRepositorySearch() {
|
|
const repositorySearchForm = document.querySelector<HTMLFormElement>('#repo-search-form');
|
|
if (!repositorySearchForm) return;
|
|
|
|
repositorySearchForm.addEventListener('change', (e: DOMEvent<Event, HTMLInputElement>) => {
|
|
e.preventDefault();
|
|
|
|
const params = new URLSearchParams();
|
|
for (const [key, value] of new FormData(repositorySearchForm).entries()) {
|
|
params.set(key, value.toString());
|
|
}
|
|
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();
|
|
});
|
|
}
|