Skip to content

Commit 3792f7d

Browse files
committed
New: Delete bookmarks from the bookmark list
1 parent d7aad3c commit 3792f7d

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
##### 🚀 New Features
1010

11+
- Delete bookmarks from the bookmark list
12+
1113
##### 🐛 Bug Fixes
1214

1315
- Error when resizing after exit comic opened from recents [`8291730`](https://github.com/ollm/OpenComic/commit/829173058bb3dde12d35b726070c19ec43a63be3)

scripts/reading.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ function goToImageCL(index, animation = true, fromScroll = false, fromPageRange
716716
if(!fromPageRange)
717717
{
718718
render.focusIndex(index);
719-
filters.focusIndex(index, readingIsEbook);
719+
filters.focusIndex(index);
720720
}
721721

722722
let animationDurationMS = ((animation) ? _config.readingViewSpeed : 0) * 1000;
@@ -2910,6 +2910,14 @@ function createAndDeleteBookmark(index = false)
29102910
}
29112911
}
29122912

2913+
function deleteBookmark(key)
2914+
{
2915+
readingCurrentBookmarks.splice(key, 1);
2916+
storage.updateVar('bookmarks', dom.indexMainPathA(), readingCurrentBookmarks);
2917+
2918+
loadBookmarks(true);
2919+
}
2920+
29132921
var saveReadingProgressA = false, fromSkip = false;
29142922

29152923
function setFromSkip()
@@ -3010,7 +3018,7 @@ function startSaveReadingProgressSI()
30103018
}
30113019

30123020
//Load the bookmarks in the current directory
3013-
function loadBookmarks()
3021+
function loadBookmarks(bookmarksChild = false)
30143022
{
30153023
var bookmarksPath = {}, mainPath = dom.indexMainPathA();
30163024

@@ -3036,6 +3044,7 @@ function loadBookmarks()
30363044
let chapterIndex = app.extract(/^([0-9]+):sortonly/, name, 1);
30373045

30383046
bookmarksPath[bookmarkDirname].push({
3047+
key: key,
30393048
name: dom.translatePageName(decodeURI(p.basename(bookmark.path).replace(/\.[^\.]*$/, ''))),
30403049
index: (bookmarkDirname !== readingCurrentPath) ? bookmark.index : imagesPath[bookmark.path],
30413050
sha: sha,
@@ -3112,8 +3121,9 @@ function loadBookmarks()
31123121
});
31133122

31143123
handlebarsContext.bookmarks = bookmarks;
3124+
handlebarsContext.bookmarksChild = bookmarksChild;
31153125

3116-
$('#collections-bookmark .menu-simple').html(template.load('reading.elements.menus.collections.bookmarks.html'));
3126+
dom.query(!bookmarksChild ? '#collections-bookmark .menu-simple' : '#collections-bookmark .menu-simple > div').html(template.load('reading.elements.menus.collections.bookmarks.html'));
31173127
}
31183128

31193129
var currentReadingConfigKey = false;
@@ -4884,6 +4894,7 @@ module.exports = {
48844894
saveReadingProgressA: function(){return saveReadingProgressA},
48854895
setFromSkip: setFromSkip,
48864896
createAndDeleteBookmark: createAndDeleteBookmark,
4897+
deleteBookmark: deleteBookmark,
48874898
currentIndex: function(){return currentIndex},
48884899
currentPageVisibility: function(){return currentPageVisibility},
48894900
loadBookmarks: loadBookmarks,

scripts/reading/filters.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,8 @@ async function focusIndex(index, notBlackAndWhite = false)
11171117

11181118
if(isBlackAndWhite[sha] === undefined)
11191119
{
1120-
isBlackAndWhiteQueue[sha] = {index: i, path: image.path, sha: image.sha};
1120+
let _path = image.path.replace(/\?page=[0-9]+$/, '');
1121+
isBlackAndWhiteQueue[sha] = {index: i, path: _path, sha: sha1(_path)};
11211122

11221123
processIsBlackAndWhiteQueue();
11231124
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1+
{{#unless bookmarksChild}}
12
<div class="menu-simple-content">
3+
{{/unless}}
24
<div>
35
{{#each bookmarks}}
46
<div class="reading-bookmark menu-simple-text-small">
57
<span>{{#if continueReading}}{{../language.comics.continueReading}}: {{else if current}}{{../language.reading.currentReading}}: {{/if}}{{name}}</span>
68
</div>
79
{{#each bookmarks}}
8-
<div class="reading-bookmark menu-simple-element gamepad-item" onclick="{{#if ../current}}{{#if ebook}}reading.goToChapterProgress({{chapterIndex}}, {{chapterProgress}}, true);{{else}}reading.goToImage({{index}}, true);{{/if}}{{else}}{{#if ebook}}reading.setNextOpenChapterProgress({{chapterIndex}}, {{chapterProgress}});{{/if}}dom.openComic(true, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', '{{chain 'escapeBackSlash' 'escapeQuotesSimples' mainPath}}');{{/if}} events.desactiveMenu('#collections-bookmark', '.bar-right-buttons .button-collections-bookmark');">
10+
<div class="reading-bookmark{{#unless ../continueReading}} reading-bookmark--{{key}}{{/unless}} menu-simple-element menu-simple-element-medium gamepad-item" onclick="{{#if ../current}}{{#if ebook}}reading.goToChapterProgress({{chapterIndex}}, {{chapterProgress}}, true);{{else}}reading.goToImage({{index}}, true);{{/if}}{{else}}{{#if ebook}}reading.setNextOpenChapterProgress({{chapterIndex}}, {{chapterProgress}});{{/if}}dom.openComic(true, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', '{{chain 'escapeBackSlash' 'escapeQuotesSimples' mainPath}}');{{/if}} events.desactiveMenu('#collections-bookmark', '.bar-right-buttons .button-collections-bookmark');">
911
<div class="menu-simple-element-image menu-simple-element-image-{{sha}}" style="background-image: url({{thumbnail}})"></div>
1012
<span>{{#if ebook}}{{round progress}}%{{else}}{{index}}{{/if}}</span>
1113
{{name}}
1214
{{#if ebook}}({{round chapterProgress}}%){{/if}}
15+
{{#unless ../continueReading}}
16+
<i class="material-icon menu-simple-icon-last" onclick="reading.deleteBookmark({{key}}); event.stopPropagation();">close<!-- bookmark_remove --></i>
17+
{{/unless}}
1318
</div>
1419
{{/each}}
1520
{{else}}
1621
<div class="menu-simple-text">{{language.reading.emptyBookmarks}}</div>
1722
{{/each}}
1823
</div>
19-
</div>
24+
{{#unless bookmarksChild}}
25+
</div>
26+
{{/unless}}

templates/reading.elements.menus.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
<div class="menu-clip-path-shadow elevation-2"></div>
9898
</div>
9999
<div class="menu" id="collections-bookmark">
100-
<div class="menu-simple menu-simple-header elevation-2" style="width: 256px;"></div>
100+
<div class="menu-simple menu-simple-header elevation-2" style="width: 512px;"></div>
101101
<div class="menu-close" onclick="reading.magnifyingGlassControl(2); events.desactiveMenu('#collections-bookmark', '.bar-right-buttons .button-collections-bookmark');"></div>
102102
</div>
103103
<div class="menu" id="tracking-sites">

themes/material-design/actions.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@
663663
background-repeat: no-repeat;
664664
background-position: center;
665665
background-size: cover;
666-
margin: 4px 6px 0px 0px;
666+
margin: 4px 12px 0px 0px;
667667
float: left;
668668
}
669669

0 commit comments

Comments
 (0)