Save the position of the last read page for comics
This commit is contained in:
parent
3d59a78c9f
commit
a80735d7d3
|
@ -186,8 +186,7 @@ function initProgressClick() {
|
|||
});
|
||||
}
|
||||
|
||||
function loadFromArrayBuffer(ab) {
|
||||
var lastCompletion = 0;
|
||||
function loadFromArrayBuffer(ab, lastCompletion = 0) {
|
||||
const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' });
|
||||
loadArchiveFormats(['rar', 'zip', 'tar'], function() {
|
||||
// Open the file as an archive
|
||||
|
@ -551,7 +550,7 @@ function init(filename) {
|
|||
request.responseType = "arraybuffer";
|
||||
request.addEventListener("load", function() {
|
||||
if (request.status >= 200 && request.status < 300) {
|
||||
loadFromArrayBuffer(request.response);
|
||||
loadFromArrayBuffer(request.response, currentImage);
|
||||
} else {
|
||||
console.warn(request.statusText, request.responseText);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
@ -17,23 +18,6 @@
|
|||
<script src="{{ url_for('static', filename='js/libs/screenfull.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/compress/uncompress.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/kthoom.js') }}"></script>
|
||||
<script>
|
||||
var updateArrows = function() {
|
||||
if ($('input[name="direction"]:checked').val() === "0") {
|
||||
$("#prev_page_key").html("←");
|
||||
$("#next_page_key").html("→");
|
||||
} else {
|
||||
$("#prev_page_key").html("→");
|
||||
$("#next_page_key").html("←");
|
||||
}
|
||||
};
|
||||
document.onreadystatechange = function () {
|
||||
if (document.readyState == "complete") {
|
||||
init("{{ url_for('web.serve_book', book_id=comicfile, book_format=extension) }}");
|
||||
updateArrows();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="sidebar">
|
||||
|
@ -75,8 +59,8 @@
|
|||
<div id="mainText" style="display:none"></div>
|
||||
<canvas id="mainImage"></canvas>
|
||||
</div>
|
||||
<div id="left" class="arrow" onclick="showLeftPage()">‹</div>
|
||||
<div id="right" class="arrow" onclick="showRightPage()">›</div>
|
||||
<div id="left" class="arrow" onclick="showLeftPage(); setBookmark();">‹</div>
|
||||
<div id="right" class="arrow" onclick="showRightPage(); setBookmark();">›</div>
|
||||
</div>
|
||||
|
||||
<div class="modal md-effect-1" id="settings-modal">
|
||||
|
@ -184,6 +168,53 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="overlay"></div>
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<script>
|
||||
var updateArrows = function () {
|
||||
if ($('input[name="direction"]:checked').val() === "0") {
|
||||
$("#prev_page_key").html("←");
|
||||
$("#next_page_key").html("→");
|
||||
} else {
|
||||
$("#prev_page_key").html("→");
|
||||
$("#next_page_key").html("←");
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
function setBookmark() {
|
||||
// get csrf_token
|
||||
let csrf_token = $("input[name='csrf_token']").val();
|
||||
//This sends a bookmark update to calibreweb.
|
||||
$.ajax(calibre.bookmarkUrl, {
|
||||
method: "post",
|
||||
data: {
|
||||
csrf_token: csrf_token,
|
||||
bookmark: currentImage
|
||||
}
|
||||
}).fail(function (xhr, status, error) {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
window.calibre = {
|
||||
filePath: "{{ url_for('static', filename='js/libs/') }}",
|
||||
cssPath: "{{ url_for('static', filename='css/') }}",
|
||||
bookUrl: "{{ url_for('static', filename=comicfile) }}/",
|
||||
bookmarkUrl: "{{ url_for('web.set_bookmark', book_id=comicfile, book_format=extension.upper()) }}",
|
||||
bookmark: "{{ bookmark.bookmark_key if bookmark != None }}",
|
||||
useBookmarks: "{{ g.user.is_authenticated | tojson }}"
|
||||
};
|
||||
if (calibre.useBookmarks) {
|
||||
currentImage = eval(calibre.bookmark)
|
||||
}
|
||||
|
||||
document.onreadystatechange = function () {
|
||||
if (document.readyState == "complete") {
|
||||
init("{{ url_for('web.serve_book', book_id=comicfile, book_format=extension) }}");
|
||||
updateArrows();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
$('input[name="direction"]').change(function() {
|
||||
updateArrows();
|
||||
|
|
|
@ -1497,7 +1497,7 @@ def read_book(book_id, book_format):
|
|||
title = title + " #" + '{0:.2f}'.format(book.series_index).rstrip('0').rstrip('.')
|
||||
log.debug(u"Start comic reader for %d", book_id)
|
||||
return render_title_template('readcbr.html', comicfile=all_name, title=title,
|
||||
extension=fileExt)
|
||||
extension=fileExt, bookmark=bookmark)
|
||||
log.debug(u"Oops! Selected book title is unavailable. File does not exist or is not accessible")
|
||||
flash(_(u"Oops! Selected book title is unavailable. File does not exist or is not accessible"),
|
||||
category="error")
|
||||
|
|
Loading…
Reference in New Issue
Block a user