diff options
Diffstat (limited to 'js/common.js')
-rw-r--r-- | js/common.js | 25 |
1 files changed, 25 insertions, 0 deletions
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); + }); + } +} + + |