@@ -5,8 +5,6 @@ let base_path = _cfg.base_path
55 : "/GameDB" ;
66let base_url = window . location . origin + base_path ;
77
8- // get search options, we will append each platform to this list
9- let search_options = document . getElementById ( "search_type" )
108
119// get platforms container
1210let platforms_container = document . getElementById ( "platforms-container" )
@@ -143,11 +141,6 @@ $(document).ready(function(){
143141 let sorted = platforms . sort ( window . rankingSorter ( "name" , "id" ) ) . reverse ( )
144142
145143 for ( let item in sorted ) {
146- // create search option
147- let search_option = document . createElement ( "option" )
148- search_option . value = sorted [ item ] [ 'id' ]
149- search_option . textContent = sorted [ item ] [ 'name' ]
150- search_options . appendChild ( search_option )
151144
152145 let column = document . createElement ( "div" )
153146 column . className = "col-lg-4 mb-5"
@@ -386,47 +379,154 @@ function run_search() {
386379 search_container . appendChild ( resultsHeading )
387380
388381 const row = document . createElement ( "div" )
389- row . className = "row row-cols-2 row-cols-sm-3 row-cols-md-4 row-cols-lg-6 g-2 "
382+ row . className = "row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-3 "
390383 search_container . appendChild ( row )
391384
392- matches . slice ( 0 , 60 ) . forEach ( ( [ id , game ] ) => {
393- const col = document . createElement ( "div" )
394- col . className = "col"
395- row . appendChild ( col )
396-
397- const card = document . createElement ( "a" )
398- card . className = "card h-100 text-decoration-none shadow-sm border-0 rounded-0"
399- card . href = `${ base_path } /browse/games/?id=${ id } `
400- col . appendChild ( card )
401-
402- // Placeholder cover
403- const placeholder = document . createElement ( "div" )
404- placeholder . className = "card-img-top bg-dark d-flex align-items-center justify-content-center"
405- placeholder . style . height = "120px"
406- const icon = document . createElement ( "span" )
407- icon . className = "material-symbols-outlined text-white"
408- icon . style . fontSize = "3rem"
409- icon . textContent = "sports_esports"
410- placeholder . appendChild ( icon )
411- card . appendChild ( placeholder )
412-
413- const cardBody = document . createElement ( "div" )
414- cardBody . className = "card-body p-2"
415- card . appendChild ( cardBody )
416-
417- const nameEl = document . createElement ( "p" )
418- nameEl . className = "card-text small mb-0"
419- nameEl . textContent = game . name
420- nameEl . title = game . name
421- cardBody . appendChild ( nameEl )
422- } )
423-
424- if ( matches . length > 60 ) {
425- const moreNote = document . createElement ( "p" )
426- moreNote . className = "text-muted mt-2 small"
427- moreNote . textContent = `Showing first 60 of ${ matches . length } results. Try a more specific search term.`
428- search_container . appendChild ( moreNote )
429- }
385+ // Fetch platform names to display
386+ fetch ( `${ base_url } /platforms/all.json` )
387+ . then ( r => r . json ( ) )
388+ . then ( allPlatforms => {
389+ matches . slice ( 0 , 60 ) . forEach ( ( [ id , game ] ) => {
390+ const col = document . createElement ( "div" )
391+ col . className = "col"
392+ row . appendChild ( col )
393+
394+ const card = document . createElement ( "a" )
395+ card . className = "card h-100 text-decoration-none shadow-sm border-0 rounded-0"
396+ card . href = `${ base_path } /browse/games/?id=${ id } `
397+ col . appendChild ( card )
398+
399+ // Cover image or placeholder
400+ if ( game . cover && game . cover . url ) {
401+ const coverImg = document . createElement ( "img" )
402+ coverImg . className = "card-img-top rounded-top-0"
403+ coverImg . src = game . cover . url . replace ( "t_thumb" , "t_cover_small" )
404+ coverImg . alt = game . name
405+ coverImg . loading = "lazy"
406+ coverImg . style . height = "180px"
407+ coverImg . style . objectFit = "cover"
408+ card . appendChild ( coverImg )
409+ } else {
410+ const placeholder = document . createElement ( "div" )
411+ placeholder . className = "card-img-top bg-secondary d-flex align-items-center justify-content-center"
412+ placeholder . style . height = "180px"
413+ const icon = document . createElement ( "span" )
414+ icon . className = "material-symbols-outlined text-white"
415+ icon . style . fontSize = "3rem"
416+ icon . textContent = "sports_esports"
417+ placeholder . appendChild ( icon )
418+ card . appendChild ( placeholder )
419+ }
420+
421+ const cardBody = document . createElement ( "div" )
422+ cardBody . className = "card-body p-2"
423+ card . appendChild ( cardBody )
424+
425+ // Game name
426+ const nameEl = document . createElement ( "h6" )
427+ nameEl . className = "card-title small mb-2 fw-bold text-truncate"
428+ nameEl . textContent = game . name
429+ nameEl . title = game . name
430+ cardBody . appendChild ( nameEl )
431+
432+ // Platforms with release years
433+ if ( game . platforms && game . platforms . length > 0 ) {
434+ const platformsDiv = document . createElement ( "div" )
435+ platformsDiv . className = "mb-2"
436+
437+ // Group release dates by platform
438+ const platformYears = { }
439+ if ( game . release_dates && game . release_dates . length > 0 ) {
440+ game . release_dates . forEach ( rd => {
441+ if ( rd . platform && rd . y ) {
442+ if ( ! platformYears [ rd . platform ] || rd . y < platformYears [ rd . platform ] ) {
443+ platformYears [ rd . platform ] = rd . y
444+ }
445+ }
446+ } )
447+ }
448+
449+ // Show first 3 platforms
450+ game . platforms . slice ( 0 , 3 ) . forEach ( platformId => {
451+ const platform = allPlatforms [ String ( platformId ) ]
452+ const platformName = platform ? platform . name : `Platform ${ platformId } `
453+ const year = platformYears [ platformId ] ? ` (${ platformYears [ platformId ] } )` : ""
454+
455+ const badge = document . createElement ( "span" )
456+ badge . className = "badge bg-secondary me-1 mb-1 small"
457+ badge . style . fontSize = "0.7rem"
458+ badge . textContent = platformName + year
459+ platformsDiv . appendChild ( badge )
460+ } )
461+
462+ if ( game . platforms . length > 3 ) {
463+ const moreBadge = document . createElement ( "span" )
464+ moreBadge . className = "badge bg-secondary me-1 mb-1 small"
465+ moreBadge . style . fontSize = "0.7rem"
466+ moreBadge . textContent = `+${ game . platforms . length - 3 } more`
467+ platformsDiv . appendChild ( moreBadge )
468+ }
469+
470+ cardBody . appendChild ( platformsDiv )
471+ }
472+ } )
473+
474+ if ( matches . length > 60 ) {
475+ const moreNote = document . createElement ( "p" )
476+ moreNote . className = "text-muted mt-3 small"
477+ moreNote . textContent = `Showing first 60 of ${ matches . length } results. Try a more specific search term.`
478+ search_container . appendChild ( moreNote )
479+ }
480+ } )
481+ . catch ( ( ) => {
482+ // Fallback if platforms can't be loaded
483+ matches . slice ( 0 , 60 ) . forEach ( ( [ id , game ] ) => {
484+ const col = document . createElement ( "div" )
485+ col . className = "col"
486+ row . appendChild ( col )
487+
488+ const card = document . createElement ( "a" )
489+ card . className = "card h-100 text-decoration-none shadow-sm border-0 rounded-0"
490+ card . href = `${ base_path } /browse/games/?id=${ id } `
491+ col . appendChild ( card )
492+
493+ if ( game . cover && game . cover . url ) {
494+ const coverImg = document . createElement ( "img" )
495+ coverImg . className = "card-img-top rounded-top-0"
496+ coverImg . src = game . cover . url . replace ( "t_thumb" , "t_cover_small" )
497+ coverImg . alt = game . name
498+ coverImg . loading = "lazy"
499+ card . appendChild ( coverImg )
500+ } else {
501+ const placeholder = document . createElement ( "div" )
502+ placeholder . className = "card-img-top bg-secondary d-flex align-items-center justify-content-center"
503+ placeholder . style . height = "180px"
504+ const icon = document . createElement ( "span" )
505+ icon . className = "material-symbols-outlined text-white"
506+ icon . style . fontSize = "3rem"
507+ icon . textContent = "sports_esports"
508+ placeholder . appendChild ( icon )
509+ card . appendChild ( placeholder )
510+ }
511+
512+ const cardBody = document . createElement ( "div" )
513+ cardBody . className = "card-body p-2"
514+ card . appendChild ( cardBody )
515+
516+ const nameEl = document . createElement ( "p" )
517+ nameEl . className = "card-text small mb-0"
518+ nameEl . textContent = game . name
519+ nameEl . title = game . name
520+ cardBody . appendChild ( nameEl )
521+ } )
522+
523+ if ( matches . length > 60 ) {
524+ const moreNote = document . createElement ( "p" )
525+ moreNote . className = "text-muted mt-3 small"
526+ moreNote . textContent = `Showing first 60 of ${ matches . length } results. Try a more specific search term.`
527+ search_container . appendChild ( moreNote )
528+ }
529+ } )
430530 } )
431531 . catch ( err => {
432532 loading . remove ( )
0 commit comments