2 function handleFormSubmit(event) {
4 let form_el = event.target;
5 let val = form_el.querySelector('input[type=edit]').value;
6 let matches = val.match(/^\s*([NWR])(\d+)\s*$/i);
9 matches = val.match(/\/(relation|way|node)\/(\d+)\s*$/);
13 alert('invalid input');
17 form_el.querySelector('input[name=osmtype]').setAttribute('value', matches[1].charAt(0).toUpperCase());
18 form_el.querySelector('input[name=osmid]').setAttribute('value', matches[2]);
22 <div class="container" id="details-index-page">
24 <div class="col-md-12">
26 <h1>Show details for place</h1>
28 <div class="search-form">
29 <h4>Search by place id</h4>
31 <form class="form-inline" action="details.html">
33 class="form-control form-control-sm"
36 placeholder="12345" />
38 class="btn btn-primary btn-sm"
43 <div class="search-form">
44 <h4>Search by OSM type and OSM id</h4>
46 <form on:submit|preventDefault={handleFormSubmit}
47 id="form-by-type-and-id"
49 action="details.html">
51 class="form-control form-control-sm"
52 pattern="^[NWR][0-9]+$"
53 placeholder="N123 or W123 or R123" />
54 <input type="hidden" name="osmtype" />
55 <input type="hidden" name="osmid" />
56 <input type="submit" class="btn btn-primary btn-sm" value="Show" />
60 <div class="search-form">
61 <h4>Search by openstreetmap.org URL</h4>
63 <form on:submit|preventDefault={handleFormSubmit}
66 action="details.html">
68 class="form-control form-control-sm"
69 pattern=".*openstreetmap.*"
70 placeholder="https://www.openstreetmap.org/relation/123" />
71 <input type="hidden" name="osmtype" />
72 <input type="hidden" name="osmid" />
73 <input type="submit" class="btn btn-primary btn-sm" value="Show" />
89 .search-form .form-control{