1
1
const domPoster = require ( p . join ( appDir , 'scripts/dom/poster.js' ) ) ,
2
2
domManager = require ( p . join ( appDir , 'scripts/dom/dom.js' ) ) ,
3
+ labels = require ( p . join ( appDir , 'scripts/dom/labels.js' ) ) ,
3
4
search = require ( p . join ( appDir , 'scripts/dom/search.js' ) ) ;
4
5
5
6
/*Page - Index*/
@@ -338,6 +339,13 @@ async function reloadIndex()
338
339
if ( indexPathA ) indexPathControlA . pop ( ) ;
339
340
}
340
341
342
+ var indexLabel = { } ;
343
+
344
+ function setIndexLabel ( config )
345
+ {
346
+ indexLabel = config ;
347
+ }
348
+
341
349
var currentPath = false , currentPathScrollTop = [ ] , fromDeepLoadNow = 0 ;
342
350
343
351
async function loadIndexPage ( animation = true , path = false , content = false , keepScroll = false , mainPath = false , fromGoBack = false , notAutomaticBrowsing = false , fromDeepLoad = false )
@@ -359,6 +367,9 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
359
367
if ( currentPathScrollTop [ path === false ? 0 : path ] )
360
368
keepScroll = currentPathScrollTop [ path === false ? 0 : path ] ;
361
369
370
+ let _indexLabel = indexLabel ;
371
+ indexLabel = { } ;
372
+
362
373
currentPath = path ;
363
374
364
375
if ( ! path )
@@ -410,7 +421,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
410
421
{
411
422
for ( let key in masterFolders )
412
423
{
413
- if ( fs . existsSync ( masterFolders [ key ] ) )
424
+ if ( fs . existsSync ( masterFolders [ key ] ) && ( ! _indexLabel . masterFolder || _indexLabel . masterFolder == masterFolders [ key ] ) )
414
425
{
415
426
let file = fileManager . file ( masterFolders [ key ] ) ;
416
427
let files = await file . readDir ( ) ;
@@ -441,7 +452,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
441
452
// Get comics in library
442
453
let comicsStorage = storage . get ( 'comics' ) ;
443
454
444
- if ( ! isEmpty ( comicsStorage ) )
455
+ if ( ! isEmpty ( comicsStorage ) && ! _indexLabel . masterFolder )
445
456
{
446
457
for ( let key in comicsStorage )
447
458
{
@@ -494,7 +505,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
494
505
495
506
if ( ! content )
496
507
{
497
- if ( template . contentLeft ( '.menu-list' ) . length === 0 ) template . loadContentLeft ( 'index.content.left.html' , animation ) ;
508
+ if ( template . contentLeft ( '.menu-list' ) . length === 0 ) dom . loadIndexContentLeft ( animation ) ;
498
509
template . loadGlobalElement ( 'index.elements.menus.html' , 'menus' ) ;
499
510
floatingActionButton ( true , 'dom.addComicButtons();' ) ;
500
511
}
@@ -532,7 +543,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
532
543
{
533
544
if ( readingActive )
534
545
{
535
- template . loadContentLeft ( 'index.content.left.html' , animation ) ;
546
+ dom . loadIndexContentLeft ( animation ) ;
536
547
}
537
548
538
549
template . loadGlobalElement ( 'index.elements.menus.html' , 'menus' ) ;
@@ -627,15 +638,40 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
627
638
if ( readingActive )
628
639
readingActive = false ;
629
640
630
- if ( ! isFromRecentlyOpened )
631
- selectMenuItem ( 'library' ) ;
632
- else
633
- selectMenuItem ( 'recently-opened' ) ;
641
+ if ( isEmpty ( _indexLabel ) )
642
+ {
643
+ if ( ! isFromRecentlyOpened )
644
+ selectMenuItem ( 'library' ) ;
645
+ else
646
+ selectMenuItem ( 'recently-opened' ) ;
647
+ }
634
648
635
649
shortcuts . register ( 'browse' ) ;
636
650
gamepad . updateBrowsableItems ( path ? sha1 ( path ) : 'library' ) ;
637
651
}
638
652
653
+ function loadIndexContentLeft ( animation , isFromSettings = false )
654
+ {
655
+ let masterFolders = storage . get ( 'masterFolders' ) ;
656
+
657
+ let _masterFolders = [ ] ;
658
+
659
+ for ( let i = 0 , len = masterFolders . length ; i < len ; i ++ )
660
+ {
661
+ _masterFolders . push ( {
662
+ name : p . basename ( masterFolders [ i ] ) ,
663
+ path : masterFolders [ i ] ,
664
+ } ) ;
665
+ }
666
+
667
+ handlebarsContext . masterFolders = _masterFolders ;
668
+ handlebarsContext . isFromSettings = isFromSettings ;
669
+
670
+ template . loadContentLeft ( 'index.content.left.html' , animation ) ;
671
+
672
+ handlebarsContext . isFromSettings = false ;
673
+ }
674
+
639
675
function compressedError ( error )
640
676
{
641
677
//console.log(error);
@@ -1064,7 +1100,7 @@ function changeLanguage(lan)
1064
1100
template . contentRight ( '.language-list.active' ) . removeClass ( 'active' ) ;
1065
1101
template . contentRight ( '.language-list-' + lan ) . addClass ( 'active' ) ;
1066
1102
1067
- template . loadContentLeft ( 'index.content.left.html' , false ) ;
1103
+ dom . loadIndexContentLeft ( false ) ;
1068
1104
template . loadHeader ( 'languages.header.html' , false ) ;
1069
1105
storage . updateVar ( 'config' , 'language' , lan ) ;
1070
1106
@@ -1661,12 +1697,15 @@ gamepad.setButtonEvent('reading', 1, function(key, button) {
1661
1697
1662
1698
module . exports = {
1663
1699
loadIndexPage : loadIndexPage ,
1700
+ loadIndexContentLeft : loadIndexContentLeft ,
1701
+ setIndexLabel : setIndexLabel ,
1664
1702
reloadIndex : reloadIndex ,
1665
1703
loadRecentlyOpened : loadRecentlyOpened ,
1666
1704
loadLanguagesPage : loadLanguagesPage ,
1667
1705
loadSettingsPage : loadSettingsPage ,
1668
1706
loadThemePage : loadThemePage ,
1669
1707
changeLanguage : changeLanguage ,
1708
+ selectMenuItem : selectMenuItem ,
1670
1709
floatingActionButton : floatingActionButton ,
1671
1710
setCurrentPageVars : setCurrentPageVars ,
1672
1711
changeView : changeView ,
@@ -1699,6 +1738,7 @@ module.exports = {
1699
1738
metadataPathName : metadataPathName ,
1700
1739
fromLibrary : fromLibrary ,
1701
1740
search : search ,
1741
+ labels : labels ,
1702
1742
this : domManager . this ,
1703
1743
query : domManager . query ,
1704
1744
queryAll : domManager . queryAll ,
0 commit comments