summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-02-26 00:14:30 +0300
committerAndrew Dolgov <[email protected]>2017-02-26 00:14:30 +0300
commitb8ae4b31c129031e89e4c7fb9801d6761513dd73 (patch)
tree4522dc5c059837a8c143c2a90c1dc562db0915ff /js
parentf858879a3d13bcec694a5e2493fbfe3a1a233e13 (diff)
experimental service worker offline stuff
Diffstat (limited to 'js')
-rw-r--r--js/index.js13
-rw-r--r--js/offline.js23
-rw-r--r--js/read.js15
3 files changed, 45 insertions, 6 deletions
diff --git a/js/index.js b/js/index.js
new file mode 100644
index 0000000..e76be90
--- /dev/null
+++ b/js/index.js
@@ -0,0 +1,13 @@
+function offline_cache(elem) {
+ try {
+ var bookId = elem.getAttribute("data-book-id");
+
+ console.log(bookId);
+
+
+ return false;
+
+ } catch (e) {
+ console.warn(e);
+ }
+}
diff --git a/js/offline.js b/js/offline.js
new file mode 100644
index 0000000..d9bed0b
--- /dev/null
+++ b/js/offline.js
@@ -0,0 +1,23 @@
+var CACHE_NAME = "epube-test";
+
+function populate_list() {
+
+ var books = $("#books_container");
+
+ window.caches.open(CACHE_NAME).then(function(cache) {
+ cache.keys().then(function(items) {
+
+ $.each(items, function(i, req) {
+
+ if (req.url.match(/\.epub/)) {
+ console.log(req.url);
+
+
+ }
+
+ });
+
+ });
+ });
+
+}
diff --git a/js/read.js b/js/read.js
index 6ba8a92..9039826 100644
--- a/js/read.js
+++ b/js/read.js
@@ -110,13 +110,16 @@ function mark_as_read() {
}
function save_and_close() {
+ if (navigator.onLine) {
+ var curPage = book.pagination.pageFromCfi(book.getCurrentLocationCfi());
- var curPage = book.pagination.pageFromCfi(book.getCurrentLocationCfi());
-
- $.post("backend.php", { op: "storelastread", id: $.urlParam("id"), page: curPage,
- cfi: book.getCurrentLocationCfi() }, function(data) {
- window.location = "index.php";
- });
+ $.post("backend.php", { op: "storelastread", id: $.urlParam("id"), page: curPage,
+ cfi: book.getCurrentLocationCfi() }, function(data) {
+ window.location = "index.php";
+ });
+ } else {
+ window.location = "index.php";
+ }
}
function invert() {