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 = "
"; var cover_read = is_read ? "read" : ""; var title_class = in_progress ? "in_progress" : ""; cell += "
"; cell += ""; cell += "
"; cell += "
" + info.title + "
"; cell += "
" + info.author_sort + "
"; if (info.series_name) { cell += "
" + info.series_name + " [" + info.series_index + "]
"; } cell += "
"; cell += "
"; cell += "" + "More..." + ""; cell += ""; cell += "
"; cell += "
"; cell += "
"; var cell = $(cell); if (cover) { cell.find("img").attr("src", cover); } books.append(cell); Holder.run(); } }); } }); }