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

Function createAndDeleteBookmark

scripts/reading.js:3555–3638  ·  view source on GitHub ↗
(index = false)

Source from the content-addressed store, hash-verified

3553
3554//Create and delete bookmarks
3555function createAndDeleteBookmark(index = false)
3556{
3557 let imageIndex = false;
3558
3559 if(!index)
3560 {
3561 let imageBookmark = false;
3562
3563 let newIndex = (currentIndex - 1);
3564
3565 if(readingManga())
3566 newIndex = (indexNum - newIndex) - 1;
3567
3568 eachImagesDistribution(newIndex, ['image'], function(image){
3569
3570 if(!imageIndex)
3571 imageIndex = image.index;
3572
3573 if(isBookmark(p.normalize(images[image.index].path)))
3574 {
3575 if(imageBookmark)
3576 {
3577 createAndDeleteBookmark(image.index);
3578 }
3579 else
3580 {
3581 imageBookmark = true;
3582 imageIndex = image.index;
3583 }
3584 }
3585 });
3586 }
3587 else
3588 {
3589 imageIndex = index;
3590 }
3591
3592 if(currentIndex <= contentNum && currentIndex > 0 && imageIndex)
3593 {
3594 let path = p.normalize(images[imageIndex].path);
3595
3596 let progress = 0;
3597 let chapterProgress = 0;
3598
3599 if(readingIsEbook)
3600 {
3601 let page = _ebook.pages[imageIndex - 1];
3602
3603 progress = page.progress;
3604 chapterProgress = page.chapterProgress;
3605 }
3606
3607 let newBookmark = {
3608 path: p.relative(dom.history.mainPath, path.replace(/\?page=[0-9]+$/, '')),
3609 index: imagesPath[path],
3610 ebook: readingIsEbook,
3611 progress: progress,
3612 chapterProgress: chapterProgress,

Callers

nothing calls this directly

Calls 4

readingMangaFunction · 0.85
eachImagesDistributionFunction · 0.85
isBookmarkFunction · 0.85
activeBookmarkFunction · 0.85

Tested by

no test coverage detected