Skip to content

Commit

Permalink
New: Ignore single folders
Browse files Browse the repository at this point in the history
  • Loading branch information
ollm committed Oct 5, 2023
1 parent 82963f9 commit 7507563
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Buttons in library to go next and prev chapter [`c41ecde`](https://github.com/ollm/OpenComic/commit/c41ecde33a3b0b2361b9ccdcbec92d848b48077d)
- Adjust the brightness, saturation, contrast, sepia and colorize black and white images [`04b1caa`](https://github.com/ollm/OpenComic/commit/04b1caa5d28a468df6e94893bd943518da762030)
- Master folder support from settings [`9edd70e`](https://github.com/ollm/OpenComic/commit/9edd70ec871855cf2b43fa5cebea4bdf83baae7f)
- Ignore single folders

##### 🐛 Bug Fixes

Expand Down
5 changes: 3 additions & 2 deletions languages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
"favoriteSites": "Llocs favorits",
"emptyFavoriteSites": "Cap lloc a favorits",
"problemChapter": "Capítol no detectat",
"chapters": "Capítol",
"chapter": "",
"chapters": "Capítols",
"chapter": "Capítol",
"volumes": "Toms",
"volume": "Tom"
},
Expand All @@ -138,6 +138,7 @@
},
"navigation": {
"main": "Navegación",
"ignoreSingleFoldersLibrary": "Ignorar carpetes individuals (S'obren automàticament)",
"showFullPathLibrary": "Mostrar la ruta completa a l'obrir els còmics de la biblioteca",
"showFullPathOpened": "Mostrar la ruta completa a l'obrir un arxiu o carpeta"
},
Expand Down
1 change: 1 addition & 0 deletions languages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
1 change: 1 addition & 0 deletions languages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
1 change: 1 addition & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "Navigation",
"ignoreSingleFoldersLibrary": "Ignore single folders (Open automatically)",
"showFullPathLibrary": "Show full path when opening library comics",
"showFullPathOpened": "Show full path when opening a file or folder"
},
Expand Down
1 change: 1 addition & 0 deletions languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "Navegación",
"ignoreSingleFoldersLibrary": "Ignorar carpetas individuales (Se abren automáticamente)",
"showFullPathLibrary": "Mostrar la ruta completa al abrir los comics de la biblioteca",
"showFullPathOpened": "Mostrar la ruta completa al abrir un archivo o carpeta"
},
Expand Down
2 changes: 1 addition & 1 deletion languages/fill-languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function loadLanguageMD(hbc, obj, onlyStructure = false)
function fillLanguages()
{
let base = {};
loadLanguageMD(base, JSON.parse(fs.readFileSync('./languages/es.json', 'utf8')), true);
loadLanguageMD(base, JSON.parse(fs.readFileSync('./languages/en.json', 'utf8')), true);
loadLanguageMD(base, JSON.parse(fs.readFileSync('./languages/es.json', 'utf8')), true);

let files = fs.readdirSync('./languages');

Expand Down
1 change: 1 addition & 0 deletions languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
1 change: 1 addition & 0 deletions languages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
1 change: 1 addition & 0 deletions languages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
1 change: 1 addition & 0 deletions languages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
1 change: 1 addition & 0 deletions languages/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
1 change: 1 addition & 0 deletions languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
1 change: 1 addition & 0 deletions languages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
1 change: 1 addition & 0 deletions languages/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
1 change: 1 addition & 0 deletions languages/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
},
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
34 changes: 29 additions & 5 deletions scripts/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,15 @@ async function loadFilesIndexPage(file, animation, path, keepScroll, mainPath)
//template.loadContentRight('index.content.right.'+config.view+'.html', animation, keepScroll);
events.events();

return pathFiles;

}).catch(function(error){

console.error(error);
dom.compressedError(error);

return [];

});

}
Expand All @@ -290,9 +294,9 @@ async function reloadIndex()
loadIndexPage(true, indexPathA, true, true, indexMainPathA);
}

var currentPath = false, currentPathScrollTop = [];
var currentPath = false, currentPathScrollTop = [], fromIgnoreSingleFoldersNow = 0;

async function loadIndexPage(animation = true, path = false, content = false, keepScroll = false, mainPath = false, fromGoBack = false)
async function loadIndexPage(animation = true, path = false, content = false, keepScroll = false, mainPath = false, fromGoBack = false, disableIgnoreSingleFolders = false, fromIgnoreSingleFolders = false)
{
selectMenuItem('library');

Expand Down Expand Up @@ -458,7 +462,17 @@ async function loadIndexPage(animation = true, path = false, content = false, ke

headerPath(path, mainPath);
template.loadHeader('index.header.html', animation);
template.loadContentRight('index.content.right.loading.html', animation, keepScroll);

if(fromIgnoreSingleFolders && Date.now() - fromIgnoreSingleFoldersNow < 300)
{
template._barHeader().firstElementChild.innerHTML = template.load('index.header.html');
template._contentRight().firstElementChild.innerHTML = template.load('reading.content.right.html');
}
else
{
template.loadHeader('index.header.html', animation);
template.loadContentRight('index.content.right.loading.html', animation, keepScroll);
}

if(!content)
{
Expand All @@ -474,13 +488,23 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
cache.cleanQueue();

let file = fileManager.file(path);
await loadFilesIndexPage(file, animation, path, keepScroll, mainPath);
let files = await loadFilesIndexPage(file, animation, path, keepScroll, mainPath);

if(config.ignoreSingleFoldersLibrary && !fromGoBack && !disableIgnoreSingleFolders && files.length == 1)
{
fromIgnoreSingleFoldersNow = Date.now();

indexPathControlA.pop();

dom.loadIndexPage(true, files[0].path, false, false, files[0].mainPath, false, false, true);

return;
}
}

if(readingActive)
readingActive = false;


shortcuts.register('browse');
gamepad.updateBrowsableItems(path ? sha1(path) : 'library');
}
Expand Down
5 changes: 5 additions & 0 deletions scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ function setGlobalZoom(value)
storage.updateVar('config', 'readingGlobalZoom', value);
}

function setIgnoreSingleFoldersLibrary(value)
{
storage.updateVar('config', 'ignoreSingleFoldersLibrary', value);
}

function setShowFullPathLibrary(value)
{
storage.updateVar('config', 'showFullPathLibrary', value);
Expand Down
40 changes: 27 additions & 13 deletions scripts/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,38 @@ var contentRightZindex = 1;

function changeContentRight(html, animation = true, keepScroll = false)
{
$('.content-right > div.to-remove').remove();
$('.content-right > div').addClass('to-remove');
dom.queryAll('.content-right > div.to-remove').remove();
dom.queryAll('.content-right > div').addClass('to-remove');

let scroll;

if(keepScroll && keepScroll < 2)
{
var previous = $('.content-right > div > div').last();
var scroll = (previous.scrollTop() / (previous.prop('scrollHeight') - previous.height()));
let previous = document.querySelector('.content-right > div > div:last-child');
scroll = (previous.scrollTop / (previous.scrollHeight - previous.getBoundingClientRect().height));
}

document.querySelector('.content-right').insertAdjacentHTML('beforeend', '<div class="content-right-'+contentRightZindex+(animation ? ' a' : '')+'" style="z-index: ' + contentRightZindex + ';"><div>'+html+'</div></div>');

if(keepScroll)
{
var current = $('.content-right > div > div').last();
let current = document.querySelector('.content-right > div > div:last-child');

if(keepScroll > 1)
current.scrollTop(keepScroll);
current.scrollTop = keepScroll;
else
current.scrollTop((current.prop('scrollHeight') - current.height()) * scroll);
current.scrollTop = (current.scrollHeight - current.getBoundingClientRect().height) * scroll;
}

contentRight = $('.content-right .content-right-'+contentRightZindex);
_contentRight = document.querySelector('.content-right .content-right-'+contentRightZindex);
setTimeout('$(\'.content-right-'+(contentRightZindex-1)+'\').remove(); $(\'.content-right-'+contentRightZindex+'\').removeClass(\'a\')', 300);
contentRight = $(_contentRight);

setTimeout(function(zIndex){

dom.queryAll('.content-right-'+(zIndex-1)).remove();
dom.queryAll('.content-right-'+zIndex).removeClass('a')

}, 300, contentRightZindex);

contentRightZindex++;
}
Expand All @@ -85,13 +93,19 @@ var headerZindex = 1;

function changeHeader(html, animation = true)
{
$('.bar-header > div.to-remove').remove();
$('.bar-header > div').addClass('to-remove');
dom.queryAll('.bar-header > div.to-remove').remove();
dom.queryAll('.bar-header > div').addClass('to-remove');
document.querySelector('.bar-header').insertAdjacentHTML('beforeend', '<div class="bar-header-'+headerZindex+(animation ? ' a' : '')+'" style="z-index: ' + headerZindex + ';"><div>'+html+'</div></div>');

barHeader = $('.bar-header .bar-header-'+headerZindex);
_barHeader = document.querySelector('.bar-header .bar-header-'+headerZindex);
setTimeout('$(\'.bar-header-'+(headerZindex-1)+'\').remove(); $(\'.bar-header-'+headerZindex+'\').removeClass(\'a\')', 300);
barHeader = $(_barHeader);

setTimeout(function(zIndex){

dom.queryAll('.bar-header-'+(zIndex-1)).remove();
dom.queryAll('.bar-header-'+zIndex).removeClass('a');

}, 300, headerZindex);

headerZindex++;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/index.header.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="bar-title title-small" style="max-width: calc(100% - ({{#if comicsDeep2}}392px{{else}}268px{{/if}} + 68px));">
{{#if headerTitlePath}}
{{#each headerTitlePath}}
<span class="bar-title-a" onclick="dom.loadIndexPage(true, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', false, false, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' mainPath}}')">{{name}}</span>
<span class="bar-title-a" onclick="dom.loadIndexPage(true, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', false, false, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' mainPath}}', false, true)">{{name}}</span>
{{#unless last}} <i class="material-icon navegation">chevron_right</i> {{/unless}}
{{/each}}
{{else}}
Expand Down
8 changes: 8 additions & 0 deletions templates/settings.content.right.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ <h2 class="headline-small">{{language.settings.reading.main}}</h2>

<h2 class="headline-small">{{language.settings.navigation.main}}</h2>

<div class="menu-simple-text gamepad-item">
{{language.settings.navigation.ignoreSingleFoldersLibrary}}
<div class="switch{{#if config.ignoreSingleFoldersLibrary}} a{{/if}}" on="settings.setIgnoreSingleFoldersLibrary(true)" off="settings.setIgnoreSingleFoldersLibrary(false)">
<div></div>
<svg viewBox="0 0 52 32"><path d="M 8,0 C 3.58,0 0,3.58 0,8 0,12.42 3.58,16 8,16 8,16 8,16 8,16 12.42,16 16,12.42 16,8 16,3.58 12.42,0 8,0 8,0 8,0 8,0 Z"></path></svg>
</div>
</div>

<div class="menu-simple-text gamepad-item">
{{language.settings.navigation.showFullPathLibrary}}
<div class="switch{{#if config.showFullPathLibrary}} a{{/if}}" on="settings.setShowFullPathLibrary(true)" off="settings.setShowFullPathLibrary(false)">
Expand Down

0 comments on commit 7507563

Please sign in to comment.