11let fpdb = {
22 api : 'https://db-api.unstable.life' ,
33 images : 'https://infinity.unstable.life/images' ,
4+ icons : 'https://flashpointproject.github.io/flashpoint-database-logos/' ,
45 resultsPerPage : 100 ,
56 metaMap : {
67 title : "Title" ,
@@ -71,9 +72,6 @@ fetch('fields.json').then(r => r.json()).then(async json => {
7172fetch ( 'sort.json' ) . then ( r => r . json ( ) ) . then ( json => {
7273 fpdb . sortOptions = json ;
7374
74- let options = document . querySelector ( '.results-sort-options' ) ,
75- direction = document . querySelector ( '.results-sort-direction' ) ;
76-
7775 for ( let sort of json ) {
7876 let opt = document . createElement ( 'option' ) ;
7977 opt . value = sort . name ;
@@ -226,22 +224,12 @@ function loadPage(page) {
226224 } ) ;
227225
228226 for ( let i = ( page - 1 ) * fpdb . displayedResults ; i < Math . min ( fpdb . list . length , page * fpdb . displayedResults ) ; i ++ ) {
229- let entry = document . createElement ( 'div' )
227+ let compact = document . querySelector ( '#compact' ) . checked ;
228+
229+ let entry = document . createElement ( 'div' ) ;
230230 entry . className = 'entry' ;
231-
232- let logo = document . createElement ( 'div' ) ;
233- logo . className = 'entry-logo' ;
234- logo . setAttribute ( 'view' , i ) ;
235- logo . setAttribute ( 'lazy-background' , `url("${ fpdb . images } /Logos/${ fpdb . list [ i ] . id . substring ( 0 , 2 ) } /${ fpdb . list [ i ] . id . substring ( 2 , 4 ) } /${ fpdb . list [ i ] . id } .png?type=jpg")` ) ;
236- logo . addEventListener ( 'click' , loadEntry ) ;
237- logoObserver . observe ( logo ) ;
238-
239- let text = document . createElement ( 'div' ) ;
240- text . className = 'entry-text' ;
241-
242- let header = document . createElement ( 'div' ) ,
243- subHeader = document . createElement ( 'div' ) ;
244-
231+ if ( compact ) entry . setAttribute ( 'compact' , 'true' ) ;
232+
245233 let title = document . createElement ( 'a' ) ;
246234 title . classList . add ( 'entry-title' , 'common-activate' ) ;
247235 title . setAttribute ( 'view' , i ) ;
@@ -256,29 +244,61 @@ function loadPage(page) {
256244 developer . textContent = ' by ' + fpdb . list [ i ] . publisher ;
257245 else
258246 developer . hidden = true ;
259-
260- let type = document . createElement ( 'span' ) ;
261- type . className = 'entry-type' ;
262- type . textContent = fpdb . list [ i ] . platform . replace ( / ; / g, '/' ) + ( fpdb . list [ i ] . library == 'arcade' ? ' game' : ' animation' ) ;
263-
247+
264248 let tags = document . createElement ( 'span' ) ;
265249 tags . className = 'entry-tags' ;
266- tags . textContent = ' - ' + fpdb . list [ i ] . tags . join ( ' - ' ) ;
250+ if ( compact )
251+ tags . textContent = fpdb . list [ i ] . tags . join ( ', ' ) ;
252+ else
253+ tags . textContent = '\u00A0- ' + fpdb . list [ i ] . tags . join ( ' - ' ) ;
267254
268255 let description = document . createElement ( 'div' ) ;
269256 description . className = 'entry-description' ;
270257 if ( fpdb . list [ i ] . originalDescription != '' )
271258 description . textContent = fpdb . list [ i ] . originalDescription ;
259+ else if ( ! compact ) {
260+ description . textContent = 'No description.' ;
261+ description . setAttribute ( 'empty' , 'true' ) ;
262+ }
263+
264+ if ( compact ) {
265+ let platform = document . createElement ( 'div' ) ;
266+ platform . className = 'entry-platform' ;
267+ let platformName = fpdb . list [ i ] . platform . split ( '; ' ) [ 0 ] ;
268+ platform . style . backgroundImage = 'url("' + fpdb . icons + platformName + '.png")' ;
269+ platform . setAttribute ( 'title' , platformName ) ;
270+
271+ let library = document . createElement ( 'div' ) ;
272+ library . className = 'entry-library' ;
273+ library . style . backgroundImage = 'url("' + ( fpdb . list [ i ] . library == 'arcade' ? 'game.png' : 'animation.png' ) + '")' ;
274+ library . setAttribute ( 'title' , fpdb . list [ i ] . library == 'arcade' ? 'Game' : 'Animation' ) ;
275+
276+ entry . append ( platform , library , title , developer , description , tags ) ;
277+ }
272278 else {
273- description . textContent = 'No description.'
274- description . style . color = '#000a' ;
275- description . style . fontStyle = 'italic' ;
279+ let logo = document . createElement ( 'div' ) ;
280+ logo . className = 'entry-logo' ;
281+ logo . setAttribute ( 'view' , i ) ;
282+ logo . setAttribute ( 'lazy-background' , `url("${ fpdb . images } /Logos/${ fpdb . list [ i ] . id . substring ( 0 , 2 ) } /${ fpdb . list [ i ] . id . substring ( 2 , 4 ) } /${ fpdb . list [ i ] . id } .png?type=jpg")` ) ;
283+ logo . addEventListener ( 'click' , loadEntry ) ;
284+ logoObserver . observe ( logo ) ;
285+
286+ let text = document . createElement ( 'div' ) ;
287+ text . className = 'entry-text' ;
288+
289+ let header = document . createElement ( 'div' ) ,
290+ subHeader = document . createElement ( 'div' ) ;
291+
292+ let type = document . createElement ( 'span' ) ;
293+ type . className = 'entry-type' ;
294+ type . textContent = fpdb . list [ i ] . platform . replace ( / ; / g, '/' ) + ( fpdb . list [ i ] . library == 'arcade' ? ' game' : ' animation' ) ;
295+
296+ header . append ( title , developer ) ;
297+ subHeader . append ( type , tags ) ;
298+ text . append ( header , subHeader , description ) ;
299+ entry . append ( logo , text ) ;
276300 }
277301
278- header . append ( title , developer ) ;
279- subHeader . append ( type , tags ) ;
280- text . append ( header , subHeader , description ) ;
281- entry . append ( logo , text ) ;
282302 htmlList . append ( entry ) ;
283303 }
284304}
@@ -436,6 +456,8 @@ function backToResults() {
436456
437457document . querySelector ( '.search-button' ) . addEventListener ( 'click' , performSearch ) ;
438458
459+ document . querySelector ( '#compact' ) . addEventListener ( 'change' , ( ) => loadPage ( fpdb . currentPage ) ) ;
460+
439461document . querySelectorAll ( '.results-first-page' ) . forEach ( elem => elem . addEventListener ( 'click' , ( ) => { if ( fpdb . currentPage > 1 ) loadPage ( 1 ) ; } ) ) ;
440462document . querySelectorAll ( '.results-back-page' ) . forEach ( elem => elem . addEventListener ( 'click' , ( ) => { if ( fpdb . currentPage > 1 ) loadPage ( fpdb . currentPage - 1 ) ; } ) ) ;
441463document . querySelectorAll ( '.results-forward-page' ) . forEach ( elem => elem . addEventListener ( 'click' , ( ) => { if ( fpdb . currentPage < fpdb . pages ) loadPage ( fpdb . currentPage + 1 ) ; } ) ) ;
0 commit comments