@@ -6,6 +6,7 @@ class FilesystemDisplay {
6
6
const path = require ( "path" ) ;
7
7
this . cwd = [ ] ;
8
8
this . iconcolor = `rgb(${ window . theme . r } , ${ window . theme . g } , ${ window . theme . b } )` ;
9
+ this . _formatBytes = ( a , b ) => { if ( 0 == a ) return "0 Bytes" ; var c = 1024 , d = b || 2 , e = [ "Bytes" , "KB" , "MB" , "GB" , "TB" , "PB" , "EB" , "ZB" , "YB" ] , f = Math . floor ( Math . log ( a ) / Math . log ( c ) ) ; return parseFloat ( ( a / Math . pow ( c , f ) ) . toFixed ( d ) ) + " " + e [ f ] } ;
9
10
this . fileIconsMatcher = require ( "./assets/misc/file-icons-match.js" ) ;
10
11
this . icons = require ( "./assets/icons/file-icons.json" ) ;
11
12
this . edexIcons = {
@@ -127,14 +128,24 @@ class FilesystemDisplay {
127
128
128
129
this . toggleHidedotfiles = ( ) => {
129
130
if ( window . settings . hideDotfiles ) {
130
- container . setAttribute ( "class" , " ") ;
131
+ container . classList . remove ( "hideDotfiles ") ;
131
132
window . settings . hideDotfiles = false ;
132
133
} else {
133
- container . setAttribute ( "class" , "hideDotfiles" ) ;
134
+ container . classList . add ( "hideDotfiles" ) ;
134
135
window . settings . hideDotfiles = true ;
135
136
}
136
137
} ;
137
138
139
+ this . toggleListview = ( ) => {
140
+ if ( window . settings . fsListView ) {
141
+ container . classList . remove ( "list-view" ) ;
142
+ window . settings . fsListView = false ;
143
+ } else {
144
+ container . classList . add ( "list-view" ) ;
145
+ window . settings . fsListView = true ;
146
+ }
147
+ } ;
148
+
138
149
this . readFS = async dir => {
139
150
if ( this . failed === true || this . _reading ) return false ;
140
151
this . _reading = true ;
@@ -182,6 +193,8 @@ class FilesystemDisplay {
182
193
} ;
183
194
184
195
if ( typeof fstat !== "undefined" ) {
196
+ e . lastAccessed = fstat . mtime ;
197
+
185
198
if ( fstat . isDirectory ( ) ) {
186
199
e . category = "dir" ;
187
200
e . type = "dir" ;
@@ -197,6 +210,7 @@ class FilesystemDisplay {
197
210
if ( fstat . isFile ( ) ) {
198
211
e . category = "file" ;
199
212
e . type = "file" ;
213
+ e . size = fstat . size ;
200
214
}
201
215
} else {
202
216
e . type = "system" ;
@@ -332,12 +346,17 @@ class FilesystemDisplay {
332
346
}
333
347
334
348
let icon = "" ;
349
+ let type = "" ;
335
350
switch ( e . type ) {
336
351
case "showDisks" :
337
352
icon = this . icons . showDisks ;
353
+ type = "--" ;
354
+ e . category = "showDisks" ;
338
355
break ;
339
356
case "up" :
340
357
icon = this . icons . up ;
358
+ type = "--" ;
359
+ e . category = "up" ;
341
360
break ;
342
361
case "symlink" :
343
362
icon = this . icons . symlink ;
@@ -353,35 +372,64 @@ class FilesystemDisplay {
353
372
break ;
354
373
case "edex-theme" :
355
374
icon = this . edexIcons . theme ;
375
+ type = "eDEX-UI theme" ;
356
376
break ;
357
377
case "edex-kblayout" :
358
378
icon = this . edexIcons . kblayout ;
379
+ type = "eDEX-UI keyboard layout" ;
359
380
break ;
360
381
case "edex-settings" :
382
+ icon = this . edexIcons . settings ;
383
+ type = "eDEX-UI config file" ;
384
+ break ;
361
385
case "system" :
362
386
icon = this . edexIcons . settings ;
363
387
break ;
364
388
case "edex-themesDir" :
365
389
icon = this . edexIcons . themesDir ;
390
+ type = "eDEX-UI themes folder" ;
366
391
break ;
367
392
case "edex-kblayoutsDir" :
368
393
icon = this . edexIcons . kblayoutsDir ;
394
+ type = "eDEX-UI keyboards folder" ;
369
395
break ;
370
396
default :
371
- icon = this . icons [ this . fileIconsMatcher ( e . name ) ] ;
397
+ if ( e . type === "dir" ) type = "folder" ;
398
+ let iconName = this . fileIconsMatcher ( e . name ) ;
399
+ icon = this . icons [ iconName ] ;
372
400
if ( typeof icon === "undefined" ) {
373
401
if ( e . type === "file" ) icon = this . icons . file ;
374
- if ( e . type === "dir" ) icon = this . icons . dir ;
402
+ if ( e . type === "dir" ) {
403
+ icon = this . icons . dir ;
404
+ }
375
405
if ( typeof icon === "undefined" ) icon = this . icons . other ;
406
+ } else {
407
+ type = iconName . replace ( "icon-" , "" ) ;
376
408
}
377
409
break ;
378
410
}
379
411
412
+ if ( type === "" ) type = e . type ;
413
+
414
+ if ( typeof e . size === "number" ) {
415
+ e . size = this . _formatBytes ( e . size ) ;
416
+ } else {
417
+ e . size = "--" ;
418
+ }
419
+ if ( typeof e . lastAccessed === "object" ) {
420
+ e . lastAccessed = e . lastAccessed . toString ( ) . substr ( 0 , e . lastAccessed . toString ( ) . indexOf ( " (" ) ) ;
421
+ } else {
422
+ e . lastAccessed = "--" ;
423
+ }
424
+
380
425
filesDOM += `<div class="fs_disp_${ e . type } ${ hidden } animationWait" onclick="${ cmd } ">
381
426
<svg viewBox="0 0 ${ icon . width } ${ icon . height } " fill="${ this . iconcolor } ">
382
427
${ icon . svg }
383
428
</svg>
384
429
<h3>${ e . name } </h3>
430
+ <h4>${ type } </h4>
431
+ <h4>${ e . size } </h4>
432
+ <h4>${ e . lastAccessed } </h4>
385
433
</div>` ;
386
434
} ) ;
387
435
this . filesContainer . innerHTML = filesDOM ;
0 commit comments