better error messages for invalid searches
This commit is contained in:
parent
88808ceb49
commit
10d97039f0
2 changed files with 15 additions and 6 deletions
|
@ -143,7 +143,7 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "row box-title justify-content-center" id = "summary">
|
||||
<div class = "row box-title justify-content-center" id = "summary" style = "color: red;">
|
||||
</div>
|
||||
<div class = "row" id = "search-results">
|
||||
|
||||
|
|
19
js/items.js
19
js/items.js
|
@ -144,30 +144,38 @@ function do_item_search() {
|
|||
}
|
||||
|
||||
// types
|
||||
let allTypes = true;
|
||||
let allTypes = true, noTypes = true;
|
||||
let typeQuery = "f:("
|
||||
for (const type of Object.keys(types)) {
|
||||
if (types[type]) {
|
||||
typeQuery += "type=\"" + type + "\"|";
|
||||
noTypes = false;
|
||||
} else {
|
||||
allTypes = false;
|
||||
}
|
||||
}
|
||||
if (!allTypes) {
|
||||
if (noTypes) {
|
||||
document.getElementById("summary").innerHTML = "Error: Cannot search without at least 1 type selected!";
|
||||
return;
|
||||
} else if (!allTypes) {
|
||||
queries.push(typeQuery.substring(0, typeQuery.length - 1) + ")");
|
||||
}
|
||||
|
||||
// rarities
|
||||
let allRarities = true;
|
||||
let allRarities = true, noRarities = true;
|
||||
let rarityQuery = "f:("
|
||||
for (const rarity of Object.keys(rarities)) {
|
||||
if (rarities[rarity]) {
|
||||
rarityQuery += "tiername=\"" + rarity + "\"|";
|
||||
noRarities = false;
|
||||
} else {
|
||||
allRarities = false;
|
||||
}
|
||||
}
|
||||
if (!allRarities) {
|
||||
if (noRarities) {
|
||||
document.getElementById("summary").innerHTML = "Error: Cannot search without at least 1 rarity selected!";
|
||||
return;
|
||||
} else if (!allRarities) {
|
||||
queries.push(rarityQuery.substring(0, rarityQuery.length - 1) + ")");
|
||||
}
|
||||
|
||||
|
@ -176,7 +184,8 @@ function do_item_search() {
|
|||
let min = parseInt(filter.min_elem.value);
|
||||
let max = parseInt(filter.max_elem.value);
|
||||
if (min > max) {
|
||||
continue; // invalid range
|
||||
document.getElementById("summary").innerHTML = "Error: The minimum of filter " + filter.input_elem.value + " (" + min + ") is greater than its maximum (" + max + ")!";
|
||||
return;
|
||||
}
|
||||
let zero_in_min_max = (isNaN(min) || min < 0) && (isNaN(max) || max > 0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue