From ebbba92a8eeb1f7c25928c667d64c177e64b05c0 Mon Sep 17 00:00:00 2001 From: reschan Date: Sun, 10 Jul 2022 10:04:28 +0700 Subject: [PATCH 1/5] partial restore of item search --- items/index.html | 3 +-- js/damage_calc.js | 1 + js/sq2items.js | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/items/index.html b/items/index.html index c35a4aa..f50a15c 100644 --- a/items/index.html +++ b/items/index.html @@ -140,13 +140,12 @@ - - + diff --git a/js/damage_calc.js b/js/damage_calc.js index a8b0b72..ce4f32a 100644 --- a/js/damage_calc.js +++ b/js/damage_calc.js @@ -5,6 +5,7 @@ function get_base_dps(item) { //SUPER JANK @HPP PLS FIX if (item.get("tier") !== "Crafted") { let total_damage = 0; + apply_weapon_powders(item); for (const damage_k of damage_keys) { damages = item.get(damage_k); total_damage += damages[0] + damages[1]; diff --git a/js/sq2items.js b/js/sq2items.js index c3c7185..811cf0d 100644 --- a/js/sq2items.js +++ b/js/sq2items.js @@ -184,7 +184,8 @@ function displayItems(items_copy) { box.appendChild(bckgrdbox); bckgrdbox.id = "item"+i+"b"; items_parent.appendChild(box); - displaysq2ExpandedItem(item, bckgrdbox.id); + item.set("powders", []); + displayExpandedItem(item, bckgrdbox.id, true); } } @@ -251,6 +252,11 @@ function resetItemSearch() { function init_items() { items_expanded = items.filter( (i) => !("remapID" in i) ).map( (i) => expandItem(i) ); + console.log(items_expanded); + console.log("a"); } -load_init(init_items); +(async function() { + await Promise.resolve(load_init()); + init_items(); +})(); From 57fa608cff0495bf1dea066def9400fe2e5f6f91 Mon Sep 17 00:00:00 2001 From: reschan Date: Sun, 10 Jul 2022 10:35:06 +0700 Subject: [PATCH 2/5] fix special queries --- builder/index.html | 1 - items/index.html | 1 - js/damage_calc.js | 1 - js/sq2items.js | 9 +++++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/builder/index.html b/builder/index.html index 6dd9d65..fd299e5 100644 --- a/builder/index.html +++ b/builder/index.html @@ -1399,7 +1399,6 @@ - diff --git a/items/index.html b/items/index.html index f50a15c..183b479 100644 --- a/items/index.html +++ b/items/index.html @@ -144,7 +144,6 @@ - diff --git a/js/damage_calc.js b/js/damage_calc.js index ce4f32a..a8b0b72 100644 --- a/js/damage_calc.js +++ b/js/damage_calc.js @@ -5,7 +5,6 @@ function get_base_dps(item) { //SUPER JANK @HPP PLS FIX if (item.get("tier") !== "Crafted") { let total_damage = 0; - apply_weapon_powders(item); for (const damage_k of damage_keys) { damages = item.get(damage_k); total_damage += damages[0] + damages[1]; diff --git a/js/sq2items.js b/js/sq2items.js index 811cf0d..7e48900 100644 --- a/js/sq2items.js +++ b/js/sq2items.js @@ -53,6 +53,8 @@ document.addEventListener("DOMContentLoaded", function() { }; }); +let itemCategories = [ "armor", "accessory", "weapon" ]; + const sq2_translate_mappings = { //"Name": "name", //"Display Name": "displayName", @@ -185,6 +187,9 @@ function displayItems(items_copy) { bckgrdbox.id = "item"+i+"b"; items_parent.appendChild(box); item.set("powders", []); + if (item.get("category") == "weapon") { + apply_weapon_powders(item); + } displayExpandedItem(item, bckgrdbox.id, true); } } @@ -219,12 +224,12 @@ function doItemSearch() { for (let i = 1; i <= 4; ++i) { let raw_dat = document.getElementById("filter"+i+"-choice").value; - let filter_dat = translate_mappings[raw_dat]; + let filter_dat = sq2_translate_mappings[raw_dat]; if (filter_dat !== undefined) { queries.push(new IdQuery(filter_dat)); continue; } - filter_dat = special_mappings[raw_dat]; + filter_dat = sq2_special_mappings[raw_dat]; if (filter_dat !== undefined) { queries.push(filter_dat); continue; From 30301021c7d52b4a749eb94ad4f3fffa13d0be16 Mon Sep 17 00:00:00 2001 From: reschan Date: Sun, 10 Jul 2022 11:01:40 +0700 Subject: [PATCH 3/5] remove items.js load --- crafter/index.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/crafter/index.html b/crafter/index.html index 31e18e8..8a59b07 100644 --- a/crafter/index.html +++ b/crafter/index.html @@ -307,7 +307,5 @@ - - From 0b047c6525182b59c0317a2a2f87ab9dd11b29e7 Mon Sep 17 00:00:00 2001 From: reschan Date: Sun, 10 Jul 2022 11:01:57 +0700 Subject: [PATCH 4/5] remove nonexistent script calls --- custom/index.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/custom/index.html b/custom/index.html index 33dc5cb..1d425e7 100644 --- a/custom/index.html +++ b/custom/index.html @@ -1906,8 +1906,6 @@ - - From 76ae9098ac287f97d8e80c7831cab396e073dd32 Mon Sep 17 00:00:00 2001 From: reschan Date: Sun, 10 Jul 2022 11:02:17 +0700 Subject: [PATCH 5/5] move dropdown creation to init func --- js/sq2items.js | 111 ++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 57 deletions(-) diff --git a/js/sq2items.js b/js/sq2items.js index 7e48900..6d62c63 100644 --- a/js/sq2items.js +++ b/js/sq2items.js @@ -1,58 +1,3 @@ -document.addEventListener("DOMContentLoaded", function() { - let filterInputs = new Map([["item-category", ["ALL", "armor", "helmet", "chestplate", "leggings", "boots", "accessory", "ring", "bracelet", "necklace", "weapon", "wand", "spear", "bow", "dagger", "relik"]], - ["item-rarity", ["ANY", "Normal", "Unique", "Set", "Rare", "Legendary", "Fabled", "Mythic", "Sane"]], - ["filter1", sq2ItemFilters], - ["filter2", sq2ItemFilters], - ["filter3", sq2ItemFilters], - ["filter4", sq2ItemFilters]]); - for (const [field, data] of filterInputs) { - let field_choice = document.getElementById(field+"-choice"); - // show dropdown on click - field_choice.onclick = function() {field_choice.dispatchEvent(new Event('input', {bubbles:true}));}; - filterInputs.set(field, new autoComplete({ - data: { - src: data, - }, - threshold: 0, - selector: "#"+ field +"-choice", - wrapper: false, - resultsList: { - maxResults: 100, - tabSelect: true, - noResults: true, - class: "search-box dark-7 rounded-bottom px-2 fw-bold dark-shadow-sm", - element: (list, data) => { - let position = document.getElementById(field+'-choice').getBoundingClientRect(); - list.style.top = position.bottom + window.scrollY +"px"; - list.style.left = position.x+"px"; - list.style.width = position.width+"px"; - list.style.maxHeight = position.height * 4 +"px"; - - if (!data.results.length) { - message = document.createElement('li'); - message.classList.add('scaled-font'); - message.textContent = "No results found!"; - list.prepend(message); - }; - }, - }, - resultItem: { - class: "scaled-font search-item", - selected: "dark-5", - }, - events: { - input: { - selection: (event) => { - if (event.detail.selection.value) { - event.target.value = event.detail.selection.value; - }; - }, - }, - } - })); - }; -}); - let itemCategories = [ "armor", "accessory", "weapon" ]; const sq2_translate_mappings = { @@ -257,8 +202,60 @@ function resetItemSearch() { function init_items() { items_expanded = items.filter( (i) => !("remapID" in i) ).map( (i) => expandItem(i) ); - console.log(items_expanded); - console.log("a"); + + //init dropdowns + let filterInputs = new Map([["item-category", ["ALL", "armor", "helmet", "chestplate", "leggings", "boots", "accessory", "ring", "bracelet", "necklace", "weapon", "wand", "spear", "bow", "dagger", "relik"]], + ["item-rarity", ["ANY", "Normal", "Unique", "Set", "Rare", "Legendary", "Fabled", "Mythic", "Sane"]], + ["filter1", sq2ItemFilters], + ["filter2", sq2ItemFilters], + ["filter3", sq2ItemFilters], + ["filter4", sq2ItemFilters]]); + for (const [field, data] of filterInputs) { + let field_choice = document.getElementById(field+"-choice"); + // show dropdown on click + field_choice.onclick = function() {field_choice.dispatchEvent(new Event('input', {bubbles:true}));}; + filterInputs.set(field, new autoComplete({ + data: { + src: data, + }, + threshold: 0, + selector: "#"+ field +"-choice", + wrapper: false, + resultsList: { + maxResults: 100, + tabSelect: true, + noResults: true, + class: "search-box dark-7 rounded-bottom px-2 fw-bold dark-shadow-sm", + element: (list, data) => { + let position = document.getElementById(field+'-choice').getBoundingClientRect(); + list.style.top = position.bottom + window.scrollY +"px"; + list.style.left = position.x+"px"; + list.style.width = position.width+"px"; + list.style.maxHeight = position.height * 4 +"px"; + + if (!data.results.length) { + message = document.createElement('li'); + message.classList.add('scaled-font'); + message.textContent = "No results found!"; + list.prepend(message); + }; + }, + }, + resultItem: { + class: "scaled-font search-item", + selected: "dark-5", + }, + events: { + input: { + selection: (event) => { + if (event.detail.selection.value) { + event.target.value = event.detail.selection.value; + }; + }, + }, + } + })); + }; } (async function() {