MCPcopy
hub / github.com/ollm/OpenComic / goToChapterProgress

Function goToChapterProgress

scripts/reading.js:1424–1454  ·  view source on GitHub ↗
(chapterIndex, chapterProgress, animation = true)

Source from the content-addressed store, hash-verified

1422
1423// Go to ebook chapter progress
1424function goToChapterProgress(chapterIndex, chapterProgress, animation = true)
1425{
1426 nextOpenChapterProgress = false;
1427 let closest = false;
1428
1429 for(let i = 0, len = _ebook.chaptersPages[chapterIndex].length; i < len; i++)
1430 {
1431 let diff = Math.abs(_ebook.chaptersPages[chapterIndex][i].chapterProgress - chapterProgress);
1432
1433 if(closest === false || diff < closest.diff)
1434 {
1435 closest = {
1436 page: _ebook.chaptersPages[chapterIndex][i],
1437 diff: diff,
1438 };
1439 }
1440 }
1441
1442 if(closest.page)
1443 {
1444 let index = closest.page.index + 1;
1445
1446 if(doublePage.active())
1447 index = Math.ceil(index / 2);
1448
1449 if(readingManga())
1450 index = (indexNum - closest.page.index);
1451
1452 reading.goToIndex(index, animation);
1453 }
1454}
1455
1456//Go to the next comic page
1457function goNext()

Callers 1

generateEbookPagesFunction · 0.85

Calls 1

readingMangaFunction · 0.85

Tested by

no test coverage detected