From 4d64e984b1ff62de3571fc132fbfced7ef24b311 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 27 Feb 2017 16:55:04 +0300 Subject: offline: add button to remove all books; index: do not move the list when using cache dropdown item --- js/offline.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'js/offline.js') 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"); -- cgit v1.2.3