mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-19 06:30:29 +00:00
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) {
|
function loadFromArrayBuffer(ab, lastCompletion = 0) {
|
||||||
var lastCompletion = 0;
|
|
||||||
const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' });
|
const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' });
|
||||||
loadArchiveFormats(['rar', 'zip', 'tar'], function() {
|
loadArchiveFormats(['rar', 'zip', 'tar'], function() {
|
||||||
// Open the file as an archive
|
// Open the file as an archive
|
||||||
@ -551,7 +550,7 @@ function init(filename) {
|
|||||||
request.responseType = "arraybuffer";
|
request.responseType = "arraybuffer";
|
||||||
request.addEventListener("load", function() {
|
request.addEventListener("load", function() {
|
||||||
if (request.status >= 200 && request.status < 300) {
|
if (request.status >= 200 && request.status < 300) {
|
||||||
loadFromArrayBuffer(request.response);
|
loadFromArrayBuffer(request.response, currentImage);
|
||||||
} else {
|
} else {
|
||||||
console.warn(request.statusText, request.responseText);
|
console.warn(request.statusText, request.responseText);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
@ -17,35 +18,18 @@
|
|||||||
<script src="{{ url_for('static', filename='js/libs/screenfull.min.js') }}"></script>
|
<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/compress/uncompress.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/kthoom.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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<div id="tocView" class="view" tabindex="-1">
|
<div id="tocView" class="view" tabindex="-1">
|
||||||
<ul id="thumbnails"></ul>
|
<ul id="thumbnails"></ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="bookmarksView" class="view">
|
<div id="bookmarksView" class="view">
|
||||||
<ul id="bookmarks"></ul>
|
<ul id="bookmarks"></ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="main" class="main">
|
<div id="main" class="main">
|
||||||
<div id="titlebar" class="main">
|
<div id="titlebar" class="main">
|
||||||
<div id="opener">
|
<div id="opener">
|
||||||
<a id="slider" class="icon-menu">Menu</a>
|
<a id="slider" class="icon-menu">Menu</a>
|
||||||
@ -75,11 +59,11 @@
|
|||||||
<div id="mainText" style="display:none"></div>
|
<div id="mainText" style="display:none"></div>
|
||||||
<canvas id="mainImage"></canvas>
|
<canvas id="mainImage"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<div id="left" class="arrow" onclick="showLeftPage()">‹</div>
|
<div id="left" class="arrow" onclick="showLeftPage(); setBookmark();">‹</div>
|
||||||
<div id="right" class="arrow" onclick="showRightPage()">›</div>
|
<div id="right" class="arrow" onclick="showRightPage(); setBookmark();">›</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal md-effect-1" id="settings-modal">
|
<div class="modal md-effect-1" id="settings-modal">
|
||||||
<div class="md-content">
|
<div class="md-content">
|
||||||
<h3>{{_('Settings')}}</h3>
|
<h3>{{_('Settings')}}</h3>
|
||||||
<div>
|
<div>
|
||||||
@ -182,12 +166,59 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="closer icon-cancel-circled"></div>
|
<div class="closer icon-cancel-circled"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="overlay"></div>
|
<div class="overlay"></div>
|
||||||
<script>
|
<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() {
|
$('input[name="direction"]').change(function() {
|
||||||
updateArrows();
|
updateArrows();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1497,7 +1497,7 @@ def read_book(book_id, book_format):
|
|||||||
title = title + " #" + '{0:.2f}'.format(book.series_index).rstrip('0').rstrip('.')
|
title = title + " #" + '{0:.2f}'.format(book.series_index).rstrip('0').rstrip('.')
|
||||||
log.debug(u"Start comic reader for %d", book_id)
|
log.debug(u"Start comic reader for %d", book_id)
|
||||||
return render_title_template('readcbr.html', comicfile=all_name, title=title,
|
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")
|
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"),
|
flash(_(u"Oops! Selected book title is unavailable. File does not exist or is not accessible"),
|
||||||
category="error")
|
category="error")
|
||||||
|
Loading…
Reference in New Issue
Block a user