@@ -125,6 +125,7 @@ export class GenLiteRecipeRecorderPlugin extends GenLitePlugin {
125125 .genlite-recipes-output-row {
126126 display: flex;
127127 column-gap: 1em;
128+ align-items: center;
128129 }
129130
130131 .genlite-recipes-search {
@@ -148,14 +149,38 @@ export class GenLiteRecipeRecorderPlugin extends GenLitePlugin {
148149 search . type = "text" ;
149150
150151 search . oninput = function ( e ) {
151- let value = search . value . trim ( ) ;
152- let list = document . getElementsByClassName ( "genlite-recipes-row" ) ;
153- for ( let i = 0 ; i < list . length ; i ++ ) {
154- let row = list [ i ] as HTMLElement ;
152+ let value = search . value . trim ( ) . toLowerCase ( ) ;
153+ let values = [ ] ;
154+ for ( const v of value . split ( "," ) ) {
155+ values . push ( v . trim ( ) ) ;
156+ }
157+
158+ let rows = document . getElementsByClassName ( "genlite-recipes-row" ) ;
159+ for ( let i = 0 ; i < rows . length ; i ++ ) {
160+ let row = rows [ i ] as HTMLElement ;
155161 let content = row . innerHTML . toLowerCase ( ) ;
156162 if ( value === "" ) {
157163 row . style . removeProperty ( "display" ) ;
158- } else if ( content . includes ( value ) ) {
164+ continue ;
165+ }
166+
167+ let match = true ;
168+ for ( let v of values ) {
169+ let invert = v [ 0 ] === "-" ;
170+ if ( invert ) {
171+ v = v . substr ( 1 ) ;
172+ }
173+
174+ if ( ! invert && ! content . includes ( v ) ) {
175+ match = false ;
176+ break ;
177+ } else if ( invert && content . includes ( v ) ) {
178+ match = false ;
179+ break ;
180+ }
181+ }
182+
183+ if ( match ) {
159184 row . style . removeProperty ( "display" ) ;
160185 } else {
161186 row . style . display = "none" ;
@@ -196,32 +221,15 @@ export class GenLiteRecipeRecorderPlugin extends GenLitePlugin {
196221 arrow . appendChild ( i ) ;
197222 icons . appendChild ( arrow ) ;
198223
199- let nInputs = 0 ;
224+ let nInputs = Infinity ;
200225 for ( const item in result . input ) {
201- nInputs = result . input [ item ] ; // TODO: make sure input #s are always equal
202- let div = < HTMLImageElement > document . createElement ( "div" ) ;
203- div . classList . add ( "genlite-recipes-icon" ) ;
204- icons . appendChild ( div ) ;
205-
206- let icon = < HTMLImageElement > document . createElement ( "img" ) ;
207- icon . classList . add ( "genlite-recipes-icon" ) ;
208- icon . title = item ;
209- div . appendChild ( icon ) ;
210-
211- const itemdata = document . game . DATA . items [ item ] ;
212- if ( itemdata && itemdata . image && itemdata . name ) {
213- icon . title = itemdata . name ;
214- icon . src = document . game . getStaticPath ( 'items/' + itemdata . image ) ;
215-
216- if ( itemdata . border ) {
217- let path = `items/placeholders/${ itemdata . border } _border.png` ;
218- path = document . game . getStaticPath ( path ) ;
219- let qual = < HTMLImageElement > document . createElement ( "img" ) ;
220- qual . classList . add ( "new_ux-inventory_quality-image" ) ;
221- qual . src = path ;
222- div . appendChild ( qual ) ;
223- }
226+ let amt = result . input [ item ] ;
227+ if ( amt < nInputs ) {
228+ nInputs = amt ;
224229 }
230+
231+ let icon = this . createIconDiv ( item ) ;
232+ icons . appendChild ( icon ) ;
225233 }
226234
227235 // now draw outputs
@@ -242,11 +250,75 @@ export class GenLiteRecipeRecorderPlugin extends GenLitePlugin {
242250 } ;
243251 }
244252
253+ createIconDiv ( item ) {
254+ let div = < HTMLImageElement > document . createElement ( "div" ) ;
255+ div . classList . add ( "genlite-recipes-icon" ) ;
256+
257+ let icon = < HTMLImageElement > document . createElement ( "img" ) ;
258+ icon . classList . add ( "genlite-recipes-icon" ) ;
259+ icon . title = item ;
260+ div . appendChild ( icon ) ;
261+
262+ const itemdata = document . game . DATA . items [ item ] ;
263+ if ( itemdata ) {
264+ if ( itemdata . name ) {
265+ icon . title = itemdata . name ;
266+ }
267+
268+ if ( itemdata . image ) {
269+ icon . src = document . game . getStaticPath ( 'items/' + itemdata . image ) ;
270+ } else if ( itemdata . images ) {
271+ let image = itemdata . images [ itemdata . images . length - 1 ] [ 1 ] ;
272+ icon . src = document . game . getStaticPath ( 'items/' + image ) ;
273+ }
274+
275+ if ( itemdata . border ) {
276+ let path = `items/placeholders/${ itemdata . border } _border.png` ;
277+ path = document . game . getStaticPath ( path ) ;
278+ let qual = < HTMLImageElement > document . createElement ( "img" ) ;
279+ qual . classList . add ( "new_ux-inventory_quality-image" ) ;
280+ qual . src = path ;
281+ div . appendChild ( qual ) ;
282+ }
283+ }
284+
285+ if ( ! icon . src ) {
286+ icon . src = document . game . getStaticPath ( 'items/unknown.png' ) ;
287+ }
288+ return div ;
289+ }
290+
245291 updateOutputBox ( outputBox : HTMLElement , results ) {
246- let nInputs = 0 ;
292+ let seo = "" ;
293+
294+ function addSEO ( prefix , s ) {
295+ seo += prefix + s ;
296+ seo += prefix + s
297+ . replace ( "L.Q." , "LQ" )
298+ . replace ( "H.Q." , "HQ" )
299+ . replace ( "Bronze Component (" , "" )
300+ . replace ( "Iron Component (" , "" )
301+ . replace ( "Steel Component (" , "" )
302+ . replace ( "Mithril Component (" , "" ) ;
303+ if ( ! s . includes ( "L.Q." ) && ! s . includes ( "H.Q." ) ) {
304+ seo += prefix + "N.Q. " + s ;
305+ seo += prefix + "NQ " + s ;
306+ }
307+ }
308+
309+ let nInputs = Infinity ;
247310 for ( const item in results . input ) {
248- nInputs = results . input [ item ] ;
249- break ;
311+ let amt = results . input [ item ] ;
312+ if ( amt < nInputs ) {
313+ nInputs = amt ;
314+ }
315+
316+ let seoitem = item + ";" ;
317+ const itemdata = document . game . DATA . items [ item ] ;
318+ if ( itemdata && itemdata . name ) {
319+ seoitem = itemdata . name + ";" ;
320+ }
321+ addSEO ( "in:" , seoitem ) ;
250322 }
251323
252324 outputBox . innerHTML = '' ;
@@ -256,37 +328,27 @@ export class GenLiteRecipeRecorderPlugin extends GenLitePlugin {
256328 let orow = < HTMLElement > document . createElement ( "div" ) ;
257329 orow . classList . add ( "genlite-recipes-output-row" ) ;
258330
259- let div = < HTMLImageElement > document . createElement ( "div" ) ;
260- div . classList . add ( "genlite-recipes-icon" ) ;
261- orow . appendChild ( div ) ;
262-
263- let icon = < HTMLImageElement > document . createElement ( "img" ) ;
264- icon . classList . add ( "genlite-recipes-icon" ) ;
265- icon . title = item ;
266- div . appendChild ( icon ) ;
331+ let icon = this . createIconDiv ( item ) ;
332+ orow . appendChild ( icon ) ;
267333
334+ let seoitem = item + ";" ;
268335 const itemdata = document . game . DATA . items [ item ] ;
269- if ( itemdata && itemdata . image && itemdata . name ) {
270- icon . title = itemdata . name ;
271- icon . src = document . game . getStaticPath ( 'items/' + itemdata . image ) ;
272-
273- if ( itemdata . border ) {
274- let path = `items/placeholders/${ itemdata . border } _border.png` ;
275- path = document . game . getStaticPath ( path ) ;
276- let qual = < HTMLImageElement > document . createElement ( "img" ) ;
277- qual . classList . add ( "new_ux-inventory_quality-image" ) ;
278- qual . src = path ;
279- div . appendChild ( qual ) ;
280- }
336+ if ( itemdata && itemdata . name ) {
337+ seoitem = itemdata . name + ";" ;
281338 }
339+ addSEO ( "out:" , seoitem ) ;
282340
283341 let n = results . output [ item ] ;
284342 let pct = ( n / nInputs * 100 ) ;
285343 pct = Math . round ( pct * 100 ) / 100 ;
286344 orow . appendChild ( document . createTextNode ( `${ n } (${ pct } %)` ) ) ;
287-
288345 outputBox . appendChild ( orow ) ;
289346 }
347+
348+ let seospan = < HTMLElement > document . createElement ( "span" ) ;
349+ seospan . style . display = "none" ;
350+ seospan . innerText = seo ;
351+ outputBox . appendChild ( seospan ) ;
290352 }
291353
292354 updateRecipeRow ( recipeName : string ) {
0 commit comments