1// Country name to slug mapping - full list from original script.js 2export function countryNameToSlug(countryName) { 3 const nameToSlugMap = { 4 'Albania': 'albanija', 5 'Andorra': 'andora', 6 'Austria': 'austrija', 7 'Belgium': 'belgija', 8 'Bosnia and Herzegovina': 'bosna-i-hercegovina', 9 'Bulgaria': 'bugarska', 10 'Croatia': 'hrvatska', 11 'Cyprus': 'cipar', 12 'Czech Republic': 'ceska', 13 'Denmark': 'danaska', 14 'Estonia': 'estonija', 15 'Finland': 'finska', 16 'France': 'francuska', 17 'Germany': 'njemacka', 18 'Greece': 'grcka', 19 'Hungary': 'madarska', 20 'Iceland': 'island', 21 'Ireland': 'irska', 22 'Italy': 'italija', 23 'Kosovo': 'kosovo', 24 'Latvia': 'latvija', 25 'Liechtenstein': 'lihtenstajn', 26 'Lithuania': 'litva', 27 'Luxembourg': 'luksemburg', 28 'Malta': 'malta', 29 'Moldova': 'moldavija', 30 'Monaco': 'monako', 31 'Montenegro': 'crna-gora', 32 'Netherlands': 'nizozemska', 33 'North Macedonia': 'sjeverna-makedonija', 34 'Norway': 'norveska', 35 'Poland': 'poljska', 36 'Portugal': 'portugal', 37 'Romania': 'rumunjska', 38 'San Marino': 'san-marino', 39 'Serbia': 'srbija', 40 'Slovakia': 'slovacka', 41 'Slovenia': 'slovenija', 42 'Spain': 'spanjolska', 43 'Sweden': 'svedska', 44 'Switzerland': 'svicarska', 45 'Turkey': 'turska', 46 'Ukraine': 'ukrajina', 47 'United Kingdom': 'velika-britanija', 48 'Vatican City': 'vatikan' 49 }; 50 return nameToSlugMap[countryName] || null; 51} 52 53// Full coordinate conversion from original script 54export function convertCoordinates(lat, lng) { 55 return { 56 lat: parseFloat(lat.replace(',', '.')), 57 lng: parseFloat(lng.replace(',', '.')) 58 }; 59} 60 61// Full address formatting from original script 62export function formatAddress(ulica, kucniBroj, naselje, opcina, zupanija) { 63 let parts = []; 64 if (ulica) parts.push(ulica); 65 if (kucniBroj) parts.push(kucniBroj); 66 if (naselje) parts.push(naselje); 67 if (opcina && opcina !== naselje) parts.push(opcina); 68 if (zupanija) parts.push(zupanija); 69 return parts.join(', '); 70} 71// Loads the outline of a country by name from a standard GeoJSON source. 72// Returns a promise that resolves with { layer: GeoJSONLayer, feature: GeoJSONFeature } 73export function loadCountryOutline(countryName, color, sourceUrl = '/geojson/countries.geojson') { 74 return fetch(sourceUrl) 75 .then(response => { 76 if (!response.ok) { 77 throw new Error(`HTTP error! status: ${response.status}`); 78 } 79 return response.json(); 80 }) 81 .then(data => { 82 const countryFeature = data.features.find( 83 feature => feature.properties.name.toLowerCase() === countryName.toLowerCase() 84 ); 85 86 if (countryFeature) { 87 const layer = L.geoJSON(countryFeature, { 88 style: { 89 color: color, 90 weight: 2, 91 fillOpacity: 0 92 }, 93 interactive: false // Disable mouse interactions 94 }); 95 // Return both the layer and the feature data 96 return { layer, feature: countryFeature }; 97 } else { 98 // Throw specific error if country not found 99 throw new Error(`Country "${countryName}" not found in GeoJSON data.`); 100 } 101 }); 102}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.