2021-01-26 09:17:11 +00:00
const translate _mappings = {
//"Name": "name",
//"Display Name": "displayName",
2022-08-19 00:15:17 +00:00
//"Tier": "tier",
2021-01-26 09:17:11 +00:00
//"Set": "set",
"Powder Slots" : "slots" ,
//"Type": "type",
2022-09-13 19:11:14 +00:00
//"Drop type": "drop", BROKEN
//"Quest requirement": "quest", BROKEN
//"Restriction": "restrict", BROKEN
2021-01-26 09:17:11 +00:00
//"Base Neutral Damage": "nDam",
//"Base Fire Damage": "fDam",
//"Base Water Damage": "wDam",
//"Base Air Damage": "aDam",
//"Base Thunder Damage": "tDam",
//"Base Earth Damage": "eDam",
//"Base Attack Speed": "atkSpd",
"Health" : "hp" ,
"Raw Fire Defense" : "fDef" ,
"Raw Water Defense" : "wDef" ,
"Raw Air Defense" : "aDef" ,
"Raw Thunder Defense" : "tDef" ,
"Raw Earth Defense" : "eDef" ,
"Combat Level" : "lvl" ,
//"Class Requirement": "classReq",
"Req Strength" : "strReq" ,
"Req Dexterity" : "dexReq" ,
"Req Intelligence" : "intReq" ,
"Req Agility" : "agiReq" ,
"Req Defense" : "defReq" ,
"% Health Regen" : "hprPct" ,
"Mana Regen" : "mr" ,
"% Spell Damage" : "sdPct" ,
"% Melee Damage" : "mdPct" ,
"Life Steal" : "ls" ,
"Mana Steal" : "ms" ,
"XP Bonus" : "xpb" ,
"Loot Bonus" : "lb" ,
"Reflection" : "ref" ,
"Strength" : "str" ,
"Dexterity" : "dex" ,
"Intelligence" : "int" ,
"Agility" : "agi" ,
"Defense" : "def" ,
"Thorns" : "thorns" ,
"Exploding" : "expd" ,
"Walk Speed" : "spd" ,
"Attack Speed Bonus" : "atkTier" ,
"Poison" : "poison" ,
"Health Bonus" : "hpBonus" ,
"Soul Point Regen" : "spRegen" ,
"Stealing" : "eSteal" ,
"Raw Health Regen" : "hprRaw" ,
"Raw Spell" : "sdRaw" ,
"Raw Melee" : "mdRaw" ,
"% Fire Damage" : "fDamPct" ,
"% Water Damage" : "wDamPct" ,
"% Air Damage" : "aDamPct" ,
"% Thunder Damage" : "tDamPct" ,
"% Earth Damage" : "eDamPct" ,
"% Fire Defense" : "fDefPct" ,
"% Water Defense" : "wDefPct" ,
"% Air Defense" : "aDefPct" ,
"% Thunder Defense" : "tDefPct" ,
"% Earth Defense" : "eDefPct" ,
"Fixed IDs" : "fixID" ,
"Custom Skin" : "skin" ,
//"Item Category": "category",
2022-01-18 03:31:29 +00:00
"1st Spell Cost %" : "-spPct1" ,
"1st Spell Cost Raw" : "-spRaw1" ,
"2nd Spell Cost %" : "-spPct2" ,
"2nd Spell Cost Raw" : "-spRaw2" ,
"3rd Spell Cost %" : "-spPct3" ,
"3rd Spell Cost Raw" : "-spRaw3" ,
"4th Spell Cost %" : "-spPct4" ,
"4th Spell Cost Raw" : "-spRaw4" ,
2021-01-26 09:17:11 +00:00
"Rainbow Spell Damage" : "rainbowRaw" ,
"Sprint" : "sprint" ,
"Sprint Regen" : "sprintReg" ,
"Jump Height" : "jh" ,
"Loot Quality" : "lq" ,
"Gather XP Bonus" : "gXp" ,
"Gather Speed Bonus" : "gSpd" ,
} ;
const special _mappings = {
2022-08-19 00:15:17 +00:00
"Sum (skill points)" : "str+dex+int+def+agi" ,
"Sum (Mana Sustain)" : "mr+ms" ,
"Sum (Life Sustain)" : "hpr+ls" ,
"Sum (Health + Health Bonus)" : "hp+hpBonus" ,
// "No Strength Req": "strReq=0",
// "No Dexterity Req": "dexReq=0",
// "No Intelligence Req": "intReq=0",
// "No Agility Req": "agiReq=0",
// "No Defense Req": "defReq=0",
2021-01-26 09:17:11 +00:00
} ;
2022-09-13 19:11:14 +00:00
let item _filters = [ ] ;
2022-08-03 07:28:54 +00:00
for ( let x in translate _mappings ) {
item _filters . push ( x ) ;
}
for ( let x in special _mappings ) {
item _filters . push ( x ) ;
2021-01-26 09:17:11 +00:00
}
2022-08-13 18:48:16 +00:00
let item _categories = [ "armor" , "accessory" , "weapon" ] ;
2021-01-26 09:17:11 +00:00
2022-09-13 18:20:20 +00:00
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 } ;
2022-08-13 18:48:16 +00:00
const rarities = { normal : true , unique : true , set : true , rare : true , legendary : true , fabled : true , mythic : true } ;
2022-09-13 19:11:14 +00:00
const filters = [ ] , excludes = [ ] ;
2022-08-19 00:15:17 +00:00
let filter _id _counter = 0 ;
2021-01-24 03:58:53 +00:00
2022-08-03 07:28:54 +00:00
function displayItems ( items _copy ) {
let items _parent = document . getElementById ( "search-results" ) ;
for ( let i in items _copy ) {
if ( i > 200 ) { break ; }
let item = items _copy [ i ] . itemExp ;
2022-08-03 08:00:39 +00:00
let box = make _elem ( 'div' , [ 'col-lg-3' , 'col-sm-6' , 'p-2' ] , { id : 'item' + i } ) ;
2022-08-03 07:28:54 +00:00
2022-08-03 08:00:39 +00:00
let bckgrdbox = make _elem ( "div" , [ "dark-7" , "rounded" , "px-2" , "col-auto" ] , { id : 'item' + i + 'b' } ) ;
box . append ( bckgrdbox ) ;
2021-01-24 03:58:53 +00:00
items _parent . appendChild ( box ) ;
2022-08-03 07:28:54 +00:00
item . set ( "powders" , [ ] ) ;
if ( item . get ( "category" ) == "weapon" ) {
apply _weapon _powders ( item ) ;
}
displayExpandedItem ( item , bckgrdbox . id , true ) ;
2021-01-24 03:58:53 +00:00
}
}
2022-08-03 07:54:40 +00:00
let search _db ;
let expr _parser ;
2021-10-18 01:21:02 +00:00
2022-08-03 07:54:40 +00:00
function do _item _search ( ) {
2022-09-13 19:11:14 +00:00
document . getElementById ( "summary" ) . style . color = "red" ; // to display errors, changed to white if search successful
2021-01-24 10:09:59 +00:00
window . scrollTo ( 0 , 0 ) ;
2021-01-26 09:17:11 +00:00
let queries = [ ] ;
2022-08-13 18:48:16 +00:00
// name
if ( document . getElementById ( "item-name-choice" ) . value != "" ) {
queries . push ( "f:name?=\"" + document . getElementById ( "item-name-choice" ) . value . trim ( ) + "\"" ) ;
2021-01-26 09:17:11 +00:00
}
2022-08-13 18:48:16 +00:00
// types
2022-09-13 18:26:46 +00:00
let allTypes = true , noTypes = true ;
2022-08-13 18:48:16 +00:00
let typeQuery = "f:("
for ( const type of Object . keys ( types ) ) {
if ( types [ type ] ) {
typeQuery += "type=\"" + type + "\"|" ;
2022-09-13 18:26:46 +00:00
noTypes = false ;
2022-08-13 18:48:16 +00:00
} else {
allTypes = false ;
2021-01-26 09:17:11 +00:00
}
}
2022-09-13 18:26:46 +00:00
if ( noTypes ) {
2022-09-13 19:11:14 +00:00
document . getElementById ( "summary" ) . innerHTML = "Error: Cannot search without at least 1 type selected" ;
2022-09-13 18:26:46 +00:00
return ;
} else if ( ! allTypes ) {
2022-08-13 18:48:16 +00:00
queries . push ( typeQuery . substring ( 0 , typeQuery . length - 1 ) + ")" ) ;
}
2021-01-26 09:17:11 +00:00
2022-08-13 18:48:16 +00:00
// rarities
2022-09-13 18:26:46 +00:00
let allRarities = true , noRarities = true ;
2022-08-13 18:48:16 +00:00
let rarityQuery = "f:("
for ( const rarity of Object . keys ( rarities ) ) {
if ( rarities [ rarity ] ) {
rarityQuery += "tiername=\"" + rarity + "\"|" ;
2022-09-13 18:26:46 +00:00
noRarities = false ;
2022-08-13 18:48:16 +00:00
} else {
allRarities = false ;
2021-01-26 09:17:11 +00:00
}
}
2022-09-13 18:26:46 +00:00
if ( noRarities ) {
2022-09-13 19:11:14 +00:00
document . getElementById ( "summary" ) . innerHTML = "Error: Cannot search without at least 1 rarity selected" ;
2022-09-13 18:26:46 +00:00
return ;
} else if ( ! allRarities ) {
2022-08-13 18:48:16 +00:00
queries . push ( rarityQuery . substring ( 0 , rarityQuery . length - 1 ) + ")" ) ;
}
// filters
2022-08-19 00:15:17 +00:00
for ( const filter of filters ) {
let min = parseInt ( filter . min _elem . value ) ;
let max = parseInt ( filter . max _elem . value ) ;
if ( min > max ) {
2022-09-13 19:11:14 +00:00
document . getElementById ( "summary" ) . innerHTML = "Error: The minimum of filter " + filter . input _elem . value + " (" + min + ") is greater than its maximum (" + max + ")" ;
2022-09-13 18:26:46 +00:00
return ;
2022-08-19 00:15:17 +00:00
}
2022-09-09 21:01:08 +00:00
let zero _in _min _max = ( isNaN ( min ) || min < 0 ) && ( isNaN ( max ) || max > 0 ) ;
2022-08-19 00:15:17 +00:00
let raw _name = filter . input _elem . value ;
let filter _name = translate _mappings [ raw _name ] ;
if ( filter _name === undefined ) {
filter _name = special _mappings [ raw _name ] ;
if ( filter _name === undefined ) {
2022-09-13 19:11:14 +00:00
document . getElementById ( "summary" ) . innerHTML = "Error: The filter \"" + filter . input _elem . value + "\" is not recognized" ;
return ;
2022-08-19 00:15:17 +00:00
}
filter _name = "(" + filter _name + ")" ;
}
if ( ! isNaN ( min ) ) {
queries . push ( "f:" + filter _name + ">=" + min ) ;
}
if ( ! isNaN ( max ) ) {
queries . push ( "f:" + filter _name + "<=" + max ) ;
}
if ( zero _in _min _max ) {
queries . push ( "f:" + filter _name + "!=0" ) ;
}
queries . push ( "s:" + ( filter . ascending ? "0-" : "" ) + filter _name ) ;
}
2021-01-26 09:17:11 +00:00
2022-09-13 19:11:14 +00:00
// 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" ) ;
}
2022-08-03 07:54:40 +00:00
let filter _query = "true" ;
let sort _queries = [ ] ;
2022-01-06 00:00:28 +00:00
console . log ( queries ) ;
2021-01-26 09:17:11 +00:00
for ( const query of queries ) {
2022-01-06 00:00:28 +00:00
if ( query . startsWith ( "s:" ) ) {
2022-08-03 07:54:40 +00:00
sort _queries . push ( query . slice ( 2 ) ) ;
2022-01-06 00:00:28 +00:00
}
else if ( query . startsWith ( "f:" ) ) {
2022-08-03 07:54:40 +00:00
filter _query = filter _query + "&" + query . slice ( 2 ) ;
2022-01-06 00:00:28 +00:00
}
}
2022-08-03 07:28:54 +00:00
document . getElementById ( "search-results" ) . textContent = "" ;
2022-01-06 00:00:28 +00:00
let results = [ ] ;
try {
2022-08-03 07:54:40 +00:00
const filter _expr = expr _parser . parse ( filter _query ) ;
const sort _exprs = sort _queries . map ( q => expr _parser . parse ( q ) ) ;
for ( let i = 0 ; i < search _db . length ; ++ i ) {
const item = search _db [ i ] [ 0 ] ;
const itemExp = search _db [ i ] [ 1 ] ;
if ( checkBool ( filter _expr . resolve ( item , itemExp ) ) ) {
results . push ( { item , itemExp , sortKeys : sort _exprs . map ( e => e . resolve ( item , itemExp ) ) } ) ;
2022-01-06 00:00:28 +00:00
}
}
results . sort ( ( a , b ) => {
return compareLexico ( a . item , a . sortKeys , b . item , b . sortKeys ) ;
} ) ;
} catch ( e ) {
document . getElementById ( "summary" ) . textContent = e . message ;
return ;
2021-01-24 10:09:59 +00:00
}
2022-09-13 19:11:14 +00:00
document . getElementById ( "summary" ) . textContent = results . length + " results:" ;
document . getElementById ( "summary" ) . style . color = "white" ;
2022-01-06 00:00:28 +00:00
displayItems ( results ) ;
2021-01-24 10:09:59 +00:00
}
2021-04-02 22:07:15 +00:00
function init _items ( ) {
2022-08-03 07:54:40 +00:00
search _db = items . filter ( i => ! i . remapID ) . map ( i => [ i , expandItem ( i , [ ] ) ] ) ;
expr _parser = new ExprParser ( itemQueryProps , itemQueryFuncs ) ;
2022-08-03 07:28:54 +00:00
2022-08-13 18:48:16 +00:00
// init type buttons
for ( const type of Object . keys ( types ) ) {
document . getElementById ( "type-" + type ) . addEventListener ( "click" , function ( ) {
types [ type ] = ! types [ type ] ;
this . classList . toggle ( "type-selected" ) ;
} ) ;
}
document . getElementById ( "all-types" ) . addEventListener ( "click" , function ( ) {
for ( const type of Object . keys ( types ) ) {
types [ type ] = true ;
document . getElementById ( "type-" + type ) . classList . add ( "type-selected" ) ;
}
} ) ;
document . getElementById ( "none-types" ) . addEventListener ( "click" , function ( ) {
for ( const type of Object . keys ( types ) ) {
types [ type ] = false ;
document . getElementById ( "type-" + type ) . classList . remove ( "type-selected" ) ;
}
} ) ;
// init rarity buttons
for ( const rarity of Object . keys ( rarities ) ) {
document . getElementById ( "rarity-" + rarity ) . addEventListener ( "click" , function ( ) {
rarities [ rarity ] = ! rarities [ rarity ] ;
this . classList . toggle ( "rarity-selected" ) ;
} ) ;
}
document . getElementById ( "all-rarities" ) . addEventListener ( "click" , function ( ) {
for ( const rarity of Object . keys ( rarities ) ) {
rarities [ rarity ] = true ;
document . getElementById ( "rarity-" + rarity ) . classList . add ( "rarity-selected" ) ;
}
} ) ;
document . getElementById ( "none-rarities" ) . addEventListener ( "click" , function ( ) {
for ( const rarity of Object . keys ( rarities ) ) {
rarities [ rarity ] = false ;
document . getElementById ( "rarity-" + rarity ) . classList . remove ( "rarity-selected" ) ;
}
} ) ;
2022-08-19 00:15:17 +00:00
// filters
document . getElementById ( "add-filter" ) . addEventListener ( "click" , create _filter ) ;
2022-09-13 19:11:14 +00:00
document . getElementById ( "add-exclude" ) . addEventListener ( "click" , create _exclude ) ;
2022-08-19 00:15:17 +00:00
create _filter ( ) ;
filters [ 0 ] . input _elem . value = "Combat Level" ;
2022-08-26 21:07:07 +00:00
init _filter _drag ( ) ;
2022-08-13 18:48:16 +00:00
}
function reset _item _search ( ) {
document . getElementById ( "item-name-choice" ) . value = "" ;
document . getElementById ( "all-types" ) . click ( ) ;
document . getElementById ( "all-rarities" ) . click ( ) ;
}
2022-08-19 00:15:17 +00:00
function create _filter ( ) {
let data = { ascending : false } ;
2022-08-26 21:07:07 +00:00
let row = make _elem ( "div" , [ "row" , "filter-row" ] , { } ) ;
2022-08-19 00:15:17 +00:00
let col = make _elem ( "div" , [ "col" ] , { } ) ;
row . appendChild ( col ) ;
2022-08-26 21:07:07 +00:00
data . div = row ;
2022-08-19 00:15:17 +00:00
2022-08-26 21:07:07 +00:00
let reorder _img = make _elem ( "img" , [ "reorder-filter" ] , { src : "../media/icons/3-lines.svg" , draggable : "true" } ) ;
2022-08-19 00:15:17 +00:00
col . appendChild ( reorder _img ) ;
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 : "Filter" }
) ;
filter _id _counter ++ ;
col . appendChild ( filter _input ) ;
data . input _elem = filter _input ;
let asc _desc = make _elem ( "div" , [ ] , { style : "cursor: pointer; display: inline-block;" } ) ;
asc _desc . appendChild ( make _elem ( "img" , [ "desc-icon" , "asc-sel" ] , { src : "../media/icons/triangle.svg" } ) ) ;
asc _desc . appendChild ( make _elem ( "img" , [ "asc-icon" ] , { src : "../media/icons/triangle.svg" } ) ) ;
asc _desc . addEventListener ( "click" , function ( ) {
data . ascending = ! data . ascending ;
asc _desc . children [ 0 ] . classList . toggle ( "asc-sel" ) ;
asc _desc . children [ 1 ] . classList . toggle ( "asc-sel" ) ;
} ) ;
col . appendChild ( asc _desc ) ;
let min = make _elem ( "input" ,
[ "col" , "border-dark" , "text-light" , "dark-5" , "rounded" , "scaled-font" , "form-control" , "form-control-sm" , "min-max-input" ] ,
{ type : "number" , placeholder : "-\u221E" }
) ;
col . appendChild ( min ) ;
data . min _elem = min ;
let to = make _elem ( "span" , [ ] , { innerHTML : " to " } ) ;
col . appendChild ( to ) ;
let max = make _elem ( "input" ,
[ "col" , "border-dark" , "text-light" , "dark-5" , "rounded" , "scaled-font" , "form-control" , "form-control-sm" , "min-max-input" ] ,
{ type : "number" , placeholder : "\u221E" }
) ;
col . appendChild ( max ) ;
data . max _elem = max ;
2022-09-13 18:50:00 +00:00
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 ) ;
2022-08-19 00:15:17 +00:00
document . getElementById ( "filter-container" ) . insertBefore ( row , document . getElementById ( "add-filter" ) . parentElement ) ;
filters . push ( data ) ;
init _filter _dropdown ( data ) ;
}
2022-08-26 21:07:07 +00:00
let currently _dragging = null ;
function init _filter _drag ( ) {
let container = document . getElementById ( "filter-container" ) ;
container . addEventListener ( "dragstart" , function ( e ) {
if ( e . path [ 0 ] . classList . contains ( "reorder-filter" ) ) {
currently _dragging = filters [ Array . from ( e . path [ 3 ] . children ) . indexOf ( e . path [ 2 ] ) - 1 ] ;
} else {
e . preventDefault ( ) ;
}
} ) ;
container . addEventListener ( "dragenter" , function ( e ) {
e . preventDefault ( ) ;
} ) ;
container . addEventListener ( "dragleave" , function ( e ) {
e . preventDefault ( ) ;
} ) ;
container . addEventListener ( "dragend" , function ( e ) {
e . preventDefault ( ) ;
for ( const el of document . getElementsByClassName ( "filter-dragged-over" ) ) {
el . classList . remove ( "filter-dragged-over" ) ;
}
currently _dragging = null ;
} ) ;
container . addEventListener ( "dragover" , function ( e ) {
e . preventDefault ( ) ;
for ( const el of document . getElementsByClassName ( "filter-dragged-over" ) ) {
el . classList . remove ( "filter-dragged-over" ) ;
}
if ( ! e . path . includes ( currently _dragging . div ) ) {
for ( let i = 0 ; i < e . path . length ; i ++ ) {
if ( e . path [ i ] . classList . contains ( "filter-row" ) ) {
e . path [ i ] . classList . add ( "filter-dragged-over" ) ;
break ;
}
}
}
} ) ;
container . addEventListener ( "drop" , function ( e ) {
e . preventDefault ( ) ;
for ( const el of document . getElementsByClassName ( "filter-dragged-over" ) ) {
el . classList . remove ( "filter-dragged-over" ) ;
}
if ( ! e . path . includes ( currently _dragging . div ) ) {
for ( let i = 0 ; i < e . path . length ; i ++ ) {
if ( e . path [ i ] . classList . contains ( "filter-row" ) ) {
let old _index = filters . indexOf ( currently _dragging ) ;
let new _index = Array . from ( e . path [ i + 1 ] . children ) . indexOf ( e . path [ i ] ) - 1 ;
filters . splice ( old _index , 1 ) ;
filters . splice ( new _index , 0 , currently _dragging ) ;
currently _dragging . div . remove ( ) ;
container . insertBefore ( currently _dragging . div , container . children [ new _index + 1 ] ) ;
break ;
}
}
}
currently _dragging = null ;
} ) ;
2022-08-19 00:15:17 +00:00
}
2022-09-13 19:11:14 +00:00
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 ) ;
}
2022-08-19 00:15:17 +00:00
function init _filter _dropdown ( filter ) {
2022-08-13 18:48:16 +00:00
let field _choice = filter . input _elem ;
field _choice . onclick = function ( ) { field _choice . dispatchEvent ( new Event ( 'input' , { bubbles : true } ) ) ; } ;
filter . autoComplete = new autoComplete ( {
data : {
src : item _filters ,
} ,
threshold : 0 ,
2022-08-19 00:15:17 +00:00
selector : "#" + field _choice . id ,
2022-08-13 18:48:16 +00:00
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 ) => {
2022-08-19 00:15:17 +00:00
let position = field _choice . getBoundingClientRect ( ) ;
2022-08-13 18:48:16 +00:00
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" ;
2022-08-19 00:15:17 +00:00
if ( ! data . results . length ) {
2022-08-13 18:48:16 +00:00
const message = make _elem ( 'li' , [ 'scaled-font' ] , { 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 ;
2022-08-03 07:28:54 +00:00
} ;
} ,
} ,
2022-08-13 18:48:16 +00:00
}
} ) ;
2022-08-03 07:39:43 +00:00
}
( async function ( ) {
await Promise . resolve ( load _init ( ) ) ;
init _items ( ) ;
2022-08-03 07:28:54 +00:00
} ) ( ) ;