11let fpdb = {
22 api : 'https://db-api.unstable.life' ,
33 images : 'https://infinity.unstable.life/images' ,
4+ icons : 'https://unstable.life/updater-data/12-1/Data/Logos/' ,
45 resultsPerPage : 100 ,
56 metaMap : {
67 title : "Title" ,
@@ -70,9 +71,6 @@ fetch('fields.json').then(r => r.json()).then(async json => {
7071fetch ( 'sort.json' ) . then ( r => r . json ( ) ) . then ( json => {
7172 fpdb . sortOptions = json ;
7273
73- let options = document . querySelector ( '.results-sort-options' ) ,
74- direction = document . querySelector ( '.results-sort-direction' ) ;
75-
7674 for ( let sort of json ) {
7775 let opt = document . createElement ( 'option' ) ;
7876 opt . value = sort . name ;
@@ -225,22 +223,12 @@ function loadPage(page) {
225223 } ) ;
226224
227225 for ( let i = ( page - 1 ) * fpdb . displayedResults ; i < Math . min ( fpdb . list . length , page * fpdb . displayedResults ) ; i ++ ) {
228- let entry = document . createElement ( 'div' )
226+ let compact = document . querySelector ( '#compact' ) . checked ;
227+
228+ let entry = document . createElement ( 'div' ) ;
229229 entry . className = 'entry' ;
230-
231- let logo = document . createElement ( 'div' ) ;
232- logo . className = 'entry-logo' ;
233- logo . setAttribute ( 'view' , i ) ;
234- 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")` ) ;
235- logo . addEventListener ( 'click' , loadEntry ) ;
236- logoObserver . observe ( logo ) ;
237-
238- let text = document . createElement ( 'div' ) ;
239- text . className = 'entry-text' ;
240-
241- let header = document . createElement ( 'div' ) ,
242- subHeader = document . createElement ( 'div' ) ;
243-
230+ if ( compact ) entry . setAttribute ( 'compact' , 'true' ) ;
231+
244232 let title = document . createElement ( 'a' ) ;
245233 title . classList . add ( 'entry-title' , 'common-activate' ) ;
246234 title . setAttribute ( 'view' , i ) ;
@@ -255,29 +243,61 @@ function loadPage(page) {
255243 developer . textContent = ' by ' + fpdb . list [ i ] . publisher ;
256244 else
257245 developer . hidden = true ;
258-
259- let type = document . createElement ( 'span' ) ;
260- type . className = 'entry-type' ;
261- type . textContent = fpdb . list [ i ] . platform . replace ( / ; / g, '/' ) + ( fpdb . list [ i ] . library == 'arcade' ? ' game' : ' animation' ) ;
262-
246+
263247 let tags = document . createElement ( 'span' ) ;
264248 tags . className = 'entry-tags' ;
265- tags . textContent = ' - ' + fpdb . list [ i ] . tags . join ( ' - ' ) ;
249+ if ( compact )
250+ tags . textContent = fpdb . list [ i ] . tags . join ( ', ' ) ;
251+ else
252+ tags . textContent = '\u00A0- ' + fpdb . list [ i ] . tags . join ( ' - ' ) ;
266253
267254 let description = document . createElement ( 'div' ) ;
268255 description . className = 'entry-description' ;
269256 if ( fpdb . list [ i ] . originalDescription != '' )
270257 description . textContent = fpdb . list [ i ] . originalDescription ;
258+ else if ( ! compact ) {
259+ description . textContent = 'No description.' ;
260+ description . setAttribute ( 'empty' , 'true' ) ;
261+ }
262+
263+ if ( compact ) {
264+ let platform = document . createElement ( 'div' ) ;
265+ platform . className = 'entry-platform' ;
266+ let platformName = fpdb . list [ i ] . platform . split ( '; ' ) [ 0 ] ;
267+ platform . style . backgroundImage = 'url("' + fpdb . icons + platformName + '.png")' ;
268+ platform . setAttribute ( 'title' , platformName ) ;
269+
270+ let library = document . createElement ( 'div' ) ;
271+ library . className = 'entry-library' ;
272+ library . style . backgroundImage = 'url("' + ( fpdb . list [ i ] . library == 'arcade' ? 'game.png' : 'animation.png' ) + '")' ;
273+ library . setAttribute ( 'title' , fpdb . list [ i ] . library == 'arcade' ? 'Game' : 'Animation' ) ;
274+
275+ entry . append ( platform , library , title , developer , description , tags ) ;
276+ }
271277 else {
272- description . textContent = 'No description.'
273- description . style . color = '#000a' ;
274- description . style . fontStyle = 'italic' ;
278+ let logo = document . createElement ( 'div' ) ;
279+ logo . className = 'entry-logo' ;
280+ logo . setAttribute ( 'view' , i ) ;
281+ 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")` ) ;
282+ logo . addEventListener ( 'click' , loadEntry ) ;
283+ logoObserver . observe ( logo ) ;
284+
285+ let text = document . createElement ( 'div' ) ;
286+ text . className = 'entry-text' ;
287+
288+ let header = document . createElement ( 'div' ) ,
289+ subHeader = document . createElement ( 'div' ) ;
290+
291+ let type = document . createElement ( 'span' ) ;
292+ type . className = 'entry-type' ;
293+ type . textContent = fpdb . list [ i ] . platform . replace ( / ; / g, '/' ) + ( fpdb . list [ i ] . library == 'arcade' ? ' game' : ' animation' ) ;
294+
295+ header . append ( title , developer ) ;
296+ subHeader . append ( type , tags ) ;
297+ text . append ( header , subHeader , description ) ;
298+ entry . append ( logo , text ) ;
275299 }
276300
277- header . append ( title , developer ) ;
278- subHeader . append ( type , tags ) ;
279- text . append ( header , subHeader , description ) ;
280- entry . append ( logo , text ) ;
281301 htmlList . append ( entry ) ;
282302 }
283303}
@@ -435,6 +455,8 @@ function backToResults() {
435455
436456document . querySelector ( '.search-button' ) . addEventListener ( 'click' , performSearch ) ;
437457
458+ document . querySelector ( '#compact' ) . addEventListener ( 'change' , ( ) => loadPage ( fpdb . currentPage ) ) ;
459+
438460document . querySelectorAll ( '.results-first-page' ) . forEach ( elem => elem . addEventListener ( 'click' , ( ) => { if ( fpdb . currentPage > 1 ) loadPage ( 1 ) ; } ) ) ;
439461document . querySelectorAll ( '.results-back-page' ) . forEach ( elem => elem . addEventListener ( 'click' , ( ) => { if ( fpdb . currentPage > 1 ) loadPage ( fpdb . currentPage - 1 ) ; } ) ) ;
440462document . querySelectorAll ( '.results-forward-page' ) . forEach ( elem => elem . addEventListener ( 'click' , ( ) => { if ( fpdb . currentPage < fpdb . pages ) loadPage ( fpdb . currentPage + 1 ) ; } ) ) ;
0 commit comments