mirror of
https://github.com/robbieandrew/robbieandrew.github.io.git
synced 2025-10-05 21:02:40 +02:00
testing
This commit is contained in:
@@ -729,7 +729,7 @@
|
||||
},
|
||||
"United Kingdom": {
|
||||
"isoCode":"GBR",
|
||||
"variants":["United Kingdom of Great Britain and Northern Ireland (the)","Royaume-Uni de Grande-Bretagne et d'Irlande du Nord (le)","Reino Unido de Gran Bretaña e Irlanda del Norte (el)","Соединенное Королевство Великобритании и Северной Ирландии","大不列颠及北爱尔兰联合王国","المملكة المتحدة لبريطانيا العظمى وأيرلندا الشمالية","the United Kingdom of Great Britain and Northern Ireland","le Royaume-Uni de Grande-Bretagne et d'Irlande du Nord","el Reino Unido de Gran Bretaña e Irlanda del Norte","Соединенное Королевство Великобритании и Северной Ирландии","大不列颠及北爱尔兰联合王国","المملكة المتحدة لبريطانيا العظمى وأيرلندا الشمالية"]
|
||||
"variants":["United Kingdom of Great Britain and Northern Ireland (the)","Royaume-Uni de Grande-Bretagne et d'Irlande du Nord (le)","Reino Unido de Gran Bretaña e Irlanda del Norte (el)","Соединенное Королевство Великобритании и Северной Ирландии","大不列颠及北爱尔兰联合王国","المملكة المتحدة لبريطانيا العظمى وأيرلندا الشمالية","the United Kingdom of Great Britain and Northern Ireland","le Royaume-Uni de Grande-Bretagne et d'Irlande du Nord","el Reino Unido de Gran Bretaña e Irlanda del Norte","Соединенное Королевство Великобритании и Северной Ирландии","大不列颠及北爱尔兰联合王国","المملكة المتحدة لبريطانيا العظمى وأيرلندا الشمالية","UK"]
|
||||
},
|
||||
"Tanzania": {
|
||||
"isoCode":"TZA",
|
||||
|
@@ -14,7 +14,7 @@ fetch('https://robbieandrew.github.io/data/countryData.json')
|
||||
([code, data]) => ({
|
||||
mainName: code,
|
||||
isoCode: data.isoCode,
|
||||
variants: [code, ...data.variants]
|
||||
variants: [code, data.isoCode, ...data.variants]
|
||||
})
|
||||
);
|
||||
// Initialize autocomplete after data is loaded
|
||||
@@ -160,8 +160,16 @@ function autocomplete(inp) {
|
||||
let currentFocus = -1;
|
||||
|
||||
const showResults = debounce((inputValue) => {
|
||||
const lowerInput = inputValue.toLowerCase();
|
||||
const listContainer = document.getElementById("autocomplete-list");
|
||||
|
||||
// Clear the list and hide it if the input is empty
|
||||
if (!inputValue.trim()) {
|
||||
listContainer.innerHTML = '';
|
||||
listContainer.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
const lowerInput = inputValue.toLowerCase();
|
||||
// Score and sort the matches
|
||||
const scoredMatches = flatCountryData
|
||||
.map(item => {
|
||||
@@ -176,11 +184,11 @@ function autocomplete(inp) {
|
||||
.sort((a, b) => b.score - a.score)
|
||||
.slice(0, MAX_RESULTS);
|
||||
|
||||
const listContainer = document.getElementById("autocomplete-list");
|
||||
listContainer.innerHTML = '';
|
||||
currentFocus = -1;
|
||||
|
||||
if (scoredMatches.length > 0) {
|
||||
listContainer.style.display = 'block';
|
||||
const fragment = document.createDocumentFragment();
|
||||
scoredMatches.forEach((item, index) => {
|
||||
const div = document.createElement("div");
|
||||
|
Reference in New Issue
Block a user