2 export let api_request_params = {};
4 function handleFormSubmit(event) {
6 let form_el = event.target;
7 let val = form_el.querySelector('input[type=edit]').value;
8 let matches = val.match(/^\s*([NWR])(\d+)\s*$/i);
11 matches = val.match(/\/(relation|way|node)\/(\d+)\s*$/);
15 alert('invalid input');
19 let osmtype_short = matches[1].charAt(0).toUpperCase();
20 form_el.querySelector('input[name=osmtype]').setAttribute('value', osmtype_short);
21 form_el.querySelector('input[name=osmid]').setAttribute('value', matches[2]);
26 <ul class="nav nav-tabs">
28 <a class="nav-link" data-toggle="tab" href="#by-osm-type-and-id" class:active={!api_request_params.place_id}>OSM type and OSM id</a>
31 <a class="nav-link" data-toggle="tab" href="#by-place-id" class:active={api_request_params.place_id}>Place id</a>
34 <a class="nav-link" data-toggle="tab" href="#by-osm-url">openstreetmap.org URL</a>
38 <div class="tab-content">
39 <div class="tab-pane" id="by-osm-type-and-id" role="tabpanel" class:active={!api_request_params.place_id}>
40 <form on:submit|preventDefault={handleFormSubmit}
41 id="form-by-type-and-id"
43 action="details.html">
45 class="form-control form-control-sm"
46 pattern="^[NWR][0-9]+$"
47 placeholder="e.g. N123 or W123 or R123"
48 value="{api_request_params.osmtype || ''}{api_request_params.osmid || ''}" />
49 <input type="hidden" name="osmtype" />
50 <input type="hidden" name="osmid" />
51 <input type="submit" class="btn btn-primary btn-sm" value="Show" />
55 <div class="tab-pane" id="by-place-id" role="tabpanel" class:active={api_request_params.place_id}>
56 <form class="form-inline" action="details.html">
58 class="form-control form-control-sm"
61 placeholder="e.g. 12345"
62 value="{api_request_params.place_id || ''}" />
64 class="btn btn-primary btn-sm"
69 <div class="tab-pane" id="by-osm-url" role="tabpanel">
70 <form on:submit|preventDefault={handleFormSubmit}
73 action="details.html">
75 class="form-control form-control-sm"
76 pattern=".*openstreetmap.*"
77 placeholder="e.g. https://www.openstreetmap.org/relation/123" />
78 <input type="hidden" name="osmtype" />
79 <input type="hidden" name="osmid" />
80 <input type="submit" class="btn btn-primary btn-sm" value="Show" />