Clear answer when nothing is found
This commit is contained in:
parent
bd6256d8ee
commit
3311dfd997
1 changed files with 11 additions and 5 deletions
16
cherche.js
16
cherche.js
|
@ -227,6 +227,9 @@ function main() {
|
|||
//});
|
||||
|
||||
$( "#question" ).keyup(function (e) {
|
||||
if (e.key != "ArrowDown") {
|
||||
currentSelection = 0;
|
||||
}
|
||||
var str = removeDiacritics($( "#question" ).val());
|
||||
var cleanstr = str ? str.trim() : null;
|
||||
if (str == "" || str == null) {
|
||||
|
@ -234,16 +237,19 @@ function main() {
|
|||
$( "#answerTable" ).empty();
|
||||
return;
|
||||
}
|
||||
$( "#answerTable" ).empty().append(title);
|
||||
var ans = words.find({'Word': { '$contains': cleanstr }});
|
||||
|
||||
$( "#answerTable" ).empty();
|
||||
if (ans.length > 0) {
|
||||
if (e.key == "ArrowDown") {
|
||||
currentSelection = (currentSelection + 1) % Math.min(maxNbRes,ans.length);
|
||||
} else {
|
||||
currentSelection = 0;
|
||||
currentSelection =
|
||||
(currentSelection + 1) % Math.min(maxNbRes,ans.length);
|
||||
}
|
||||
$( "#proposition" ).empty().append(listMany(ans,currentSelection));
|
||||
$( "#answerTable" ).append(displayOne(ans[currentSelection]));
|
||||
$( "#answerTable" ).append(title+displayOne(ans[currentSelection]));
|
||||
} else {
|
||||
$( "#answerTable" ).empty();
|
||||
$( "#proposition" ).empty();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue