mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-25 01:20:32 +00:00
Merged comic save position
This commit is contained in:
parent
d253804a50
commit
9b99427c84
@ -71,7 +71,8 @@ var settings = {
|
||||
fitMode: kthoom.Key.B,
|
||||
theme: "light",
|
||||
direction: 0, // 0 = Left to Right, 1 = Right to Left
|
||||
scrollbar: 1, // 0 = Hide Scrollbar, 1 = Show Scrollbar
|
||||
nextPage: 0, // 0 = Reset to Top, 1 = Remember Position
|
||||
scrollbar: 1, // 0 = Hide Scrollbar, 1 = Show Scrollbar
|
||||
pageDisplay: 0 // 0 = Single Page, 1 = Long Strip
|
||||
};
|
||||
|
||||
@ -131,7 +132,7 @@ var createURLFromArray = function(array, mimeType) {
|
||||
}
|
||||
|
||||
if ((typeof URL !== "function" && typeof URL !== "object") ||
|
||||
typeof URL.createObjectURL !== "function") {
|
||||
typeof URL.createObjectURL !== "function") {
|
||||
throw "Browser support for Object URLs is missing";
|
||||
}
|
||||
|
||||
@ -187,7 +188,7 @@ function initProgressClick() {
|
||||
});
|
||||
}
|
||||
|
||||
function loadFromArrayBuffer(ab) {
|
||||
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
|
||||
@ -222,7 +223,7 @@ function loadFromArrayBuffer(ab) {
|
||||
|
||||
// display first page if we haven't yet
|
||||
if (imageFiles.length === currentImage + 1) {
|
||||
updatePage();
|
||||
updatePage(lastCompletion);
|
||||
}
|
||||
} else {
|
||||
totalImages--;
|
||||
@ -237,17 +238,6 @@ function loadFromArrayBuffer(ab) {
|
||||
}
|
||||
|
||||
function scrollTocToActive() {
|
||||
$(".page").text((currentImage + 1 ) + "/" + totalImages);
|
||||
|
||||
// Mark the current page in the TOC
|
||||
$("#tocView a[data-page]")
|
||||
// Remove the currently active thumbnail
|
||||
.removeClass("active")
|
||||
// Find the new one
|
||||
.filter("[data-page=" + (currentImage + 1) + "]")
|
||||
// Set it to active
|
||||
.addClass("active");
|
||||
|
||||
// Scroll to the thumbnail in the TOC on page change
|
||||
$("#tocView").stop().animate({
|
||||
scrollTop: $("#tocView a.active").position().top
|
||||
@ -255,12 +245,31 @@ function scrollTocToActive() {
|
||||
}
|
||||
|
||||
function updatePage() {
|
||||
$(".page").text((currentImage + 1 ) + "/" + totalImages);
|
||||
|
||||
// Mark the current page in the TOC
|
||||
$("#tocView a[data-page]")
|
||||
// Remove the currently active thumbnail
|
||||
.removeClass("active")
|
||||
// Find the new one
|
||||
.filter("[data-page=" + (currentImage + 1) + "]")
|
||||
// Set it to active
|
||||
.addClass("active");
|
||||
|
||||
scrollTocToActive();
|
||||
scrollCurrentImageIntoView();
|
||||
updateProgress();
|
||||
pageDisplayUpdate();
|
||||
setTheme();
|
||||
|
||||
if (imageFiles[currentImage]) {
|
||||
setImage(imageFiles[currentImage].dataURI);
|
||||
} else {
|
||||
setImage("loading");
|
||||
}
|
||||
|
||||
$("body").toggleClass("dark-theme", settings.theme === "dark");
|
||||
$("#mainContent").toggleClass("disabled-scrollbar", settings.scrollbar === 0);
|
||||
|
||||
kthoom.setSettings();
|
||||
kthoom.saveSettings();
|
||||
}
|
||||
@ -335,6 +344,7 @@ function setImage(url, _canvas) {
|
||||
img.onerror = function() {
|
||||
canvas.width = innerWidth - 100;
|
||||
canvas.height = 300;
|
||||
updateScale(true);
|
||||
x.fillStyle = "black";
|
||||
x.font = "50px sans-serif";
|
||||
x.strokeStyle = "black";
|
||||
@ -388,6 +398,8 @@ function setImage(url, _canvas) {
|
||||
scrollTo(0, 0);
|
||||
x.drawImage(img, 0, 0);
|
||||
|
||||
updateScale(false);
|
||||
|
||||
canvas.style.display = "";
|
||||
$("body").css("overflowY", "");
|
||||
x.restore();
|
||||
@ -426,6 +438,9 @@ function showPrevPage() {
|
||||
currentImage++;
|
||||
} else {
|
||||
updatePage();
|
||||
if (settings.nextPage === 0) {
|
||||
$("#mainContent").scrollTop(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,6 +451,9 @@ function showNextPage() {
|
||||
currentImage--;
|
||||
} else {
|
||||
updatePage();
|
||||
if (settings.nextPage === 0) {
|
||||
$("#mainContent").scrollTop(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,7 +469,7 @@ function scrollCurrentImageIntoView() {
|
||||
}
|
||||
}
|
||||
|
||||
function updateScale() {
|
||||
function updateScale(clear) {
|
||||
var canvasArray = $("#mainContent > canvas");
|
||||
var maxheight = innerHeight - 50;
|
||||
|
||||
@ -460,7 +478,7 @@ function updateScale() {
|
||||
canvasArray.css("maxWidth", "");
|
||||
canvasArray.css("maxHeight", "");
|
||||
|
||||
if(settings.pageDisplay === 0) {
|
||||
if(!clear) {
|
||||
canvasArray.addClass("hide");
|
||||
pageDisplayUpdate();
|
||||
}
|
||||
@ -627,7 +645,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);
|
||||
}
|
||||
@ -681,7 +699,7 @@ function init(filename) {
|
||||
}
|
||||
|
||||
updatePage();
|
||||
updateScale();
|
||||
updateScale(false);
|
||||
});
|
||||
|
||||
// Close modal
|
||||
@ -694,6 +712,9 @@ function init(filename) {
|
||||
$("#thumbnails").on("click", "a", function() {
|
||||
currentImage = $(this).data("page") - 1;
|
||||
updatePage();
|
||||
if (settings.nextPage === 0) {
|
||||
$("#mainContent").scrollTop(0);
|
||||
}
|
||||
});
|
||||
|
||||
// Fullscreen mode
|
||||
|
@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
@ -20,23 +21,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">
|
||||
@ -77,8 +61,8 @@
|
||||
<div id="mainContent" tabindex="-1">
|
||||
<div id="mainText" style="display:none"></div>
|
||||
</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">
|
||||
@ -89,8 +73,8 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th colspan="2">{{_('Keyboard Shortcuts')}}</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td id="prev_page_key">←</td> <td>{{_('Previous Page')}}</td></tr>
|
||||
<tr><td id="next_page_key">→</td> <td>{{_('Next Page')}}</td></tr>
|
||||
<tr><td>S</td> <td>{{_('Single Page Display')}}</td></tr>
|
||||
@ -102,21 +86,21 @@
|
||||
<tr><td>R</td> <td>{{_('Rotate Right')}}</td></tr>
|
||||
<tr><td>L</td> <td>{{_('Rotate Left')}}</td></tr>
|
||||
<tr><td>F</td> <td>{{_('Flip Image')}}</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="settings-column">
|
||||
<table id="settings">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{_('Settings')}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{{_('Theme')}}:</th>
|
||||
<td>
|
||||
<div class="inputs">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="settings-column">
|
||||
<table id="settings">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{_('Settings')}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{{_('Theme')}}:</th>
|
||||
<td>
|
||||
<div class="inputs">
|
||||
<label for="lightTheme"><input type="radio" id="lightTheme" name="theme" value="light" /> {{_('Light')}}</label>
|
||||
<label for="darkTheme"><input type="radio" id="darkTheme" name="theme" value="dark" /> {{_('Dark')}}</label>
|
||||
</div>
|
||||
@ -139,59 +123,118 @@
|
||||
<label for="fitWidth"><input type="radio" id="fitWidth" name="fitMode" value="87" /> {{_('Width')}}</label>
|
||||
<label for="fitHeight"><input type="radio" id="fitHeight" name="fitMode" value="72" /> {{_('Height')}}</label>
|
||||
<label for="fitNative"><input type="radio" id="fitNative" name="fitMode" value="78" /> {{_('Native')}}</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{_('Rotate')}}:</th>
|
||||
<td>
|
||||
<div class="inputs">
|
||||
<label for="r0"><input type="radio" id="r0" name="rotateTimes" value="0" /> 0°</label>
|
||||
<label for="r90"><input type="radio" id="r90" name="rotateTimes" value="1" /> 90°</label>
|
||||
<label for="r180"><input type="radio" id="r180" name="rotateTimes" value="2" /> 180°</label>
|
||||
<label for="r270"><input type="radio" id="r270" name="rotateTimes" value="3" /> 270°</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{_('Flip')}}:</th>
|
||||
<td>
|
||||
<div class="inputs">
|
||||
<label for="vflip"><input type="checkbox" id="vflip" name="vflip" /> {{_('Horizontal')}}</label>
|
||||
<label for="hflip"><input type="checkbox" id="hflip" name="hflip" /> {{_('Vertical')}}</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{_('Direction')}}:</th>
|
||||
<td>
|
||||
<div class="inputs">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{_('Rotate')}}:</th>
|
||||
<td>
|
||||
<div class="inputs">
|
||||
<label for="r0"><input type="radio" id="r0" name="rotateTimes" value="0" /> 0°</label>
|
||||
<label for="r90"><input type="radio" id="r90" name="rotateTimes" value="1" /> 90°</label>
|
||||
<label for="r180"><input type="radio" id="r180" name="rotateTimes" value="2" /> 180°</label>
|
||||
<label for="r270"><input type="radio" id="r270" name="rotateTimes" value="3" /> 270°</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{_('Flip')}}:</th>
|
||||
<td>
|
||||
<div class="inputs">
|
||||
<label for="vflip"><input type="checkbox" id="vflip" name="vflip" /> {{_('Horizontal')}}</label>
|
||||
<label for="hflip"><input type="checkbox" id="hflip" name="hflip" /> {{_('Vertical')}}</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{_('Direction')}}:</th>
|
||||
<td>
|
||||
<div class="inputs">
|
||||
<label for="leftToRight"><input type="radio" id="leftToRight" name="direction" value="0" /> {{_('Left to Right')}}</label>
|
||||
<label for="rightToLeft"><input type="radio" id="rightToLeft" name="direction" value="1" /> {{_('Right to Left')}}</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{_('Next Page')}}:</th>
|
||||
<td>
|
||||
<div class="inputs">
|
||||
<label for="resetToTop"><input type="radio" id="resetToTop" name="nextPage" value="0" /> {{_('Reset to Top')}}</label>
|
||||
<label for="rememberPosition"><input type="radio" id="rememberPosition" name="nextPage" value="1" /> {{_('Remember Position')}}</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{_('Scrollbar')}}:</th>
|
||||
<td>
|
||||
<div class="inputs">
|
||||
<label for="showScrollbar"><input type="radio" id="showScrollbar" name="scrollbar" value="1" /> {{_('Show')}}</label>
|
||||
<label for="hideScrollbar"><input type="radio" id="hideScrollbar" name="scrollbar" value="0" /> {{_('Hide')}}</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="closer icon-cancel-circled"></div>
|
||||
</div>
|
||||
<div class="closer icon-cancel-circled"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="overlay"></div>
|
||||
<script>
|
||||
$('input[name="direction"]').change(function() {
|
||||
updateArrows();
|
||||
});
|
||||
</script>
|
||||
<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: "{{ current_user.is_authenticated | tojson }}"
|
||||
};
|
||||
if (calibre.useBookmarks) {
|
||||
currentImage = eval(calibre.bookmark);
|
||||
if (typeof currentImage !== 'number'){
|
||||
currentImage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1561,7 +1561,7 @@ def read_book(book_id, book_format):
|
||||
title = title + " #" + '{0:.2f}'.format(book.series_index).rstrip('0').rstrip('.')
|
||||
log.debug("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("Selected book is unavailable. File does not exist or is not accessible")
|
||||
flash(_("Oops! Selected book is unavailable. File does not exist or is not accessible"),
|
||||
category="error")
|
||||
|
Loading…
Reference in New Issue
Block a user