summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-02-27 16:55:04 +0300
committerAndrew Dolgov <[email protected]>2017-02-27 16:55:04 +0300
commit4d64e984b1ff62de3571fc132fbfced7ef24b311 (patch)
tree1dee4c6ef0dd781c1bd9d2f70f022ee706de00fd /js
parent292b735fd8b8efa8da767321113c01c7e1ae0f64 (diff)
offline: add button to remove all books; index: do not move the list when using cache dropdown item
Diffstat (limited to 'js')
-rw-r--r--js/index.js2
-rw-r--r--js/offline.js22
2 files changed, 24 insertions, 0 deletions
diff --git a/js/index.js b/js/index.js
index b314cc0..60e4d12 100644
--- a/js/index.js
+++ b/js/index.js
@@ -24,6 +24,7 @@ function mark_offline(elem) {
offline_remove(bookId, function() {
mark_offline(elem);
});
+ return false;
};
elem.innerHTML = "Remove offline data";
@@ -34,6 +35,7 @@ function mark_offline(elem) {
offline_cache(bookId, function() {
mark_offline(elem);
});
+ return false;
};
elem.innerHTML = "Make available offline";
diff --git a/js/offline.js b/js/offline.js
index 959982c..8a61417 100644
--- a/js/offline.js
+++ b/js/offline.js
@@ -6,6 +6,28 @@ function offline_remove2(elem) {
});
}
+function offline_clear() {
+
+ if (confirm("Remove all offline data?")) {
+
+ var promises = [];
+
+ localforage.iterate(function(value, key, i) {
+
+ if (key.match("epube-book")) {
+ promises.push(localforage.removeItem(key));
+ }
+ });
+
+ Promise.all(promises).then(function() {
+ window.setTimeout(function() {
+ populate_list();
+ }, 500);
+ });
+ }
+}
+
+
function populate_list() {
var books = $("#books_container");