From 0d99e2dd1bfd15e406083f1e924429701d587140 Mon Sep 17 00:00:00 2001
From: Michele Casanova <68413054+m-casanova@users.noreply.github.com>
Date: Sun, 13 Oct 2024 08:46:44 +0200
Subject: [PATCH] Update script.js
---
assets/js/script.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/assets/js/script.js b/assets/js/script.js
index 91cca17..6e32feb 100644
--- a/assets/js/script.js
+++ b/assets/js/script.js
@@ -328,14 +328,14 @@ function impostaRicerca(category) {
if (risultati.length > 0) {
const suggestionsHtml = risultati.map(item => {
const description = category === 1 ? 'Comune' : dizTipo[item.t];
- return `
${item.n}
◼ ${item.c} ${description}
`;
+ return `${item.n}
◼ ${item.c} ${description}
`;
}).join('');
suggestionsBox.innerHTML = suggestionsHtml;
suggestionsBox.style.display = 'block';
suggestionsBox.querySelectorAll('div').forEach(div => {
div.addEventListener('click', function() {
- input.value = div.innerHTML.replace(/
.*?$/g, '');
+ input.value = div.dataset.name;
suggestionsBox.style.display = 'none';
aggiorna(category, div.dataset.id);
});
@@ -356,12 +356,12 @@ function impostaRicerca(category) {
} else if (e.key === 'ArrowUp') {
newActive = active ? active.previousElementSibling : suggestionsBox.lastElementChild;
} else if (e.key === 'Enter' && active) {
- input.value = active.innerHTML.replace(/
.*?$/g, '');
+ input.value = active.dataset.name;
suggestionsBox.style.display = 'none';
aggiorna(category, active.dataset.id);
} else if (e.key === 'Enter' && suggestionsBox.childElementCount === 1) {
const singleSuggestion = suggestionsBox.firstElementChild;
- input.value = singleSuggestion.innerHTML.replace(/
.*^$/, '');
+ input.value = singleSuggestion.dataset.name;
suggestionsBox.style.display = 'none';
aggiorna(category, singleSuggestion.dataset.id);
}