Skip to content

Commit ff35144

Browse files
committed
New: Label to display only the contents of a master folder
1 parent a727249 commit ff35144

File tree

8 files changed

+96
-15
lines changed

8 files changed

+96
-15
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
##### 🚀 New Features
1010

11-
- Option to set maximum size of temporary files, preserving them when closing the app
11+
- Option to set maximum size of temporary files, preserving them when closing the app [`a727249`](https://github.com/ollm/OpenComic/commit/a7272499407191064f9d6bd7c42ecf3bb1231a83)
12+
- Label to display only the contents of a master folder
1213

1314
##### 🐛 Bug Fixes
1415

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<div align="center">
1414

15-
[Screenshots](https://github.com/ollm/OpenComic/blob/master/SCREENSHOTS.MD) | [Features](#features) | [Changelog](https://github.com/ollm/OpenComic/blob/master/CHANGELOG.md) | [Download](#download-beta-v100-beta5)
15+
[Screenshots](https://github.com/ollm/OpenComic/blob/master/SCREENSHOTS.MD) | [Features](#features) | [Changelog](https://github.com/ollm/OpenComic/blob/master/CHANGELOG.md) | [Download](#download-v100)
1616

1717
</div>
1818

scripts/dom.js

+49-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const domPoster = require(p.join(appDir, 'scripts/dom/poster.js')),
22
domManager = require(p.join(appDir, 'scripts/dom/dom.js')),
3+
labels = require(p.join(appDir, 'scripts/dom/labels.js')),
34
search = require(p.join(appDir, 'scripts/dom/search.js'));
45

56
/*Page - Index*/
@@ -338,6 +339,13 @@ async function reloadIndex()
338339
if(indexPathA) indexPathControlA.pop();
339340
}
340341

342+
var indexLabel = {};
343+
344+
function setIndexLabel(config)
345+
{
346+
indexLabel = config;
347+
}
348+
341349
var currentPath = false, currentPathScrollTop = [], fromDeepLoadNow = 0;
342350

343351
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
359367
if(currentPathScrollTop[path === false ? 0 : path])
360368
keepScroll = currentPathScrollTop[path === false ? 0 : path];
361369

370+
let _indexLabel = indexLabel;
371+
indexLabel = {};
372+
362373
currentPath = path;
363374

364375
if(!path)
@@ -410,7 +421,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
410421
{
411422
for(let key in masterFolders)
412423
{
413-
if(fs.existsSync(masterFolders[key]))
424+
if(fs.existsSync(masterFolders[key]) && (!_indexLabel.masterFolder || _indexLabel.masterFolder == masterFolders[key]))
414425
{
415426
let file = fileManager.file(masterFolders[key]);
416427
let files = await file.readDir();
@@ -441,7 +452,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
441452
// Get comics in library
442453
let comicsStorage = storage.get('comics');
443454

444-
if(!isEmpty(comicsStorage))
455+
if(!isEmpty(comicsStorage) && !_indexLabel.masterFolder)
445456
{
446457
for(let key in comicsStorage)
447458
{
@@ -494,7 +505,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
494505

495506
if(!content)
496507
{
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);
498509
template.loadGlobalElement('index.elements.menus.html', 'menus');
499510
floatingActionButton(true, 'dom.addComicButtons();');
500511
}
@@ -532,7 +543,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
532543
{
533544
if(readingActive)
534545
{
535-
template.loadContentLeft('index.content.left.html', animation);
546+
dom.loadIndexContentLeft(animation);
536547
}
537548

538549
template.loadGlobalElement('index.elements.menus.html', 'menus');
@@ -627,15 +638,40 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
627638
if(readingActive)
628639
readingActive = false;
629640

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+
}
634648

635649
shortcuts.register('browse');
636650
gamepad.updateBrowsableItems(path ? sha1(path) : 'library');
637651
}
638652

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+
639675
function compressedError(error)
640676
{
641677
//console.log(error);
@@ -1064,7 +1100,7 @@ function changeLanguage(lan)
10641100
template.contentRight('.language-list.active').removeClass('active');
10651101
template.contentRight('.language-list-'+lan).addClass('active');
10661102

1067-
template.loadContentLeft('index.content.left.html', false);
1103+
dom.loadIndexContentLeft(false);
10681104
template.loadHeader('languages.header.html', false);
10691105
storage.updateVar('config', 'language', lan);
10701106

@@ -1661,12 +1697,15 @@ gamepad.setButtonEvent('reading', 1, function(key, button) {
16611697

16621698
module.exports = {
16631699
loadIndexPage: loadIndexPage,
1700+
loadIndexContentLeft: loadIndexContentLeft,
1701+
setIndexLabel: setIndexLabel,
16641702
reloadIndex: reloadIndex,
16651703
loadRecentlyOpened: loadRecentlyOpened,
16661704
loadLanguagesPage: loadLanguagesPage,
16671705
loadSettingsPage: loadSettingsPage,
16681706
loadThemePage: loadThemePage,
16691707
changeLanguage: changeLanguage,
1708+
selectMenuItem: selectMenuItem,
16701709
floatingActionButton: floatingActionButton,
16711710
setCurrentPageVars: setCurrentPageVars,
16721711
changeView: changeView,
@@ -1699,6 +1738,7 @@ module.exports = {
16991738
metadataPathName: metadataPathName,
17001739
fromLibrary: fromLibrary,
17011740
search: search,
1741+
labels: labels,
17021742
this: domManager.this,
17031743
query: domManager.query,
17041744
queryAll: domManager.queryAll,

scripts/dom/labels.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
function masterFolder(folder, index)
3+
{
4+
dom.selectMenuItem('master-folder-'+index);
5+
dom.setIndexLabel({masterFolder: folder});
6+
dom.loadIndexPage(true);
7+
}
8+
9+
module.exports = {
10+
masterFolder: masterFolder,
11+
};

scripts/opencomic.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ async function startApp()
341341

342342
template.loadContentRight('index.content.right.empty.html', false);
343343
template.loadHeader('index.header.html', false);
344-
template.loadContentLeft('index.content.left.html', false);
345344
template.loadGlobalElement('index.elements.menus.html', 'menus');
345+
dom.loadIndexContentLeft(false);
346346

347347
if(!toOpenFile)
348348
{
@@ -940,6 +940,20 @@ hb.registerHelper('compare', function(lvalue, operator, rvalue, options) {
940940

941941
});
942942

943+
hb.registerHelper('ifOr', function() {
944+
945+
let options = arguments[arguments.length - 1];
946+
947+
for(let i = 0, len = arguments.length - 1; i < len; i++)
948+
{
949+
if(!playmax.empty(arguments[i]))
950+
return options.fn(this);
951+
}
952+
953+
return options.inverse(this);
954+
955+
});
956+
943957
hb.registerHelper('for', function(from, to, incr, options) {
944958

945959
var accum = '';

scripts/recently-opened.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async function load(animation = true, content = false)
126126

127127
if(!content)
128128
{
129-
if(template.contentLeft('.menu-list').length === 0) template.loadContentLeft('index.content.left.html', animation);
129+
if(template.contentLeft('.menu-list').length === 0) dom.loadIndexContentLeft(animation);
130130
template.loadGlobalElement('index.elements.menus.html', 'menus');
131131
dom.floatingActionButton(false);
132132
}

scripts/settings.js

+2
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ function removeMasterFolder(key)
202202
storage.set('masterFolders', masterFolders);
203203

204204
updateMasterFolders();
205+
dom.loadIndexContentLeft(true, true);
205206
}
206207
}
207208

@@ -224,6 +225,7 @@ function addMasterFolder()
224225
storage.set('masterFolders', masterFolders);
225226

226227
updateMasterFolders();
228+
dom.loadIndexContentLeft(true, true);
227229
}
228230
}
229231

templates/index.content.left.html

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<div class="menu-list">
3-
<div class="menu-item menu-item-library body-medium gamepad-item{{#unless isFromRecentlyOpened}} active{{/unless}}" onclick="dom.loadIndexPage(true);">
3+
<div class="menu-item menu-item-library body-medium gamepad-item{{#unless isFromRecentlyOpened}}{{#unless isFromSettings}} active{{/unless}}{{/unless}}" onclick="dom.loadIndexPage(true);">
44
<div class="icon-24 material-icon">book</div>
55
{{language.global.library}}
66
</div>
@@ -10,6 +10,19 @@
1010
{{language.global.recents}}
1111
</div>
1212

13+
{{#if masterFolders}}
14+
15+
<div class="separator-2" style="width: calc(100% + 12px);"></div>
16+
17+
{{#each masterFolders}}
18+
<div class="menu-item menu-item-master-folder-{{@key}} body-medium gamepad-item" onclick="dom.labels.masterFolder('{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', {{@key}});">
19+
<div class="icon-24 material-icon">folder</div>
20+
{{name}}
21+
</div>
22+
{{/each}}
23+
24+
{{/if}}
25+
1326
<div class="separator-2" style="width: calc(100% + 12px);"></div>
1427

1528
<div class="menu-item menu-item-language body-medium gamepad-item" onclick="dom.loadLanguagesPage();">
@@ -22,7 +35,7 @@
2235
{{language.global.theme}}
2336
</div>
2437

25-
<div class="menu-item menu-item-settings body-medium gamepad-item" onclick="dom.loadSettingsPage();">
38+
<div class="menu-item menu-item-settings body-medium gamepad-item{{#if isFromSettings}} active{{/if}}" onclick="dom.loadSettingsPage();">
2639
<div class="icon-24 material-icon">settings</div>
2740
{{language.global.settings}}
2841
</div>

0 commit comments

Comments
 (0)