summaryrefslogtreecommitdiff
path: root/read.html
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-07-30 23:18:28 +0300
committerAndrew Dolgov <[email protected]>2017-07-30 23:18:28 +0300
commitfe88505aaa7ce84d2c6e5a706edf0e99490ab52d (patch)
tree3522379ff628143c270993838d96041435bd756c /read.html
parent70f38e9c4fc9eec74a7f648474433184b4dede18 (diff)
simplify initial page selection on startup: prefer local CFI is stored, request possible uptodate position from the server afterwards
Diffstat (limited to 'read.html')
-rw-r--r--read.html40
1 files changed, 20 insertions, 20 deletions
diff --git a/read.html b/read.html
index bc5e0b1..203eb2c 100644
--- a/read.html
+++ b/read.html
@@ -647,26 +647,26 @@
localforage.setItem(cacheId("pagination"), pageList);
}
- if (navigator.onLine) {
- $.post("backend.php", { op: "getlastread", id: $.urlParam("id") }, function(data) {
- console.log(data);
-
- if (navigator.onLine && data) {
- localforage.setItem(cacheId("lastread"),
- {cfi: data.cfi, page: data.page, total: data.total});
-
- if (data.cfi) book.gotoCfi(data.cfi);
- } else {
- localforage.getItem(cacheId("lastread")).then(function(item) {
- if (item && item.cfi) book.gotoCfi(item.cfi);
- });
- }
- });
- } else {
- localforage.getItem(cacheId("lastread")).then(function(item) {
- if (item && item.cfi) book.gotoCfi(item.cfi);
- });
- }
+ localforage.getItem(cacheId("lastread")).then(function(item) {
+ console.log('lr local', item.cfi);
+
+ if (item && item.cfi) book.gotoCfi(item.cfi);
+
+ if (navigator.onLine) {
+
+ $.post("backend.php", { op: "getlastread", id: $.urlParam("id") }, function(data) {
+ console.log('lr remote', data.cfi);
+
+ if (navigator.onLine && data) {
+ localforage.setItem(cacheId("lastread"),
+ {cfi: data.cfi, page: data.page, total: data.total});
+
+ if (data.cfi) book.gotoCfi(data.cfi);
+ }
+ });
+ }
+
+ });
var curPage = book.pagination.pageFromCfi(book.getCurrentLocationCfi());