X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/76e3136f32e35ded2caf989b0bf699de64798921..71b9066d9eed97aee7eff27a25d5c317b6f89595:/src/components/UrlSubmitForm.svelte

diff --git a/src/components/UrlSubmitForm.svelte b/src/components/UrlSubmitForm.svelte
index f902f70..019fa8c 100644
--- a/src/components/UrlSubmitForm.svelte
+++ b/src/components/UrlSubmitForm.svelte
@@ -1,18 +1,24 @@
 <script>
-  import { serialize_form, clean_up_url_parameters } from '../lib/api_utils.js';
   import { refresh_page } from '../lib/stores.js';
 
-  function handleSubmit(event) {
-    event.preventDefault();
+  export let page;
 
-    var target_url = serialize_form(event.target);
-    target_url = clean_up_url_parameters(target_url);
+  function serialize_form(form) {
+    var params = new URLSearchParams();
 
-    window.history.pushState({}, '', '?' + target_url);
-    refresh_page();
+    Array.prototype.slice.call(form.elements).forEach(function (field) {
+      if (!field.name || field.disabled || ['submit', 'button'].indexOf(field.type) > -1) return;
+
+      if (['checkbox', 'radio'].indexOf(field.type) > -1 && !field.checked) return;
+      if (typeof field.value === 'undefined' || field.value === '') return;
+
+      params.set(field.name, field.value);
+    });
+
+    return params;
   }
 </script>
 
-<form on:submit={handleSubmit} class="form-inline" role="search" accept-charset="UTF-8" action="">
-    <slot></slot>
+<form on:submit|preventDefault={(e) => refresh_page(page, serialize_form(e.target))} class="form-inline" role="search" accept-charset="UTF-8" action="">
+  <slot></slot>
 </form>
