From 3f40a9eb86556d7a85162b5e2aae1ee4aff5126c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 26 Feb 2017 13:16:44 +0300 Subject: add common.js --- js/common.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 js/common.js (limited to 'js/common.js') diff --git a/js/common.js b/js/common.js new file mode 100644 index 0000000..34467ae --- /dev/null +++ b/js/common.js @@ -0,0 +1,25 @@ +function offline_remove(elem, callback) { + + if (confirm("Remove download?")) { + + var id = elem.getAttribute("data-book-id"); + var cacheId = "epube-book." + id; + var promises = []; + + console.log("offline remove: " + id); + + localforage.iterate(function(value, key, i) { + if (key.match(cacheId)) { + promises.push(localforage.removeItem(key)); + } + }); + + Promise.all(promises).then(function() { + window.setTimeout(function() { + callback(); + }, 500); + }); + } +} + + -- cgit v1.2.3