function offline_remove2(elem) { var bookId = elem.getAttribute("data-book-id"); return offline_remove(bookId, function() { $("#cell-" + bookId).remove(); }); } function populate_list() { var books = $("#books_container"); books.html(""); localforage.iterate(function(value, key, i) { if (key.match(/epube-book\.\d{1,}$/)) { Promise.all([ localforage.getItem(key), localforage.getItem(key + ".cover"), localforage.getItem(key + ".lastread"), localforage.getItem(key + ".book") ]).then(function(results) { if (results[0] && results[3]) { var info = results[0]; var cover = false; if (results && results[1]) { cover = URL.createObjectURL(results[1]); } var in_progress = false; var is_read = false; var lastread = results[2]; if (lastread) { in_progress = lastread.page > 0; is_read = lastread.total > 0 && lastread.total - lastread.page < 5; } var cell = "