diff options
author | Andrew Dolgov <[email protected]> | 2017-02-26 13:16:44 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-02-26 13:16:44 +0300 |
commit | 3f40a9eb86556d7a85162b5e2aae1ee4aff5126c (patch) | |
tree | e1c213a87f367d6e63c56c4a0997792560e0a9d8 | |
parent | e01f57a3d98943954372110dc75e8d731fbacc10 (diff) |
add 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); + }); + } +} + + |