Skip to content

Commit 39f1954

Browse files
committed
New: Tracking at the end of the chapter/volume setting option
1 parent d4e584e commit 39f1954

20 files changed

+84
-44
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1919
- Master folder support from settings [`9edd70e`](https://github.com/ollm/OpenComic/commit/9edd70ec871855cf2b43fa5cebea4bdf83baae7f)
2020
- Ignore single folders in browsing [`7507563`](https://github.com/ollm/OpenComic/commit/75075631fcad5fb269427c178e9bac86bc352971)
2121
- Search and filter in library/browsing [`8393903`](https://github.com/ollm/OpenComic/commit/8393903117981bea2b8a79e2e50b77d02334aa05)
22+
- Tracking at the end of the chapter/volume setting option
2223

2324
##### 🐛 Bug Fixes
2425

languages/ca.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "Preferències de lectura",
138138
"maxMargin": "Marge horitzontal i vertical màxim",
139-
"globalZoom": "Aplica un zoom global en comptes d'imatge a imatge (Només en lectura vertical)"
139+
"globalZoom": "Aplica un zoom global en comptes d'imatge a imatge (Només en lectura vertical)",
140+
"trackingAtTheEnd": "Seguiment al final del capítol/tom"
140141
},
141142
"navigation": {
142143
"main": "Navegación",

languages/cs.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

languages/de.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

languages/en.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "Reading preferences",
138138
"maxMargin": "Maximum horizontal and vertical margin",
139-
"globalZoom": "Applies a global zoom instead of image by image (Only in vertical reading)"
139+
"globalZoom": "Applies a global zoom instead of image by image (Only in vertical reading)",
140+
"trackingAtTheEnd": "Tracking at the end of the chapter/volume"
140141
},
141142
"navigation": {
142143
"main": "Navigation",
@@ -174,7 +175,8 @@
174175
"main": "Master folders",
175176
"folder": "Folder",
176177
"noFolders": "No folders"
177-
}
178+
},
179+
"tracking": {}
178180
},
179181
"menu": {
180182
"file": {

languages/es.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "Preferencias de lectura",
138138
"maxMargin": "Margen horizontal y vertical máximo",
139-
"globalZoom": "Aplica un zoom global en vez de imagen a imagen (Solo en lectura vertical)"
139+
"globalZoom": "Aplica un zoom global en vez de imagen a imagen (Solo en lectura vertical)",
140+
"trackingAtTheEnd": "Seguimiento al final del capítulo/tomo"
140141
},
141142
"navigation": {
142143
"main": "Navegación",

languages/fr.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

languages/hu.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

languages/it.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

languages/ja.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

languages/pt-br.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

languages/ru.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

languages/vi.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

languages/zh-hans.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

languages/zh-hant.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
"reading": {
137137
"main": "",
138138
"maxMargin": "",
139-
"globalZoom": ""
139+
"globalZoom": "",
140+
"trackingAtTheEnd": ""
140141
},
141142
"navigation": {
142143
"main": "",

scripts/reading.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,12 @@ function changeHeaderButtons(scrollInStart = null, scrollInEnd = null)
688688
lastPage.innerHTML = nextIsNextComic ? 'skip_next' : 'last_page';
689689
lastPage.setAttribute('hover-text', nextIsNextComic ? language.reading.nextChapter : language.reading.lastPage);
690690

691+
if(config.readingTrackingAtTheEnd && !trackingCurrent && ((_config.readingManga && prevIsPrevComic) || (!_config.readingManga && nextIsNextComic)))
692+
{
693+
trackingCurrent = true;
694+
tracking.track();
695+
}
696+
691697
prevChangeHeaderButtons = currentChangeHeaderButtons;
692698
changeHeaderButtonsDelayed = false;
693699
}
@@ -3014,12 +3020,12 @@ function eachImagesDistribution(index, contains, callback, first = false, notFou
30143020
}
30153021
}
30163022

3017-
var touchTimeout, mouseOut = {lens: false, body: false}, touchStart = false, magnifyingGlassOffset = false, readingCurrentPath = false, readingCurrentBookmarks = undefined, zoomMoveData = {}, magnifyingGlassScroll = {scrollTop: false, time: 0}, readingDragScroll = false, gamepadScroll = false, readingIsCanvas = false, readingFile = false, gamepadAxesNow = 0, scrollInStart = false, scrollInEnd = false;
3023+
var touchTimeout, mouseOut = {lens: false, body: false}, touchStart = false, magnifyingGlassOffset = false, readingCurrentPath = false, readingCurrentBookmarks = undefined, zoomMoveData = {}, magnifyingGlassScroll = {scrollTop: false, time: 0}, readingDragScroll = false, gamepadScroll = false, readingIsCanvas = false, readingFile = false, gamepadAxesNow = 0, scrollInStart = false, scrollInEnd = false, trackingCurrent = false;
30183024

30193025
//It starts with the reading of a comic, events, argar images, counting images ...
30203026
async function read(path, index = 1, end = false, isCanvas = false)
30213027
{
3022-
images = {}, imagesData = {}, imagesDataClip = {}, imagesPath = {}, imagesNum = 0, contentNum = 0, imagesNumLoad = 0, currentIndex = index, foldersPosition = {}, currentScale = 1, currentZoomIndex = false, previousScrollTop = 0, scalePrevData = {tranX: 0, tranX2: 0, tranY: 0, tranY2: 0, scale: 1, scrollTop: 0}, originalRect = false, scrollInStart = false, scrollInEnd = false, prevChangeHeaderButtons = {};
3028+
images = {}, imagesData = {}, imagesDataClip = {}, imagesPath = {}, imagesNum = 0, contentNum = 0, imagesNumLoad = 0, currentIndex = index, foldersPosition = {}, currentScale = 1, currentZoomIndex = false, previousScrollTop = 0, scalePrevData = {tranX: 0, tranX2: 0, tranY: 0, tranY2: 0, scale: 1, scrollTop: 0}, originalRect = false, scrollInStart = false, scrollInEnd = false, prevChangeHeaderButtons = {}, trackingCurrent = false;
30233029

30243030
loadReadingConfig(currentReadingConfigKey);
30253031

@@ -3737,7 +3743,11 @@ async function read(path, index = 1, end = false, isCanvas = false)
37373743

37383744
template.contentRight().children('div').css({scrollbarGutter: readingViewIs('scroll') ? '' : 'initial'});
37393745

3740-
tracking.track();
3746+
if(!config.readingTrackingAtTheEnd)
3747+
{
3748+
trackingCurrent = true;
3749+
tracking.track();
3750+
}
37413751

37423752
filters.apply();
37433753

scripts/settings.js

+6
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ function setGlobalZoom(value)
233233
storage.updateVar('config', 'readingGlobalZoom', value);
234234
}
235235

236+
function setTrackingAtTheEnd(value)
237+
{
238+
storage.updateVar('config', 'readingTrackingAtTheEnd', value);
239+
}
240+
236241
function setIgnoreSingleFoldersLibrary(value)
237242
{
238243
storage.updateVar('config', 'ignoreSingleFoldersLibrary', value);
@@ -276,6 +281,7 @@ module.exports = {
276281
start: start,
277282
setMaxMargin: setMaxMargin,
278283
setGlobalZoom: setGlobalZoom,
284+
setTrackingAtTheEnd: setTrackingAtTheEnd,
279285
setIgnoreSingleFoldersLibrary: setIgnoreSingleFoldersLibrary,
280286
setShowFullPathLibrary: setShowFullPathLibrary,
281287
setShowFullPathOpened: setShowFullPathOpened,

scripts/storage.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var changes = 51; // Update this if readingPagesConfig is updated
1+
var changes = 52; // Update this if readingPagesConfig is updated
22

33
var readingPagesConfig = {
44
readingConfigName: '',
@@ -80,6 +80,7 @@ var storageDefault = {
8080
readingHideBarHeaderFullScreen: true,
8181
readingMaxMargin: 400,
8282
readingGlobalZoom: true,
83+
readingTrackingAtTheEnd: true,
8384
controllerDeadZone: 0.06,
8485
startInFullScreen: false,
8586
startOnStartup: false,
@@ -338,7 +339,7 @@ function updateStorageMD(data, defaultObj)
338339
{
339340
newData = updateStorageArrayMD(data, defaultObj);
340341
}
341-
else if(defaultObj !== 'object')
342+
else if(typeof defaultObj !== 'object')
342343
{
343344
newData = data;
344345
}

scripts/tracking.js

+22-23
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var tracked = {}, trackST = [], trackIndex = 0;
2929

3030
async function track(chapter = false, volume = false, onlySite = false)
3131
{
32-
var fromDialog = false;
32+
let fromDialog = false;
3333

3434
if(chapter !== false || volume !== false)
3535
{
@@ -41,9 +41,9 @@ async function track(chapter = false, volume = false, onlySite = false)
4141
volume = getVolume();
4242
}
4343

44-
var _trackingSites = trackingSites.list(true);
44+
let _trackingSites = trackingSites.list(true);
4545

46-
var haveToTracking = false;
46+
let haveToTracking = false;
4747

4848
for(let key in _trackingSites)
4949
{
@@ -62,21 +62,22 @@ async function track(chapter = false, volume = false, onlySite = false)
6262
if(!fromDialog)
6363
$('.bar-right-buttons .button-tracking-sites').html('sync').removeClass('tracking-problem');
6464

65-
var allTracked = true;
65+
let indexMainPathA = dom.indexMainPathA();
66+
let readingCurrentPath = reading.readingCurrentPath();
67+
68+
let allTracked = true;
6669

6770
for(let key in _trackingSites)
6871
{
69-
var site = _trackingSites[key];
72+
let site = _trackingSites[key];
7073

71-
var prevTracked = false;
74+
let prevTracked = false;
7275

73-
if(tracked[dom.indexMainPathA()] && tracked[dom.indexMainPathA()][site.key])
76+
if(tracked[indexMainPathA] && tracked[indexMainPathA][site.key])
7477
{
75-
var readingCurrentPath = reading.readingCurrentPath();
76-
77-
for(let key2 in tracked[dom.indexMainPathA()][site.key])
78+
for(let key2 in tracked[indexMainPathA][site.key])
7879
{
79-
if(readingCurrentPath == tracked[dom.indexMainPathA()][site.key][key2])
80+
if(readingCurrentPath == tracked[indexMainPathA][site.key][key2])
8081
{
8182
prevTracked = true;
8283

@@ -92,7 +93,7 @@ async function track(chapter = false, volume = false, onlySite = false)
9293
let chapters = '??';
9394
let volumes = '??';
9495

95-
let tracking = storage.getKey('tracking', dom.indexMainPathA());
96+
let tracking = storage.getKey('tracking', indexMainPathA);
9697

9798
for(let site in tracking)
9899
{
@@ -110,7 +111,7 @@ async function track(chapter = false, volume = false, onlySite = false)
110111
{
111112
console.log('Get chapters and volumes number');
112113

113-
let path = dom.indexMainPathA();
114+
let path = indexMainPathA;
114115

115116
sitesScripts[site].getComicData(data.id, function(data){
116117

@@ -129,17 +130,15 @@ async function track(chapter = false, volume = false, onlySite = false)
129130

130131
for(let key in _trackingSites)
131132
{
132-
var site = _trackingSites[key];
133+
let site = _trackingSites[key];
133134

134-
var prevTracked = false;
135+
let prevTracked = false;
135136

136-
if(tracked[dom.indexMainPathA()] && tracked[dom.indexMainPathA()][site.key])
137+
if(tracked[indexMainPathA] && tracked[indexMainPathA][site.key])
137138
{
138-
var readingCurrentPath = reading.readingCurrentPath();
139-
140-
for(let key2 in tracked[dom.indexMainPathA()][site.key])
139+
for(let key2 in tracked[indexMainPathA][site.key])
141140
{
142-
if(readingCurrentPath == tracked[dom.indexMainPathA()][site.key][key2])
141+
if(readingCurrentPath == tracked[indexMainPathA][site.key][key2])
143142
{
144143
prevTracked = true;
145144

@@ -150,9 +149,9 @@ async function track(chapter = false, volume = false, onlySite = false)
150149

151150
if(site.config.session.valid && ((vars.onlySite && vars.onlySite == site.key) || (site.tracking.active && !prevTracked && !vars.onlySite)))
152151
{
153-
if(!tracked[dom.indexMainPathA()]) tracked[dom.indexMainPathA()] = {};
154-
if(!tracked[dom.indexMainPathA()][site.key]) tracked[dom.indexMainPathA()][site.key] = [];
155-
tracked[dom.indexMainPathA()][site.key].push(reading.readingCurrentPath());
152+
if(!tracked[indexMainPathA]) tracked[indexMainPathA] = {};
153+
if(!tracked[indexMainPathA][site.key]) tracked[indexMainPathA][site.key] = [];
154+
tracked[indexMainPathA][site.key].push(readingCurrentPath);
156155

157156
loadSiteScript(site.key);
158157

templates/settings.content.right.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ <h2 class="headline-small">{{language.settings.reading.main}}</h2>
4343
</div>
4444
</div>
4545

46-
<div class="simple-slider gamepad-item" data-gamepad-left="events.rangeMoveStep(this, -1)" data-gamepad-right="events.rangeMoveStep(this, 1)">
46+
<div class="menu-simple-text gamepad-item">
47+
{{language.settings.reading.trackingAtTheEnd}}
48+
<div class="switch{{#if config.readingTrackingAtTheEnd}} a{{/if}}" on="settings.setTrackingAtTheEnd(true)" off="settings.setTrackingAtTheEnd(false)">
49+
<div></div>
50+
<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>
51+
</div>
52+
</div>
53+
54+
<div class="simple-slider gamepad-item" data-gamepad-left="events.rangeMoveStep(this, -1)" data-gamepad-right="events.rangeMoveStep(this, 1)" style="margin-top: 10px;">
4755
<div class="simple-slider-text">{{language.settings.reading.maxMargin}}<div><span>{{config.readingMaxMargin}}</span>px</div></div>
4856
<div class="range">
4957
<div class="range-position">

0 commit comments

Comments
 (0)