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 let osmtype_short = matches[1].charAt(0).toUpperCase();
18 form_el.querySelector('input[name=osmtype]').setAttribute('value', osmtype_short);
19 form_el.querySelector('input[name=osmid]').setAttribute('value', matches[2]);
23 <div class="container" id="details-index-page">
25 <div class="col-md-12">
27 <h1>Show details for place</h1>
29 <div class="search-form">
30 <h4>Search by place id</h4>
32 <form class="form-inline" action="details.html">
34 class="form-control form-control-sm"
37 placeholder="12345" />
39 class="btn btn-primary btn-sm"
44 <div class="search-form">
45 <h4>Search by OSM type and OSM id</h4>
47 <form on:submit|preventDefault={handleFormSubmit}
48 id="form-by-type-and-id"
50 action="details.html">
52 class="form-control form-control-sm"
53 pattern="^[NWR][0-9]+$"
54 placeholder="N123 or W123 or R123" />
55 <input type="hidden" name="osmtype" />
56 <input type="hidden" name="osmid" />
57 <input type="submit" class="btn btn-primary btn-sm" value="Show" />
61 <div class="search-form">
62 <h4>Search by openstreetmap.org URL</h4>
64 <form on:submit|preventDefault={handleFormSubmit}
67 action="details.html">
69 class="form-control form-control-sm"
70 pattern=".*openstreetmap.*"
71 placeholder="https://www.openstreetmap.org/relation/123" />
72 <input type="hidden" name="osmtype" />
73 <input type="hidden" name="osmid" />
74 <input type="submit" class="btn btn-primary btn-sm" value="Show" />
90 .search-form .form-control{