Skip to content

Commit ee9ec44

Browse files
committed
simplify search form serialization
1 parent 24762db commit ee9ec44

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

ui/site/src/gameSearch.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
window.lichess.load.then(() => {
22

33
const form = document.querySelector('.search__form') as HTMLFormElement,
4-
$form = $(form),
5-
$usernames = $form.find(".usernames input"),
6-
$userRows = $form.find(".user-row"),
7-
$result = $(".search__result");
4+
$form = $(form),
5+
$usernames = $form.find(".usernames input"),
6+
$userRows = $form.find(".user-row"),
7+
$result = $(".search__result");
88

99
function getUsernames() {
1010
const us: string[] = [];
@@ -53,10 +53,9 @@ window.lichess.load.then(() => {
5353
$form.find(".opponent select").change(toggleAiLevel);
5454

5555
function serialize() {
56-
const params = new URLSearchParams(new FormData(form) as any),
57-
keys = Array.from(params.keys());
58-
for (let k of keys) {
59-
if (params.get(k) == '') params.delete(k);
56+
const params = new URLSearchParams();
57+
for (let [k, v] of new FormData(form).entries()) {
58+
if (v != '') params.set(k, v as any); // typescript wants v to be a File
6059
}
6160
return params.toString();
6261
}

0 commit comments

Comments
 (0)