summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-02-26 13:42:00 +0300
committerAndrew Dolgov <[email protected]>2017-02-26 13:42:00 +0300
commit8aaf1fad0c1cfa65132f052f0f98b3452ddc4eeb (patch)
tree2b44d22cb37d126caca770eb63d6608b6efb8000 /js
parent84230a6809d7ce8bd5d0161d1f91df4a4b7b32a0 (diff)
various offline-related fixes
Diffstat (limited to 'js')
-rw-r--r--js/offline.js27
-rw-r--r--js/read.js3
2 files changed, 25 insertions, 5 deletions
diff --git a/js/offline.js b/js/offline.js
index d1c49d6..7815b83 100644
--- a/js/offline.js
+++ b/js/offline.js
@@ -1,3 +1,7 @@
+function offline_remove2(elem) {
+ return offline_remove(elem, populate_list);
+}
+
function populate_list() {
var books = $("#books_container");
@@ -8,7 +12,8 @@ function populate_list() {
Promise.all([
localforage.getItem(key),
- localforage.getItem(key + ".cover")
+ localforage.getItem(key + ".cover"),
+ localforage.getItem(key + ".lastread")
]).then(function(results) {
var info = results[0];
@@ -20,13 +25,27 @@ function populate_list() {
cover = URL.createObjectURL(results[1]);
}
+ var in_progress = false;
+ var is_read = false;
+
+ var lastread = results[2];
+ if (lastread) {
+
+ in_progress = lastread.page > 0;
+ is_read = lastread.total - lastread.page < 5;
+ }
+
var cell = "<div class='col-xs-6 col-sm-3 col-md-2 index_cell'>";
- cell += "<div class=\"thumb\">";
+ var cover_read = is_read ? "read" : "";
+ var title_class = in_progress ? "in_progress" : "";
+
+ cell += "<div class=\"thumb "+cover_read+"\">";
cell += "<a href=\"read.html?id="+info.epub_id+"&b="+info.id+"\"><img data-src=\"holder.js/120x180\"></a>";
cell += "<div class=\"caption\">";
- cell += "<div><a href=\"read.html?id="+info.epub_id+"&b="+info.id+"\">" + info.title + "</a></div>";
+ cell += "<div><a class=\""+title_class+"\" href=\"read.html?id="+info.epub_id+"&b="+info.id+"\">" +
+ info.title + "</a></div>";
cell += "<div>" + info.author_sort + "</div>";
if (info.series_name) {
@@ -40,7 +59,7 @@ function populate_list() {
"More..." + "<span class=\"caret\"></span></a>";
cell += "<ul class=\"dropdown-menu\">";
- cell += "<li><a href=\"#\" data-book-id=\""+info.id+"\" onclick=\"offline_remove(this)\">Remove download</a></li>";
+ cell += "<li><a href=\"#\" data-book-id=\""+info.id+"\" onclick=\"offline_remove2(this)\">Remove download</a></li>";
cell += "</ul>";
cell += "</div>";
diff --git a/js/read.js b/js/read.js
index dc968f4..4fb74ce 100644
--- a/js/read.js
+++ b/js/read.js
@@ -113,9 +113,10 @@ function save_and_close() {
if (navigator.onLine) {
var currentPage = book.pagination.pageFromCfi(book.getCurrentLocationCfi());
var currentCfi = book.getCurrentLocationCfi();
+ var totalPages = book.pagination.totalPages;
localforage.setItem("epube-book." + $.urlParam("b") + ".lastread",
- {cfi: currentCfi, page: currentPage});
+ {cfi: currentCfi, page: currentPage, total: totalPages});
$.post("backend.php", { op: "storelastread", id: $.urlParam("id"), page: currentPage,
cfi: currentCfi }, function(data) {