2   import { results_store, current_result_store } from '../lib/stores.js';
 
   3   import { formatLabel, detailsURL } from '../lib/helpers.js';
 
   5   import Welcome from './Welcome.svelte';
 
   6   import MapIcon from './MapIcon.svelte';
 
   8   export let reverse_search=false;
 
  14   results_store.subscribe(data => {
 
  15     if (!data) { return; }
 
  16     aSearchResults = data;
 
  18     current_result_store.set(aSearchResults[0]);
 
  21     let search_params = new URLSearchParams(window.location.search);
 
  24     // lonvia wrote: https://github.com/osm-search/nominatim-ui/issues/24
 
  25     // I would suggest to remove the guessing and always show the link. Nominatim only returns
 
  26     // one or two results when it believes the result to be a good enough match.
 
  27     // if (aResults.length >= 10) {
 
  28     var aExcludePlaceIds = [];
 
  29     if (search_params.has('exclude_place_ids')) {
 
  30       aExcludePlaceIds = search_params.get('exclude_place_ids').split(',');
 
  32     for (var i = 0; i < aResults.length; i += 1) {
 
  33       aExcludePlaceIds.push(aResults[i].place_id);
 
  35     var parsed_url = new URLSearchParams(window.location.search);
 
  36     parsed_url.set('exclude_place_ids', aExcludePlaceIds.join(','));
 
  37     sMoreURL = '?' + parsed_url.toString();
 
  40   function handleClick(e) {
 
  41     let result_el = e.target;
 
  42     if (! result_el.className.match('result') ){
 
  43       result_el = result_el.parentElement;
 
  45     let pos = Number(result_el.dataset.position);
 
  47     current_result_store.set(aSearchResults[pos]);
 
  53 {#if aSearchResults && aSearchResults.length > 0}
 
  54   <div id="searchresults">
 
  56     {#each aSearchResults as aResult, iResNum}
 
  57       <div class="result" class:highlight={iResNum === iHighlightNum} data-position="{iResNum}" on:click|stopPropagation={handleClick}>
 
  58         <div style="float:right">
 
  59           <MapIcon aPlace={aResult} />
 
  61         <span class="name">{aResult.display_name}</span>
 
  62         <span class="type">{formatLabel(aResult)}</span>
 
  63         <p class="coords">{aResult.lat},{aResult.lon}</p>  
 
  65         <a class="details btn btn-outline-secondary btn-sm" href="{detailsURL(aResult)}">details</a>
 
  69     {#if sMoreURL && !reverse_search}
 
  71         <a class="btn btn-primary" href="{sMoreURL}">
 
  72           Search for more results
 
  77 {:else if aSearchResults}
 
  79     <div id="intro" class="sidebar">Search for coordinates or click anywhere on the map.</div>
 
  81     <div class="noresults">No search results found</div>
 
  95     border: 2px solid #D7E7FF;
 
 101     background-color: #D9E7F7;
 
 102     border-color: #9DB9E4;
 
 104   .result.highlight .details {
 
 132   .btn-outline-secondary {
 
 133     background-color: white;
 
 136   .btn-outline-secondary:hover {