Skip to content
Snippets Groups Projects
Commit 97b11b9a authored by Jiří Setnička's avatar Jiří Setnička
Browse files

Zpracování skenů: Při opuštění autocomplete políčka bez vybrání buď match nebo vyprázdnění políčka

Doteď tam zůstala rozeditovaná hodnota bez jakékoliv indikace, jestli byla
vybrána a zpracována, nebo ne. Teď když se povede zadavateli napsat jméno
úlohy/soutěžícího (a přitom ho nepotvrdí ani enterem ani kliknutím), tak se
i tak vybere. V opačném případě se políčko vyprázdní.
parent f4d0cbd9
No related branches found
No related tags found
1 merge request!112Drobnosti ve skenech
......@@ -28,6 +28,9 @@ function autocomplete(inp, arr, callback=null, max=10) {
if (index != -1) {
listCount++;
b = document.createElement("DIV");
if (text.toUpperCase() == val.toUpperCase()) {
b.classList.add("exact");
}
b.innerHTML = text.substr(0, index) + "<strong>" + text.substr(index, val.length) + "</strong>" + text.substr(index + val.length)
b.innerHTML += "<input type='hidden' value='" + key + "'>";
b.innerHTML += "<input type='hidden' value='" + text + "'>";
......@@ -75,6 +78,32 @@ function autocomplete(inp, arr, callback=null, max=10) {
e.stopPropagation();
});
inp.addEventListener("blur", function(e) {
var found = false;
for (i = 0; i < arr.length; i++) {
var key, text;
if (Array.isArray(arr[i])) {
key = arr[i][0]; text = arr[i][1];
} else {
key = arr[i]; text = arr[i];
}
if (inp.value.toUpperCase() == text.toUpperCase()) {
found = true;
if (callback) {
callback(key);
}
break;
}
}
if (!found) {
inp.value = "";
if (callback) {
callback(null);
}
}
});
function addActive(x) {
if (!x) return false;
removeActive(x);
......
......@@ -454,6 +454,9 @@ div.message .msg-date {
background-color: #fff;
border-bottom: 1px solid #d4d4d4;
}
.autocomplete-items div.exact {
background-color: rgb(255, 255, 145);
}
.autocomplete-items div:hover {
background-color: #e9e9e9;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment