@@ -183,7 +183,7 @@ function addImageToDom(querySelector, path, animation = true)
183
183
184
184
async function loadFilesIndexPage ( file , animation , path , keepScroll , mainPath )
185
185
{
186
- file . read ( ) . then ( async function ( files ) {
186
+ return file . read ( ) . then ( async function ( files ) {
187
187
188
188
queue . clean ( 'folderThumbnails' ) ;
189
189
@@ -305,211 +305,6 @@ async function loadFilesIndexPage(file, animation, path, keepScroll, mainPath)
305
305
306
306
var currentPath = false , currentPathScrollTop = [ ] ;
307
307
308
- function _loadIndexPage ( animation = true , path = false , content = false , keepScroll = false , mainPath = false , fromGoBack = false )
309
- {
310
- onReading = false ;
311
-
312
- reading . hideContent ( ) ;
313
-
314
- generateAppMenu ( ) ;
315
-
316
- currentPathScrollTop [ currentPath === false ? 0 : currentPath ] = template . contentRight ( ) . children ( ) . scrollTop ( ) ;
317
-
318
- for ( let _path in currentPathScrollTop )
319
- {
320
- if ( _path != 0 && ! new RegExp ( '^' + pregQuote ( _path ) ) . test ( path ) )
321
- delete currentPathScrollTop [ _path ] ;
322
- }
323
-
324
- if ( currentPathScrollTop [ path === false ? 0 : path ] )
325
- keepScroll = currentPathScrollTop [ path === false ? 0 : path ] ;
326
-
327
- currentPath = path ;
328
-
329
- if ( ! path )
330
- {
331
- var sort = config . sortIndex ;
332
- var sortInvert = config . sortInvertIndex ;
333
- var foldersFirst = config . foldersFirstIndex ;
334
- }
335
- else
336
- {
337
- var sort = config . sort ;
338
- var sortInvert = config . sortInvert ;
339
- var foldersFirst = config . foldersFirst ;
340
- }
341
-
342
- var orderKey2 = false ;
343
-
344
- if ( sort == 'name' )
345
- {
346
- var order = 'simple' ;
347
- var orderKey = 'name' ;
348
- }
349
- else if ( sort == 'numeric' )
350
- {
351
- var order = 'numeric' ;
352
- var orderKey = 'name' ;
353
- }
354
- else if ( sort == 'name-numeric' )
355
- {
356
- var order = 'simple-numeric' ;
357
- var orderKey = 'name' ;
358
- }
359
- else if ( sort == 'last-add' )
360
- {
361
- var order = 'real-numeric' ;
362
- var orderKey = 'added' ;
363
- sortInvert = ! sortInvert ;
364
- }
365
- else
366
- {
367
- var order = 'real-numeric' ;
368
- var orderKey = 'readingProgress' ;
369
- var orderKey2 = 'lastReading' ;
370
- sortInvert = ! sortInvert ;
371
- }
372
-
373
- if ( ! path )
374
- {
375
- indexPathControl ( false ) ;
376
-
377
- var comicsStorage = storage . get ( 'comics' ) ;
378
- var comics = [ ] ;
379
-
380
- if ( ! isEmpty ( comicsStorage ) )
381
- {
382
- for ( let key in comicsStorage )
383
- {
384
- if ( fs . existsSync ( comicsStorage [ key ] . path ) )
385
- {
386
- comics . push ( comicsStorage [ key ] ) ;
387
- }
388
- else
389
- {
390
- //console.log(comicsStorage[key]);
391
- }
392
- }
393
-
394
- for ( let key in comics )
395
- {
396
- var images = getFolderThumbnails ( comics [ key ] . path ) ;
397
-
398
- comics [ key ] . images = images ;
399
- comics [ key ] . mainPath = config . showFullPathLibrary ? p . parse ( comics [ key ] . path ) . root : comics [ key ] . path ;
400
- }
401
-
402
- comics . sort ( function ( a , b ) {
403
- return ( sortInvert ) ? - ( orderBy ( a , b , order , orderKey , orderKey2 ) ) : orderBy ( a , b , order , orderKey , orderKey2 ) ;
404
- } ) ;
405
- }
406
-
407
- handlebarsContext . comics = comics ;
408
- handlebarsContext . comicsIndex = true ;
409
- handlebarsContext . comicsIndexVar = 'true' ;
410
- handlebarsContext . comicsReadingProgress = false ;
411
-
412
- template . loadContentRight ( 'index.content.right.' + config . viewIndex + '.html' , animation , keepScroll ) ;
413
-
414
- handlebarsContext . headerTitle = false ;
415
- handlebarsContext . headerTitlePath = false ;
416
- template . loadHeader ( 'index.header.html' , animation ) ;
417
-
418
- if ( ! content )
419
- {
420
- template . loadContentLeft ( 'index.content.left.html' , animation ) ;
421
- template . loadGlobalElement ( 'index.elements.menus.html' , 'menus' ) ;
422
- floatingActionButton ( true , 'dom.addComicButtons();' ) ;
423
- }
424
-
425
- events . events ( ) ;
426
-
427
- }
428
- else
429
- {
430
- if ( ! fromGoBack )
431
- indexPathControl ( path , mainPath ) ;
432
-
433
- handlebarsContext . comicsIndex = false ;
434
- handlebarsContext . comicsIndexVar = 'false' ;
435
-
436
- headerPath ( path , mainPath ) ;
437
- template . loadHeader ( 'index.header.html' , animation ) ;
438
- template . loadContentRight ( 'index.content.right.loading.html' , animation , keepScroll ) ;
439
-
440
- if ( ! content )
441
- {
442
- if ( readingActive )
443
- {
444
- template . loadContentLeft ( 'index.content.left.html' , animation ) ;
445
- }
446
-
447
- template . loadGlobalElement ( 'index.elements.menus.html' , 'menus' ) ;
448
- floatingActionButton ( false ) ;
449
- }
450
-
451
- cache . cleanQueue ( ) ;
452
-
453
- if ( ! fs . existsSync ( fileManager . realPath ( path , - 1 ) ) && fileManager . containsCompressed ( path ) )
454
- {
455
- fileCompressed . decompressRecursive ( path , function ( files ) {
456
-
457
- if ( checkError ( files ) && files . error == ERROR_UNZIPPING_THE_FILE )
458
- return dom . compressedError ( files ) ;
459
-
460
- if ( ! fs . statSync ( fileManager . realPath ( path , - 1 ) ) . isDirectory ( ) && inArray ( fileExtension ( path ) , compressedExtensions . all ) )
461
- {
462
- fileCompressed . returnFiles ( path , false , false , function ( files ) {
463
-
464
- if ( checkError ( files ) && files . error == ERROR_UNZIPPING_THE_FILE )
465
- return dom . compressedError ( files ) ;
466
-
467
- loadFilesIndexPage ( animation , path , keepScroll , mainPath ) ;
468
-
469
- } ) ;
470
- }
471
- else
472
- {
473
- loadFilesIndexPage ( animation , path , keepScroll , mainPath ) ;
474
- }
475
-
476
- } ) ;
477
- }
478
- else
479
- {
480
- if ( ! fs . statSync ( fileManager . realPath ( path , - 1 ) ) . isDirectory ( ) && inArray ( fileExtension ( path ) , compressedExtensions . all ) )
481
- {
482
- fileCompressed . returnFiles ( path , false , false , function ( files ) {
483
-
484
- if ( checkError ( files ) && files . error == ERROR_UNZIPPING_THE_FILE )
485
- return dom . compressedError ( files ) ;
486
-
487
- loadFilesIndexPage ( animation , path , keepScroll , mainPath ) ;
488
-
489
- } ) ;
490
- }
491
- else
492
- {
493
- loadFilesIndexPage ( animation , path , keepScroll , mainPath ) ;
494
- }
495
- }
496
- }
497
-
498
- if ( readingActive )
499
- {
500
- readingActive = false ;
501
- }
502
-
503
- justifyViewModule ( ) ;
504
-
505
- gamepad . updateBrowsableItems ( ) ;
506
-
507
- $ ( window ) . off ( 'resize' ) . on ( 'resize' , function ( ) {
508
- justifyViewModule ( ) ;
509
- } ) ;
510
-
511
- }
512
-
513
308
async function loadIndexPage ( animation = true , path = false , content = false , keepScroll = false , mainPath = false , fromGoBack = false )
514
309
{
515
310
onReading = false ;
@@ -646,13 +441,11 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
646
441
cache . cleanQueue ( ) ;
647
442
648
443
let file = fileManager . file ( path ) ;
649
- loadFilesIndexPage ( file , animation , path , keepScroll , mainPath ) ;
444
+ await loadFilesIndexPage ( file , animation , path , keepScroll , mainPath ) ;
650
445
}
651
446
652
447
if ( readingActive )
653
- {
654
448
readingActive = false ;
655
- }
656
449
657
450
justifyViewModule ( ) ;
658
451
@@ -1397,12 +1190,7 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
1397
1190
gamepad . setButtonEvent ( 'reading' , 1 , function ( key , button ) {
1398
1191
1399
1192
if ( key == 1 )
1400
- {
1401
- let barBack = document . querySelector ( '.bar-back.active, .bar-back.show' ) ;
1402
-
1403
- if ( barBack )
1404
- eval ( barBack . getAttribute ( 'onclick' ) ) ;
1405
- }
1193
+ gamepad . goBack ( ) ;
1406
1194
1407
1195
} ) ;
1408
1196
0 commit comments