Skip to content

Commit

Permalink
New: Option to open directly in continue reading instead of the file …
Browse files Browse the repository at this point in the history
…list
  • Loading branch information
ollm committed Oct 11, 2023
1 parent cd09ac4 commit 78646fe
Show file tree
Hide file tree
Showing 20 changed files with 67 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

##### 🚀 New Features

- Option to open directly in continue reading instead of the file list

##### 🐛 Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions languages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"navigation": {
"main": "Navegación",
"ignoreSingleFoldersLibrary": "Ignorar carpetes individuals (S'obren automàticament)",
"whenOpenFolderContinueReading": "Obrir directament en continuar llegint en lloc de la llista de fitxers",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "Navigation",
"ignoreSingleFoldersLibrary": "Ignore single folders (Open automatically)",
"whenOpenFolderContinueReading": "Open directly in continue reading instead of the file list",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "Navegación",
"ignoreSingleFoldersLibrary": "Ignorar carpetas individuales (Se abren automáticamente)",
"whenOpenFolderContinueReading": "Abrir directamente en continuar leyendo en lugar de la lista de archivos",
"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
1 change: 1 addition & 0 deletions languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"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 @@ -143,6 +143,7 @@
"navigation": {
"main": "",
"ignoreSingleFoldersLibrary": "",
"whenOpenFolderContinueReading": "",
"showFullPathLibrary": "",
"showFullPathOpened": ""
},
Expand Down
48 changes: 35 additions & 13 deletions scripts/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ async function loadFilesIndexPage(file, animation, path, keepScroll, mainPath)
//template.loadContentRight('index.content.right.'+config.view+'.html', animation, keepScroll);
events.events();

return pathFiles;
return {files: pathFiles, readingProgress: readingProgress[mainPath] || {}};

}).catch(function(error){

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

return [];
return {files: [], readingProgress: {}};

});

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

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

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

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

headerPath(path, mainPath);

if(fromIgnoreSingleFolders && Date.now() - fromIgnoreSingleFoldersNow < 300)
if(fromDeepLoad && Date.now() - fromDeepLoadNow < 300)
{
template._barHeader().firstElementChild.innerHTML = template.load('index.header.html');
template._contentRight().firstElementChild.innerHTML = template.load('index.content.right.loading.html');
Expand All @@ -525,16 +525,24 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
queue.stop('folderThumbnails');

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

if(config.ignoreSingleFoldersLibrary && !fromGoBack && !disableIgnoreSingleFolders && files.length == 1 && (files[0].folder || files[0].compressed))
if(config.whenOpenFolderContinueReading && !fromGoBack && !disableIgnoreSingleFolders && indexData.readingProgress && indexData.readingProgress.lastReading > 0)
{
fromIgnoreSingleFoldersNow = Date.now();
fromDeepLoadNow = Date.now();
indexPathControlA.pop();

dom.openComic(true, indexData.readingProgress.path, indexData.readingProgress.mainPath, false, false, false, true);

return;
}
else if(config.ignoreSingleFoldersLibrary && !fromGoBack && !disableIgnoreSingleFolders && indexData.files.length == 1 && (indexData.files[0].folder || indexData.files[0].compressed))
{
fromDeepLoadNow = Date.now();
indexPathControlA.pop();

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

return;
}
Expand Down Expand Up @@ -1284,7 +1292,7 @@ function removeComic(path, confirm = false)

var readingActive = false, skipNextComic = false, skipPreviousComic = false;

async function openComic(animation = true, path = true, mainPath = true, end = false, fromGoBack = false, fromNextAndPrev = false)
async function openComic(animation = true, path = true, mainPath = true, end = false, fromGoBack = false, fromNextAndPrev = false, fromDeepLoad = false)
{
// Start reading comic
currentPathScrollTop[currentPath === false ? 0 : currentPath] = template.contentRight().children().scrollTop();
Expand All @@ -1306,9 +1314,19 @@ async function openComic(animation = true, path = true, mainPath = true, end = f
headerPath(path, mainPath);

handlebarsContext.comics = [];
template.loadContentLeft('reading.content.left.html', true);
template.loadContentRight('reading.content.right.html', true);
template.loadHeader('reading.header.html', true);

if(fromDeepLoad && Date.now() - fromDeepLoadNow < 300)
{
template._contentLeft().firstElementChild.innerHTML = template.load('reading.content.left.html');
template._contentRight().firstElementChild.innerHTML = template.load('reading.content.right.html');
template._barHeader().firstElementChild.innerHTML = template.load('reading.header.html');
}
else
{
template.loadContentLeft('reading.content.left.html', true);
template.loadContentRight('reading.content.right.html', true);
template.loadHeader('reading.header.html', true);
}

// Load files
let file = fileManager.file(path);
Expand Down Expand Up @@ -1343,6 +1361,9 @@ async function openComic(animation = true, path = true, mainPath = true, end = f

readingActive = true;

cache.cleanQueue();
cache.stopQueue();

let comics = [];

if(files)
Expand Down Expand Up @@ -1440,6 +1461,7 @@ async function openComic(animation = true, path = true, mainPath = true, end = f

generateAppMenu();

cache.resumeQueue();
shortcuts.register('reading');
gamepad.updateBrowsableItems('reading-'+sha1(path));
}
Expand Down
7 changes: 7 additions & 0 deletions scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ function setIgnoreSingleFoldersLibrary(value)
storage.updateVar('config', 'ignoreSingleFoldersLibrary', value);
}

function setWhenOpenFolderContinueReading(value)
{
storage.updateVar('config', 'whenOpenFolderContinueReading', value);

}

function setShowFullPathLibrary(value)
{
storage.updateVar('config', 'showFullPathLibrary', value);
Expand Down Expand Up @@ -346,6 +352,7 @@ module.exports = {
setGlobalZoom: setGlobalZoom,
setTrackingAtTheEnd: setTrackingAtTheEnd,
setIgnoreSingleFoldersLibrary: setIgnoreSingleFoldersLibrary,
setWhenOpenFolderContinueReading: setWhenOpenFolderContinueReading,
setShowFullPathLibrary: setShowFullPathLibrary,
setShowFullPathOpened: setShowFullPathOpened,
setStartInFullScreen: setStartInFullScreen,
Expand Down
1 change: 1 addition & 0 deletions scripts/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ var storageDefault = {
startInFullScreen: false,
startOnStartup: false,
ignoreSingleFoldersLibrary: true,
whenOpenFolderContinueReading: false,
renderMaxWidth: 12000,
checkReleases: true,
checkPreReleases: true,
Expand Down
2 changes: 1 addition & 1 deletion templates/reading.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% - (884px + 68px));">
{{#if headerTitlePath}}
{{#each headerTitlePath}}
<span class="bar-title-a" onclick="reading.saveReadingProgress(); dom.loadIndexPage(true, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', false, false, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' mainPath}}')">{{name}}</span>
<span class="bar-title-a" onclick="reading.saveReadingProgress(); dom.loadIndexPage(true, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', false, false, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' mainPath}}', 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 @@ -75,6 +75,14 @@ <h2 class="headline-small">{{language.settings.navigation.main}}</h2>
</div>
</div>

<div class="menu-simple-text gamepad-item">
{{language.settings.navigation.whenOpenFolderContinueReading}}
<div class="switch{{#if config.whenOpenFolderContinueReading}} a{{/if}}" on="settings.setWhenOpenFolderContinueReading(true)" off="settings.setWhenOpenFolderContinueReading(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 78646fe

Please sign in to comment.