From 88808ceb49430cb2d911faabae3a0523e4677fc2 Mon Sep 17 00:00:00 2001 From: fin444 Date: Tue, 13 Sep 2022 14:20:20 -0400 Subject: [PATCH 1/4] atlas categories default to none selected --- items/index.html | 24 ++++++++++++------------ js/items.js | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/items/index.html b/items/index.html index 6503497..4c30a96 100644 --- a/items/index.html +++ b/items/index.html @@ -95,18 +95,18 @@
Type: All   None
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+

diff --git a/js/items.js b/js/items.js index c26ad80..4f78a0a 100644 --- a/js/items.js +++ b/js/items.js @@ -108,7 +108,7 @@ for (let x in special_mappings) { let item_categories = ["armor", "accessory", "weapon"]; -const types = {bow: true, spear: true, wand: true, dagger: true, relik: true, helmet: true, chestplate: true, leggings: true, boots: true, ring: true, bracelet: true, necklace: true}; +const types = {bow: false, spear: false, wand: false, dagger: false, relik: false, helmet: false, chestplate: false, leggings: false, boots: false, ring: false, bracelet: false, necklace: false}; const rarities = {normal: true, unique: true, set: true, rare: true, legendary: true, fabled: true, mythic: true}; const filters = []; let filter_id_counter = 0; From 10d97039f0b02a8f40515052738eaf6498b803f5 Mon Sep 17 00:00:00 2001 From: fin444 Date: Tue, 13 Sep 2022 14:26:46 -0400 Subject: [PATCH 2/4] better error messages for invalid searches --- items/index.html | 2 +- js/items.js | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/items/index.html b/items/index.html index 4c30a96..808711d 100644 --- a/items/index.html +++ b/items/index.html @@ -143,7 +143,7 @@ -
+
diff --git a/js/items.js b/js/items.js index 4f78a0a..21e20f4 100644 --- a/js/items.js +++ b/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); From c85cd3cb5e7c819b457c9ab27a000d3a43fd7ccc Mon Sep 17 00:00:00 2001 From: fin444 Date: Tue, 13 Sep 2022 14:50:00 -0400 Subject: [PATCH 3/4] delete atlas filters --- css/items.css | 4 ++++ js/items.js | 7 +++++++ media/icons/trash.svg | 7 +++++++ 3 files changed, 18 insertions(+) create mode 100644 media/icons/trash.svg diff --git a/css/items.css b/css/items.css index 6535941..b39a02b 100644 --- a/css/items.css +++ b/css/items.css @@ -89,6 +89,10 @@ input.min-max-input { display: inline-block; } +.delete-filter { + cursor: pointer; +} + #filter-container > div > div > * { margin: 0 2px; } diff --git a/js/items.js b/js/items.js index 21e20f4..2253928 100644 --- a/js/items.js +++ b/js/items.js @@ -348,6 +348,13 @@ function create_filter() { col.appendChild(max); data.max_elem = max; + let trash = make_elem("img", ["delete-filter"], {src: "../media/icons/trash.svg"}); + trash.addEventListener("click", function() { + filters.splice(Array.from(row.parentElement.children).indexOf(row) - 1, 1); + row.remove(); + }); + col.appendChild(trash); + document.getElementById("filter-container").insertBefore(row, document.getElementById("add-filter").parentElement); filters.push(data); diff --git a/media/icons/trash.svg b/media/icons/trash.svg new file mode 100644 index 0000000..f188f94 --- /dev/null +++ b/media/icons/trash.svg @@ -0,0 +1,7 @@ + + + + + + + From ec8e0e7003f7beae4f0af544db45714d72b5c40a Mon Sep 17 00:00:00 2001 From: fin444 Date: Tue, 13 Sep 2022 15:11:14 -0400 Subject: [PATCH 4/4] exclude filters from search, improve atlas error display --- css/items.css | 2 +- items/index.html | 23 +++++++++++----- js/items.js | 68 ++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 75 insertions(+), 18 deletions(-) diff --git a/css/items.css b/css/items.css index b39a02b..862265c 100644 --- a/css/items.css +++ b/css/items.css @@ -93,7 +93,7 @@ input.min-max-input { cursor: pointer; } -#filter-container > div > div > * { +#filter-container > div > div > *, #exclude-container > div > div > * { margin: 0 2px; } diff --git a/items/index.html b/items/index.html index 808711d..9a713b9 100644 --- a/items/index.html +++ b/items/index.html @@ -122,11 +122,22 @@
-
-
Filters:
-
-
- + Add Filter +
+
+
Filters:
+
+
+ + Add Filter +
+
+
+
+
+
Excluded Filters:
+
+
+ + Add Excluded Filter +
@@ -143,7 +154,7 @@
-
+
diff --git a/js/items.js b/js/items.js index 2253928..a00b146 100644 --- a/js/items.js +++ b/js/items.js @@ -5,9 +5,9 @@ const translate_mappings = { //"Set": "set", "Powder Slots": "slots", //"Type": "type", - "Drop type": "drop", - "Quest requirement": "quest", - "Restriction": "restrict", + //"Drop type": "drop", BROKEN + //"Quest requirement": "quest", BROKEN + //"Restriction": "restrict", BROKEN //"Base Neutral Damage": "nDam", //"Base Fire Damage": "fDam", //"Base Water Damage": "wDam", @@ -98,7 +98,7 @@ const special_mappings = { // "No Defense Req": "defReq=0", }; -let item_filters = [] +let item_filters = []; for (let x in translate_mappings) { item_filters.push(x); } @@ -110,7 +110,7 @@ let item_categories = ["armor", "accessory", "weapon"]; const types = {bow: false, spear: false, wand: false, dagger: false, relik: false, helmet: false, chestplate: false, leggings: false, boots: false, ring: false, bracelet: false, necklace: false}; const rarities = {normal: true, unique: true, set: true, rare: true, legendary: true, fabled: true, mythic: true}; -const filters = []; +const filters = [], excludes = []; let filter_id_counter = 0; function displayItems(items_copy) { @@ -135,6 +135,7 @@ let search_db; let expr_parser; function do_item_search() { + document.getElementById("summary").style.color = "red"; // to display errors, changed to white if search successful window.scrollTo(0, 0); let queries = []; @@ -155,7 +156,7 @@ function do_item_search() { } } if (noTypes) { - document.getElementById("summary").innerHTML = "Error: Cannot search without at least 1 type selected!"; + 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) + ")"); @@ -173,7 +174,7 @@ function do_item_search() { } } if (noRarities) { - document.getElementById("summary").innerHTML = "Error: Cannot search without at least 1 rarity selected!"; + 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) + ")"); @@ -184,7 +185,7 @@ function do_item_search() { let min = parseInt(filter.min_elem.value); let max = parseInt(filter.max_elem.value); if (min > max) { - document.getElementById("summary").innerHTML = "Error: The minimum of filter " + filter.input_elem.value + " (" + min + ") is greater than its maximum (" + max + ")!"; + 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); @@ -194,7 +195,8 @@ function do_item_search() { if (filter_name === undefined) { filter_name = special_mappings[raw_name]; if (filter_name === undefined) { - continue; // not a valid filter + document.getElementById("summary").innerHTML = "Error: The filter \"" + filter.input_elem.value + "\" is not recognized"; + return; } filter_name = "(" + filter_name + ")"; } @@ -211,6 +213,21 @@ function do_item_search() { queries.push("s:" + (filter.ascending ? "0-" : "") + filter_name); } + // excludes + for (const exclude of excludes) { + let raw_name = exclude.input_elem.value; + let filter_name = translate_mappings[raw_name]; + if (filter_name === undefined) { + filter_name = special_mappings[raw_name]; + if (filter_name === undefined) { + document.getElementById("summary").innerHTML = "Error: The excluded filter \"" + exclude.input_elem.value + "\" is not recognized"; + return; + } + filter_name = "(" + filter_name + ")"; + } + queries.push("f:" + filter_name + "!=0"); + } + let filter_query = "true"; let sort_queries = []; console.log(queries); @@ -241,7 +258,8 @@ function do_item_search() { document.getElementById("summary").textContent = e.message; return; } - document.getElementById("summary").textContent = results.length + " results:" + document.getElementById("summary").textContent = results.length + " results:"; + document.getElementById("summary").style.color = "white"; displayItems(results); } @@ -291,6 +309,7 @@ function init_items() { // filters document.getElementById("add-filter").addEventListener("click", create_filter); + document.getElementById("add-exclude").addEventListener("click", create_exclude); create_filter(); filters[0].input_elem.value = "Combat Level"; init_filter_drag(); @@ -356,7 +375,6 @@ function create_filter() { col.appendChild(trash); document.getElementById("filter-container").insertBefore(row, document.getElementById("add-filter").parentElement); - filters.push(data); init_filter_dropdown(data); } @@ -426,6 +444,34 @@ function init_filter_drag() { }); } +function create_exclude() { + let data = {}; + + let row = make_elem("div", ["row", "filter-row"], {}); + let col = make_elem("div", ["col"], {}); + row.appendChild(col); + data.div = row; + + let filter_input = make_elem("input", + ["col", "border-dark", "text-light", "dark-5", "rounded", "scaled-font", "form-control", "form-control-sm", "filter-input"], + {id: "filter-input-" + filter_id_counter, type: "text", placeholder: "Excluded Filter"} + ); + filter_id_counter++; + col.appendChild(filter_input); + data.input_elem = filter_input; + + let trash = make_elem("img", ["delete-filter"], {src: "../media/icons/trash.svg"}); + trash.addEventListener("click", function() { + excludes.splice(Array.from(row.parentElement.children).indexOf(row) - 1, 1); + row.remove(); + }); + col.appendChild(trash); + + document.getElementById("exclude-container").insertBefore(row, document.getElementById("add-exclude").parentElement); + excludes.push(data); + init_filter_dropdown(data); +} + function init_filter_dropdown(filter) { let field_choice = filter.input_elem; field_choice.onclick = function() {field_choice.dispatchEvent(new Event('input', {bubbles:true}));};